-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: refacor MallocedBuffer
to it's usage scope
#23641
Conversation
Original commit message: [api] Remove deprecated wasm methods These methods were deprecated in 7.0, now we can remove them. R=adamk@chromium.org Bug: v8:7868 Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: I60badb378a055152bdd27aed67d11ddf74fce174 Reviewed-on: https://chromium-review.googlesource.com/1209283 Reviewed-by: Adam Klein <adamk@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{nodejs#55695} Refs: v8/v8@b0af309 PR-URL: nodejs#23415 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: nodejs#23455 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Covering the case when fs-read get invalid argument for file handle PR-URL: nodejs#23601 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Minor cleanup in the lifetime for the platform worker initialization synchronization barrier. PR-URL: nodejs#23419 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
When using `assert.strictEqual`, the first argument must be the actual value and the second argument must be the expected value. PR-URL: nodejs#23448 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23449 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Have actual first, expected second. PR-URL: nodejs#23450 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reverse the argument for assertion. The first argument should be the actual value and the second value should be the expected value. When there is an AssertionError, the expected and actual value will be labeled correctly. PR-URL: nodejs#23451 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Catch statement defines err variable that is never used, so it is safe to remove that. PR-URL: nodejs#23452 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Converts RangeError assertions to use common.expectsError and includes an assertion for the error code. PR-URL: nodejs#23454 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23456 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23457 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23458 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23459 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23461 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23463 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: nodejs#23465 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
I am not sure about arguing that
Whereas with
|
20ea06d
to
d16f098
Compare
As @joyeecheung said, the semantics are defined right next to the class.
I don’t think that bug lets you make conclusions about “maturity” – this is not a full-featured memory manager, this is a small utility class.
There’s no reason to believe that there is any difference in runtime cost. The memory cost of extra 8 bytes is negligible, and is actually useful a lot of the time. I don’t think comparing to This structure always represents a continuous array of data. It’s closest STL equivalent is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1, see above.
It might be my perspective, but https://en.cppreference.com/w/cpp/memory/unique_ptr seems to answer these quastion, and leave much less ambiguity. |
As I see it (again this might point to ambiguity) I think that the main difference between this and |
Yes. So let’s use it when it matters that we use a specific memory allocator. |
I agree that it makes sense to abstract that, I just disagree on the implementation. IMHO we should minimize our own code. Something like: template<typename T>
struct Free {
void operator()(T* ptr) const { free(ptr); }
};
// Specialization of std::unique_ptr that used Malloc<t>
template<typename T>
using malloced_unique_ptr = std::unique_ptr<T, Free<T>>;
template<typename T>
malloced_unique_ptr make_malloced_unique(size_t number_of_t) {
return malloced_unique_ptr(Malloc<T>(number_of_t));
} |
@refack I think the main downside to that is that it does not provide
This PR seems to do a lot more than changing the implementation. |
As I see it we have two use cases:
|
Ok, so an alternative suggested at #23642 |
@refack That is a long document which just explains Maybe I wasn't being clear: (Also, I think it's even possible to implement EDIT: oh, yeah there is a (sort-of) implementation #23641 (comment) already |
Abandoned |
As discussed in #23543 (review).
MallocedBuffer
is an unknown quantity as compared tostd::unique_ptr
.MallocedBuffer
is a new utility and is node specific, so it's semantics are not clear to me, so I assume to others as well.MallocedBuffer::size
is in units ofT
or number ofbyte
std::unique_ptr
is free of runtime cost (except for its dtor), whileMallocedBuffer
at minimum carries the runtime cost of construction, and the memory cost ofMallocedBuffer::size
.std::unique_ptr
is standardized and well documented.MallocedBuffer
is only documented by its code.Ref: #23543 (review)
Ref: #23434
CI: https://ci.nodejs.org/job/node-test-pull-request/17821
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes