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

Issue 1689733002: Optimize @@species based on a global 'protector' cell (Closed)

Created:
4 years, 10 months ago by Dan Ehrenberg
Modified:
4 years, 9 months ago
CC:
adamk, Hannes Payer (out of office), Paweł Hajdan Jr., ulan, v8-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/v8/v8.git@master
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

Optimize @@species based on a global 'protector' cell This patch makes ArraySpeciesCreate fast in V8 by avoiding two property reads when the following conditions are met: - No Array instance has had its __proto__ reset - No Array instance has had a constructor property defined - Array.prototype has not had its constructor changed - Array[Symbol.species] has not been reset For subclasses of Array, or for conditions where one of these assumptions is violated, the full lookup of species is done according to the ArraySpeciesCreate algorithm. Although this is a "performance cliff", it does not come up in the expected typical use case of @@species (Array subclassing), so it is hoped that this can form a good start. Array subclasses will incur the slowness of looking up @@species, but their use won't slow down invocations of, for example, Array.prototype.slice on Array base class instances. Possible future optimizations: - For the fallback case where the assumptions don't hold, optimize the two property lookups. - For Array.prototype.slice and Array.prototype.splice, even if the full lookup of @@species needs to take place, we still could take the rest of the C++ fastpath. However, to do this correctly requires changing the calling convention from C++ to JS to pass the @@species out, so it is not attempted in this patch. With this patch, microbenchmarks of Array.prototype.slice do not suffer a noticeable performance regression, unlike their previous 2.5x penalty. TBR=hpayer@chromium.org Committed: https://crrev.com/7033ae511f3cca7e5464353e80acbba645e07c44 Cr-Commit-Position: refs/heads/master@{#34199}

Patch Set 1 #

Patch Set 2 : Starting tracking the relevant changes #

Patch Set 3 : Complete first draft #

Patch Set 4 : It passes the tests! #

Patch Set 5 : Everything works now, and the fastpath gets taken for Array.prototype.slice! #

Patch Set 6 : avoid taking splice slow path #

Patch Set 7 : Fix message bug #

Patch Set 8 : Rebase #

Total comments: 8

Patch Set 9 : Disallow heap GC #

Patch Set 10 : DCHECK #

Total comments: 5

Patch Set 11 : Cleanup suggested by cbruni, and include deletions as they are needed #

Patch Set 12 : Remove blank lines #

Unified diffs Side-by-side diffs Delta from patch set Stats (+287 lines, -25 lines) Patch
M include/v8.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +5 lines, -0 lines 0 comments Download
M src/builtins.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +9 lines, -18 lines 0 comments Download
M src/heap/heap.h View 1 2 3 4 5 6 7 1 chunk +2 lines, -1 line 0 comments Download
M src/heap/heap.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -0 lines 0 comments Download
M src/isolate.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +2 lines, -0 lines 0 comments Download
M src/isolate.cc View 1 2 3 4 5 6 7 8 9 10 2 chunks +28 lines, -0 lines 0 comments Download
M src/lookup.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +3 lines, -0 lines 0 comments Download
M src/lookup.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +46 lines, -0 lines 0 comments Download
M src/objects.cc View 1 2 3 4 5 6 7 8 9 10 6 chunks +22 lines, -2 lines 0 comments Download
M test/mjsunit/harmony/array-species.js View 1 2 3 1 chunk +2 lines, -4 lines 0 comments Download
A test/mjsunit/harmony/array-species-constructor.js View 1 2 1 chunk +27 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/array-species-constructor-delete.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +28 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/array-species-delete.js View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +28 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/array-species-modified.js View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/array-species-parent-constructor.js View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A test/mjsunit/harmony/array-species-proto.js View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download

Messages

Total messages: 57 (26 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/60001
4 years, 10 months ago (2016-02-17 06:26:46 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux64_asan_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux64_asan_rel/builds/13789) v8_linux_arm64_rel on ...
4 years, 10 months ago (2016-02-17 06:27:37 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/80001
4 years, 10 months ago (2016-02-17 23:17:40 UTC) #6
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_presubmit on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/11150)
4 years, 10 months ago (2016-02-17 23:25:05 UTC) #10
Dan Ehrenberg
Camillo, there are a couple small test failures, but I'm wondering if you could review ...
4 years, 10 months ago (2016-02-18 00:46:34 UTC) #13
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/100001
4 years, 10 months ago (2016-02-18 00:51:36 UTC) #15
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_arm_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_arm_rel/builds/13924)
4 years, 10 months ago (2016-02-18 01:04:17 UTC) #17
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/120001
4 years, 10 months ago (2016-02-18 22:49:58 UTC) #19
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_linux_arm64_rel on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_linux_arm64_rel/builds/15561) v8_linux_mips64el_compile_rel on ...
4 years, 10 months ago (2016-02-18 22:51:00 UTC) #21
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/140001
4 years, 10 months ago (2016-02-18 23:00:07 UTC) #23
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 10 months ago (2016-02-18 23:32:48 UTC) #25
Dan Ehrenberg
PTAL, all the issues I know of have been fixed.
4 years, 10 months ago (2016-02-18 23:44:01 UTC) #26
adamk
A few stylistic notes, deferring to cbruni for the meat of this review. https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc File ...
4 years, 10 months ago (2016-02-19 00:01:18 UTC) #28
Dan Ehrenberg
https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc File src/isolate.cc (right): https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc#newcode2533 src/isolate.cc:2533: CHECK(factory()->species_protector()->value()->IsSmi()); On 2016/02/19 at 00:01:17, adamk wrote: > Normally ...
4 years, 10 months ago (2016-02-19 00:15:37 UTC) #29
adamk
https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc File src/isolate.cc (right): https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc#newcode2533 src/isolate.cc:2533: CHECK(factory()->species_protector()->value()->IsSmi()); On 2016/02/19 00:15:37, Dan Ehrenberg wrote: > On ...
4 years, 10 months ago (2016-02-19 01:06:01 UTC) #30
Dan Ehrenberg
On 2016/02/19 at 01:06:01, adamk wrote: > https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc > File src/isolate.cc (right): > > https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc#newcode2533 ...
4 years, 10 months ago (2016-02-19 02:16:29 UTC) #31
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/180001
4 years, 10 months ago (2016-02-19 02:16:39 UTC) #33
Dan Ehrenberg
https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc File src/isolate.cc (right): https://codereview.chromium.org/1689733002/diff/140001/src/isolate.cc#newcode2533 src/isolate.cc:2533: CHECK(factory()->species_protector()->value()->IsSmi()); On 2016/02/19 at 01:06:01, adamk wrote: > On ...
4 years, 10 months ago (2016-02-19 02:16:41 UTC) #34
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 10 months ago (2016-02-19 02:44:47 UTC) #36
Camillo Bruni
lgtm with nits. https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc File src/lookup.cc (right): https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc#newcode170 src/lookup.cc:170: } nit: Could you copy over ...
4 years, 10 months ago (2016-02-22 12:44:47 UTC) #37
Camillo Bruni
https://codereview.chromium.org/1689733002/diff/140001/src/lookup.cc File src/lookup.cc (right): https://codereview.chromium.org/1689733002/diff/140001/src/lookup.cc#newcode159 src/lookup.cc:159: Object* context = heap()->native_contexts_list(); On 2016/02/19 at 01:06:01, adamk ...
4 years, 10 months ago (2016-02-22 15:29:34 UTC) #38
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/200001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/200001
4 years, 10 months ago (2016-02-22 20:01:29 UTC) #40
Dan Ehrenberg
https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc File src/lookup.cc (right): https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc#newcode170 src/lookup.cc:170: } On 2016/02/22 at 12:44:47, cbruni wrote: > nit: ...
4 years, 10 months ago (2016-02-22 20:02:00 UTC) #41
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: v8_presubmit on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/11323)
4 years, 10 months ago (2016-02-22 20:04:05 UTC) #43
Camillo Bruni
https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc File src/lookup.cc (right): https://codereview.chromium.org/1689733002/diff/180001/src/lookup.cc#newcode179 src/lookup.cc:179: if (current_context->array_function() == *holder_) { On 2016/02/22 at 20:02:00, ...
4 years, 10 months ago (2016-02-22 20:05:22 UTC) #44
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/220001
4 years, 10 months ago (2016-02-22 20:36:48 UTC) #47
commit-bot: I haz the power
Try jobs failed on following builders: v8_presubmit on tryserver.v8 (JOB_FAILED, http://build.chromium.org/p/tryserver.v8/builders/v8_presubmit/builds/11327)
4 years, 10 months ago (2016-02-22 20:39:32 UTC) #49
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1689733002/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1689733002/220001
4 years, 10 months ago (2016-02-22 20:43:30 UTC) #52
commit-bot: I haz the power
Committed patchset #12 (id:220001)
4 years, 10 months ago (2016-02-22 21:01:36 UTC) #53
commit-bot: I haz the power
Patchset 12 (id:??) landed as https://crrev.com/7033ae511f3cca7e5464353e80acbba645e07c44 Cr-Commit-Position: refs/heads/master@{#34199}
4 years, 10 months ago (2016-02-22 21:02:58 UTC) #55
Toon Verwaest
4 years, 9 months ago (2016-02-29 18:12:24 UTC) #57
Message was sent while issue was closed.
This doesn't seem to handle redefining .constructor as accessor. Also, this
slows down Object.assign by around 5%.

Powered by Google App Engine
This is Rietveld 408576698