dart-sdk/runtime
Vyacheslav Egorov 7887c34a29 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 d87cc52c3e.

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

Review-Url: https://codereview.chromium.org/2951053003 .
2017-06-23 12:51:53 +02:00
..
bin Reland "Load service isolate from a .dill file." 2017-06-22 10:10:45 -07:00
include 1. Dynamically compute the main closure that needs to be run by the main isolate 2017-06-15 10:40:45 -07:00
lib VM(RegExp): Allow OSR optimization of RegExp :matcher functions. 2017-06-23 12:51:53 +02:00
observatory Introduce dart_host_toolchain argument for generate_patch_sdk.gni. This allows for Flutter build to make sure that host_toolchain used for patched_sdk generation word size matches target platform. 2017-06-22 12:41:31 -07:00
platform Remove MIPS support 2017-06-22 08:49:22 -07:00
tests/vm [kernel] Update vm.status file for mac 2017-06-21 10:34:30 +02:00
third_party [fuchsia] Make symbols in the Dart VM visible, so they are available to the profiler. 2017-06-20 15:21:07 -07:00
tools Remove MIPS support 2017-06-22 08:49:22 -07:00
vm VM(RegExp): Allow OSR optimization of RegExp :matcher functions. 2017-06-23 12:51:53 +02:00
.gitignore
BUILD.gn Remove MIPS support 2017-06-22 08:49:22 -07:00
codereview.settings Remove trailing slash in codereview.settings to fix review url double slash 2015-10-01 07:27:13 -07:00
CPPLINT.cfg clang-formats remaining files and adds a presubmit check. 2016-11-09 12:43:57 -08:00
dart-runtime.gyp Remove dart_noopt and related parts from the VM. 2017-01-11 16:55:55 -08:00
PRESUBMIT.py VM: Enforce correctly formatted C++ code 2016-11-30 23:52:52 +01:00
runtime_args.gni [Fuchsia] Use the trusted certs in the image 2017-06-09 13:18:09 -07:00