| 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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 } | 1270 } |
| 1271 func.ClearICDataArray(); | 1271 func.ClearICDataArray(); |
| 1272 func.ClearCode(); | 1272 func.ClearCode(); |
| 1273 } | 1273 } |
| 1274 } | 1274 } |
| 1275 } | 1275 } |
| 1276 return error.raw(); | 1276 return error.raw(); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 | 1279 |
| 1280 static void CreateLocalVarDescriptors(const ParsedFunction& parsed_function) { | |
| 1281 const Function& func = parsed_function.function(); | |
| 1282 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(); | |
| 1283 var_descs = parsed_function.node_sequence()->scope()->GetVarDescriptors(func); | |
| 1284 Code::Handle(func.unoptimized_code()).set_var_descriptors(var_descs); | |
| 1285 } | |
| 1286 | |
| 1287 | |
| 1288 void Compiler::CompileStaticInitializer(const Field& field) { | 1280 void Compiler::CompileStaticInitializer(const Field& field) { |
| 1289 ASSERT(field.is_static()); | 1281 ASSERT(field.is_static()); |
| 1290 if (field.initializer() != Function::null()) { | 1282 if (field.initializer() != Function::null()) { |
| 1291 // TODO(rmacnak): Investigate why this happens for _enum_names. | 1283 // TODO(rmacnak): Investigate why this happens for _enum_names. |
| 1292 OS::Print("Warning: Ignoring repeated request for initializer for %s\n", | 1284 OS::Print("Warning: Ignoring repeated request for initializer for %s\n", |
| 1293 field.ToCString()); | 1285 field.ToCString()); |
| 1294 return; | 1286 return; |
| 1295 } | 1287 } |
| 1296 ASSERT(field.initializer() == Function::null()); | 1288 ASSERT(field.initializer() == Function::null()); |
| 1297 Thread* thread = Thread::Current(); | 1289 Thread* thread = Thread::Current(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 ParsedFunction* parsed_function = | 1323 ParsedFunction* parsed_function = |
| 1332 Parser::ParseStaticFieldInitializer(field); | 1324 Parser::ParseStaticFieldInitializer(field); |
| 1333 | 1325 |
| 1334 parsed_function->AllocateVariables(); | 1326 parsed_function->AllocateVariables(); |
| 1335 // Non-optimized code generator. | 1327 // Non-optimized code generator. |
| 1336 DartCompilationPipeline pipeline; | 1328 DartCompilationPipeline pipeline; |
| 1337 CompileParsedFunctionHelper(&pipeline, | 1329 CompileParsedFunctionHelper(&pipeline, |
| 1338 parsed_function, | 1330 parsed_function, |
| 1339 false, // optimized | 1331 false, // optimized |
| 1340 Isolate::kNoDeoptId); | 1332 Isolate::kNoDeoptId); |
| 1341 // Eagerly create local var descriptors. | |
| 1342 CreateLocalVarDescriptors(*parsed_function); | |
| 1343 | |
| 1344 initializer = parsed_function->function().raw(); | 1333 initializer = parsed_function->function().raw(); |
| 1345 } | 1334 } |
| 1346 // Invoke the function to evaluate the expression. | 1335 // Invoke the function to evaluate the expression. |
| 1347 const Object& result = PassiveObject::Handle( | 1336 return DartEntry::InvokeFunction(initializer, Object::empty_array()); |
| 1348 DartEntry::InvokeFunction(initializer, Object::empty_array())); | |
| 1349 return result.raw(); | |
| 1350 } else { | 1337 } else { |
| 1351 Thread* const thread = Thread::Current(); | 1338 Thread* const thread = Thread::Current(); |
| 1352 Isolate* const isolate = thread->isolate(); | 1339 Isolate* const isolate = thread->isolate(); |
| 1353 StackZone zone(thread); | 1340 StackZone zone(thread); |
| 1354 const Error& error = | 1341 const Error& error = |
| 1355 Error::Handle(thread->zone(), isolate->object_store()->sticky_error()); | 1342 Error::Handle(thread->zone(), isolate->object_store()->sticky_error()); |
| 1356 isolate->object_store()->clear_sticky_error(); | 1343 isolate->object_store()->clear_sticky_error(); |
| 1357 return error.raw(); | 1344 return error.raw(); |
| 1358 } | 1345 } |
| 1359 UNREACHABLE(); | 1346 UNREACHABLE(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 parsed_function->current_context_var()); | 1390 parsed_function->current_context_var()); |
| 1404 parsed_function->AllocateVariables(); | 1391 parsed_function->AllocateVariables(); |
| 1405 | 1392 |
| 1406 // Non-optimized code generator. | 1393 // Non-optimized code generator. |
| 1407 DartCompilationPipeline pipeline; | 1394 DartCompilationPipeline pipeline; |
| 1408 CompileParsedFunctionHelper(&pipeline, | 1395 CompileParsedFunctionHelper(&pipeline, |
| 1409 parsed_function, | 1396 parsed_function, |
| 1410 false, | 1397 false, |
| 1411 Isolate::kNoDeoptId); | 1398 Isolate::kNoDeoptId); |
| 1412 | 1399 |
| 1413 // Eagerly create local var descriptors. | |
| 1414 CreateLocalVarDescriptors(*parsed_function); | |
| 1415 const Object& result = PassiveObject::Handle( | 1400 const Object& result = PassiveObject::Handle( |
| 1416 DartEntry::InvokeFunction(func, Object::empty_array())); | 1401 DartEntry::InvokeFunction(func, Object::empty_array())); |
| 1417 return result.raw(); | 1402 return result.raw(); |
| 1418 } else { | 1403 } else { |
| 1419 Thread* const thread = Thread::Current(); | 1404 Thread* const thread = Thread::Current(); |
| 1420 Isolate* const isolate = thread->isolate(); | 1405 Isolate* const isolate = thread->isolate(); |
| 1421 const Object& result = | 1406 const Object& result = |
| 1422 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1407 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
| 1423 isolate->object_store()->clear_sticky_error(); | 1408 isolate->object_store()->clear_sticky_error(); |
| 1424 return result.raw(); | 1409 return result.raw(); |
| 1425 } | 1410 } |
| 1426 UNREACHABLE(); | 1411 UNREACHABLE(); |
| 1427 return Object::null(); | 1412 return Object::null(); |
| 1428 } | 1413 } |
| 1429 | 1414 |
| 1430 } // namespace dart | 1415 } // namespace dart |
| OLD | NEW |