| 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/code_descriptors.h" | 9 #include "vm/code_descriptors.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 PushArgumentInstr* EffectGraphVisitor::PushArgument(Value* value) { | 400 PushArgumentInstr* EffectGraphVisitor::PushArgument(Value* value) { |
| 401 PushArgumentInstr* result = new PushArgumentInstr(value); | 401 PushArgumentInstr* result = new PushArgumentInstr(value); |
| 402 AddInstruction(result); | 402 AddInstruction(result); |
| 403 return result; | 403 return result; |
| 404 } | 404 } |
| 405 | 405 |
| 406 | 406 |
| 407 Definition* EffectGraphVisitor::BuildStoreTemp(const LocalVariable& local, | 407 Definition* EffectGraphVisitor::BuildStoreTemp(const LocalVariable& local, |
| 408 Value* value) { | 408 Value* value) { |
| 409 ASSERT(!local.is_captured()); | 409 ASSERT(!local.is_captured()); |
| 410 return new StoreLocalInstr(local, value, owner()->context_level()); | 410 return new StoreLocalInstr(local, value); |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 Definition* EffectGraphVisitor::BuildStoreExprTemp(Value* value) { | 414 Definition* EffectGraphVisitor::BuildStoreExprTemp(Value* value) { |
| 415 return BuildStoreTemp(*owner()->parsed_function().expression_temp_var(), | 415 return BuildStoreTemp(*owner()->parsed_function().expression_temp_var(), |
| 416 value); | 416 value); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 Definition* EffectGraphVisitor::BuildLoadExprTemp() { | 420 Definition* EffectGraphVisitor::BuildLoadExprTemp() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 444 Context::variable_offset(local.index()), | 444 Context::variable_offset(local.index()), |
| 445 value, | 445 value, |
| 446 local.type()); | 446 local.type()); |
| 447 if (result_is_needed) { | 447 if (result_is_needed) { |
| 448 Do(store); | 448 Do(store); |
| 449 return BuildLoadExprTemp(); | 449 return BuildLoadExprTemp(); |
| 450 } else { | 450 } else { |
| 451 return store; | 451 return store; |
| 452 } | 452 } |
| 453 } else { | 453 } else { |
| 454 return new StoreLocalInstr(local, value, owner()->context_level()); | 454 return new StoreLocalInstr(local, value); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 | 458 |
| 459 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { | 459 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { |
| 460 if (local.is_captured()) { | 460 if (local.is_captured()) { |
| 461 InlineBailout("EffectGraphVisitor::BuildLoadLocal (context)"); | 461 InlineBailout("EffectGraphVisitor::BuildLoadLocal (context)"); |
| 462 intptr_t delta = | 462 intptr_t delta = |
| 463 owner()->context_level() - local.owner()->context_level(); | 463 owner()->context_level() - local.owner()->context_level(); |
| 464 ASSERT(delta >= 0); | 464 ASSERT(delta >= 0); |
| 465 Value* context = Bind(new CurrentContextInstr()); | 465 Value* context = Bind(new CurrentContextInstr()); |
| 466 while (delta-- > 0) { | 466 while (delta-- > 0) { |
| 467 context = Bind(new LoadFieldInstr( | 467 context = Bind(new LoadFieldInstr( |
| 468 context, Context::parent_offset(), Type::ZoneHandle())); | 468 context, Context::parent_offset(), Type::ZoneHandle())); |
| 469 } | 469 } |
| 470 return new LoadFieldInstr(context, | 470 return new LoadFieldInstr(context, |
| 471 Context::variable_offset(local.index()), | 471 Context::variable_offset(local.index()), |
| 472 local.type()); | 472 local.type()); |
| 473 } else { | 473 } else { |
| 474 return new LoadLocalInstr(local, owner()->context_level()); | 474 return new LoadLocalInstr(local); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 | 478 |
| 479 // Stores current context into the 'variable' | 479 // Stores current context into the 'variable' |
| 480 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { | 480 void EffectGraphVisitor::BuildStoreContext(const LocalVariable& variable) { |
| 481 Value* context = Bind(new CurrentContextInstr()); | 481 Value* context = Bind(new CurrentContextInstr()); |
| 482 Do(BuildStoreLocal(variable, context, kResultNotNeeded)); | 482 Do(BuildStoreLocal(variable, context, kResultNotNeeded)); |
| 483 } | 483 } |
| 484 | 484 |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 node->type(), | 1673 node->type(), |
| 1674 element_type); | 1674 element_type); |
| 1675 Value* array_val = Bind(create); | 1675 Value* array_val = Bind(create); |
| 1676 Definition* store = BuildStoreTemp(node->temp_local(), array_val); | 1676 Definition* store = BuildStoreTemp(node->temp_local(), array_val); |
| 1677 Do(store); | 1677 Do(store); |
| 1678 | 1678 |
| 1679 const intptr_t class_id = create->Type()->ToCid(); | 1679 const intptr_t class_id = create->Type()->ToCid(); |
| 1680 const intptr_t deopt_id = Isolate::kNoDeoptId; | 1680 const intptr_t deopt_id = Isolate::kNoDeoptId; |
| 1681 for (int i = 0; i < node->length(); ++i) { | 1681 for (int i = 0; i < node->length(); ++i) { |
| 1682 Value* array = Bind( | 1682 Value* array = Bind( |
| 1683 new LoadLocalInstr(node->temp_local(), owner()->context_level())); | 1683 new LoadLocalInstr(node->temp_local())); |
| 1684 Value* index = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(i)))); | 1684 Value* index = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(i)))); |
| 1685 ValueGraphVisitor for_value(owner(), temp_index()); | 1685 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1686 node->ElementAt(i)->Visit(&for_value); | 1686 node->ElementAt(i)->Visit(&for_value); |
| 1687 Append(for_value); | 1687 Append(for_value); |
| 1688 // No store barrier needed for constants. | 1688 // No store barrier needed for constants. |
| 1689 const StoreBarrierType emit_store_barrier = | 1689 const StoreBarrierType emit_store_barrier = |
| 1690 for_value.value()->BindsToConstant() | 1690 for_value.value()->BindsToConstant() |
| 1691 ? kNoStoreBarrier | 1691 ? kNoStoreBarrier |
| 1692 : kEmitStoreBarrier; | 1692 : kEmitStoreBarrier; |
| 1693 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id); | 1693 intptr_t index_scale = FlowGraphCompiler::ElementSizeFor(class_id); |
| 1694 StoreIndexedInstr* store = new StoreIndexedInstr( | 1694 StoreIndexedInstr* store = new StoreIndexedInstr( |
| 1695 array, index, for_value.value(), | 1695 array, index, for_value.value(), |
| 1696 emit_store_barrier, index_scale, class_id, deopt_id); | 1696 emit_store_barrier, index_scale, class_id, deopt_id); |
| 1697 Do(store); | 1697 Do(store); |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 ReturnDefinition( | 1700 ReturnDefinition(new LoadLocalInstr(node->temp_local())); |
| 1701 new LoadLocalInstr(node->temp_local(), owner()->context_level())); | |
| 1702 } | 1701 } |
| 1703 | 1702 |
| 1704 | 1703 |
| 1705 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1704 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1706 const Function& function = node->function(); | 1705 const Function& function = node->function(); |
| 1707 | 1706 |
| 1708 if (function.IsImplicitStaticClosureFunction()) { | 1707 if (function.IsImplicitStaticClosureFunction()) { |
| 1709 Instance& closure = Instance::ZoneHandle(); | 1708 Instance& closure = Instance::ZoneHandle(); |
| 1710 closure ^= function.implicit_static_closure(); | 1709 closure ^= function.implicit_static_closure(); |
| 1711 if (closure.IsNull()) { | 1710 if (closure.IsNull()) { |
| (...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3299 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3298 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3300 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3299 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3301 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3300 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3302 const Error& error = Error::Handle( | 3301 const Error& error = Error::Handle( |
| 3303 LanguageError::New(String::Handle(String::New(chars)))); | 3302 LanguageError::New(String::Handle(String::New(chars)))); |
| 3304 Isolate::Current()->long_jump_base()->Jump(1, error); | 3303 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3305 } | 3304 } |
| 3306 | 3305 |
| 3307 | 3306 |
| 3308 } // namespace dart | 3307 } // namespace dart |
| OLD | NEW |