| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/compiler.h" | 5 #include "vm/compiler.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 void DartCompilationPipeline::FinalizeCompilation() { } | 100 void DartCompilationPipeline::FinalizeCompilation() { } |
| 101 | 101 |
| 102 | 102 |
| 103 void IrregexpCompilationPipeline::ParseFunction( | 103 void IrregexpCompilationPipeline::ParseFunction( |
| 104 ParsedFunction* parsed_function) { | 104 ParsedFunction* parsed_function) { |
| 105 RegExpParser::ParseFunction(parsed_function); | 105 RegExpParser::ParseFunction(parsed_function); |
| 106 // Variables are allocated after compilation. | 106 // Variables are allocated after compilation. |
| 107 } | 107 } |
| 108 | 108 |
| 109 |
| 109 FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph( | 110 FlowGraph* IrregexpCompilationPipeline::BuildFlowGraph( |
| 110 Zone* zone, | 111 Zone* zone, |
| 111 ParsedFunction* parsed_function, | 112 ParsedFunction* parsed_function, |
| 112 const ZoneGrowableArray<const ICData*>& ic_data_array, | 113 const ZoneGrowableArray<const ICData*>& ic_data_array, |
| 113 intptr_t osr_id) { | 114 intptr_t osr_id) { |
| 114 // Compile to the dart IR. | 115 // Compile to the dart IR. |
| 115 RegExpEngine::CompilationResult result = | 116 RegExpEngine::CompilationResult result = |
| 116 RegExpEngine::CompileIR(parsed_function->regexp_compile_data(), | 117 RegExpEngine::CompileIR(parsed_function->regexp_compile_data(), |
| 117 parsed_function, | 118 parsed_function, |
| 118 ic_data_array); | 119 ic_data_array); |
| 119 backtrack_goto_ = result.backtrack_goto; | 120 backtrack_goto_ = result.backtrack_goto; |
| 120 | 121 |
| 121 // Allocate variables now that we know the number of locals. | 122 // Allocate variables now that we know the number of locals. |
| 122 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); | 123 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); |
| 123 | 124 |
| 124 // Build the flow graph. | 125 // Build the flow graph. |
| 125 FlowGraphBuilder builder(*parsed_function, | 126 FlowGraphBuilder builder(*parsed_function, |
| 126 ic_data_array, | 127 ic_data_array, |
| 127 NULL, // NULL = not inlining. | 128 NULL, // NULL = not inlining. |
| 128 osr_id); | 129 osr_id); |
| 129 | 130 |
| 130 return new(zone) FlowGraph(*parsed_function, | 131 return new(zone) FlowGraph(*parsed_function, |
| 131 result.graph_entry, | 132 result.graph_entry, |
| 132 result.num_blocks); | 133 result.num_blocks); |
| 133 } | 134 } |
| 134 | 135 |
| 136 |
| 135 void IrregexpCompilationPipeline::FinalizeCompilation() { | 137 void IrregexpCompilationPipeline::FinalizeCompilation() { |
| 136 backtrack_goto_->ComputeOffsetTable(); | 138 backtrack_goto_->ComputeOffsetTable(); |
| 137 } | 139 } |
| 138 | 140 |
| 141 |
| 139 CompilationPipeline* CompilationPipeline::New(Zone* zone, | 142 CompilationPipeline* CompilationPipeline::New(Zone* zone, |
| 140 const Function& function) { | 143 const Function& function) { |
| 141 if (function.IsIrregexpFunction()) { | 144 if (function.IsIrregexpFunction()) { |
| 142 return new(zone) IrregexpCompilationPipeline(); | 145 return new(zone) IrregexpCompilationPipeline(); |
| 143 } else { | 146 } else { |
| 144 return new(zone) DartCompilationPipeline(); | 147 return new(zone) DartCompilationPipeline(); |
| 145 } | 148 } |
| 146 } | 149 } |
| 147 | 150 |
| 148 | 151 |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 | 1287 |
| 1285 RawError* Compiler::CompileOptimizedFunction(Thread* thread, | 1288 RawError* Compiler::CompileOptimizedFunction(Thread* thread, |
| 1286 const Function& function, | 1289 const Function& function, |
| 1287 intptr_t osr_id) { | 1290 intptr_t osr_id) { |
| 1288 VMTagScope tagScope(thread, VMTag::kCompileOptimizedTagId); | 1291 VMTagScope tagScope(thread, VMTag::kCompileOptimizedTagId); |
| 1289 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, | 1292 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, |
| 1290 "OptimizedFunction", function); | 1293 "OptimizedFunction", function); |
| 1291 | 1294 |
| 1292 // Optimization must happen in non-mutator/Dart thread if background | 1295 // Optimization must happen in non-mutator/Dart thread if background |
| 1293 // compilation is on. OSR compilation still occurs in the main thread. | 1296 // compilation is on. OSR compilation still occurs in the main thread. |
| 1297 // TODO(Srdjan): Remove assert allowance for regular expression functions |
| 1298 // once they can be compiled in background. |
| 1294 ASSERT((osr_id != kNoOSRDeoptId) || !FLAG_background_compilation || | 1299 ASSERT((osr_id != kNoOSRDeoptId) || !FLAG_background_compilation || |
| 1295 !thread->IsMutatorThread()); | 1300 !thread->IsMutatorThread() || |
| 1301 function.IsIrregexpFunction()); |
| 1296 CompilationPipeline* pipeline = | 1302 CompilationPipeline* pipeline = |
| 1297 CompilationPipeline::New(thread->zone(), function); | 1303 CompilationPipeline::New(thread->zone(), function); |
| 1298 return CompileFunctionHelper(pipeline, | 1304 return CompileFunctionHelper(pipeline, |
| 1299 function, | 1305 function, |
| 1300 true, /* optimized */ | 1306 true, /* optimized */ |
| 1301 osr_id); | 1307 osr_id); |
| 1302 } | 1308 } |
| 1303 | 1309 |
| 1304 | 1310 |
| 1305 // This is only used from unit tests. | 1311 // This is only used from unit tests. |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 } | 1864 } |
| 1859 | 1865 |
| 1860 | 1866 |
| 1861 void BackgroundCompiler::EnsureInit(Thread* thread) { | 1867 void BackgroundCompiler::EnsureInit(Thread* thread) { |
| 1862 UNREACHABLE(); | 1868 UNREACHABLE(); |
| 1863 } | 1869 } |
| 1864 | 1870 |
| 1865 #endif // DART_PRECOMPILED_RUNTIME | 1871 #endif // DART_PRECOMPILED_RUNTIME |
| 1866 | 1872 |
| 1867 } // namespace dart | 1873 } // namespace dart |
| OLD | NEW |