| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 | 131 |
| 132 FlowGraph* DartCompilationPipeline::BuildFlowGraph( | 132 FlowGraph* DartCompilationPipeline::BuildFlowGraph( |
| 133 Zone* zone, | 133 Zone* zone, |
| 134 ParsedFunction* parsed_function, | 134 ParsedFunction* parsed_function, |
| 135 const ZoneGrowableArray<const ICData*>& ic_data_array, | 135 const ZoneGrowableArray<const ICData*>& ic_data_array, |
| 136 intptr_t osr_id) { | 136 intptr_t osr_id) { |
| 137 if (UseKernelFrontEndFor(parsed_function)) { | 137 if (UseKernelFrontEndFor(parsed_function)) { |
| 138 kernel::TreeNode* node = static_cast<kernel::TreeNode*>( | 138 kernel::TreeNode* node = static_cast<kernel::TreeNode*>( |
| 139 parsed_function->function().kernel_function()); | 139 parsed_function->function().kernel_function()); |
| 140 kernel::FlowGraphBuilder builder(node, parsed_function, ic_data_array, NULL, | 140 kernel::FlowGraphBuilder builder(node, parsed_function, ic_data_array, |
| 141 osr_id); | 141 /* not building var desc */ NULL, |
| 142 /* not inlining */ NULL, osr_id); |
| 142 FlowGraph* graph = builder.BuildGraph(); | 143 FlowGraph* graph = builder.BuildGraph(); |
| 143 ASSERT(graph != NULL); | 144 ASSERT(graph != NULL); |
| 144 return graph; | 145 return graph; |
| 145 } | 146 } |
| 146 FlowGraphBuilder builder(*parsed_function, ic_data_array, | 147 FlowGraphBuilder builder(*parsed_function, ic_data_array, |
| 147 NULL, // NULL = not inlining. | 148 /* not building var desc */ NULL, |
| 148 osr_id); | 149 /* not inlining */ NULL, osr_id); |
| 149 | 150 |
| 150 return builder.BuildGraph(); | 151 return builder.BuildGraph(); |
| 151 } | 152 } |
| 152 | 153 |
| 153 | 154 |
| 154 void DartCompilationPipeline::FinalizeCompilation(FlowGraph* flow_graph) {} | 155 void DartCompilationPipeline::FinalizeCompilation(FlowGraph* flow_graph) {} |
| 155 | 156 |
| 156 | 157 |
| 157 void IrregexpCompilationPipeline::ParseFunction( | 158 void IrregexpCompilationPipeline::ParseFunction( |
| 158 ParsedFunction* parsed_function) { | 159 ParsedFunction* parsed_function) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 // Compile to the dart IR. | 170 // Compile to the dart IR. |
| 170 RegExpEngine::CompilationResult result = RegExpEngine::CompileIR( | 171 RegExpEngine::CompilationResult result = RegExpEngine::CompileIR( |
| 171 parsed_function->regexp_compile_data(), parsed_function, ic_data_array); | 172 parsed_function->regexp_compile_data(), parsed_function, ic_data_array); |
| 172 backtrack_goto_ = result.backtrack_goto; | 173 backtrack_goto_ = result.backtrack_goto; |
| 173 | 174 |
| 174 // Allocate variables now that we know the number of locals. | 175 // Allocate variables now that we know the number of locals. |
| 175 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); | 176 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); |
| 176 | 177 |
| 177 // Build the flow graph. | 178 // Build the flow graph. |
| 178 FlowGraphBuilder builder(*parsed_function, ic_data_array, | 179 FlowGraphBuilder builder(*parsed_function, ic_data_array, |
| 179 NULL, // NULL = not inlining. | 180 /* not building var desc */ NULL, |
| 180 osr_id); | 181 /* not inlining */ NULL, osr_id); |
| 181 | 182 |
| 182 return new (zone) | 183 return new (zone) |
| 183 FlowGraph(*parsed_function, result.graph_entry, result.num_blocks); | 184 FlowGraph(*parsed_function, result.graph_entry, result.num_blocks); |
| 184 } | 185 } |
| 185 | 186 |
| 186 | 187 |
| 187 void IrregexpCompilationPipeline::FinalizeCompilation(FlowGraph* flow_graph) { | 188 void IrregexpCompilationPipeline::FinalizeCompilation(FlowGraph* flow_graph) { |
| 188 backtrack_goto_->ComputeOffsetTable(); | 189 backtrack_goto_->ComputeOffsetTable(); |
| 189 } | 190 } |
| 190 | 191 |
| (...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 void Compiler::ComputeLocalVarDescriptors(const Code& code) { | 1581 void Compiler::ComputeLocalVarDescriptors(const Code& code) { |
| 1581 ASSERT(!code.is_optimized()); | 1582 ASSERT(!code.is_optimized()); |
| 1582 const Function& function = Function::Handle(code.function()); | 1583 const Function& function = Function::Handle(code.function()); |
| 1583 ParsedFunction* parsed_function = new ParsedFunction( | 1584 ParsedFunction* parsed_function = new ParsedFunction( |
| 1584 Thread::Current(), Function::ZoneHandle(function.raw())); | 1585 Thread::Current(), Function::ZoneHandle(function.raw())); |
| 1585 ASSERT(code.var_descriptors() == Object::null()); | 1586 ASSERT(code.var_descriptors() == Object::null()); |
| 1586 // IsIrregexpFunction have eager var descriptors generation. | 1587 // IsIrregexpFunction have eager var descriptors generation. |
| 1587 ASSERT(!function.IsIrregexpFunction()); | 1588 ASSERT(!function.IsIrregexpFunction()); |
| 1588 // In background compilation, parser can produce 'errors": bailouts | 1589 // In background compilation, parser can produce 'errors": bailouts |
| 1589 // if state changed while compiling in background. | 1590 // if state changed while compiling in background. |
| 1591 const intptr_t prev_deopt_id = Thread::Current()->deopt_id(); |
| 1592 Thread::Current()->set_deopt_id(0); |
| 1590 LongJumpScope jump; | 1593 LongJumpScope jump; |
| 1591 if (setjmp(*jump.Set()) == 0) { | 1594 if (setjmp(*jump.Set()) == 0) { |
| 1592 if (function.kernel_function() == NULL) { | 1595 ZoneGrowableArray<const ICData*>* ic_data_array = |
| 1596 new ZoneGrowableArray<const ICData*>(); |
| 1597 ZoneGrowableArray<intptr_t>* context_level_array = |
| 1598 new ZoneGrowableArray<intptr_t>(); |
| 1599 |
| 1600 if (!UseKernelFrontEndFor(parsed_function)) { |
| 1593 Parser::ParseFunction(parsed_function); | 1601 Parser::ParseFunction(parsed_function); |
| 1594 parsed_function->AllocateVariables(); | 1602 parsed_function->AllocateVariables(); |
| 1603 FlowGraphBuilder builder( |
| 1604 *parsed_function, *ic_data_array, context_level_array, |
| 1605 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); |
| 1606 builder.BuildGraph(); |
| 1595 } else { | 1607 } else { |
| 1596 parsed_function->EnsureKernelScopes(); | 1608 parsed_function->EnsureKernelScopes(); |
| 1609 kernel::TreeNode* node = static_cast<kernel::TreeNode*>( |
| 1610 parsed_function->function().kernel_function()); |
| 1611 kernel::FlowGraphBuilder builder( |
| 1612 node, parsed_function, *ic_data_array, context_level_array, |
| 1613 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); |
| 1614 builder.BuildGraph(); |
| 1597 } | 1615 } |
| 1616 |
| 1598 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 1617 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
| 1599 parsed_function->node_sequence()->scope()->GetVarDescriptors(function)); | 1618 parsed_function->node_sequence()->scope()->GetVarDescriptors( |
| 1619 function, context_level_array)); |
| 1600 ASSERT(!var_descs.IsNull()); | 1620 ASSERT(!var_descs.IsNull()); |
| 1601 code.set_var_descriptors(var_descs); | 1621 code.set_var_descriptors(var_descs); |
| 1602 } else { | 1622 } else { |
| 1603 // Only possible with background compilation. | 1623 // Only possible with background compilation. |
| 1604 ASSERT(Compiler::IsBackgroundCompilation()); | 1624 ASSERT(Compiler::IsBackgroundCompilation()); |
| 1605 } | 1625 } |
| 1626 Thread::Current()->set_deopt_id(prev_deopt_id); |
| 1606 } | 1627 } |
| 1607 | 1628 |
| 1608 | 1629 |
| 1609 RawError* Compiler::CompileAllFunctions(const Class& cls) { | 1630 RawError* Compiler::CompileAllFunctions(const Class& cls) { |
| 1610 Thread* thread = Thread::Current(); | 1631 Thread* thread = Thread::Current(); |
| 1611 Zone* zone = thread->zone(); | 1632 Zone* zone = thread->zone(); |
| 1612 Object& result = Object::Handle(zone); | 1633 Object& result = Object::Handle(zone); |
| 1613 Array& functions = Array::Handle(zone, cls.functions()); | 1634 Array& functions = Array::Handle(zone, cls.functions()); |
| 1614 Function& func = Function::Handle(zone); | 1635 Function& func = Function::Handle(zone); |
| 1615 // Class dynamic lives in the vm isolate. Its array fields cannot be set to | 1636 // Class dynamic lives in the vm isolate. Its array fields cannot be set to |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2333 |
| 2313 | 2334 |
| 2314 bool BackgroundCompiler::IsDisabled() { | 2335 bool BackgroundCompiler::IsDisabled() { |
| 2315 UNREACHABLE(); | 2336 UNREACHABLE(); |
| 2316 return true; | 2337 return true; |
| 2317 } | 2338 } |
| 2318 | 2339 |
| 2319 #endif // DART_PRECOMPILED_RUNTIME | 2340 #endif // DART_PRECOMPILED_RUNTIME |
| 2320 | 2341 |
| 2321 } // namespace dart | 2342 } // namespace dart |
| OLD | NEW |