Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: runtime/vm/compiler.cc

Issue 1261673004: Non-tree-shaking --precompile. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Create fewer implicit closure functions Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 return Error::null(); 1074 return Error::null();
1075 } 1075 }
1076 1076
1077 1077
1078 RawError* Compiler::CompileFunction(Thread* thread, 1078 RawError* Compiler::CompileFunction(Thread* thread,
1079 const Function& function) { 1079 const Function& function) {
1080 Isolate* isolate = thread->isolate(); 1080 Isolate* isolate = thread->isolate();
1081 VMTagScope tagScope(isolate, VMTag::kCompileUnoptimizedTagId); 1081 VMTagScope tagScope(isolate, VMTag::kCompileUnoptimizedTagId);
1082 TIMELINE_FUNCTION_COMPILATION_DURATION(isolate, "Function", function); 1082 TIMELINE_FUNCTION_COMPILATION_DURATION(isolate, "Function", function);
1083 1083
1084 if (!isolate->compilation_allowed()) {
1085 FATAL2("Precompilation missed function %s (%s)\n",
1086 function.ToQualifiedCString(),
1087 Function::KindToCString(function.kind()));
1088 }
1089
1084 CompilationPipeline* pipeline = 1090 CompilationPipeline* pipeline =
1085 CompilationPipeline::New(thread->zone(), function); 1091 CompilationPipeline::New(thread->zone(), function);
1086 1092
1087 const bool optimized = 1093 const bool optimized =
1088 Compiler::always_optimize() && function.IsOptimizable(); 1094 Compiler::always_optimize() && function.IsOptimizable();
1089 1095
1090 return CompileFunctionHelper(pipeline, function, optimized, 1096 return CompileFunctionHelper(pipeline, function, optimized,
1091 Isolate::kNoDeoptId); 1097 Isolate::kNoDeoptId);
1092 } 1098 }
1093 1099
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 1240
1235 1241
1236 static void CreateLocalVarDescriptors(const ParsedFunction& parsed_function) { 1242 static void CreateLocalVarDescriptors(const ParsedFunction& parsed_function) {
1237 const Function& func = parsed_function.function(); 1243 const Function& func = parsed_function.function();
1238 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(); 1244 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle();
1239 var_descs = parsed_function.node_sequence()->scope()->GetVarDescriptors(func); 1245 var_descs = parsed_function.node_sequence()->scope()->GetVarDescriptors(func);
1240 Code::Handle(func.unoptimized_code()).set_var_descriptors(var_descs); 1246 Code::Handle(func.unoptimized_code()).set_var_descriptors(var_descs);
1241 } 1247 }
1242 1248
1243 1249
1250 void Compiler::CompileStaticInitializer(const Field& field) {
1251 ASSERT(field.is_static());
1252 if (field.initializer() != Function::null()) {
1253 // TODO(rmacnak): Investigate why this happens for _enum_names.
1254 OS::Print("Warning: Ignoring repeated request for initializer for %s\n",
1255 field.ToCString());
1256 return;
1257 }
1258 ASSERT(field.initializer() == Function::null());
1259 Isolate* isolate = Isolate::Current();
1260 StackZone zone(isolate);
1261
1262 ParsedFunction* parsed_function = Parser::ParseStaticFieldInitializer(field);
1263
1264 parsed_function->AllocateVariables();
1265 // Non-optimized code generator.
1266 DartCompilationPipeline pipeline;
1267 CompileParsedFunctionHelper(&pipeline,
1268 parsed_function,
1269 false,
srdjan 2015/07/29 21:39:13 describe/comment what argument false is assigned t
rmacnak 2015/07/29 23:09:27 Done.
1270 Isolate::kNoDeoptId);
1271
1272 const Function& initializer = parsed_function->function();
1273 field.set_initializer(initializer);
1274 }
1275
1276
1244 RawObject* Compiler::EvaluateStaticInitializer(const Field& field) { 1277 RawObject* Compiler::EvaluateStaticInitializer(const Field& field) {
1245 ASSERT(field.is_static()); 1278 ASSERT(field.is_static());
1246 // The VM sets the field's value to transiton_sentinel prior to 1279 // The VM sets the field's value to transiton_sentinel prior to
1247 // evaluating the initializer value. 1280 // evaluating the initializer value.
1248 ASSERT(field.value() == Object::transition_sentinel().raw()); 1281 ASSERT(field.value() == Object::transition_sentinel().raw());
1249 LongJumpScope jump; 1282 LongJumpScope jump;
1250 if (setjmp(*jump.Set()) == 0) { 1283 if (setjmp(*jump.Set()) == 0) {
1251 Isolate* const isolate = Isolate::Current(); 1284 Function& initializer = Function::Handle(field.initializer());
1252 StackZone zone(isolate); 1285
1253 ParsedFunction* parsed_function = 1286 if (initializer.IsNull()) {
srdjan 2015/07/29 21:39:13 Please describe what is going on (when can field.i
rmacnak 2015/07/29 23:09:27 Done.
1287 Isolate* const isolate = Isolate::Current();
1288 StackZone zone(isolate);
1289 ParsedFunction* parsed_function =
1254 Parser::ParseStaticFieldInitializer(field); 1290 Parser::ParseStaticFieldInitializer(field);
srdjan 2015/07/29 21:39:13 4 spaces indent.
rmacnak 2015/07/29 23:09:27 Done.
1255 1291
1256 parsed_function->AllocateVariables(); 1292 parsed_function->AllocateVariables();
1257 // Non-optimized code generator. 1293 // Non-optimized code generator.
1258 DartCompilationPipeline pipeline; 1294 DartCompilationPipeline pipeline;
1259 CompileParsedFunctionHelper(&pipeline, 1295 CompileParsedFunctionHelper(&pipeline,
1260 parsed_function, 1296 parsed_function,
1261 false, 1297 false,
1262 Isolate::kNoDeoptId); 1298 Isolate::kNoDeoptId);
1263 // Eagerly create local var descriptors. 1299 // Eagerly create local var descriptors.
1264 CreateLocalVarDescriptors(*parsed_function); 1300 CreateLocalVarDescriptors(*parsed_function);
1265 1301
1302 initializer = parsed_function->function().raw();
1303 }
1266 // Invoke the function to evaluate the expression. 1304 // Invoke the function to evaluate the expression.
1267 const Function& initializer = parsed_function->function();
1268 const Object& result = PassiveObject::Handle( 1305 const Object& result = PassiveObject::Handle(
1269 DartEntry::InvokeFunction(initializer, Object::empty_array())); 1306 DartEntry::InvokeFunction(initializer, Object::empty_array()));
1270 return result.raw(); 1307 return result.raw();
1271 } else { 1308 } else {
1272 Isolate* const isolate = Isolate::Current(); 1309 Isolate* const isolate = Isolate::Current();
1273 StackZone zone(isolate); 1310 StackZone zone(isolate);
1274 const Error& error = 1311 const Error& error =
1275 Error::Handle(isolate, isolate->object_store()->sticky_error()); 1312 Error::Handle(isolate, isolate->object_store()->sticky_error());
1276 isolate->object_store()->clear_sticky_error(); 1313 isolate->object_store()->clear_sticky_error();
1277 return error.raw(); 1314 return error.raw();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 const Object& result = 1379 const Object& result =
1343 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1380 PassiveObject::Handle(isolate->object_store()->sticky_error());
1344 isolate->object_store()->clear_sticky_error(); 1381 isolate->object_store()->clear_sticky_error();
1345 return result.raw(); 1382 return result.raw();
1346 } 1383 }
1347 UNREACHABLE(); 1384 UNREACHABLE();
1348 return Object::null(); 1385 return Object::null();
1349 } 1386 }
1350 1387
1351 } // namespace dart 1388 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698