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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10825035: Add an explicit push-argument instruction to the IL. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
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/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 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 } 1368 }
1369 receiver = BuildNullValue(); 1369 receiver = BuildNullValue();
1370 } else if (function.IsImplicitInstanceClosureFunction()) { 1370 } else if (function.IsImplicitInstanceClosureFunction()) {
1371 ValueGraphVisitor for_receiver(owner(), temp_index()); 1371 ValueGraphVisitor for_receiver(owner(), temp_index());
1372 node->receiver()->Visit(&for_receiver); 1372 node->receiver()->Visit(&for_receiver);
1373 Append(for_receiver); 1373 Append(for_receiver);
1374 receiver = for_receiver.value(); 1374 receiver = for_receiver.value();
1375 } else { 1375 } else {
1376 receiver = BuildNullValue(); 1376 receiver = BuildNullValue();
1377 } 1377 }
1378 AddInstruction(new PushArgumentInstr(receiver));
1378 ASSERT(function.context_scope() != ContextScope::null()); 1379 ASSERT(function.context_scope() != ContextScope::null());
1379 1380
1380 // The function type of a closure may have type arguments. In that case, pass 1381 // The function type of a closure may have type arguments. In that case, pass
1381 // the type arguments of the instantiator. Otherwise, pass null object. 1382 // the type arguments of the instantiator. Otherwise, pass null object.
1382 const Class& cls = Class::Handle(function.signature_class()); 1383 const Class& cls = Class::Handle(function.signature_class());
1383 ASSERT(!cls.IsNull()); 1384 ASSERT(!cls.IsNull());
1384 const bool requires_type_arguments = cls.HasTypeArguments(); 1385 const bool requires_type_arguments = cls.HasTypeArguments();
1385 Value* type_arguments = NULL; 1386 Value* type_arguments = NULL;
1386 if (requires_type_arguments) { 1387 if (requires_type_arguments) {
1387 ASSERT(!function.IsImplicitStaticClosureFunction()); 1388 ASSERT(!function.IsImplicitStaticClosureFunction());
1388 type_arguments = BuildInstantiatorTypeArguments(node->token_pos(), NULL); 1389 type_arguments = BuildInstantiatorTypeArguments(node->token_pos(), NULL);
1389 } else { 1390 } else {
1390 type_arguments = BuildNullValue(); 1391 type_arguments = BuildNullValue();
1391 } 1392 }
1392 1393 AddInstruction(new PushArgumentInstr(type_arguments));
1393 CreateClosureComp* create = new CreateClosureComp( 1394 ReturnComputation(new CreateClosureComp(node, owner()->try_index()));
Kevin Millikin (Google) 2012/07/26 13:03:18 I imagine we'll also want a list of the push argum
Florian Schneider 2012/07/26 13:45:24 Done.
1394 node, owner()->try_index(), type_arguments, receiver);
1395 ReturnComputation(create);
1396 } 1395 }
1397 1396
1398 1397
1399 void EffectGraphVisitor::TranslateArgumentList( 1398 void EffectGraphVisitor::TranslateArgumentList(
1400 const ArgumentListNode& node, 1399 const ArgumentListNode& node,
1401 ZoneGrowableArray<Value*>* values) { 1400 ZoneGrowableArray<Value*>* values) {
1402 for (intptr_t i = 0; i < node.length(); ++i) { 1401 for (intptr_t i = 0; i < node.length(); ++i) {
1403 ValueGraphVisitor for_argument(owner(), temp_index()); 1402 ValueGraphVisitor for_argument(owner(), temp_index());
1404 node.NodeAt(i)->Visit(&for_argument); 1403 node.NodeAt(i)->Visit(&for_argument);
1405 Append(for_argument); 1404 Append(for_argument);
1406 values->Add(for_argument.value()); 1405 values->Add(for_argument.value());
1407 } 1406 }
1408 } 1407 }
1409 1408
1409
1410 void EffectGraphVisitor::BuildPushArguments(
1411 const ArgumentListNode& node,
1412 ZoneGrowableArray<PushArgumentInstr*>* values) {
1413 for (intptr_t i = 0; i < node.length(); ++i) {
1414 ValueGraphVisitor for_argument(owner(), temp_index());
1415 node.NodeAt(i)->Visit(&for_argument);
1416 Append(for_argument);
1417 PushArgumentInstr* push_arg = new PushArgumentInstr(for_argument.value());
1418 AddInstruction(push_arg);
1419 values->Add(push_arg);
1420 }
1421 }
1422
1423
1410 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { 1424 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
1411 ArgumentListNode* arguments = node->arguments(); 1425 ArgumentListNode* arguments = node->arguments();
1412 int length = arguments->length(); 1426 int length = arguments->length();
1413 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); 1427 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1);
1414 1428
1415 ValueGraphVisitor for_receiver(owner(), temp_index()); 1429 ValueGraphVisitor for_receiver(owner(), temp_index());
1416 node->receiver()->Visit(&for_receiver); 1430 node->receiver()->Visit(&for_receiver);
1417 Append(for_receiver); 1431 Append(for_receiver);
1418 values->Add(for_receiver.value()); 1432 values->Add(for_receiver.value());
1419 1433
(...skipping 20 matching lines...) Expand all
1440 values); 1454 values);
1441 ReturnComputation(call); 1455 ReturnComputation(call);
1442 } 1456 }
1443 1457
1444 1458
1445 ClosureCallComp* EffectGraphVisitor::BuildClosureCall( 1459 ClosureCallComp* EffectGraphVisitor::BuildClosureCall(
1446 ClosureCallNode* node) { 1460 ClosureCallNode* node) {
1447 ValueGraphVisitor for_closure(owner(), temp_index()); 1461 ValueGraphVisitor for_closure(owner(), temp_index());
1448 node->closure()->Visit(&for_closure); 1462 node->closure()->Visit(&for_closure);
1449 Append(for_closure); 1463 Append(for_closure);
1464 PushArgumentInstr* push_closure = new PushArgumentInstr(for_closure.value());
1465 AddInstruction(push_closure);
1450 1466
1451 ZoneGrowableArray<Value*>* arguments = 1467 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1452 new ZoneGrowableArray<Value*>(node->arguments()->length()); 1468 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
1453 arguments->Add(for_closure.value()); 1469 arguments->Add(push_closure);
1454 TranslateArgumentList(*node->arguments(), arguments); 1470 BuildPushArguments(*node->arguments(), arguments);
1455 1471
1456 // Save context around the call. 1472 // Save context around the call.
1457 BuildStoreContext(*owner()->parsed_function().expression_temp_var()); 1473 BuildStoreContext(*owner()->parsed_function().expression_temp_var());
1458 return new ClosureCallComp(node, owner()->try_index(), arguments); 1474 return new ClosureCallComp(node, owner()->try_index(), arguments);
1459 } 1475 }
1460 1476
1461 1477
1462 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { 1478 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
1463 Do(BuildClosureCall(node)); 1479 Do(BuildClosureCall(node));
1464 // Restore context from saved location. 1480 // Restore context from saved location.
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 char* chars = reinterpret_cast<char*>( 2712 char* chars = reinterpret_cast<char*>(
2697 Isolate::Current()->current_zone()->Allocate(len)); 2713 Isolate::Current()->current_zone()->Allocate(len));
2698 OS::SNPrint(chars, len, kFormat, function_name, reason); 2714 OS::SNPrint(chars, len, kFormat, function_name, reason);
2699 const Error& error = Error::Handle( 2715 const Error& error = Error::Handle(
2700 LanguageError::New(String::Handle(String::New(chars)))); 2716 LanguageError::New(String::Handle(String::New(chars))));
2701 Isolate::Current()->long_jump_base()->Jump(1, error); 2717 Isolate::Current()->long_jump_base()->Jump(1, error);
2702 } 2718 }
2703 2719
2704 2720
2705 } // namespace dart 2721 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler.cc » ('j') | vm/flow_graph_compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698