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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10833068: Refactor building arguments for InstanceCall and fix deoptimization environment for pushed argument… (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 | « no previous file | vm/flow_graph_optimizer.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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 if (node->kind() == Token::kAND) { 552 if (node->kind() == Token::kAND) {
553 Join(for_left, for_right, empty); 553 Join(for_left, for_right, empty);
554 } else { 554 } else {
555 Join(for_left, empty, for_right); 555 Join(for_left, empty, for_right);
556 } 556 }
557 return; 557 return;
558 } 558 }
559 ValueGraphVisitor for_left_value(owner(), temp_index()); 559 ValueGraphVisitor for_left_value(owner(), temp_index());
560 node->left()->Visit(&for_left_value); 560 node->left()->Visit(&for_left_value);
561 Append(for_left_value); 561 Append(for_left_value);
562 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
563
562 ValueGraphVisitor for_right_value(owner(), temp_index()); 564 ValueGraphVisitor for_right_value(owner(), temp_index());
563 node->right()->Visit(&for_right_value); 565 node->right()->Visit(&for_right_value);
564 Append(for_right_value); 566 Append(for_right_value);
565 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 567 PushArgumentInstr* push_right = PushArgument(for_right_value.value());
566 arguments->Add(for_left_value.value()); 568
567 arguments->Add(for_right_value.value()); 569 ZoneGrowableArray<PushArgumentInstr*>* arguments =
570 new ZoneGrowableArray<PushArgumentInstr*>(2);
571 arguments->Add(push_left);
572 arguments->Add(push_right);
568 const String& name = String::ZoneHandle(Symbols::New(node->Name())); 573 const String& name = String::ZoneHandle(Symbols::New(node->Name()));
569 InstanceCallComp* call = new InstanceCallComp(node->token_pos(), 574 InstanceCallComp* call = new InstanceCallComp(node->token_pos(),
570 owner()->try_index(), 575 owner()->try_index(),
571 name, 576 name,
572 node->kind(), 577 node->kind(),
573 arguments, 578 arguments,
574 Array::ZoneHandle(), 579 Array::ZoneHandle(),
575 2); 580 2);
576 ReturnComputation(call); 581 ReturnComputation(call);
577 } 582 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 owner()->try_index(), 906 owner()->try_index(),
902 value)); 907 value));
903 } 908 }
904 BooleanNegateComp* negate = new BooleanNegateComp(value); 909 BooleanNegateComp* negate = new BooleanNegateComp(value);
905 ReturnComputation(negate); 910 ReturnComputation(negate);
906 return; 911 return;
907 } 912 }
908 ValueGraphVisitor for_value(owner(), temp_index()); 913 ValueGraphVisitor for_value(owner(), temp_index());
909 node->operand()->Visit(&for_value); 914 node->operand()->Visit(&for_value);
910 Append(for_value); 915 Append(for_value);
911 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1); 916 PushArgumentInstr* push_value = PushArgument(for_value.value());
912 arguments->Add(for_value.value()); 917 ZoneGrowableArray<PushArgumentInstr*>* arguments =
918 new ZoneGrowableArray<PushArgumentInstr*>(1);
919 arguments->Add(push_value);
913 Token::Kind token_kind = 920 Token::Kind token_kind =
914 (node->kind() == Token::kSUB) ? Token::kNEGATE : node->kind(); 921 (node->kind() == Token::kSUB) ? Token::kNEGATE : node->kind();
915
916 const String& name = 922 const String& name =
917 String::ZoneHandle(Symbols::New(Token::Str(token_kind))); 923 String::ZoneHandle(Symbols::New(Token::Str(token_kind)));
918 InstanceCallComp* call = new InstanceCallComp( 924 InstanceCallComp* call = new InstanceCallComp(
919 node->token_pos(), owner()->try_index(), name, token_kind, 925 node->token_pos(), owner()->try_index(), name, token_kind,
920 arguments, Array::ZoneHandle(), 1); 926 arguments, Array::ZoneHandle(), 1);
921 ReturnComputation(call); 927 ReturnComputation(call);
922 } 928 }
923 929
924 930
925 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) { 931 void EffectGraphVisitor::VisitConditionalExprNode(ConditionalExprNode* node) {
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 ValueGraphVisitor for_argument(owner(), temp_index()); 1425 ValueGraphVisitor for_argument(owner(), temp_index());
1420 node.NodeAt(i)->Visit(&for_argument); 1426 node.NodeAt(i)->Visit(&for_argument);
1421 Append(for_argument); 1427 Append(for_argument);
1422 PushArgumentInstr* push_arg = PushArgument(for_argument.value()); 1428 PushArgumentInstr* push_arg = PushArgument(for_argument.value());
1423 values->Add(push_arg); 1429 values->Add(push_arg);
1424 } 1430 }
1425 } 1431 }
1426 1432
1427 1433
1428 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) { 1434 void EffectGraphVisitor::VisitInstanceCallNode(InstanceCallNode* node) {
1429 ArgumentListNode* arguments = node->arguments();
1430 int length = arguments->length();
1431 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(length + 1);
1432
1433 ValueGraphVisitor for_receiver(owner(), temp_index()); 1435 ValueGraphVisitor for_receiver(owner(), temp_index());
1434 node->receiver()->Visit(&for_receiver); 1436 node->receiver()->Visit(&for_receiver);
1435 Append(for_receiver); 1437 Append(for_receiver);
1436 values->Add(for_receiver.value()); 1438 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value());
1439 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1440 new ZoneGrowableArray<PushArgumentInstr*>(
1441 node->arguments()->length() + 1);
1442 arguments->Add(push_receiver);
1437 1443
1438 TranslateArgumentList(*arguments, values); 1444 BuildPushArguments(*node->arguments(), arguments);
1439 InstanceCallComp* call = new InstanceCallComp( 1445 InstanceCallComp* call = new InstanceCallComp(
1440 node->token_pos(), owner()->try_index(), 1446 node->token_pos(), owner()->try_index(),
1441 node->function_name(), Token::kILLEGAL, values, 1447 node->function_name(), Token::kILLEGAL, arguments,
1442 arguments->names(), 1); 1448 node->arguments()->names(), 1);
1443 ReturnComputation(call); 1449 ReturnComputation(call);
1444 } 1450 }
1445 1451
1446 1452
1447 // <Expression> ::= StaticCall { function: Function 1453 // <Expression> ::= StaticCall { function: Function
1448 // arguments: <ArgumentList> } 1454 // arguments: <ArgumentList> }
1449 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { 1455 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) {
1450 int length = node->arguments()->length();
1451 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1456 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1452 new ZoneGrowableArray<PushArgumentInstr*>(length); 1457 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
1453 BuildPushArguments(*node->arguments(), arguments); 1458 BuildPushArguments(*node->arguments(), arguments);
1454 StaticCallComp* call = 1459 StaticCallComp* call =
1455 new StaticCallComp(node->token_pos(), 1460 new StaticCallComp(node->token_pos(),
1456 owner()->try_index(), 1461 owner()->try_index(),
1457 node->function(), 1462 node->function(),
1458 node->arguments()->names(), 1463 node->arguments()->names(),
1459 arguments); 1464 arguments);
1460 ReturnComputation(call); 1465 ReturnComputation(call);
1461 } 1466 }
1462 1467
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 node->allocated_object_var()); 1768 node->allocated_object_var());
1764 allocated_value = Bind(load_allocated); 1769 allocated_value = Bind(load_allocated);
1765 ReturnValue(allocated_value); 1770 ReturnValue(allocated_value);
1766 } 1771 }
1767 1772
1768 1773
1769 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) { 1774 void EffectGraphVisitor::VisitInstanceGetterNode(InstanceGetterNode* node) {
1770 ValueGraphVisitor for_receiver(owner(), temp_index()); 1775 ValueGraphVisitor for_receiver(owner(), temp_index());
1771 node->receiver()->Visit(&for_receiver); 1776 node->receiver()->Visit(&for_receiver);
1772 Append(for_receiver); 1777 Append(for_receiver);
1773 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(1); 1778 PushArgumentInstr* push_receiver = PushArgument(for_receiver.value());
1774 arguments->Add(for_receiver.value()); 1779 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1780 new ZoneGrowableArray<PushArgumentInstr*>(1);
1781 arguments->Add(push_receiver);
1775 const String& name = 1782 const String& name =
1776 String::ZoneHandle(Field::GetterSymbol(node->field_name())); 1783 String::ZoneHandle(Field::GetterSymbol(node->field_name()));
1777 InstanceCallComp* call = new InstanceCallComp( 1784 InstanceCallComp* call = new InstanceCallComp(
1778 node->token_pos(), owner()->try_index(), name, Token::kGET, 1785 node->token_pos(), owner()->try_index(), name, Token::kGET,
1779 arguments, Array::ZoneHandle(), 1); 1786 arguments, Array::ZoneHandle(), 1);
1780 ReturnComputation(call); 1787 ReturnComputation(call);
1781 } 1788 }
1782 1789
1783 1790
1784 void EffectGraphVisitor::BuildInstanceSetterValues( 1791 void EffectGraphVisitor::BuildInstanceSetterValues(
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 if ((as_bind != NULL) && as_bind->computation()->IsStoreLocal()) { 2658 if ((as_bind != NULL) && as_bind->computation()->IsStoreLocal()) {
2652 // For each use of a StoreLocal: Replace it with the value from the 2659 // For each use of a StoreLocal: Replace it with the value from the
2653 // environment. 2660 // environment.
2654 Computation* comp = as_bind->computation(); 2661 Computation* comp = as_bind->computation();
2655 intptr_t index = 2662 intptr_t index =
2656 comp->AsStoreLocal()->local().BitIndexIn(fixed_parameter_count); 2663 comp->AsStoreLocal()->local().BitIndexIn(fixed_parameter_count);
2657 current->SetInputAt(i, CopyValue((*env)[index])); 2664 current->SetInputAt(i, CopyValue((*env)[index]));
2658 } 2665 }
2659 } 2666 }
2660 2667
2668 // Drop pushed arguments for calls.
2669 for (intptr_t j = 0; j < current->ArgumentCount(); j++) {
2670 env->RemoveLast();
2671 }
2672
2661 // 2b. Handle LoadLocal and StoreLocal. 2673 // 2b. Handle LoadLocal and StoreLocal.
2662 // For each LoadLocal: Remove it from the graph. 2674 // For each LoadLocal: Remove it from the graph.
2663 // For each StoreLocal: Remove it from the graph and update the environment. 2675 // For each StoreLocal: Remove it from the graph and update the environment.
2664 BindInstr* bind = current->AsBind(); 2676 BindInstr* bind = current->AsBind();
2665 if (bind != NULL) { 2677 if (bind != NULL) {
2666 LoadLocalComp* load = bind->computation()->AsLoadLocal(); 2678 LoadLocalComp* load = bind->computation()->AsLoadLocal();
2667 StoreLocalComp* store = bind->computation()->AsStoreLocal(); 2679 StoreLocalComp* store = bind->computation()->AsStoreLocal();
2668 if ((load != NULL) || (store != NULL)) { 2680 if ((load != NULL) || (store != NULL)) {
2669 intptr_t index; 2681 intptr_t index;
2670 if (store != NULL) { 2682 if (store != NULL) {
(...skipping 13 matching lines...) Expand all
2684 it.RemoveCurrentFromGraph(); 2696 it.RemoveCurrentFromGraph();
2685 } else { 2697 } else {
2686 // Not a load or store. 2698 // Not a load or store.
2687 if (bind->is_used()) { 2699 if (bind->is_used()) {
2688 // Assign fresh SSA temporary and update expression stack. 2700 // Assign fresh SSA temporary and update expression stack.
2689 bind->set_ssa_temp_index(alloc_ssa_temp_index()); 2701 bind->set_ssa_temp_index(alloc_ssa_temp_index());
2690 env->Add(new UseVal(bind)); 2702 env->Add(new UseVal(bind));
2691 } 2703 }
2692 } 2704 }
2693 } 2705 }
2706
2707 // 2c. Handle pushed argument.
2708 PushArgumentInstr* push = current->AsPushArgument();
2709 if (push != NULL) {
2710 env->Add(push->value());
2711 }
2694 } 2712 }
2695 2713
2696 // 3. Process dominated blocks. 2714 // 3. Process dominated blocks.
2697 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { 2715 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) {
2698 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; 2716 BlockEntryInstr* block = block_entry->dominated_blocks()[i];
2699 GrowableArray<Value*> new_env(env->length()); 2717 GrowableArray<Value*> new_env(env->length());
2700 new_env.AddArray(*env); 2718 new_env.AddArray(*env);
2701 RenameRecursive(block, &new_env, var_count, fixed_parameter_count); 2719 RenameRecursive(block, &new_env, var_count, fixed_parameter_count);
2702 } 2720 }
2703 2721
(...skipping 28 matching lines...) Expand all
2732 char* chars = reinterpret_cast<char*>( 2750 char* chars = reinterpret_cast<char*>(
2733 Isolate::Current()->current_zone()->Allocate(len)); 2751 Isolate::Current()->current_zone()->Allocate(len));
2734 OS::SNPrint(chars, len, kFormat, function_name, reason); 2752 OS::SNPrint(chars, len, kFormat, function_name, reason);
2735 const Error& error = Error::Handle( 2753 const Error& error = Error::Handle(
2736 LanguageError::New(String::Handle(String::New(chars)))); 2754 LanguageError::New(String::Handle(String::New(chars))));
2737 Isolate::Current()->long_jump_base()->Jump(1, error); 2755 Isolate::Current()->long_jump_base()->Jump(1, error);
2738 } 2756 }
2739 2757
2740 2758
2741 } // namespace dart 2759 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698