Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Issue 2934893002: [builtins] Properly optimize Object.prototype.isPrototypeOf. (Closed)

Created:
3 years, 6 months ago by Benedikt Meurer
Modified:
3 years, 6 months ago
Reviewers:
jgruber
CC:
v8-reviews_googlegroups.com
Target Ref:
refs/heads/master
Project:
v8
Visibility:
Public.

Description

[builtins] Properly optimize Object.prototype.isPrototypeOf. Port the baseline implementation of Object.prototype.isPrototypeOf to the CodeStubAssembler, sharing the existing prototype chain lookup logic with the instanceof / OrdinaryHasInstance implementation. Based on that, do the same in TurboFan, introducing a new JSHasInPrototypeChain operator, which encapsulates the central prototype chain walk logic. This speeds up Object.prototype.isPrototypeOf by more than a factor of four, so that the code A.prototype.isPrototypeOf(a) is now performance-wise on par with a instanceof A for the case where A is a regular constructor function and a is an instance of A. Since instanceof does more than just the fundamental prototype chain lookup, it was discovered in Node core that O.p.isPrototypeOf would be a more appropriate alternative for certain sanity checks, since it's less vulnerable to monkey-patching. In addition, the Object builtin would also avoid the performance-cliff associated with instanceof (due to the Symbol.hasInstance hook), as for example hit by https://github.com/nodejs/node/pull/13403#issuecomment-305915874. The main blocker was the missing performance of isPrototypeOf, since it was still a JS builtin backed by a runtime call. This CL also adds more test coverage for the Object.prototype.isPrototypeOf builtin, especially when called from optimized code. CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_chromium_rel_ng BUG=v8:5269, v8:5989, v8:6483 R=jgruber@chromium.org Review-Url: https://codereview.chromium.org/2934893002 Cr-Commit-Position: refs/heads/master@{#45925} Committed: https://chromium.googlesource.com/v8/v8/+/b11c557d32846fde2615621ac7528e28dd992c86

Patch Set 1 #

Total comments: 2

Patch Set 2 : Make debug-evaluate happy. #

Total comments: 10

Patch Set 3 : Address feedback. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+553 lines, -256 lines) Patch
M src/bootstrapper.cc View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M src/builtins/builtins-definitions.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/builtins/builtins-object-gen.cc View 1 2 1 chunk +46 lines, -0 lines 0 comments Download
M src/code-stub-assembler.h View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M src/code-stub-assembler.cc View 1 2 2 chunks +66 lines, -41 lines 0 comments Download
M src/compiler/js-call-reducer.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler/js-call-reducer.cc View 2 chunks +34 lines, -0 lines 0 comments Download
M src/compiler/js-generic-lowering.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M src/compiler/js-native-context-specialization.h View 1 chunk +0 lines, -11 lines 0 comments Download
M src/compiler/js-native-context-specialization.cc View 3 chunks +6 lines, -191 lines 0 comments Download
M src/compiler/js-operator.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler/js-operator.cc View 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler/js-typed-lowering.h View 2 chunks +12 lines, -0 lines 0 comments Download
M src/compiler/js-typed-lowering.cc View 2 chunks +206 lines, -0 lines 0 comments Download
M src/compiler/opcodes.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler/operator-properties.cc View 1 chunk +1 line, -0 lines 0 comments Download
M src/compiler/typer.cc View 2 chunks +6 lines, -0 lines 0 comments Download
M src/compiler/verifier.cc View 1 chunk +1 line, -0 lines 0 comments Download
M src/debug/debug-evaluate.cc View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/js/v8natives.js View 2 chunks +1 line, -10 lines 0 comments Download
M src/objects.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/runtime/runtime-object.cc View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
A test/mjsunit/compiler/object-isprototypeof.js View 1 chunk +153 lines, -0 lines 0 comments Download

Messages

Total messages: 28 (20 generated)
Benedikt Meurer
3 years, 6 months ago (2017-06-12 19:49:29 UTC) #1
Benedikt Meurer
Hey Jakob, Here's follow-up work for the instanceof core functionality shared with Object.prototype.isPrototypeOf. The motivation ...
3 years, 6 months ago (2017-06-12 19:52:26 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2934893002/1
3 years, 6 months ago (2017-06-12 19:54:59 UTC) #9
commit-bot: I haz the power
No L-G-T-M from a valid reviewer yet. CQ run can only be started once the ...
3 years, 6 months ago (2017-06-12 19:55:01 UTC) #11
jgruber
lgtm, thanks! Looked at compiler/ and it looks like the lowering is doing the right ...
3 years, 6 months ago (2017-06-13 07:49:52 UTC) #21
Benedikt Meurer
Thanks for the review! Feedback addressed. https://codereview.chromium.org/2934893002/diff/20001/src/builtins/builtins-object-gen.cc File src/builtins/builtins-object-gen.cc (right): https://codereview.chromium.org/2934893002/diff/20001/src/builtins/builtins-object-gen.cc#newcode219 src/builtins/builtins-object-gen.cc:219: GotoIf(WordEqual(receiver, NullConstant()), &if_receiverisnullorundefined); ...
3 years, 6 months ago (2017-06-13 18:22:45 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2934893002/40001
3 years, 6 months ago (2017-06-13 18:23:35 UTC) #25
commit-bot: I haz the power
3 years, 6 months ago (2017-06-13 19:14:09 UTC) #28
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/v8/v8/+/b11c557d32846fde2615621ac7528e28dd9...

Powered by Google App Engine
This is Rietveld 408576698