| 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/bit_vector.h" | 8 #include "vm/bit_vector.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 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 owner()->try_index(), | 1301 owner()->try_index(), |
| 1302 values, | 1302 values, |
| 1303 element_type); | 1303 element_type); |
| 1304 ReturnComputation(create); | 1304 ReturnComputation(create); |
| 1305 } | 1305 } |
| 1306 | 1306 |
| 1307 | 1307 |
| 1308 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1308 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1309 const Function& function = node->function(); | 1309 const Function& function = node->function(); |
| 1310 | 1310 |
| 1311 Value* receiver = NULL; |
| 1311 if (function.IsNonImplicitClosureFunction()) { | 1312 if (function.IsNonImplicitClosureFunction()) { |
| 1312 // The context scope may have already been set by the non-optimizing | 1313 // The context scope may have already been set by the non-optimizing |
| 1313 // compiler. If it was not, set it here. | 1314 // compiler. If it was not, set it here. |
| 1314 if (function.context_scope() == ContextScope::null()) { | 1315 if (function.context_scope() == ContextScope::null()) { |
| 1315 const ContextScope& context_scope = ContextScope::ZoneHandle( | 1316 const ContextScope& context_scope = ContextScope::ZoneHandle( |
| 1316 node->scope()->PreserveOuterScope(owner()->context_level())); | 1317 node->scope()->PreserveOuterScope(owner()->context_level())); |
| 1317 ASSERT(!function.HasCode()); | 1318 ASSERT(!function.HasCode()); |
| 1318 ASSERT(function.context_scope() == ContextScope::null()); | 1319 ASSERT(function.context_scope() == ContextScope::null()); |
| 1319 function.set_context_scope(context_scope); | 1320 function.set_context_scope(context_scope); |
| 1320 } | 1321 } |
| 1322 receiver = BuildNullValue(); |
| 1321 } else if (function.IsImplicitInstanceClosureFunction()) { | 1323 } else if (function.IsImplicitInstanceClosureFunction()) { |
| 1322 ValueGraphVisitor for_receiver(owner(), temp_index()); | 1324 ValueGraphVisitor for_receiver(owner(), temp_index()); |
| 1323 node->receiver()->Visit(&for_receiver); | 1325 node->receiver()->Visit(&for_receiver); |
| 1324 Append(for_receiver); | 1326 Append(for_receiver); |
| 1327 receiver = for_receiver.value(); |
| 1328 } else { |
| 1329 receiver = BuildNullValue(); |
| 1325 } | 1330 } |
| 1326 ASSERT(function.context_scope() != ContextScope::null()); | 1331 ASSERT(function.context_scope() != ContextScope::null()); |
| 1327 | 1332 |
| 1328 // The function type of a closure may have type arguments. In that case, pass | 1333 // The function type of a closure may have type arguments. In that case, pass |
| 1329 // the type arguments of the instantiator. | 1334 // the type arguments of the instantiator. Otherwise, pass null object. |
| 1330 const Class& cls = Class::Handle(function.signature_class()); | 1335 const Class& cls = Class::Handle(function.signature_class()); |
| 1331 ASSERT(!cls.IsNull()); | 1336 ASSERT(!cls.IsNull()); |
| 1332 const bool requires_type_arguments = cls.HasTypeArguments(); | 1337 const bool requires_type_arguments = cls.HasTypeArguments(); |
| 1333 Value* type_arguments = NULL; | 1338 Value* type_arguments = NULL; |
| 1334 if (requires_type_arguments) { | 1339 if (requires_type_arguments) { |
| 1335 ASSERT(!function.IsImplicitStaticClosureFunction()); | 1340 ASSERT(!function.IsImplicitStaticClosureFunction()); |
| 1336 type_arguments = BuildInstantiatorTypeArguments(node->token_index(), NULL); | 1341 type_arguments = BuildInstantiatorTypeArguments(node->token_index(), NULL); |
| 1342 } else { |
| 1343 type_arguments = BuildNullValue(); |
| 1337 } | 1344 } |
| 1338 | 1345 |
| 1339 CreateClosureComp* create = | 1346 CreateClosureComp* create = new CreateClosureComp( |
| 1340 new CreateClosureComp(node, owner()->try_index(), type_arguments); | 1347 node, owner()->try_index(), type_arguments, receiver); |
| 1341 ReturnComputation(create); | 1348 ReturnComputation(create); |
| 1342 } | 1349 } |
| 1343 | 1350 |
| 1344 | 1351 |
| 1345 void EffectGraphVisitor::TranslateArgumentList( | 1352 void EffectGraphVisitor::TranslateArgumentList( |
| 1346 const ArgumentListNode& node, | 1353 const ArgumentListNode& node, |
| 1347 ZoneGrowableArray<Value*>* values) { | 1354 ZoneGrowableArray<Value*>* values) { |
| 1348 for (intptr_t i = 0; i < node.length(); ++i) { | 1355 for (intptr_t i = 0; i < node.length(); ++i) { |
| 1349 ValueGraphVisitor for_argument(owner(), temp_index()); | 1356 ValueGraphVisitor for_argument(owner(), temp_index()); |
| 1350 node.NodeAt(i)->Visit(&for_argument); | 1357 node.NodeAt(i)->Visit(&for_argument); |
| (...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2436 char* chars = reinterpret_cast<char*>( | 2443 char* chars = reinterpret_cast<char*>( |
| 2437 Isolate::Current()->current_zone()->Allocate(len)); | 2444 Isolate::Current()->current_zone()->Allocate(len)); |
| 2438 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2445 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2439 const Error& error = Error::Handle( | 2446 const Error& error = Error::Handle( |
| 2440 LanguageError::New(String::Handle(String::New(chars)))); | 2447 LanguageError::New(String::Handle(String::New(chars)))); |
| 2441 Isolate::Current()->long_jump_base()->Jump(1, error); | 2448 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2442 } | 2449 } |
| 2443 | 2450 |
| 2444 | 2451 |
| 2445 } // namespace dart | 2452 } // namespace dart |
| OLD | NEW |