-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
v8: fix new.target inheritance from c++ #9293
Conversation
CI: https://ci.nodejs.org/job/node-test-pull-request/4684/ I'll add a regression test if we decide to land this. |
deps/v8/include/v8.h
Outdated
internal::Object** implicit_args_; | ||
internal::Object** values_; | ||
int length_; | ||
int is_construct_call_; |
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.
Yeah, removing this field will definitely break addons compiled for the existing versions of node v6. Maybe the changes can be patched up to duplicate information, so that is_construct_call_
is always populated with a correct value? (I can look into that myself but I wouldn’t want to make any promises about time.)
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.
I'm in Germany for the next few days (Jena, in case you're wondering) so I probably won't have time to get back to it until next week.
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.
It turned out to be a little more involved than just adding back the field because it's also set directly by generated code. I got it working locally and I'll push the changes shortly.
deps/v8/src/objects.cc
Outdated
case JS_DATE_TYPE: | ||
case JS_ARRAY_TYPE: | ||
case JS_MESSAGE_OBJECT_TYPE: | ||
case JS_API_OBJECT_TYPE: |
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.
This line should probably be dropped? (Right now this breaks compiling a debug build, there is no JS_API_OBJECT_TYPE
).
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.
Good catch. Fixed, and I checked that the other fields do exist.
Updated, PTAL. https://ci.nodejs.org/job/node-test-pull-request/4761/ EDIT: Le sigh, the node-test-commit-v8-linux job still has infrastructural issues... |
deps/v8/include/v8.h
Outdated
@@ -3177,12 +3177,13 @@ class FunctionCallbackInfo { | |||
Local<Function> Callee() const); | |||
V8_INLINE Local<Object> This() const; | |||
V8_INLINE Local<Object> Holder() const; | |||
V8_INLINE Local<Value> NewTarget() const; |
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.
I can break out the new method into a separate commit in order to keep the meat of the pull request semver-patch.
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.
nit: It might be a good idea to add the a DCHECK in IsConstructCall
to make sure that the equivalence relationship between is_construct_call_ & 1
and !NewTarget->IsUndefined
holds.
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.
I see that a subsequent commit drops NewTarget. Feel free to ignore.
Did an earlier version of this include the ABI breaking changes because I don't think I see it in the current incarnation, at least I don't see the I quite like the idea of keeping the |
@rvagg Yes to both questions. |
OK then, my vote goes for splitting this into a semver-patch so we can get a fix out in the next v6 release and a semver-minor so we can complete the API at some point after. Thanks for the hard work of making this fit nicely @bnoordhuis. @thealphanerd this'll be a good one to try your new ABI compatibility tester on. |
@bnoordhuis @nodejs/v8 do we want to try and get this in the next release? |
Updated with a commit that backs out NewTarget(). #9689 is the regression test, that should land in master first before it gets back-ported. I tested locally that the test fails with v6.x-staging and passes with this pull request applied. |
No clue as to why this PR would trigger a lint error, it only touches code in deps/v8... |
Now with patches for s390, ppc and x87 applied. CI: https://ci.nodejs.org/job/node-test-pull-request/4902/ |
1e0a8d7
to
ce999a6
Compare
Rebased again: https://ci.nodejs.org/job/node-test-pull-request/4908/ |
Add a test that checks that new.target inheritance works when inheriting from a constructor defined in C++. PR-URL: nodejs#9689 Refs: nodejs#9288 Refs: nodejs#9293 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Added the regression test from #9689. New CI: https://ci.nodejs.org/job/node-test-pull-request/4920/ |
@bnoordhuis linting error is unrelated to this PR |
V8 CI is brilliantly green, node CI is... eh, nothing that's caused by this PR. @addaleax @nodejs/v8 Perhaps one of you can review the last commit? |
STATIC_ASSERT(FCA::kArgsLength == 8); | ||
|
||
// new target | ||
__ PushRoot(Heap::kUndefinedValueRootIndex); |
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.
For posterity, can you add a link to the commit where the s390 and x87 stubs come from.
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.
ppc: v8/v8@4f75124
s390: v8/v8@38e7d1f
x87: v8/v8@1542e46
deps/v8/include/v8.h
Outdated
@@ -3177,12 +3177,13 @@ class FunctionCallbackInfo { | |||
Local<Function> Callee() const); | |||
V8_INLINE Local<Object> This() const; | |||
V8_INLINE Local<Object> Holder() const; | |||
V8_INLINE Local<Value> NewTarget() const; |
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.
nit: It might be a good idea to add the a DCHECK in IsConstructCall
to make sure that the equivalence relationship between is_construct_call_ & 1
and !NewTarget->IsUndefined
holds.
deps/v8/include/v8.h
Outdated
@@ -3177,12 +3177,13 @@ class FunctionCallbackInfo { | |||
Local<Function> Callee() const); | |||
V8_INLINE Local<Object> This() const; | |||
V8_INLINE Local<Object> Holder() const; | |||
V8_INLINE Local<Value> NewTarget() const; |
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.
I see that a subsequent commit drops NewTarget. Feel free to ignore.
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.
LGTM
c359018
to
1d631ce
Compare
@MylesBorins Should I land this or do you? |
@bnoordhuis ... I'm not @MylesBorins of course, but feel free to land in the staging branch :-) |
Don't try to optimize known-unoptimizable functions when --always-opt is specified on the command line, it makes Crankshaft emit wrong code. This was fixed upstream when improved WASM support was introduced but that specific change can't be back-ported because it depends on prior work that doesn't exist in V8 5.1. Ergo, I decided to redo the fix from scratch. PR-URL: nodejs#9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
The patch has been modified to maintain ABI compatibility. The original change removes the v8::FunctionCallbackInfo<T>::is_construct_call_ field from deps/v8/include/v8.h. The field is set directly by JIT-ted code so the removal of those code paths has been backed out as well. Original commit message: [api] Expose FunctionCallbackInfo::NewTarget This is needed by Blink to implement the Custom Elements spec. BUG=v8:4261 LOG=y Review-Url: https://codereview.chromium.org/1910253005 Cr-Commit-Position: refs/heads/master@{nodejs#35833} Fixes: nodejs#9288 PR-URL: nodejs#9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Original commit message: When instantiating a subclassed API function, the instance cache is avoided. There is currently no direct API yet to instantiate a Template while passing in a new.target. It probably makes sense to extend ObjectTemplate::NewInstance to accept a new.target, in line with Reflect.construct. BUG=v8:3330, v8:5001 Review-Url: https://codereview.chromium.org/1972613002 Cr-Commit-Position: refs/heads/master@{nodejs#36179} Fixes: nodejs#9288 PR-URL: nodejs#9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Remove the new method that was introduced in the back-port of v8/v8@306c412c ("[api] Expose FunctionCallbackInfo::NewTarget") so that the meat of the patch can land in a patch release. This commit can be reverted again in the next minor release. Fixes: nodejs#9288 PR-URL: nodejs#9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Landed in 1d631ce...2ebceed, cheers. |
@bnoordhuis is this able to be landed in the next release? The next release will be a patch and will not be able to include the revert that is mentioned above |
@MylesBorins Yes, this PR is semver-patch, #11652 the semver-minor. |
Don't try to optimize known-unoptimizable functions when --always-opt is specified on the command line, it makes Crankshaft emit wrong code. This was fixed upstream when improved WASM support was introduced but that specific change can't be back-ported because it depends on prior work that doesn't exist in V8 5.1. Ergo, I decided to redo the fix from scratch. PR-URL: #9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
The patch has been modified to maintain ABI compatibility. The original change removes the v8::FunctionCallbackInfo<T>::is_construct_call_ field from deps/v8/include/v8.h. The field is set directly by JIT-ted code so the removal of those code paths has been backed out as well. Original commit message: [api] Expose FunctionCallbackInfo::NewTarget This is needed by Blink to implement the Custom Elements spec. BUG=v8:4261 LOG=y Review-Url: https://codereview.chromium.org/1910253005 Cr-Commit-Position: refs/heads/master@{#35833} Fixes: #9288 PR-URL: #9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Original commit message: When instantiating a subclassed API function, the instance cache is avoided. There is currently no direct API yet to instantiate a Template while passing in a new.target. It probably makes sense to extend ObjectTemplate::NewInstance to accept a new.target, in line with Reflect.construct. BUG=v8:3330, v8:5001 Review-Url: https://codereview.chromium.org/1972613002 Cr-Commit-Position: refs/heads/master@{#36179} Fixes: #9288 PR-URL: #9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Remove the new method that was introduced in the back-port of v8/v8@306c412c ("[api] Expose FunctionCallbackInfo::NewTarget") so that the meat of the patch can land in a patch release. This commit can be reverted again in the next minor release. Fixes: #9288 PR-URL: #9293 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
See #9288. Cherry-pick two commits from V8 5.2. The actual fix is commit v8/v8@73ee794 but it depends on commit v8/v8@306c412 which might be something of an ABI change. Opinions welcome on whether we should do this.
cc @nodejs/v8