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

Issue 28184: Avoids allocating a JSArray of capture information on each non-global... (Closed)

Created:
11 years, 10 months ago by Erik Corry
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Avoids allocating a JSArray of capture information on each non-global regular expression match. Also moves all last-match information into one place where it can be updated from C++ code (this will be used in another afsnit). Committed: http://code.google.com/p/v8/source/detail?r=1383

Patch Set 1 #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats (+356 lines, -187 lines) Patch
M src/jsregexp.h View 5 chunks +41 lines, -6 lines 0 comments Download
M src/jsregexp.cc View 14 chunks +110 lines, -46 lines 6 comments Download
M src/macros.py View 2 chunks +19 lines, -1 line 1 comment Download
M src/regexp-delay.js View 8 chunks +61 lines, -57 lines 0 comments Download
M src/runtime.h View 1 chunk +2 lines, -2 lines 0 comments Download
M src/runtime.cc View 2 chunks +10 lines, -5 lines 1 comment Download
M src/string.js View 17 chunks +89 lines, -68 lines 0 comments Download
test/mjsunit/regexp-string-methods.js View 1 chunk +22 lines, -0 lines 0 comments Download
M tools/js2c.py View 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Erik Corry
11 years, 10 months ago (2009-02-26 14:12:48 UTC) #1
Christian Plesner Hansen
11 years, 10 months ago (2009-02-26 15:18:53 UTC) #2
Lgtm, with comments.

The test case wasn't uploaded for some reason so I can't see it.

http://codereview.chromium.org/28184/diff/1/10
File src/jsregexp.cc (right):

http://codereview.chromium.org/28184/diff/1/10#newcode257
Line 257: static void EnsureSize(Handle<JSArray> lastMatchInfo,
You might consider making this a method on JSArray or JSObject even -- it looks
generally useful.  In fact, I know one other place that does the exact same
thing, NeanderArray::add in api.cc.

http://codereview.chromium.org/28184/diff/1/10#newcode276
Line 276: Smi* index,
Consider converting the index to a C right away -- we usually do that eagerly. 
Also, what happens when using an integer > 2^30?

http://codereview.chromium.org/28184/diff/1/10#newcode338
Line 338: SetLastCaptureCount(*array, 2);
Could this sequence of 'Set's be packed into a function?  It looks like you're
doing the exact same thing 30 lines below.

http://codereview.chromium.org/28184/diff/1/10#newcode351
Line 351: CHECK(lastMatchInfo->HasFastElements());
Don't you mean ASSERT?

http://codereview.chromium.org/28184/diff/1/10#newcode365
Line 365: Handle<FixedArray> array(lastMatchInfo->elements());
You're creating an unbounded number of handles here.  You should insert a handle
scope.

http://codereview.chromium.org/28184/diff/1/10#newcode592
Line 592: Handle<FixedArray> matches_array(JSArray::cast(*matches)->elements());
Again with the unbounded number of handles.

http://codereview.chromium.org/28184/diff/1/4
File src/macros.py (right):

http://codereview.chromium.org/28184/diff/1/4#newcode113
Line 113: macro LAST_SUBJECT(array) = ((array)[(array)[0] + 1]);
Beware: this evaluates its argument twice.

http://codereview.chromium.org/28184/diff/1/6
File src/runtime.cc (right):

http://codereview.chromium.org/28184/diff/1/6#newcode866
Line 866: CONVERT_CHECKED(Smi, index, args[2]);
This looks suspect -- plain small integers sometimes end up in heap numbers. 
Maybe CONVERT_NUMBER_CHECKED is what you're looking for.

Powered by Google App Engine
This is Rietveld 408576698