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

Issue 1706013: Changing string length field type from int to SMI. It will make it be a regu... (Closed)

Created:
10 years, 8 months ago by SeRya
Modified:
10 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Changing string length field type from int to SMI. It will make it be a regular field. Code generated in EmitNamedLoad could be patched for faster access to string.length. Committed: http://code.google.com/p/v8/source/detail?r=4581

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Patch Set 4 : '' #

Patch Set 5 : '' #

Patch Set 6 : '' #

Total comments: 23

Patch Set 7 : '' #

Patch Set 8 : '' #

Patch Set 9 : '' #

Patch Set 10 : '' #

Total comments: 24

Patch Set 11 : '' #

Patch Set 12 : '' #

Total comments: 22

Patch Set 13 : '' #

Patch Set 14 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+242 lines, -120 lines) Patch
M include/v8.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M src/arm/codegen-arm.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 8 chunks +20 lines, -8 lines 0 comments Download
M src/arm/macro-assembler-arm.h View 13 1 chunk +6 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 5 chunks +36 lines, -21 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 2 chunks +0 lines, -2 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 26 chunks +42 lines, -26 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 2 chunks +6 lines, -2 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 2 chunks +0 lines, -2 lines 0 comments Download
M src/objects.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -1 line 0 comments Download
M src/objects-inl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +3 lines, -5 lines 0 comments Download
M src/x64/codegen-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 21 chunks +53 lines, -39 lines 0 comments Download
M src/x64/macro-assembler-x64.h View 13 3 chunks +8 lines, -1 line 0 comments Download
M src/x64/macro-assembler-x64.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 7 chunks +62 lines, -7 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 2 chunks +2 lines, -4 lines 0 comments Download
M test/cctest/test-serialize.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +2 lines, -1 line 0 comments Download

Messages

Total messages: 12 (0 generated)
SeRya
10 years, 8 months ago (2010-04-27 10:48:18 UTC) #1
Kevin Millikin (Chromium)
Drive by. http://codereview.chromium.org/1706013/diff/50001/51012 File src/arm/codegen-arm.cc (right): http://codereview.chromium.org/1706013/diff/50001/51012#newcode8119 src/arm/codegen-arm.cc:8119: // r3: Length of subject string as ...
10 years, 8 months ago (2010-04-27 11:25:55 UTC) #2
SeRya
http://codereview.chromium.org/1706013/diff/50001/51012 File src/arm/codegen-arm.cc (right): http://codereview.chromium.org/1706013/diff/50001/51012#newcode8119 src/arm/codegen-arm.cc:8119: // r3: Length of subject string as a SMI ...
10 years, 8 months ago (2010-04-27 11:41:00 UTC) #3
Vyacheslav Egorov (Chromium)
First round of comments. I will do a second pass over sources later [probably tomorrow]. ...
10 years, 8 months ago (2010-04-27 12:27:24 UTC) #4
SeRya
http://codereview.chromium.org/1706013/diff/50001/51013 File src/arm/macro-assembler-arm.cc (right): http://codereview.chromium.org/1706013/diff/50001/51013#newcode1025 src/arm/macro-assembler-arm.cc:1025: str(scratch2, FieldMemOperand(result, String::kLengthOffset)); On 2010/04/27 12:27:24, Vyacheslav Egorov wrote: ...
10 years, 8 months ago (2010-04-27 16:16:30 UTC) #5
Erik Corry
http://codereview.chromium.org/1706013/diff/65002/41014 File src/arm/codegen-arm.cc (right): http://codereview.chromium.org/1706013/diff/65002/41014#newcode8119 src/arm/codegen-arm.cc:8119: // r3: Length of subject string as a smi ...
10 years, 8 months ago (2010-04-28 13:25:26 UTC) #6
Vyacheslav Egorov (Chromium)
Did a second pass over sources. http://codereview.chromium.org/1706013/diff/50001/51004 File src/ia32/codegen-ia32.cc (right): http://codereview.chromium.org/1706013/diff/50001/51004#newcode10786 src/ia32/codegen-ia32.cc:10786: __ j(below, &runtime); ...
10 years, 8 months ago (2010-04-28 13:33:41 UTC) #7
SeRya
http://codereview.chromium.org/1706013/diff/65002/41014 File src/arm/codegen-arm.cc (right): http://codereview.chromium.org/1706013/diff/65002/41014#newcode8119 src/arm/codegen-arm.cc:8119: // r3: Length of subject string as a smi ...
10 years, 8 months ago (2010-04-28 16:40:31 UTC) #8
Vyacheslav Egorov (Chromium)
LGTM (with helper in macro-assembler-arm.cc) Still you should probably wait for Erik's opinion on ARM ...
10 years, 8 months ago (2010-04-28 17:10:03 UTC) #9
Erik Corry
http://codereview.chromium.org/1706013/diff/65002/41014 File src/arm/codegen-arm.cc (right): http://codereview.chromium.org/1706013/diff/65002/41014#newcode9144 src/arm/codegen-arm.cc:9144: __ cmp(r2, Operand(0)); // Test if first string is ...
10 years, 8 months ago (2010-04-28 18:24:35 UTC) #10
Lasse Reichstein
In X64 code, never assume anything about the representation of smis outside of the Smi-macros ...
10 years, 8 months ago (2010-04-29 07:04:06 UTC) #11
SeRya
10 years, 7 months ago (2010-04-29 12:16:35 UTC) #12
http://codereview.chromium.org/1706013/diff/65002/41014
File src/arm/codegen-arm.cc (right):

http://codereview.chromium.org/1706013/diff/65002/41014#newcode9144
src/arm/codegen-arm.cc:9144: __ cmp(r2, Operand(0));  // Test if first string is
empty.
On 2010/04/28 18:24:35, Erik Corry wrote:
> On 2010/04/28 13:33:41, Vyacheslav Egorov wrote:
> > Comparing smi with non-smi.
> > 
> > Assert kSmiTag == 0 or use Smi::FromInt() ?
> > 
> > Another interesting question [yes I am aware that you are not the author of
> the
> > code] what is faster on ARM tst(x,x) or cmp(x, 0)?
> 
> Both take 1 cycle.
> 
> In the future I suppose that cmp(x, 0) might be faster, since it affects all
the
> flags so there's no false dependency on the previous state of the flags.
> 
> 

Changed back to cmp and added Smi::FromInt.

http://codereview.chromium.org/1706013/diff/35003/48015
File src/arm/macro-assembler-arm.cc (left):

http://codereview.chromium.org/1706013/diff/35003/48015#oldcode1101
src/arm/macro-assembler-arm.cc:1101: }
On 2010/04/28 17:10:04, Vyacheslav Egorov wrote:
> Well. This is getting hairy. I just noticed that all this pieces of code are
the
> same. They just have different scratch1, scratch2 usage. Changing them
> simultaneously probably annoys you.
> 
> Best solution from my point of view is to create helper:
> 
> void InitializeStringFields (Register string, Register length, Register
> scratch1, Register scratch2) {
>   // Load goes first to improve pipeline utilization.
>   LoadRoot(scratch1, Heap::kConsAsciiStringMapRootIndex);
>   mov(scratch2, Operand(length, LSL, kSmiTagSize));
>   str(scratch2, FieldMemOperand(string, String::kLengthOffset));
>   mov(scratch2, Operand(String::kEmptyHashField));
>   str(scratch2, FieldMemOperand(string, String::kHashFieldOffset)); 
>   str(scratch1, FieldMemOperand(string, HeapObject::kMapOffset));
> } 
> 
> What do you think? From my point of view it is very readable and not fragile
> solution. Will it work?

Done.

http://codereview.chromium.org/1706013/diff/35003/48011
File src/x64/codegen-x64.cc (right):

http://codereview.chromium.org/1706013/diff/35003/48011#newcode3924
src/x64/codegen-x64.cc:3924: __ cmpq(index.reg(), FieldOperand(object.reg(),
String::kLengthOffset));
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiCompare(Operand,Register) instead.
> Don't make any operation that assumes anything about Smi representation
directly
> in X64 code, use the SmiXXX macros instead.

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode5614
src/x64/codegen-x64.cc:5614: __ SmiSubConstant(temp2.reg(), temp2.reg(),
Smi::FromInt(1));
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> It's undocumented that SmiSubConstant sets flags like sub does. If you rely on
> it, please add it to the documentation for SmiSubConstant in
> macro-assembler-x64.h, so any rewrite of the function will preserve that.

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode7449
src/x64/codegen-x64.cc:7449: __ cmpq(rax, rbx);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiCompare

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9685
src/x64/codegen-x64.cc:9685: __ testq(rcx, rcx);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiTest(rcx).
> This one is important (don't assume that the tag or filler bits are zero! This
> is likely to change).

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9692
src/x64/codegen-x64.cc:9692: __ testq(rbx, rbx);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> SmiTest again.

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9721
src/x64/codegen-x64.cc:9721: __ addq(rbx, rcx);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiAdd when adding smis.

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10303
src/x64/codegen-x64.cc:10303: __ subq(scratch4, FieldOperand(right,
String::kLengthOffset));
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiSub for subtracting smis.
> 
> There is no SmiSub(Register, Operand), so either use movq to load from memory
> and SmiSub(Register,Register), or add a SmiSub(Register,Operand) macro.,

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10311
src/x64/codegen-x64.cc:10311: __ subq(scratch1, length_difference);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiSub.

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10319
src/x64/codegen-x64.cc:10319: __ testq(min_length, min_length);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Use SmiTest

Done.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10354
src/x64/codegen-x64.cc:10354: ASSERT(kSmiTag == 0);
On 2010/04/29 07:04:19, Lasse Reichstein wrote:
> Don't ASSERT or assume anything about the smi tag value. Use Smi-macros
instead
> (SmiTest here).

Done.

Powered by Google App Engine
This is Rietveld 408576698