| Index: runtime/vm/compiler.cc
|
| diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
|
| index c2ad811f1bd6aafa1294177d8d4ded8e5b89505e..3c9f21ddd2510ae4fca128b569e49a0de0878a1a 100644
|
| --- a/runtime/vm/compiler.cc
|
| +++ b/runtime/vm/compiler.cc
|
| @@ -29,6 +29,8 @@
|
| #include "vm/object_store.h"
|
| #include "vm/os.h"
|
| #include "vm/parser.h"
|
| +#include "vm/regexp_parser.h"
|
| +#include "vm/regexp_assembler.h"
|
| #include "vm/scanner.h"
|
| #include "vm/symbols.h"
|
| #include "vm/tags.h"
|
| @@ -63,6 +65,7 @@ DEFINE_FLAG(bool, verify_compiler, false,
|
|
|
| DECLARE_FLAG(bool, trace_failed_optimization_attempts);
|
| DECLARE_FLAG(bool, trace_patching);
|
| +DECLARE_FLAG(bool, trace_irregexp);
|
|
|
| // Compile a function. Should call only if the function has not been compiled.
|
| // Arg0: function object.
|
| @@ -296,6 +299,8 @@ static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function,
|
| // constructor and unregisters itself upon destruction.
|
| CHA cha(isolate);
|
|
|
| + IRRegExpMacroAssembler* macro_assembler = NULL;
|
| +
|
| // TimerScope needs an isolate to be properly terminated in case of a
|
| // LongJump.
|
| {
|
| @@ -321,12 +326,35 @@ static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function,
|
| }
|
| }
|
|
|
| - // Build the flow graph.
|
| - FlowGraphBuilder builder(parsed_function,
|
| - *ic_data_array,
|
| - NULL, // NULL = not inlining.
|
| - osr_id);
|
| - flow_graph = builder.BuildGraph();
|
| + if (function.IsIrregexpFunction()) {
|
| + // Compile to the dart IR.
|
| + RegExpEngine::CompilationResult result =
|
| + RegExpEngine::Compile(parsed_function->regexp_compile_data(),
|
| + parsed_function,
|
| + ic_data_array);
|
| + macro_assembler = result.macro_assembler;
|
| +
|
| + // Allocate variables now that we know the number of locals.
|
| + parsed_function->AllocateIrregexpVariables(result.num_stack_locals);
|
| +
|
| + // Build the flow graph.
|
| + FlowGraphBuilder builder(parsed_function,
|
| + *ic_data_array,
|
| + NULL, // NULL = not inlining.
|
| + osr_id);
|
| +
|
| + flow_graph = new(isolate) FlowGraph(builder,
|
| + result.graph_entry,
|
| + result.num_blocks);
|
| + } else {
|
| + // Build the flow graph.
|
| + FlowGraphBuilder builder(parsed_function,
|
| + *ic_data_array,
|
| + NULL, // NULL = not inlining.
|
| + osr_id);
|
| +
|
| + flow_graph = builder.BuildGraph();
|
| + }
|
| }
|
|
|
| if (FLAG_print_flow_graph ||
|
| @@ -583,6 +611,9 @@ static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function,
|
| &CompilerStats::graphcompiler_timer,
|
| isolate);
|
| graph_compiler.CompileGraph();
|
| + if (function.IsIrregexpFunction()) {
|
| + macro_assembler->FinalizeBlockOffsetTable();
|
| + }
|
| }
|
| {
|
| TimerScope timer(FLAG_compiler_stats,
|
| @@ -829,8 +860,14 @@ static RawError* CompileFunctionHelper(const Function& function,
|
| }
|
| {
|
| HANDLESCOPE(isolate);
|
| - Parser::ParseFunction(parsed_function);
|
| - parsed_function->AllocateVariables();
|
| +
|
| + if (function.IsIrregexpFunction()) {
|
| + RegExpParser::ParseFunction(parsed_function);
|
| + // Variables are allocated after compilation.
|
| + } else {
|
| + Parser::ParseFunction(parsed_function);
|
| + parsed_function->AllocateVariables();
|
| + }
|
| }
|
|
|
| const bool success =
|
|
|