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

Issue 22545007: Hack forEach to use HasFastPackedElements (Closed)

Created:
7 years, 4 months ago by arv (Not doing code reviews)
Modified:
7 years, 4 months ago
CC:
v8-dev
Visibility:
Public.

Description

Hack forEach to use HasFastPackedElements WIP BUG=

Patch Set 1 : Changed to use benchmarks/base.js #

Patch Set 2 : Now with sparse tests #

Patch Set 3 : cleanup #

Patch Set 4 : check undefined instead #

Patch Set 5 : Need to special case proxies #

Patch Set 6 : Branch on proxies #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+175 lines, -47 lines) Patch
M src/array.js View 1 2 3 4 5 3 chunks +96 lines, -1 line 6 comments Download
M src/objects.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M src/objects-inl.h View 1 chunk +5 lines, -0 lines 0 comments Download
M src/runtime.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/runtime.cc View 1 chunk +1 line, -0 lines 0 comments Download
A + test.js View 1 2 3 1 chunk +71 lines, -46 lines 0 comments Download

Messages

Total messages: 18 (0 generated)
arv (Not doing code reviews)
Remember that we talked a bit about how slow forEach is due to the in ...
7 years, 4 months ago (2013-08-08 20:26:36 UTC) #1
adamk
I like it! I doubt it would slow things down much, but can you add ...
7 years, 4 months ago (2013-08-08 20:40:32 UTC) #2
arv (Not doing code reviews)
On 2013/08/08 20:40:32, adamk wrote: > I like it! I doubt it would slow things ...
7 years, 4 months ago (2013-08-08 20:57:46 UTC) #3
adamk
On 2013/08/08 20:57:46, arv wrote: > On 2013/08/08 20:40:32, adamk wrote: > > I like ...
7 years, 4 months ago (2013-08-08 20:59:46 UTC) #4
arv (Not doing code reviews)
Added sparse array check: arv@zapp:~/src/v8 (faster-for-each) $ out/ia32.release/d8 test.js ForEach: 179435 ForEach2: 363199 ForEachWithHoles: 117389 ...
7 years, 4 months ago (2013-08-08 21:10:18 UTC) #5
arv (Not doing code reviews)
One more idea... taken from reduce Instead of doing the in check we [[Get]] the ...
7 years, 4 months ago (2013-08-09 14:24:06 UTC) #6
adamk
On 2013/08/09 14:24:06, arv wrote: > One more idea... taken from reduce > > Instead ...
7 years, 4 months ago (2013-08-09 15:40:00 UTC) #7
arv (Not doing code reviews)
Hi Michael, I've been thinking about how to improve the perf of Array.prototype.forEach. I have ...
7 years, 4 months ago (2013-08-12 16:26:33 UTC) #8
Michael Starzinger
https://codereview.chromium.org/22545007/diff/20001/src/array.js File src/array.js (right): https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 src/array.js:1263: if (!isProxy && %HasFastPackedElements(array) || i in array) { ...
7 years, 4 months ago (2013-08-13 14:10:21 UTC) #9
Michael Starzinger
https://codereview.chromium.org/22545007/diff/20001/src/array.js File src/array.js (right): https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1315 src/array.js:1315: if (!IS_UNDEFINED(element) || i in array) { On 2013/08/13 ...
7 years, 4 months ago (2013-08-13 14:18:58 UTC) #10
arv (Not doing code reviews)
On 2013/08/13 14:10:21, Michael Starzinger wrote: > https://codereview.chromium.org/22545007/diff/20001/src/array.js > File src/array.js (right): > > https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 ...
7 years, 4 months ago (2013-08-13 14:40:33 UTC) #11
Michael Starzinger
https://codereview.chromium.org/22545007/diff/20001/src/array.js File src/array.js (right): https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 src/array.js:1263: if (!isProxy && %HasFastPackedElements(array) || i in array) { ...
7 years, 4 months ago (2013-08-13 15:47:16 UTC) #12
Toon Verwaest
Dbc https://codereview.chromium.org/22545007/diff/20001/src/array.js File src/array.js (right): https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 src/array.js:1263: if (!isProxy && %HasFastPackedElements(array) || i in array) ...
7 years, 4 months ago (2013-08-13 20:47:42 UTC) #13
Michael Starzinger
https://codereview.chromium.org/22545007/diff/20001/src/array.js File src/array.js (right): https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 src/array.js:1263: if (!isProxy && %HasFastPackedElements(array) || i in array) { ...
7 years, 4 months ago (2013-08-14 07:48:47 UTC) #14
arv (Not doing code reviews)
On 2013/08/14 07:48:47, Michael Starzinger wrote: > https://codereview.chromium.org/22545007/diff/20001/src/array.js > File src/array.js (right): > > https://codereview.chromium.org/22545007/diff/20001/src/array.js#newcode1263 ...
7 years, 4 months ago (2013-08-14 14:43:35 UTC) #15
Toon Verwaest
You can actually create, using Object.defineProperty, an array that doesn't have foreign accessors as its ...
7 years, 4 months ago (2013-08-14 14:48:55 UTC) #16
arv (Not doing code reviews)
On 2013/08/14 14:48:55, Toon Verwaest wrote: > You can actually create, using Object.defineProperty, an array ...
7 years, 4 months ago (2013-08-14 15:01:31 UTC) #17
Toon Verwaest
7 years, 4 months ago (2013-08-14 15:13:48 UTC) #18
What I mean is that you can't break when you go past the length. You actually
have to go to a slow path when you read past the length, that does the entire
in-check; and loops until the index surpasses the preloaded length value. And
that's independent of whether the receiver is fast-packed or not.

In any case, we don't think this is the right way to optimize this function. We
rather should first teach crankshaft to inline this function into the caller,
and then we should teach crankshaft to do the optimizations you are doing by
hand; to ensure that all such JavaScript code benefits from that optimization.

Do you have a particular pressing need for this function to become fast? In
other words, is there a real-world application that is currently blocked by
this, performance-wise? If not, we'd rather focus on doing what we described
above, rather than adding more localized (potentially buggy) optimizations that
we'll have to throw out again later.

Powered by Google App Engine
This is Rietveld 408576698