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

Issue 2951053003: VM(RegExp): Allow OSR optimization of RegExp :matcher functions. (Closed)

Created:
3 years, 6 months ago by Vyacheslav Egorov (Google)
Modified:
3 years, 6 months ago
Reviewers:
erikcorry
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

VM(RegExp): Allow OSR optimization of RegExp :matcher functions. Previously these functions would only contain a single CheckStackOverflowInstr in a backtracking block and that CheckStackOverflowInstr would have a zero loop_depth - which means it would not be considered eligable for OSR. This change: * adds CheckStackOverflowInstr with non-zero loop_depth in two other places (Boyer-Moore lookahead skip loop and greedy loop) where loops arise in the generated IL; * sets non-zero loop depth on the CheckStackOverflowInstr in the backtracking block; * adds a flag on CheckStackOverflowInstr that allows optimizing compiler to optimize away those checks that were inserted solely to serve as OSR entries. * ensures that IR generated by IRRegExpMacroAssembler is OSR compatible: * GraphEntryInstr has correct osr_id; * GraphEntry and normal entry have different block ids (B0 and B1 - instead of B0 and B0); * unreachable blocks are pruned and GraphEntry is rewired to point to OSR entry; * IRRegExpMacroAssembler::GrowStack should not assume that stack_array_cell and :stack are always in sync, because :stack can come from OSR or deoptimization why stack_array_cell is a constant associated with a particular Code object. * refactors the way the RegExp stack was growing: instead of having a special instruction just emit a call to a Dart function; * refactors the way block pruning for OSR is done by consolidating duplicated code in a single function. We allow the optimizing compiler to remove preemption checks from non-backtracking loops in the regexp code because those loops unlike backtracking have guaranteed O(input_length) time complexity. Performance Implications ------------------------ This change improves performance of regexps in cases where regexp spends a lot of time in the first invocation (either due to backtracking or due to long non matching prefix) by allowing VM to optimize the :matcher while :matcher is running. For example on regex-redux[1] benchmark it improves Dart performance by 3x (from ~18s to ~6s on my Mac Book Pro). CL history ---------- This relands commit d87cc52c3ee791e4dff9136c5c80353deb0f36a3. Original code review: https://codereview.chromium.org/2950783003/ [1] https://benchmarksgame.alioth.debian.org/u64q/program.php?test=regexredux&lang=dart&id=2 R=erikcorry@google.com Committed: https://github.com/dart-lang/sdk/commit/7887c34a29b015fcf7411bafc27ace0d4a1e73e7

Patch Set 1 #

Patch Set 2 : Fix compilation errors #

Patch Set 3 : Fix bugs with stack growing and block pruning #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+131 lines, -215 lines) Patch
M runtime/lib/internal_patch.dart View 1 2 2 chunks +10 lines, -0 lines 0 comments Download
M runtime/vm/compiler.cc View 1 2 1 chunk +9 lines, -6 lines 2 comments Download
M runtime/vm/constant_propagator.cc View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M runtime/vm/flow_graph_builder.cc View 1 2 2 chunks +1 line, -10 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 2 8 chunks +28 lines, -28 lines 2 comments Download
M runtime/vm/intermediate_language.cc View 1 2 3 chunks +28 lines, -2 lines 0 comments Download
M runtime/vm/intermediate_language_arm.cc View 1 2 1 chunk +0 lines, -24 lines 0 comments Download
M runtime/vm/intermediate_language_arm64.cc View 1 2 1 chunk +0 lines, -24 lines 0 comments Download
M runtime/vm/intermediate_language_dbc.cc View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 1 chunk +0 lines, -24 lines 0 comments Download
M runtime/vm/intermediate_language_mips.cc View 1 2 1 chunk +0 lines, -27 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 2 1 chunk +0 lines, -24 lines 0 comments Download
M runtime/vm/kernel_binary_flowgraph.cc View 1 2 1 chunk +4 lines, -9 lines 0 comments Download
M runtime/vm/regexp.h View 1 chunk +2 lines, -1 line 0 comments Download
M runtime/vm/regexp.cc View 4 chunks +7 lines, -4 lines 0 comments Download
M runtime/vm/regexp_assembler.h View 1 chunk +3 lines, -0 lines 2 comments Download
M runtime/vm/regexp_assembler_ir.h View 1 2 3 chunks +4 lines, -3 lines 0 comments Download
M runtime/vm/regexp_assembler_ir.cc View 1 2 6 chunks +32 lines, -8 lines 0 comments Download
M runtime/vm/runtime_entry.cc View 1 2 1 chunk +0 lines, -17 lines 0 comments Download
M runtime/vm/runtime_entry_list.h View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M runtime/vm/symbols.h View 1 2 1 chunk +2 lines, -1 line 0 comments Download
M tests/corelib/corelib.status View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 10 (6 generated)
Vyacheslav Egorov (Google)
Hi Erik, Please take a look. The changes from the previous CL: 1) Fixed compilation ...
3 years, 6 months ago (2017-06-21 20:33:45 UTC) #6
erikcorry
LGTM https://codereview.chromium.org/2951053003/diff/40001/runtime/vm/compiler.cc File runtime/vm/compiler.cc (right): https://codereview.chromium.org/2951053003/diff/40001/runtime/vm/compiler.cc#newcode179 runtime/vm/compiler.cc:179: // When compiling for OSR, use a depth ...
3 years, 6 months ago (2017-06-22 13:08:06 UTC) #7
Vyacheslav Egorov (Google)
Thanks for the review. Landing. https://codereview.chromium.org/2951053003/diff/40001/runtime/vm/compiler.cc File runtime/vm/compiler.cc (right): https://codereview.chromium.org/2951053003/diff/40001/runtime/vm/compiler.cc#newcode179 runtime/vm/compiler.cc:179: // When compiling for ...
3 years, 6 months ago (2017-06-22 14:58:48 UTC) #8
Vyacheslav Egorov (Google)
3 years, 6 months ago (2017-06-23 10:51:58 UTC) #10
Message was sent while issue was closed.
Committed patchset #3 (id:40001) manually as
7887c34a29b015fcf7411bafc27ace0d4a1e73e7 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698