| 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 "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1476 arguments, | 1476 arguments, |
| 1477 node->type(), | 1477 node->type(), |
| 1478 element_type); | 1478 element_type); |
| 1479 ReturnDefinition(create); | 1479 ReturnDefinition(create); |
| 1480 } | 1480 } |
| 1481 | 1481 |
| 1482 | 1482 |
| 1483 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1483 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1484 const Function& function = node->function(); | 1484 const Function& function = node->function(); |
| 1485 | 1485 |
| 1486 if (function.IsImplicitStaticClosureFunction()) { |
| 1487 Instance& closure = Instance::ZoneHandle(); |
| 1488 closure ^= function.implicit_static_closure(); |
| 1489 if (closure.IsNull()) { |
| 1490 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 1491 const Context& context = Context::Handle(object_store->empty_context()); |
| 1492 closure ^= Closure::New(function, context, Heap::kOld); |
| 1493 function.set_implicit_static_closure(closure); |
| 1494 } |
| 1495 ReturnDefinition(new ConstantInstr(closure)); |
| 1496 return; |
| 1497 } |
| 1486 Value* receiver = NULL; | 1498 Value* receiver = NULL; |
| 1487 if (function.IsNonImplicitClosureFunction()) { | 1499 if (function.IsNonImplicitClosureFunction()) { |
| 1488 // The context scope may have already been set by the non-optimizing | 1500 // The context scope may have already been set by the non-optimizing |
| 1489 // compiler. If it was not, set it here. | 1501 // compiler. If it was not, set it here. |
| 1490 if (function.context_scope() == ContextScope::null()) { | 1502 if (function.context_scope() == ContextScope::null()) { |
| 1491 // TODO(regis): Why are we not doing this in the parser? | 1503 // TODO(regis): Why are we not doing this in the parser? |
| 1492 const ContextScope& context_scope = ContextScope::ZoneHandle( | 1504 const ContextScope& context_scope = ContextScope::ZoneHandle( |
| 1493 node->scope()->PreserveOuterScope(owner()->context_level())); | 1505 node->scope()->PreserveOuterScope(owner()->context_level())); |
| 1494 ASSERT(!function.HasCode()); | 1506 ASSERT(!function.HasCode()); |
| 1495 ASSERT(function.context_scope() == ContextScope::null()); | 1507 ASSERT(function.context_scope() == ContextScope::null()); |
| 1496 function.set_context_scope(context_scope); | 1508 function.set_context_scope(context_scope); |
| 1497 } | 1509 } |
| 1498 receiver = BuildNullValue(); | 1510 receiver = BuildNullValue(); |
| 1499 } else if (function.IsImplicitInstanceClosureFunction()) { | 1511 } else { |
| 1512 ASSERT(function.IsImplicitInstanceClosureFunction()); |
| 1500 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth()); | 1513 ValueGraphVisitor for_receiver(owner(), temp_index(), loop_depth()); |
| 1501 node->receiver()->Visit(&for_receiver); | 1514 node->receiver()->Visit(&for_receiver); |
| 1502 Append(for_receiver); | 1515 Append(for_receiver); |
| 1503 receiver = for_receiver.value(); | 1516 receiver = for_receiver.value(); |
| 1504 } else { | |
| 1505 receiver = BuildNullValue(); | |
| 1506 } | 1517 } |
| 1507 PushArgumentInstr* push_receiver = PushArgument(receiver); | 1518 PushArgumentInstr* push_receiver = PushArgument(receiver); |
| 1508 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1519 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1509 new ZoneGrowableArray<PushArgumentInstr*>(2); | 1520 new ZoneGrowableArray<PushArgumentInstr*>(2); |
| 1510 arguments->Add(push_receiver); | 1521 arguments->Add(push_receiver); |
| 1511 ASSERT(function.context_scope() != ContextScope::null()); | 1522 ASSERT(function.context_scope() != ContextScope::null()); |
| 1512 | 1523 |
| 1513 // The function type of a closure may have type arguments. In that case, pass | 1524 // The function type of a closure may have type arguments. In that case, pass |
| 1514 // the type arguments of the instantiator. Otherwise, pass null object. | 1525 // the type arguments of the instantiator. Otherwise, pass null object. |
| 1515 const Class& cls = Class::Handle(function.signature_class()); | 1526 const Class& cls = Class::Handle(function.signature_class()); |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2947 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2937 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2948 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2938 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2949 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2939 const Error& error = Error::Handle( | 2950 const Error& error = Error::Handle( |
| 2940 LanguageError::New(String::Handle(String::New(chars)))); | 2951 LanguageError::New(String::Handle(String::New(chars)))); |
| 2941 Isolate::Current()->long_jump_base()->Jump(1, error); | 2952 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2942 } | 2953 } |
| 2943 | 2954 |
| 2944 | 2955 |
| 2945 } // namespace dart | 2956 } // namespace dart |
| OLD | NEW |