Uh oh!
There was an error while loading. Please reload this page.
buffer: make FastBuffer safe to construct - #36587
Conversation
Benchmark results are not as good as the one I got locally, that might be related to using a different OS / architecture, not sure 🤔 @mscdex FYI Details |
aduh95
commented
Dec 20, 2020
From what I can see based on the architecture I have at my disposal, this PR is neutral for performance on |
mscdex
commented
Dec 20, 2020
I'm inclined to believe Jenkins on this one as this is literally the same behavior as before. If anything, I'd expect a minor perf hit because V8 may be able to optimize calling default constructors of built-in types. |
aduh95
commented
Dec 20, 2020
Except it doesn't use |
mscdex
commented
Dec 20, 2020
I don't follow. What I'm referring to is the change in this PR: From an implicit, inherited constructor: classFastBufferextendsUint8Array{}To an explicit constructor that passes the exact same parameters: classFastBufferextendsUint8Array{// eslint-disable-next-line no-useless-constructorconstructor(bufferOrLength,byteOffset,length){super(bufferOrLength,byteOffset,length);}}Neither of these should invoke anything |
ExE-Boss
commented
Dec 20, 2020
@mscdex Except that a missing constructor in a derived class is equivalent to: constructor(...args){super(...args)}And the spread operator invokes the deleteArray.prototype[Symbol.iterator];new(classextendsObject{})();You’ll get: Until tc39/ecma262#2216 is implemented. |
mscdex
commented
Dec 20, 2020
I think if this is going to be merged, we should have at least a code comment describing why this is being done this way. I'm +0 on this since it doesn't really seem to change much, at least with the |
Relevant spec section: https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation
Note that there's also a difference because the |
Uh oh!
There was an error while loading. Please reload this page.
Using an explicit constructor is necessary to avoid relying on `Array.prototype[Symbol.iterator]` and `%ArrayIteratorPrototype%.next`, which can be mutated by users.
aduh95
commented
Dec 21, 2020
Force pushed to fix the commit message. |
nodejs-github-bot
commented
Dec 21, 2020
nodejs-github-bot
commented
Dec 24, 2020
Landed in bd6f230...0187716 |
Default constructor iterates over the argument when calling the
superconstructor, we can get better result by passing an exact number of arguments on Apple Silicon processors.Benchmark I run locally
Related Issues
Refs: #36428
Refs: #36532
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes