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

Issue 6894003: Better support for 'polymorphic' JS and external arrays (Closed)

Created:
9 years, 8 months ago by danno
Modified:
9 years, 6 months ago
CC:
v8-dev
Visibility:
Public.

Description

Better support for 'polymorphic' JS and external arrays Allow keyed store/load stubs to switch between external array and fast JS arrays without forcing a state transition to the generic stub. There CL consists of two pieces of functionality. First, code stubs for fast element arrays don't immediately transition to the MEGAMORPHIC state when there's a map mismatch. Second, two ICs are cached per map for fast elements, the MONOMORPHIC version, and a new MEGAMORPHIC version that handles two or more different maps. Currently, the only array types supported by the MEGAMORPHIC stub are fast elements for objects and JSArrays. BUG= TEST= Committed: http://code.google.com/p/v8/source/detail?r=7917

Patch Set 1 : initial ia32 implementation #

Patch Set 2 : implement x64 #

Patch Set 3 : implement arm #

Patch Set 4 : allow polymorphic fast case elements #

Patch Set 5 : polish ia32 and x64 #

Patch Set 6 : implement arm support #

Patch Set 7 : new strategy #

Total comments: 8

Patch Set 8 : more changes #

Patch Set 9 : share between machines #

Patch Set 10 : merge with latest #

Patch Set 11 : share non-map-checking stubs #

Patch Set 12 : fix nits #

Patch Set 13 : fewer diffs #

Patch Set 14 : properly handle CALLBACKS properties #

Patch Set 15 : fix nits #

Patch Set 16 : merge with latest #

Total comments: 36

Patch Set 17 : review feedback #

Patch Set 18 : review feedback and merge #

Total comments: 28

Patch Set 19 : review feedback #

Patch Set 20 : final review feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1997 lines, -849 lines) Patch
M src/arm/code-stubs-arm.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +1 line, -1 line 0 comments Download
M src/arm/ic-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +31 lines, -10 lines 0 comments Download
M src/arm/macro-assembler-arm.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +11 lines, -0 lines 0 comments Download
M src/arm/macro-assembler-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +17 lines, -0 lines 0 comments Download
M src/arm/stub-cache-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 13 chunks +281 lines, -134 lines 0 comments Download
M src/builtins.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +117 lines, -110 lines 0 comments Download
M src/builtins.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +23 lines, -3 lines 0 comments Download
M src/code-stubs.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +84 lines, -0 lines 0 comments Download
M src/code-stubs.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 chunks +22 lines, -1 line 0 comments Download
M src/flag-definitions.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +3 lines, -4 lines 0 comments Download
M src/heap.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +10 lines, -29 lines 0 comments Download
M src/ia32/ic-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 6 chunks +33 lines, -8 lines 0 comments Download
M src/ia32/macro-assembler-ia32.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +12 lines, -3 lines 0 comments Download
M src/ia32/macro-assembler-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +15 lines, -0 lines 0 comments Download
M src/ia32/stub-cache-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 chunks +264 lines, -114 lines 0 comments Download
M src/ic.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 7 chunks +116 lines, -26 lines 0 comments Download
M src/ic.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 9 chunks +392 lines, -44 lines 0 comments Download
M src/list.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +5 lines, -0 lines 0 comments Download
M src/log.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +46 lines, -44 lines 0 comments Download
M src/log.cc View 1 2 3 4 5 6 7 8 9 3 chunks +1 line, -9 lines 0 comments Download
M src/mark-compact.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +2 lines, -2 lines 0 comments Download
M src/mips/code-stubs-mips.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +0 lines, -1 line 0 comments Download
M src/objects.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +1 line, -8 lines 0 comments Download
M src/objects.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +0 lines, -4 lines 0 comments Download
M src/objects-inl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +3 lines, -5 lines 0 comments Download
M src/spaces.cc View 1 2 3 4 5 6 7 8 9 2 chunks +1 line, -3 lines 0 comments Download
M src/stub-cache.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 8 chunks +53 lines, -20 lines 0 comments Download
M src/stub-cache.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 8 chunks +111 lines, -142 lines 0 comments Download
M src/type-info.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +9 lines, -6 lines 0 comments Download
M src/v8-counters.h View 1 2 3 4 3 chunks +4 lines, -1 line 0 comments Download
M src/x64/ic-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 6 chunks +33 lines, -8 lines 0 comments Download
M src/x64/macro-assembler-x64.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 chunks +9 lines, -0 lines 0 comments Download
M src/x64/macro-assembler-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +15 lines, -0 lines 0 comments Download
M src/x64/stub-cache-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 8 chunks +272 lines, -109 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
danno
Please review.
9 years, 8 months ago (2011-04-27 14:56:28 UTC) #1
Mads Ager (chromium)
Very high-level comments for now. I don't like the idea of creating new full stubs ...
9 years, 8 months ago (2011-04-27 15:57:21 UTC) #2
danno
WIP, so don't worry about nits for now. Please take a look specifically at ic.cc ...
9 years, 8 months ago (2011-04-28 12:01:54 UTC) #3
Mads Ager (chromium)
Only looked at load for now. This seems like the right approach. We should get ...
9 years, 8 months ago (2011-04-28 13:02:01 UTC) #4
Jakob Kummerow
A few drive-by comments... I haven't looked at everything in detail yet, but these caught ...
9 years, 7 months ago (2011-05-09 14:58:40 UTC) #5
danno%chromium.org
Ready to land, please review.
9 years, 7 months ago (2011-05-10 07:24:06 UTC) #6
Mads Ager (chromium)
Urgh, this change is getting massive. With the size of this I'm afraid I have ...
9 years, 7 months ago (2011-05-10 13:38:06 UTC) #7
danno
Addressed all your feedback and filed bug 1384 for moving the megamorphic cache off the ...
9 years, 7 months ago (2011-05-11 14:20:19 UTC) #8
Lasse Reichstein
drive-by comment. http://codereview.chromium.org/6894003/diff/43002/src/x64/stub-cache-x64.cc File src/x64/stub-cache-x64.cc (right): http://codereview.chromium.org/6894003/diff/43002/src/x64/stub-cache-x64.cc#newcode2538 src/x64/stub-cache-x64.cc:2538: Handle<Code>(handler_ics->at(current)), You repeatedly read the map out ...
9 years, 7 months ago (2011-05-12 08:33:45 UTC) #9
Mads Ager (chromium)
LGTM, with a couple of nits. http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc File src/arm/stub-cache-arm.cc (right): http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc#newcode3128 src/arm/stub-cache-arm.cc:3128: true); I already ...
9 years, 7 months ago (2011-05-12 09:42:47 UTC) #10
danno
9 years, 6 months ago (2011-06-01 13:16:08 UTC) #11
Feedback addressed and landed.

http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc
File src/arm/stub-cache-arm.cc (right):

http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc#n...
src/arm/stub-cache-arm.cc:3128: true);
On 2011/05/12 09:42:47, Mads Ager wrote:
> I already forgot what this boolean is. Using an enum value would make it
easier
> to read.

Done.

http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc#n...
src/arm/stub-cache-arm.cc:4114: __ tst(r0, Operand(kSmiTagMask));
On 2011/05/12 09:42:47, Mads Ager wrote:
> Use JumpIfNotSmi?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc#n...
src/arm/stub-cache-arm.cc:4166: __ tst(key_reg, Operand(kSmiTagMask));
On 2011/05/12 09:42:47, Mads Ager wrote:
> JumpIfNotSmi?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/arm/stub-cache-arm.cc#n...
src/arm/stub-cache-arm.cc:4172: __ ldr(scratch, FieldMemOperand(elements_reg,
HeapObject::kMapOffset));
On 2011/05/12 09:42:47, Mads Ager wrote:
> Can you use CheckMap with kFixedArrayMapRootIndex here?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/code-stubs.h
File src/code-stubs.h (right):

http://codereview.chromium.org/6894003/diff/43002/src/code-stubs.h#newcode950
src/code-stubs.h:950: bool is_js_array_;
On 2011/05/12 09:42:47, Mads Ager wrote:
> Remove, this is unused?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/code-stubs.h#newcode960
src/code-stubs.h:960: int MinorKey() { return is_js_array_; }
On 2011/05/12 09:42:47, Mads Ager wrote:
> Let's do an explicit type conversion here:
> 
> return is_js_array ? 1 : 0;

Done.

http://codereview.chromium.org/6894003/diff/43002/src/ic.cc
File src/ic.cc (right):

http://codereview.chromium.org/6894003/diff/43002/src/ic.cc#newcode1590
src/ic.cc:1590: // cases (external arrays need the array type from the
MONOMORPHIC stub).
On 2011/05/12 09:42:47, Mads Ager wrote:
> I don't know how much that will happen, but we shouldn't generate the
> monomorphic fast elements stub unless we need them. So we shouldn't generate
> them if we are (going) megamorphic. They are not needed later in that case.
> 
> That should be simple to avoid?

It's not the easy here, unfortunately. We need to make sure that the array type
is available from the monomorphic stub, otherwise we don't know which external
array shared stub to use in the megamorphic case (thus the comment). I'll add a
TODO that when we finally figure out a better way to track the external array
type with the map that we should remove this.

http://codereview.chromium.org/6894003/diff/43002/src/ic.h
File src/ic.h (right):

http://codereview.chromium.org/6894003/diff/43002/src/ic.h#newcode329
src/ic.h:329: 
On 2011/05/12 09:42:47, Mads Ager wrote:
> Could you use two blank lines between class declarations?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/ic.h#newcode375
src/ic.h:375: 
On 2011/05/12 09:42:47, Mads Ager wrote:
> Ditto.

Done.

http://codereview.chromium.org/6894003/diff/43002/src/log.h
File src/log.h (right):

http://codereview.chromium.org/6894003/diff/43002/src/log.h#newcode125
src/log.h:125: V(KEYED_LOAD_MEGAMORPHIC_IC_TAG,  "KeyedLoadMegamorphicIC")   \
On 2011/05/12 09:42:47, Mads Ager wrote:
> Not introduced with your change, but can you right align all of the '\' here?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/objects.cc
File src/objects.cc (left):

http://codereview.chromium.org/6894003/diff/43002/src/objects.cc#oldcode3767
src/objects.cc:3767: ASSERT(code->ic_state() == MONOMORPHIC);
Agreed.
On 2011/05/12 09:42:47, Mads Ager wrote:
> We should reintroduce this assert once we have removed the megamorphic keyed
ICs
> from the map caches.

http://codereview.chromium.org/6894003/diff/43002/src/objects.h
File src/objects.h (right):

http://codereview.chromium.org/6894003/diff/43002/src/objects.h#newcode6712
src/objects.h:6712: class Map;
On 2011/05/12 09:42:47, Mads Ager wrote:
> Can we move these to list.h and avoid depending on list.h here? It seems that
> forward declarations in list.h should be enough?

Done.

http://codereview.chromium.org/6894003/diff/43002/src/x64/stub-cache-x64.cc
File src/x64/stub-cache-x64.cc (right):

http://codereview.chromium.org/6894003/diff/43002/src/x64/stub-cache-x64.cc#n...
src/x64/stub-cache-x64.cc:2538: Handle<Code>(handler_ics->at(current)),
On 2011/05/12 08:33:46, Lasse Reichstein wrote:
> You repeatedly read the map out of the value. It'll obviously be hot, so the
> memory compare should be quick. Still, would it be possible to find a scratch
> register and read the map once, before the checks, and only do register
> compares? 
> It would save one byte per compare, at the cost of one memory load (~4 bytes
> IIRC).

Done.

http://codereview.chromium.org/6894003/diff/43002/src/x64/stub-cache-x64.cc#n...
src/x64/stub-cache-x64.cc:3546: masm->isolate()->factory()->fixed_array_map());
On 2011/05/12 09:42:47, Mads Ager wrote:
> You could load this from the root array into kScratchRegister and compare to
> that instead of embedding the map here.

Done.

Powered by Google App Engine
This is Rietveld 408576698