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

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
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 PushArgumentInstr* push_receiver = new PushArgumentInstr(receiver);
1379 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1380 new ZoneGrowableArray<PushArgumentInstr*>(2);
1381 arguments->Add(push_receiver);
1382 AddInstruction(push_receiver);
1378 ASSERT(function.context_scope() != ContextScope::null()); 1383 ASSERT(function.context_scope() != ContextScope::null());
1379 1384
1380 // The function type of a closure may have type arguments. In that case, pass 1385 // 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. 1386 // the type arguments of the instantiator. Otherwise, pass null object.
1382 const Class& cls = Class::Handle(function.signature_class()); 1387 const Class& cls = Class::Handle(function.signature_class());
1383 ASSERT(!cls.IsNull()); 1388 ASSERT(!cls.IsNull());
1384 const bool requires_type_arguments = cls.HasTypeArguments(); 1389 const bool requires_type_arguments = cls.HasTypeArguments();
1385 Value* type_arguments = NULL; 1390 Value* type_arguments = NULL;
1386 if (requires_type_arguments) { 1391 if (requires_type_arguments) {
1387 ASSERT(!function.IsImplicitStaticClosureFunction()); 1392 ASSERT(!function.IsImplicitStaticClosureFunction());
1388 type_arguments = BuildInstantiatorTypeArguments(node->token_pos(), NULL); 1393 type_arguments = BuildInstantiatorTypeArguments(node->token_pos(), NULL);
1389 } else { 1394 } else {
1390 type_arguments = BuildNullValue(); 1395 type_arguments = BuildNullValue();
1391 } 1396 }
1392 1397 PushArgumentInstr* push_type_arguments =
1393 CreateClosureComp* create = new CreateClosureComp( 1398 new PushArgumentInstr(type_arguments);
1394 node, owner()->try_index(), type_arguments, receiver); 1399 arguments->Add(push_type_arguments);
1395 ReturnComputation(create); 1400 AddInstruction(push_type_arguments);
1401 ReturnComputation(
1402 new CreateClosureComp(node, owner()->try_index(), arguments));
1396 } 1403 }
1397 1404
1398 1405
1399 void EffectGraphVisitor::TranslateArgumentList( 1406 void EffectGraphVisitor::TranslateArgumentList(
1400 const ArgumentListNode& node, 1407 const ArgumentListNode& node,
1401 ZoneGrowableArray<Value*>* values) { 1408 ZoneGrowableArray<Value*>* values) {
1402 for (intptr_t i = 0; i < node.length(); ++i) { 1409 for (intptr_t i = 0; i < node.length(); ++i) {
1403 ValueGraphVisitor for_argument(owner(), temp_index()); 1410 ValueGraphVisitor for_argument(owner(), temp_index());
1404 node.NodeAt(i)->Visit(&for_argument); 1411 node.NodeAt(i)->Visit(&for_argument);
1405 Append(for_argument); 1412 Append(for_argument);
1406 values->Add(for_argument.value()); 1413 values->Add(for_argument.value());
1407 } 1414 }
1408 } 1415 }
1409 1416
1417
1418 void EffectGraphVisitor::BuildPushArguments(
1419 const ArgumentListNode& node,
1420 ZoneGrowableArray<PushArgumentInstr*>* values) {
1421 for (intptr_t i = 0; i < node.length(); ++i) {
1422 ValueGraphVisitor for_argument(owner(), temp_index());
1423 node.NodeAt(i)->Visit(&for_argument);
1424 Append(for_argument);
1425 PushArgumentInstr* push_arg = new PushArgumentInstr(for_argument.value());
1426 AddInstruction(push_arg);
1427 values->Add(push_arg);
1428 }
1429 }
1430
1431
1410 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { 1432 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
1411 ArgumentListNode* arguments = node->arguments(); 1433 ArgumentListNode* arguments = node->arguments();
1412 int length = arguments->length(); 1434 int length = arguments->length();
1413 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1); 1435 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1);
1414 1436
1415 ValueGraphVisitor for_receiver(owner(), temp_index()); 1437 ValueGraphVisitor for_receiver(owner(), temp_index());
1416 node->receiver()->Visit(&for_receiver); 1438 node->receiver()->Visit(&for_receiver);
1417 Append(for_receiver); 1439 Append(for_receiver);
1418 values->Add(for_receiver.value()); 1440 values->Add(for_receiver.value());
1419 1441
(...skipping 20 matching lines...) Expand all
1440 values); 1462 values);
1441 ReturnComputation(call); 1463 ReturnComputation(call);
1442 } 1464 }
1443 1465
1444 1466
1445 ClosureCallComp* EffectGraphVisitor::BuildClosureCall( 1467 ClosureCallComp* EffectGraphVisitor::BuildClosureCall(
1446 ClosureCallNode* node) { 1468 ClosureCallNode* node) {
1447 ValueGraphVisitor for_closure(owner(), temp_index()); 1469 ValueGraphVisitor for_closure(owner(), temp_index());
1448 node->closure()->Visit(&for_closure); 1470 node->closure()->Visit(&for_closure);
1449 Append(for_closure); 1471 Append(for_closure);
1472 PushArgumentInstr* push_closure = new PushArgumentInstr(for_closure.value());
1473 AddInstruction(push_closure);
1450 1474
1451 ZoneGrowableArray<Value*>* arguments = 1475 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1452 new ZoneGrowableArray<Value*>(node->arguments()->length()); 1476 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
1453 arguments->Add(for_closure.value()); 1477 arguments->Add(push_closure);
1454 TranslateArgumentList(*node->arguments(), arguments); 1478 BuildPushArguments(*node->arguments(), arguments);
1455 1479
1456 // Save context around the call. 1480 // Save context around the call.
1457 BuildStoreContext(*owner()->parsed_function().expression_temp_var()); 1481 BuildStoreContext(*owner()->parsed_function().expression_temp_var());
1458 return new ClosureCallComp(node, owner()->try_index(), arguments); 1482 return new ClosureCallComp(node, owner()->try_index(), arguments);
1459 } 1483 }
1460 1484
1461 1485
1462 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) { 1486 void EffectGraphVisitor::VisitClosureCallNode(ClosureCallNode* node) {
1463 Do(BuildClosureCall(node)); 1487 Do(BuildClosureCall(node));
1464 // Restore context from saved location. 1488 // Restore context from saved location.
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 char* chars = reinterpret_cast<char*>( 2720 char* chars = reinterpret_cast<char*>(
2697 Isolate::Current()->current_zone()->Allocate(len)); 2721 Isolate::Current()->current_zone()->Allocate(len));
2698 OS::SNPrint(chars, len, kFormat, function_name, reason); 2722 OS::SNPrint(chars, len, kFormat, function_name, reason);
2699 const Error& error = Error::Handle( 2723 const Error& error = Error::Handle(
2700 LanguageError::New(String::Handle(String::New(chars)))); 2724 LanguageError::New(String::Handle(String::New(chars))));
2701 Isolate::Current()->long_jump_base()->Jump(1, error); 2725 Isolate::Current()->long_jump_base()->Jump(1, error);
2702 } 2726 }
2703 2727
2704 2728
2705 } // namespace dart 2729 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.h ('k') | vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698