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, NULL, | 140 ic_data_array, NULL, osr_id); |
141 osr_id); | |
142 FlowGraph* graph = builder.BuildGraph(); | 141 FlowGraph* graph = builder.BuildGraph(); |
143 ASSERT(graph != NULL); | 142 ASSERT(graph != NULL); |
144 return graph; | 143 return graph; |
145 } | 144 } |
146 FlowGraphBuilder builder(*parsed_function, ic_data_array, | 145 FlowGraphBuilder builder(*parsed_function, ic_data_array, |
147 NULL, // NULL = not inlining. | 146 NULL, // NULL = not inlining. |
148 osr_id); | 147 osr_id); |
149 | 148 |
150 return builder.BuildGraph(); | 149 return builder.BuildGraph(); |
151 } | 150 } |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 const Function& function = Function::Handle(code.function()); | 1580 const Function& function = Function::Handle(code.function()); |
1582 ParsedFunction* parsed_function = new ParsedFunction( | 1581 ParsedFunction* parsed_function = new ParsedFunction( |
1583 Thread::Current(), Function::ZoneHandle(function.raw())); | 1582 Thread::Current(), Function::ZoneHandle(function.raw())); |
1584 ASSERT(code.var_descriptors() == Object::null()); | 1583 ASSERT(code.var_descriptors() == Object::null()); |
1585 // IsIrregexpFunction have eager var descriptors generation. | 1584 // IsIrregexpFunction have eager var descriptors generation. |
1586 ASSERT(!function.IsIrregexpFunction()); | 1585 ASSERT(!function.IsIrregexpFunction()); |
1587 // In background compilation, parser can produce 'errors": bailouts | 1586 // In background compilation, parser can produce 'errors": bailouts |
1588 // if state changed while compiling in background. | 1587 // if state changed while compiling in background. |
1589 LongJumpScope jump; | 1588 LongJumpScope jump; |
1590 if (setjmp(*jump.Set()) == 0) { | 1589 if (setjmp(*jump.Set()) == 0) { |
1591 if (function.kernel_function() == NULL) { | 1590 if (function.kernel_offset() <= 0) { |
1592 Parser::ParseFunction(parsed_function); | 1591 Parser::ParseFunction(parsed_function); |
1593 parsed_function->AllocateVariables(); | 1592 parsed_function->AllocateVariables(); |
1594 } else { | 1593 } else { |
1595 parsed_function->EnsureKernelScopes(); | 1594 parsed_function->EnsureKernelScopes(); |
1596 } | 1595 } |
1597 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( | 1596 const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle( |
1598 parsed_function->node_sequence()->scope()->GetVarDescriptors(function)); | 1597 parsed_function->node_sequence()->scope()->GetVarDescriptors(function)); |
1599 ASSERT(!var_descs.IsNull()); | 1598 ASSERT(!var_descs.IsNull()); |
1600 code.set_var_descriptors(var_descs); | 1599 code.set_var_descriptors(var_descs); |
1601 } else { | 1600 } else { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1703 tds.CopyArgument(0, "field", field.ToCString()); | 1702 tds.CopyArgument(0, "field", field.ToCString()); |
1704 } | 1703 } |
1705 #endif // !defined(PRODUCT) | 1704 #endif // !defined(PRODUCT) |
1706 | 1705 |
1707 StackZone stack_zone(thread); | 1706 StackZone stack_zone(thread); |
1708 Zone* zone = stack_zone.GetZone(); | 1707 Zone* zone = stack_zone.GetZone(); |
1709 ParsedFunction* parsed_function; | 1708 ParsedFunction* parsed_function; |
1710 | 1709 |
1711 // Create a one-time-use function to evaluate the initializer and invoke | 1710 // Create a one-time-use function to evaluate the initializer and invoke |
1712 // it immediately. | 1711 // it immediately. |
1713 if (field.kernel_field() != NULL) { | 1712 if (field.kernel_offset() > 0) { |
1714 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); | 1713 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); |
1715 } else { | 1714 } else { |
1716 parsed_function = Parser::ParseStaticFieldInitializer(field); | 1715 parsed_function = Parser::ParseStaticFieldInitializer(field); |
1717 parsed_function->AllocateVariables(); | 1716 parsed_function->AllocateVariables(); |
1718 } | 1717 } |
1719 | 1718 |
1720 // Non-optimized code generator. | 1719 // Non-optimized code generator. |
1721 DartCompilationPipeline pipeline; | 1720 DartCompilationPipeline pipeline; |
1722 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); | 1721 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); |
1723 const Code& code = Code::Handle(helper.Compile(&pipeline)); | 1722 const Code& code = Code::Handle(helper.Compile(&pipeline)); |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 | 2310 |
2312 | 2311 |
2313 bool BackgroundCompiler::IsDisabled() { | 2312 bool BackgroundCompiler::IsDisabled() { |
2314 UNREACHABLE(); | 2313 UNREACHABLE(); |
2315 return true; | 2314 return true; |
2316 } | 2315 } |
2317 | 2316 |
2318 #endif // DART_PRECOMPILED_RUNTIME | 2317 #endif // DART_PRECOMPILED_RUNTIME |
2319 | 2318 |
2320 } // namespace dart | 2319 } // namespace dart |
OLD | NEW |