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

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)

Created:
4 years, 1 month ago by Vyacheslav Egorov (Google)
Modified:
4 years, 1 month ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. This is the same as a sticky RegExp flag in ES2015. Overlay some RegExp fields on top of each other - given that they should never be used simultaneously. BUG=http://dartbug.com/27810 R=rmacnak@google.com Committed: https://github.com/dart-lang/sdk/commit/2403444eba54675d8b5d96912fce86f13eff1f1c

Patch Set 1 #

Patch Set 2 : Done #

Total comments: 14

Patch Set 3 : Done #

Unified diffs Side-by-side diffs Delta from patch set Stats (+249 lines, -100 lines) Patch
M runtime/lib/regexp.cc View 1 2 1 chunk +20 lines, -5 lines 0 comments Download
M runtime/lib/regexp_patch.dart View 2 chunks +4 lines, -4 lines 0 comments Download
M runtime/vm/bootstrap_natives.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/intrinsifier.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier.cc View 1 2 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/intrinsifier_arm.cc View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M runtime/vm/intrinsifier_arm64.cc View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M runtime/vm/intrinsifier_ia32.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M runtime/vm/intrinsifier_mips.cc View 1 2 2 chunks +4 lines, -2 lines 0 comments Download
M runtime/vm/intrinsifier_x64.cc View 1 2 2 chunks +4 lines, -3 lines 0 comments Download
M runtime/vm/method_recognizer.h View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/object.h View 2 chunks +43 lines, -19 lines 0 comments Download
M runtime/vm/object.cc View 2 chunks +36 lines, -9 lines 0 comments Download
M runtime/vm/object_service.cc View 1 2 1 chunk +29 lines, -15 lines 0 comments Download
M runtime/vm/raw_object.h View 1 chunk +20 lines, -5 lines 0 comments Download
M runtime/vm/raw_object_snapshot.cc View 1 2 1 chunk +5 lines, -9 lines 0 comments Download
M runtime/vm/regexp.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/regexp.cc View 1 2 8 chunks +18 lines, -14 lines 0 comments Download
M runtime/vm/regexp_assembler_bytecode.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/regexp_assembler_bytecode.cc View 6 chunks +10 lines, -7 lines 0 comments Download
M runtime/vm/regexp_assembler_ir.h View 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/regexp_assembler_ir.cc View 1 chunk +2 lines, -1 line 0 comments Download
M tests/corelib/regexp/regexp_test.dart View 1 2 1 chunk +24 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (4 generated)
Vyacheslav Egorov (Google)
PTAL This improves matchAsPrefix performance for RegExp-s by at least a factor of 2.
4 years, 1 month ago (2016-11-16 18:12:41 UTC) #3
rmacnak
lgtm https://codereview.chromium.org/2510783002/diff/20001/runtime/lib/regexp.cc File runtime/lib/regexp.cc (right): https://codereview.chromium.org/2510783002/diff/20001/runtime/lib/regexp.cc#newcode99 runtime/lib/regexp.cc:99: // This function is intrinsified. See Intrinsifier::RegExp_ExecuteMatch. MatchSticky ...
4 years, 1 month ago (2016-11-17 00:49:52 UTC) #4
erikcorry
https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/intrinsifier_x64.cc File runtime/vm/intrinsifier_x64.cc (right): https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/intrinsifier_x64.cc#newcode2195 runtime/vm/intrinsifier_x64.cc:2195: void Intrinsifier::RegExp_ExecuteMatch(Assembler* assembler) { Can't RegExp_ExecuteMatch and RegExp_ExecuteMatchSticky not ...
4 years, 1 month ago (2016-11-17 13:56:17 UTC) #6
Vyacheslav Egorov (Google)
Committed patchset #3 (id:40001) manually as 2403444eba54675d8b5d96912fce86f13eff1f1c (presubmit successful).
4 years, 1 month ago (2016-11-17 16:46:25 UTC) #8
Vyacheslav Egorov (Google)
4 years, 1 month ago (2016-11-17 16:51:34 UTC) #9
Message was sent while issue was closed.
Thanks for the reviews! Landing.

https://codereview.chromium.org/2510783002/diff/20001/runtime/lib/regexp.cc
File runtime/lib/regexp.cc (right):

https://codereview.chromium.org/2510783002/diff/20001/runtime/lib/regexp.cc#n...
runtime/lib/regexp.cc:99: // This function is intrinsified. See
Intrinsifier::RegExp_ExecuteMatch.
On 2016/11/17 00:49:52, rmacnak wrote:
> MatchSticky

Done.

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/intrinsifier...
File runtime/vm/intrinsifier_x64.cc (right):

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/intrinsifier...
runtime/vm/intrinsifier_x64.cc:2195: void
Intrinsifier::RegExp_ExecuteMatch(Assembler* assembler) {
On 2016/11/17 13:56:17, erikcorry wrote:
> Can't RegExp_ExecuteMatch and RegExp_ExecuteMatchSticky not both call a helper
> with a bool argument?

In this case code below would have to check for boolean argument. It makes entry
into regexp slower.

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/intrinsifier...
runtime/vm/intrinsifier_x64.cc:2196: if (FLAG_interpret_irregexp ||
FLAG_precompiled_runtime) return;
On 2016/11/17 00:49:52, rmacnak wrote:
> Why add this? FLAG_interpret_irregexp should already be compile-time true in
the
> AOT runtime.

There was a code somewhere that checked both so I added it here too to match. 

Instead I should remove it there.

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/raw_object_s...
File runtime/vm/raw_object_snapshot.cc (right):

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/raw_object_s...
runtime/vm/raw_object_snapshot.cc:2897: // TODO(18854): Need to implement a way
of recreating the irrexp functions.
On 2016/11/17 00:49:52, rmacnak wrote:
> Remove this todo.

Done.

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/raw_object_s...
runtime/vm/raw_object_snapshot.cc:2899: for (intptr_t cid = kOneByteStringCid;
cid <= kExternalTwoByteStringCid;
On 2016/11/17 13:56:17, erikcorry wrote:
> Here and elsewhere you put in a loop. Perhaps there should be kFirstStringCid
> and kLastStringCid for use in loops, which are equal in value to the current
> kOneByteStringCid and kExternalTwoByteStringCid.

Yeah, that sounds like a nice improvement - but I will not do that as a part of
this CL.

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/regexp.cc
File runtime/vm/regexp.cc (right):

https://codereview.chromium.org/2510783002/diff/20001/runtime/vm/regexp.cc#ne...
runtime/vm/regexp.cc:4906:
macro_assembler->SetCurrentPositionFromEnd(max_length);
On 2016/11/17 13:56:17, erikcorry wrote:
> This needs fixing here too and we need a test for it.

As we discussed I have fixed it here and I will port a sticky test from V8.

Powered by Google App Engine
This is Rietveld 408576698