| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 DECLARE_FLAG(bool, huge_method_cutoff_in_code_size); | 108 DECLARE_FLAG(bool, huge_method_cutoff_in_code_size); |
| 109 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 109 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
| 110 DECLARE_FLAG(bool, trace_irregexp); | 110 DECLARE_FLAG(bool, trace_irregexp); |
| 111 | 111 |
| 112 | 112 |
| 113 #ifndef DART_PRECOMPILED_RUNTIME | 113 #ifndef DART_PRECOMPILED_RUNTIME |
| 114 | 114 |
| 115 | 115 |
| 116 bool UseKernelFrontEndFor(ParsedFunction* parsed_function) { | 116 bool UseKernelFrontEndFor(ParsedFunction* parsed_function) { |
| 117 const Function& function = parsed_function->function(); | 117 const Function& function = parsed_function->function(); |
| 118 return (function.kernel_function() != NULL) || | 118 return (function.kernel_offset() > 0) || |
| 119 (function.kind() == RawFunction::kNoSuchMethodDispatcher) || | 119 (function.kind() == RawFunction::kNoSuchMethodDispatcher) || |
| 120 (function.kind() == RawFunction::kInvokeFieldDispatcher); | 120 (function.kind() == RawFunction::kInvokeFieldDispatcher); |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 void DartCompilationPipeline::ParseFunction(ParsedFunction* parsed_function) { | 124 void DartCompilationPipeline::ParseFunction(ParsedFunction* parsed_function) { |
| 125 if (!UseKernelFrontEndFor(parsed_function)) { | 125 if (!UseKernelFrontEndFor(parsed_function)) { |
| 126 Parser::ParseFunction(parsed_function); | 126 Parser::ParseFunction(parsed_function); |
| 127 parsed_function->AllocateVariables(); | 127 parsed_function->AllocateVariables(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 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::FlowGraphBuilder builder( |
| 139 parsed_function->function().kernel_function()); | 139 parsed_function->function().kernel_offset(), parsed_function, |
| 140 kernel::FlowGraphBuilder builder(node, parsed_function, ic_data_array, | 140 ic_data_array, |
| 141 /* not building var desc */ NULL, | 141 /* not building var desc */ NULL, |
| 142 /* not inlining */ NULL, osr_id); | 142 /* not inlining */ NULL, osr_id); |
| 143 FlowGraph* graph = builder.BuildGraph(); | 143 FlowGraph* graph = builder.BuildGraph(); |
| 144 ASSERT(graph != NULL); | 144 ASSERT(graph != NULL); |
| 145 return graph; | 145 return graph; |
| 146 } | 146 } |
| 147 FlowGraphBuilder builder(*parsed_function, ic_data_array, | 147 FlowGraphBuilder builder(*parsed_function, ic_data_array, |
| 148 /* not building var desc */ NULL, | 148 /* not building var desc */ NULL, |
| 149 /* not inlining */ NULL, osr_id); | 149 /* not inlining */ NULL, osr_id); |
| 150 | 150 |
| 151 return builder.BuildGraph(); | 151 return builder.BuildGraph(); |
| 152 } | 152 } |
| (...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 | 1599 |
| 1600 if (!UseKernelFrontEndFor(parsed_function)) { | 1600 if (!UseKernelFrontEndFor(parsed_function)) { |
| 1601 Parser::ParseFunction(parsed_function); | 1601 Parser::ParseFunction(parsed_function); |
| 1602 parsed_function->AllocateVariables(); | 1602 parsed_function->AllocateVariables(); |
| 1603 FlowGraphBuilder builder( | 1603 FlowGraphBuilder builder( |
| 1604 *parsed_function, *ic_data_array, context_level_array, | 1604 *parsed_function, *ic_data_array, context_level_array, |
| 1605 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); | 1605 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); |
| 1606 builder.BuildGraph(); | 1606 builder.BuildGraph(); |
| 1607 } else { | 1607 } else { |
| 1608 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( | 1609 kernel::FlowGraphBuilder builder( |
| 1612 node, parsed_function, *ic_data_array, context_level_array, | 1610 parsed_function->function().kernel_offset(), parsed_function, |
| 1611 *ic_data_array, context_level_array, |
| 1613 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); | 1612 /* not inlining */ NULL, Compiler::kNoOSRDeoptId); |
| 1614 builder.BuildGraph(); | 1613 builder.BuildGraph(); |
| 1615 } | 1614 } |
| 1616 | 1615 |
| 1617 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 1616 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
| 1618 parsed_function->node_sequence()->scope()->GetVarDescriptors( | 1617 parsed_function->node_sequence()->scope()->GetVarDescriptors( |
| 1619 function, context_level_array)); | 1618 function, context_level_array)); |
| 1620 ASSERT(!var_descs.IsNull()); | 1619 ASSERT(!var_descs.IsNull()); |
| 1621 code.set_var_descriptors(var_descs); | 1620 code.set_var_descriptors(var_descs); |
| 1622 } else { | 1621 } else { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1725 tds.CopyArgument(0, "field", field.ToCString()); | 1724 tds.CopyArgument(0, "field", field.ToCString()); |
| 1726 } | 1725 } |
| 1727 #endif // !defined(PRODUCT) | 1726 #endif // !defined(PRODUCT) |
| 1728 | 1727 |
| 1729 StackZone stack_zone(thread); | 1728 StackZone stack_zone(thread); |
| 1730 Zone* zone = stack_zone.GetZone(); | 1729 Zone* zone = stack_zone.GetZone(); |
| 1731 ParsedFunction* parsed_function; | 1730 ParsedFunction* parsed_function; |
| 1732 | 1731 |
| 1733 // Create a one-time-use function to evaluate the initializer and invoke | 1732 // Create a one-time-use function to evaluate the initializer and invoke |
| 1734 // it immediately. | 1733 // it immediately. |
| 1735 if (field.kernel_field() != NULL) { | 1734 if (field.kernel_offset() > 0) { |
| 1736 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); | 1735 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); |
| 1737 } else { | 1736 } else { |
| 1738 parsed_function = Parser::ParseStaticFieldInitializer(field); | 1737 parsed_function = Parser::ParseStaticFieldInitializer(field); |
| 1739 parsed_function->AllocateVariables(); | 1738 parsed_function->AllocateVariables(); |
| 1740 } | 1739 } |
| 1741 | 1740 |
| 1742 // Non-optimized code generator. | 1741 // Non-optimized code generator. |
| 1743 DartCompilationPipeline pipeline; | 1742 DartCompilationPipeline pipeline; |
| 1744 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); | 1743 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); |
| 1745 const Code& code = Code::Handle(helper.Compile(&pipeline)); | 1744 const Code& code = Code::Handle(helper.Compile(&pipeline)); |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 | 2332 |
| 2334 | 2333 |
| 2335 bool BackgroundCompiler::IsDisabled() { | 2334 bool BackgroundCompiler::IsDisabled() { |
| 2336 UNREACHABLE(); | 2335 UNREACHABLE(); |
| 2337 return true; | 2336 return true; |
| 2338 } | 2337 } |
| 2339 | 2338 |
| 2340 #endif // DART_PRECOMPILED_RUNTIME | 2339 #endif // DART_PRECOMPILED_RUNTIME |
| 2341 | 2340 |
| 2342 } // namespace dart | 2341 } // namespace dart |
| OLD | NEW |