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

Issue 8187: Serendipitously arrange the tags so that String.length() becomes a branch-fre... (Closed)

Created:
12 years, 1 month ago by Erik Corry
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Serendipitously arrange the tags so that String.length() becomes a branch-free operation. I have another version of this change that does not remove the special inline caches for difference sized strings. The other version is ever so slightly faster, but the nice thing about this version is that it removes 253 lines of code. Committed: http://code.google.com/p/v8/source/detail?r=603

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+88 lines, -341 lines) Patch
M src/builtins.h View 1 chunk +1 line, -3 lines 0 comments Download
M src/builtins.cc View 1 chunk +2 lines, -12 lines 0 comments Download
M src/codegen-ia32.cc View 4 chunks +16 lines, -32 lines 4 comments Download
M src/ic.h View 1 chunk +1 line, -3 lines 0 comments Download
M src/ic.cc View 2 chunks +2 lines, -17 lines 0 comments Download
M src/ic-ia32.cc View 2 chunks +2 lines, -36 lines 0 comments Download
M src/objects.h View 3 chunks +15 lines, -16 lines 5 comments Download
M src/objects.cc View 1 chunk +4 lines, -2 lines 0 comments Download
M src/objects-inl.h View 3 chunks +21 lines, -52 lines 0 comments Download
M src/stub-cache.h View 3 chunks +7 lines, -23 lines 0 comments Download
M src/stub-cache.cc View 2 chunks +3 lines, -37 lines 0 comments Download
M src/stub-cache-ia32.cc View 4 chunks +14 lines, -108 lines 2 comments Download

Messages

Total messages: 3 (0 generated)
Erik Corry
12 years, 1 month ago (2008-10-27 08:12:58 UTC) #1
Kasper Lund
I think you should let Mads take a look at the specifics of the length ...
12 years, 1 month ago (2008-10-27 08:27:31 UTC) #2
Mads Ager (chromium)
12 years, 1 month ago (2008-10-27 09:37:00 UTC) #3
LGTM.  

The new encoding is quite clever and it could use a comment in objects.h.

Let's hope we don't have to change the encoding much.

http://codereview.chromium.org/8187/diff/1/12
File src/codegen-ia32.cc (right):

http://codereview.chromium.org/8187/diff/1/12#newcode2868
Line 2868: __ shr(edx);  // Ecx is implicit operand.
Since Ecx is a register name, I probably would not capitalize it.

http://codereview.chromium.org/8187/diff/1/8
File src/objects.h (right):

http://codereview.chromium.org/8187/diff/1/8#newcode398
Line 398: // If bit 7 is clear, bits 5 and 6 are the string's size (short,
medium or long).
This is now bits 4 and 5?

Also, you should add a comment explaining that you use this encoding so that you
can perform the length shifts based on the tags in the instance type.

http://codereview.chromium.org/8187/diff/1/8#newcode404
Line 404: // If bit 7 is clear, bit 4 indicates that the string is a symbol (if
set) or
And this is now bit 5?

http://codereview.chromium.org/8187/diff/1/8#newcode417
Line 417: // If bit 7 is clear, the low-order 3 bits indicate the representation
3 -> 2 bits.

http://codereview.chromium.org/8187/diff/1/8#newcode3157
Line 3157: static const int kMaxMediumStringSize = 16383;
These reductions in the limits is the only thing that worries me.  It means that
a lot of strings could potentially have worse hash-codes.

http://codereview.chromium.org/8187/diff/1/8#newcode3183
Line 3183: static const int kShortLengthShift = 26;
Could we write these as kShortStringTag + kRepresentationTagSize and
kMediumStringTag + kRepresentationTagSize.  That would make it clearer to me
what the encoding is.

http://codereview.chromium.org/8187/diff/1/2
File src/stub-cache-ia32.cc (right):

http://codereview.chromium.org/8187/diff/1/2#newcode182
Line 182: // Ecx is also the receiver.
Ecx -> ecx since it is a register name?

http://codereview.chromium.org/8187/diff/1/2#newcode184
Line 184: __ shr(eax);  // Ecx is implicit shift register.
Ditto?

Powered by Google App Engine
This is Rietveld 408576698