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

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)

Created:
10 years, 9 months ago by antonm
Modified:
9 years, 4 months ago
CC:
v8-dev, Lasse Reichstein, sandholm
Visibility:
Public.

Description

Introduce fast native caches and use it in String.search. Committed: http://code.google.com/p/v8/source/detail?r=4418

Patch Set 1 #

Patch Set 2 : Minor fixes #

Total comments: 8

Patch Set 3 : Addressing Kevin's concerns #

Patch Set 4 : Removing assert #

Total comments: 33

Patch Set 5 : Addressing Lasse's comments #

Patch Set 6 : Next iteration #

Total comments: 36

Patch Set 7 : Next round #

Patch Set 8 : Ported to ARM and x64 #

Patch Set 9 : Last round :) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+427 lines, -33 lines) Patch
M src/arm/codegen-arm.h View 8 1 chunk +3 lines, -0 lines 0 comments Download
M src/arm/codegen-arm.cc View 8 1 chunk +66 lines, -0 lines 0 comments Download
M src/bootstrapper.cc View 7 8 3 chunks +40 lines, -0 lines 0 comments Download
M src/codegen.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -0 lines 0 comments Download
M src/contexts.h View 6 7 8 2 chunks +2 lines, -0 lines 0 comments Download
M src/factory.h View 1 chunk +3 lines, -1 line 0 comments Download
M src/factory.cc View 1 chunk +4 lines, -2 lines 0 comments Download
M src/heap.h View 1 2 3 4 5 6 7 8 2 chunks +6 lines, -2 lines 0 comments Download
M src/heap.cc View 1 2 3 4 5 6 7 8 4 chunks +28 lines, -26 lines 0 comments Download
M src/ia32/codegen-ia32.h View 1 2 3 4 5 6 7 8 1 chunk +3 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 2 3 4 5 6 7 8 1 chunk +74 lines, -0 lines 0 comments Download
M src/macros.py View 1 chunk +3 lines, -0 lines 0 comments Download
M src/objects.h View 7 8 2 chunks +18 lines, -0 lines 0 comments Download
M src/runtime.h View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M src/runtime.cc View 1 2 3 4 5 6 7 8 1 chunk +83 lines, -0 lines 0 comments Download
M src/string.js View 1 2 3 4 5 6 7 8 1 chunk +8 lines, -2 lines 0 comments Download
M src/x64/codegen-x64.h View 8 1 chunk +3 lines, -0 lines 0 comments Download
M src/x64/codegen-x64.cc View 8 1 chunk +76 lines, -0 lines 0 comments Download
M test/mjsunit/fuzz-natives.js View 1 2 3 4 5 6 7 8 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (0 generated)
antonm
Kevin, may you have a look? If overall approach is fine, I'd stub other platforms ...
10 years, 9 months ago (2010-03-30 10:32:40 UTC) #1
antonm
friendly ping
10 years, 8 months ago (2010-04-06 10:29:20 UTC) #2
Kevin Millikin (Chromium)
I looked mainly at the code generator changes, which LGTM. Maybe Lasse should take a ...
10 years, 8 months ago (2010-04-07 13:34:36 UTC) #3
antonm
Thanks a lot, Kevin! Looping Lasse in (if you don't mind, Lasse.) http://codereview.chromium.org/1563005/diff/2001/3005 File src/heap.h ...
10 years, 8 months ago (2010-04-07 15:01:35 UTC) #4
Kevin Millikin (Chromium)
http://codereview.chromium.org/1563005/diff/2001/3006 File src/ia32/codegen-ia32.cc (right): http://codereview.chromium.org/1563005/diff/2001/3006#newcode6508 src/ia32/codegen-ia32.cc:6508: cache.ToRegister(); On 2010/04/07 15:01:35, antonm wrote: > On 2010/04/07 ...
10 years, 8 months ago (2010-04-07 15:31:56 UTC) #5
antonm
http://codereview.chromium.org/1563005/diff/2001/3006 File src/ia32/codegen-ia32.cc (right): http://codereview.chromium.org/1563005/diff/2001/3006#newcode6508 src/ia32/codegen-ia32.cc:6508: cache.ToRegister(); On 2010/04/07 15:31:56, Kevin Millikin wrote: > On ...
10 years, 8 months ago (2010-04-07 15:38:59 UTC) #6
Lasse Reichstein
I'm not convinced this is a good idea. It seems like it would be a ...
10 years, 8 months ago (2010-04-08 17:04:28 UTC) #7
antonm
Lasse, thanks a lot for comments. Let me start with the principal question. My current ...
10 years, 8 months ago (2010-04-08 17:50:14 UTC) #8
antonm
http://codereview.chromium.org/1563005/diff/12001/13008 File src/runtime.cc (right): http://codereview.chromium.org/1563005/diff/12001/13008#newcode10071 src/runtime.cc:10071: int target_index = (finger_index > kEntriesIndex) ? finger_index - ...
10 years, 8 months ago (2010-04-09 05:20:20 UTC) #9
Lasse Reichstein
If you make the FixedArrays completely hidden from JS code, then they should be safe ...
10 years, 8 months ago (2010-04-09 07:18:25 UTC) #10
antonm
Lasse, thanks a lot for comments and clarifications. May you have another look? Major features: ...
10 years, 8 months ago (2010-04-09 13:48:51 UTC) #11
Lasse Reichstein
Seems much better, and safer. I would consider creating all caches from C++ code during ...
10 years, 8 months ago (2010-04-13 09:30:13 UTC) #12
antonm
Lasse, thanks a lot for comments and suggestions. I am starting on ports to ARM ...
10 years, 8 months ago (2010-04-13 14:41:45 UTC) #13
Lasse Reichstein
LGTM. http://codereview.chromium.org/1563005/diff/9012/25009 File src/runtime.cc (right): http://codereview.chromium.org/1563005/diff/9012/25009#newcode10022 src/runtime.cc:10022: cache->set(kCacheSizeIndex, Smi::FromInt(kEntriesIndex)); My mistake. I was confusing the ...
10 years, 8 months ago (2010-04-14 09:11:09 UTC) #14
antonm
10 years, 8 months ago (2010-04-14 14:32:27 UTC) #15
Lasse, thanks a lot for review!

Running tests and submitting with some minor corrections.  If you'd like to see
something changed, just let me know.

http://codereview.chromium.org/1563005/diff/9012/25009
File src/runtime.cc (right):

http://codereview.chromium.org/1563005/diff/9012/25009#newcode10022
src/runtime.cc:10022: cache->set(kCacheSizeIndex, Smi::FromInt(kEntriesIndex));
On 2010/04/14 09:11:09, Lasse Reichstein wrote:
> My mistake. I was confusing the two meanings of size (initial capacity and
> currently used capacity) so I thought this field was holding the capacity, not
> the next free entry pointer.

np

http://codereview.chromium.org/1563005/diff/9012/25009#newcode10079
src/runtime.cc:10079: // Search the cache in less recently used order.
On 2010/04/14 09:11:09, Lasse Reichstein wrote:
> Maybe something to say that LRU only holds as long as we miss.
> 
> I'm worrying that if you alternate between two input values, every other
> finger-miss will take the maximal time to find the match. And using a new key
at
> that point is 50% likely to overwrite the second-most-recently-used entry.
> 
> On the other hand, we don't want to reorder the cache based on usage, so we
only
> track the most recently used element (the finger) and don't really know what
the
> second most recently used element was.
> I guess there isn't any simple way to do better.

I just decided to drop the comment.  If you think we'de better have one, please,
let me know.

http://codereview.chromium.org/1563005/diff/9012/25011
File src/string.js (right):

http://codereview.chromium.org/1563005/diff/9012/25011#newcode519
src/string.js:519: %NewCache(0, 16, function(re) { return new $RegExp(re); });
On 2010/04/14 09:11:09, Lasse Reichstein wrote:
> Not sure why you couldn't use $RegExp, but a guess would be that it didn't
exist
> yet at the time the natives code file was loaded.
> Our natives code files really contain two parts: the runtime functions and the
> initialization time setup. The setup cannot rely on another natives file
having
> been loaded before it, but the runtime functions are only called when all
> natives files have been loaded and initialized.
> In this case, global.RegExp was created by the bootstrapper code before
loading
> natives, but $RegExp isn't created until regexp.js is loaded (and
global.RegExp
> doesn't work until that has happened either, because regexp.js sets the code
of
> the function).

Thanks a lot for explanations, I think it's indeed the case

http://codereview.chromium.org/1563005/diff/9012/25012
File test/mjsunit/fuzz-natives.js (right):

http://codereview.chromium.org/1563005/diff/9012/25012#newcode164
test/mjsunit/fuzz-natives.js:164: // additional checks.
On 2010/04/14 09:11:09, Lasse Reichstein wrote:
> Maybe add something saying that the function only accepts a Smi literal as
first
> argument, which is checked at compile time. That's the real reason we can't
test
> it properly with fuzz-natives (right?).

That is already done, see patch 8.  Again, going to submit, but if you would
like to have this comment altered, just let me know.

Powered by Google App Engine
This is Rietveld 408576698