| 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 } | 935 } |
| 936 OS::Print("}\n"); | 936 OS::Print("}\n"); |
| 937 } | 937 } |
| 938 } | 938 } |
| 939 | 939 |
| 940 | 940 |
| 941 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, | 941 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, |
| 942 const Function& function, | 942 const Function& function, |
| 943 bool optimized, | 943 bool optimized, |
| 944 intptr_t osr_id) { | 944 intptr_t osr_id) { |
| 945 Isolate* isolate = Isolate::Current(); | 945 Thread* thread = Thread::Current(); |
| 946 StackZone zone(isolate); | 946 Isolate* isolate = thread->isolate(); |
| 947 StackZone stack_zone(isolate); |
| 948 Zone* zone = stack_zone.GetZone(); |
| 947 LongJumpScope jump; | 949 LongJumpScope jump; |
| 948 if (setjmp(*jump.Set()) == 0) { | 950 if (setjmp(*jump.Set()) == 0) { |
| 949 TIMERSCOPE(isolate, time_compilation); | 951 TIMERSCOPE(isolate, time_compilation); |
| 950 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 952 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
| 951 per_compile_timer.Start(); | 953 per_compile_timer.Start(); |
| 952 ParsedFunction* parsed_function = new(isolate) ParsedFunction( | 954 ParsedFunction* parsed_function = new(zone) ParsedFunction( |
| 953 isolate, Function::ZoneHandle(isolate, function.raw())); | 955 thread, Function::ZoneHandle(zone, function.raw())); |
| 954 if (FLAG_trace_compiler) { | 956 if (FLAG_trace_compiler) { |
| 955 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 957 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
| 956 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 958 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
| 957 (optimized ? "optimized " : ""), | 959 (optimized ? "optimized " : ""), |
| 958 function.ToFullyQualifiedCString(), | 960 function.ToFullyQualifiedCString(), |
| 959 function.token_pos(), | 961 function.token_pos(), |
| 960 (function.end_token_pos() - function.token_pos())); | 962 (function.end_token_pos() - function.token_pos())); |
| 961 } | 963 } |
| 962 { | 964 { |
| 963 HANDLESCOPE(isolate); | 965 HANDLESCOPE(isolate); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 isolate->object_store()->clear_sticky_error(); | 1142 isolate->object_store()->clear_sticky_error(); |
| 1141 return error.raw(); | 1143 return error.raw(); |
| 1142 } | 1144 } |
| 1143 UNREACHABLE(); | 1145 UNREACHABLE(); |
| 1144 return Object::null(); | 1146 return Object::null(); |
| 1145 } | 1147 } |
| 1146 | 1148 |
| 1147 | 1149 |
| 1148 | 1150 |
| 1149 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { | 1151 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { |
| 1150 Isolate* isolate = Isolate::Current(); | 1152 Thread* thread = Thread::Current(); |
| 1153 Isolate* isolate = thread->isolate(); |
| 1151 LongJumpScope jump; | 1154 LongJumpScope jump; |
| 1152 if (setjmp(*jump.Set()) == 0) { | 1155 if (setjmp(*jump.Set()) == 0) { |
| 1153 if (FLAG_trace_compiler) { | 1156 if (FLAG_trace_compiler) { |
| 1154 OS::Print("compiling expression: "); | 1157 OS::Print("compiling expression: "); |
| 1155 AstPrinter::PrintNode(fragment); | 1158 AstPrinter::PrintNode(fragment); |
| 1156 } | 1159 } |
| 1157 | 1160 |
| 1158 // Create a dummy function object for the code generator. | 1161 // Create a dummy function object for the code generator. |
| 1159 // The function needs to be associated with a named Class: the interface | 1162 // The function needs to be associated with a named Class: the interface |
| 1160 // Function fits the bill. | 1163 // Function fits the bill. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1173 func.set_result_type(Type::Handle(Type::DynamicType())); | 1176 func.set_result_type(Type::Handle(Type::DynamicType())); |
| 1174 func.set_num_fixed_parameters(0); | 1177 func.set_num_fixed_parameters(0); |
| 1175 func.SetNumOptionalParameters(0, true); | 1178 func.SetNumOptionalParameters(0, true); |
| 1176 // Manually generated AST, do not recompile. | 1179 // Manually generated AST, do not recompile. |
| 1177 func.SetIsOptimizable(false); | 1180 func.SetIsOptimizable(false); |
| 1178 func.set_is_debuggable(false); | 1181 func.set_is_debuggable(false); |
| 1179 | 1182 |
| 1180 // We compile the function here, even though InvokeFunction() below | 1183 // We compile the function here, even though InvokeFunction() below |
| 1181 // would compile func automatically. We are checking fewer invariants | 1184 // would compile func automatically. We are checking fewer invariants |
| 1182 // here. | 1185 // here. |
| 1183 ParsedFunction* parsed_function = new ParsedFunction(isolate, func); | 1186 ParsedFunction* parsed_function = new ParsedFunction(thread, func); |
| 1184 parsed_function->SetNodeSequence(fragment); | 1187 parsed_function->SetNodeSequence(fragment); |
| 1185 parsed_function->set_default_parameter_values(Object::null_array()); | 1188 parsed_function->set_default_parameter_values(Object::null_array()); |
| 1186 fragment->scope()->AddVariable(parsed_function->EnsureExpressionTemp()); | 1189 fragment->scope()->AddVariable(parsed_function->EnsureExpressionTemp()); |
| 1187 fragment->scope()->AddVariable( | 1190 fragment->scope()->AddVariable( |
| 1188 parsed_function->current_context_var()); | 1191 parsed_function->current_context_var()); |
| 1189 parsed_function->AllocateVariables(); | 1192 parsed_function->AllocateVariables(); |
| 1190 | 1193 |
| 1191 // Non-optimized code generator. | 1194 // Non-optimized code generator. |
| 1192 DartCompilationPipeline pipeline; | 1195 DartCompilationPipeline pipeline; |
| 1193 CompileParsedFunctionHelper(&pipeline, | 1196 CompileParsedFunctionHelper(&pipeline, |
| 1194 parsed_function, | 1197 parsed_function, |
| 1195 false, | 1198 false, |
| 1196 Isolate::kNoDeoptId); | 1199 Isolate::kNoDeoptId); |
| 1197 | 1200 |
| 1198 const Object& result = PassiveObject::Handle( | 1201 const Object& result = PassiveObject::Handle( |
| 1199 DartEntry::InvokeFunction(func, Object::empty_array())); | 1202 DartEntry::InvokeFunction(func, Object::empty_array())); |
| 1200 return result.raw(); | 1203 return result.raw(); |
| 1201 } else { | 1204 } else { |
| 1202 const Object& result = | 1205 const Object& result = |
| 1203 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1206 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
| 1204 isolate->object_store()->clear_sticky_error(); | 1207 isolate->object_store()->clear_sticky_error(); |
| 1205 return result.raw(); | 1208 return result.raw(); |
| 1206 } | 1209 } |
| 1207 UNREACHABLE(); | 1210 UNREACHABLE(); |
| 1208 return Object::null(); | 1211 return Object::null(); |
| 1209 } | 1212 } |
| 1210 | 1213 |
| 1211 } // namespace dart | 1214 } // namespace dart |
| OLD | NEW |