@@ -121,57 +121,36 @@ DEFINE_FLAG_HANDLER(PrecompilationModeHandler,
121121
122122#ifndef DART_PRECOMPILED_RUNTIME
123123
124- void DartCompilationPipeline::ParseFunction (ParsedFunction* parsed_function) {
125- // Nothing to do here.
126- }
127-
128- FlowGraph* DartCompilationPipeline::BuildFlowGraph (
124+ static FlowGraph* BuildIrregexpFunctionFlowGraph (
129125 Zone* zone,
130126 ParsedFunction* parsed_function,
131127 ZoneGrowableArray<const ICData*>* ic_data_array,
132128 intptr_t osr_id,
133129 bool optimized) {
134- kernel::FlowGraphBuilder builder (parsed_function, ic_data_array,
135- /* not building var desc */ nullptr ,
136- /* not inlining */ nullptr , optimized,
137- osr_id);
138- FlowGraph* graph = builder.BuildGraph ();
139- ASSERT (graph != nullptr );
140- return graph;
141- }
142-
143- void IrregexpCompilationPipeline::ParseFunction (
144- ParsedFunction* parsed_function) {
145- VMTagScope tagScope (parsed_function->thread (),
146- VMTag::kCompileParseRegExpTagId );
147- Zone* zone = parsed_function->zone ();
148- RegExp& regexp = RegExp::Handle (parsed_function->function ().regexp ());
130+ if (parsed_function->regexp_compile_data () == nullptr ) {
131+ VMTagScope tagScope (parsed_function->thread (),
132+ VMTag::kCompileParseRegExpTagId );
133+ RegExp& regexp = RegExp::Handle (parsed_function->function ().regexp ());
149134
150- const String& pattern = String::Handle (regexp.pattern ());
135+ const String& pattern = String::Handle (regexp.pattern ());
151136
152- RegExpCompileData* compile_data = new (zone) RegExpCompileData ();
153- // Parsing failures are handled in the RegExp factory constructor.
154- RegExpParser::ParseRegExp (pattern, regexp.flags (), compile_data);
137+ RegExpCompileData* compile_data = new (zone) RegExpCompileData ();
138+ // Parsing failures are handled in the RegExp factory constructor.
139+ RegExpParser::ParseRegExp (pattern, regexp.flags (), compile_data);
155140
156- regexp.set_num_bracket_expressions (compile_data->capture_count );
157- regexp.set_capture_name_map (compile_data->capture_name_map );
158- if (compile_data->simple ) {
159- regexp.set_is_simple ();
160- } else {
161- regexp.set_is_complex ();
162- }
141+ regexp.set_num_bracket_expressions (compile_data->capture_count );
142+ regexp.set_capture_name_map (compile_data->capture_name_map );
143+ if (compile_data->simple ) {
144+ regexp.set_is_simple ();
145+ } else {
146+ regexp.set_is_complex ();
147+ }
163148
164- parsed_function->SetRegExpCompileData (compile_data);
149+ parsed_function->SetRegExpCompileData (compile_data);
165150
166- // Variables are allocated after compilation.
167- }
151+ // Variables are allocated after compilation.
152+ }
168153
169- FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph (
170- Zone* zone,
171- ParsedFunction* parsed_function,
172- ZoneGrowableArray<const ICData*>* ic_data_array,
173- intptr_t osr_id,
174- bool optimized) {
175154 // Compile to the dart IR.
176155 RegExpEngine::CompilationResult result =
177156 RegExpEngine::CompileIR (parsed_function->regexp_compile_data (),
@@ -180,7 +159,6 @@ FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph(
180159 Report::LongJump (LanguageError::Handle (
181160 LanguageError::New (String::Handle (String::New (result.error_message )))));
182161 }
183- backtrack_goto_ = result.backtrack_goto ;
184162
185163 // Allocate variables now that we know the number of locals.
186164 parsed_function->AllocateIrregexpVariables (result.num_stack_locals );
@@ -198,13 +176,23 @@ FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph(
198176 prologue_info, FlowGraph::CompilationModeFrom (optimized));
199177}
200178
201- CompilationPipeline* CompilationPipeline::New (Zone* zone,
202- const Function& function) {
203- if (function.IsIrregexpFunction ()) {
204- return new (zone) IrregexpCompilationPipeline ();
205- } else {
206- return new (zone) DartCompilationPipeline ();
179+ FlowGraph* Compiler::BuildFlowGraph (
180+ Zone* zone,
181+ ParsedFunction* parsed_function,
182+ ZoneGrowableArray<const ICData*>* ic_data_array,
183+ intptr_t osr_id,
184+ bool optimized) {
185+ if (parsed_function->function ().IsIrregexpFunction ()) {
186+ return BuildIrregexpFunctionFlowGraph (zone, parsed_function, ic_data_array,
187+ osr_id, optimized);
207188 }
189+ kernel::FlowGraphBuilder builder (parsed_function, ic_data_array,
190+ /* not building var desc */ nullptr ,
191+ /* not inlining */ nullptr , optimized,
192+ osr_id);
193+ FlowGraph* graph = builder.BuildGraph ();
194+ ASSERT (graph != nullptr );
195+ return graph;
208196}
209197
210198// Compile a function. Should call only if the function has not been compiled.
@@ -310,7 +298,7 @@ class CompileParsedFunctionHelper : public ValueObject {
310298 osr_id_(osr_id),
311299 thread_(Thread::Current()) {}
312300
313- CodePtr Compile (CompilationPipeline* pipeline );
301+ CodePtr Compile ();
314302
315303 private:
316304 ParsedFunction* parsed_function () const { return parsed_function_; }
@@ -484,7 +472,7 @@ CodePtr CompileParsedFunctionHelper::FinalizeCompilation(
484472}
485473
486474// Return null if bailed out.
487- CodePtr CompileParsedFunctionHelper::Compile (CompilationPipeline* pipeline ) {
475+ CodePtr CompileParsedFunctionHelper::Compile () {
488476 ASSERT (!FLAG_precompiled_mode);
489477 const Function& function = parsed_function ()->function ();
490478 if (optimized () && !function.IsOptimizable ()) {
@@ -544,7 +532,7 @@ CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
544532 }
545533
546534 TIMELINE_DURATION (thread (), CompilerVerbose, " BuildFlowGraph" );
547- flow_graph = pipeline-> BuildFlowGraph (
535+ flow_graph = Compiler:: BuildFlowGraph (
548536 zone, parsed_function (), ic_data_array, osr_id (), optimized ());
549537 }
550538
@@ -679,8 +667,7 @@ CodePtr CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
679667 return result->ptr ();
680668}
681669
682- static ObjectPtr CompileFunctionHelper (CompilationPipeline* pipeline,
683- const Function& function,
670+ static ObjectPtr CompileFunctionHelper (const Function& function,
684671 bool optimized,
685672 intptr_t osr_id) {
686673 Thread* const thread = Thread::Current ();
@@ -708,15 +695,10 @@ static ObjectPtr CompileFunctionHelper(CompilationPipeline* pipeline,
708695 function.ToFullyQualifiedCString (),
709696 function.token_pos ().ToCString (), token_size);
710697 }
711- // Makes sure no classes are loaded during parsing in background.
712- {
713- HANDLESCOPE (thread);
714- pipeline->ParseFunction (parsed_function);
715- }
716698
717699 CompileParsedFunctionHelper helper (parsed_function, optimized, osr_id);
718700
719- const Code& result = Code::Handle (helper.Compile (pipeline ));
701+ const Code& result = Code::Handle (helper.Compile ());
720702
721703 if (result.IsNull ()) {
722704 const Error& error = Error::Handle (thread->StealStickyError ());
@@ -843,11 +825,8 @@ ObjectPtr Compiler::CompileFunction(Thread* thread, const Function& function) {
843825 TIMELINE_FUNCTION_COMPILATION_DURATION (thread, event_name, function);
844826#endif // defined(SUPPORT_TIMELINE)
845827
846- CompilationPipeline* pipeline =
847- CompilationPipeline::New (thread->zone (), function);
848-
849828 const bool optimized = function.ForceOptimize ();
850- return CompileFunctionHelper (pipeline, function, optimized, kNoOSRDeoptId );
829+ return CompileFunctionHelper (function, optimized, kNoOSRDeoptId );
851830}
852831
853832ErrorPtr Compiler::EnsureUnoptimizedCode (Thread* thread,
@@ -860,11 +839,9 @@ ErrorPtr Compiler::EnsureUnoptimizedCode(Thread* thread,
860839 if (function.HasCode ()) {
861840 original_code = function.CurrentCode ();
862841 }
863- CompilationPipeline* pipeline =
864- CompilationPipeline::New (thread->zone (), function);
865842 const bool optimized = function.ForceOptimize ();
866- const Object& result = Object::Handle (
867- CompileFunctionHelper (pipeline, function, optimized, kNoOSRDeoptId ));
843+ const Object& result =
844+ Object::Handle ( CompileFunctionHelper (function, optimized, kNoOSRDeoptId ));
868845 if (result.IsError ()) {
869846 return Error::Cast (result).ptr ();
870847 }
@@ -899,10 +876,7 @@ ObjectPtr Compiler::CompileOptimizedFunction(Thread* thread,
899876 TIMELINE_FUNCTION_COMPILATION_DURATION (thread, event_name, function);
900877#endif // defined(SUPPORT_TIMELINE)
901878
902- CompilationPipeline* pipeline =
903- CompilationPipeline::New (thread->zone (), function);
904- return CompileFunctionHelper (pipeline, function, /* optimized = */ true ,
905- osr_id);
879+ return CompileFunctionHelper (function, /* optimized = */ true , osr_id);
906880}
907881
908882void Compiler::ComputeLocalVarDescriptors (const Code& code) {
@@ -1253,12 +1227,6 @@ void BackgroundCompiler::Disable() {
12531227
12541228#else // DART_PRECOMPILED_RUNTIME
12551229
1256- CompilationPipeline* CompilationPipeline::New (Zone* zone,
1257- const Function& function) {
1258- UNREACHABLE ();
1259- return nullptr ;
1260- }
1261-
12621230DEFINE_RUNTIME_ENTRY (CompileFunction, 1 ) {
12631231 const Function& function = Function::CheckedHandle (zone, arguments.ArgAt (0 ));
12641232 FATAL (" Precompilation missed function %s (%s, %s)\n " ,
0 commit comments