-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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. [email protected] 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 <[email protected]> Commit-Queue: Clemens Hammacher <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#55695} Refs: v8/v8@b0af309 PR-URL: nodejs#23415 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: nodejs#23455 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Covering the case when fs-read get invalid argument for file handle PR-URL: nodejs#23601 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
Minor cleanup in the lifetime for the platform worker initialization synchronization barrier. PR-URL: nodejs#23419 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23449 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Beth Griggs <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Have actual first, expected second. PR-URL: nodejs#23450 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Catch statement defines err variable that is never used, so it is safe to remove that. PR-URL: nodejs#23452 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Converts RangeError assertions to use common.expectsError and includes an assertion for the error code. PR-URL: nodejs#23454 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23456 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23457 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23458 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Hitesh Kanwathirtha <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23459 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23461 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23463 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
PR-URL: nodejs#23465 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
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