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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 9588001: Remove an unneeded temp in instance setters and indexed stores. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | runtime/vm/flow_graph_compiler_x64.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/flags.h" 7 #include "vm/flags.h"
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 #include "vm/longjump.h" 9 #include "vm/longjump.h"
10 #include "vm/os.h" 10 #include "vm/os.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 arguments->Add(for_receiver.value()); 464 arguments->Add(for_receiver.value());
465 const String& name = 465 const String& name =
466 String::ZoneHandle(Field::GetterSymbol(node->field_name())); 466 String::ZoneHandle(Field::GetterSymbol(node->field_name()));
467 InstanceCallComp* call = 467 InstanceCallComp* call =
468 new InstanceCallComp(node, name, arguments, Array::ZoneHandle(), 1); 468 new InstanceCallComp(node, name, arguments, Array::ZoneHandle(), 1);
469 ReturnComputation(call); 469 ReturnComputation(call);
470 } 470 }
471 471
472 472
473 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { 473 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) {
474 // We preallocate a temporary to overlap with the value of the assignment. 474 ArgumentGraphVisitor for_receiver(owner(), temp_index());
475 const Smi& zero = Smi::ZoneHandle(Smi::New(0));
476 AddInstruction(new BindInstr(temp_index(), new ConstantVal(zero)));
477 TempVal* placeholder = new TempVal(temp_index());
478 ArgumentGraphVisitor for_receiver(owner(), temp_index() + 1);
479 node->receiver()->Visit(&for_receiver); 475 node->receiver()->Visit(&for_receiver);
480 Append(for_receiver); 476 Append(for_receiver);
481 ArgumentGraphVisitor for_value(owner(), for_receiver.temp_index()); 477 ArgumentGraphVisitor for_value(owner(), for_receiver.temp_index());
482 node->value()->Visit(&for_value); 478 node->value()->Visit(&for_value);
483 Append(for_value); 479 Append(for_value);
484 InstanceSetterComp* setter = new InstanceSetterComp(node, 480 InstanceSetterComp* setter = new InstanceSetterComp(node,
485 placeholder,
486 for_receiver.value(), 481 for_receiver.value(),
487 for_value.value()); 482 for_value.value());
488 ReturnComputation(setter); 483 ReturnComputation(setter);
489 } 484 }
490 485
491 486
492 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { 487 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) {
493 Bailout("EffectGraphVisitor::VisitStaticGetterNode"); 488 Bailout("EffectGraphVisitor::VisitStaticGetterNode");
494 } 489 }
495 490
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 arguments->Add(for_index.value()); 575 arguments->Add(for_index.value());
581 const String& name = 576 const String& name =
582 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 577 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX)));
583 InstanceCallComp* call = 578 InstanceCallComp* call =
584 new InstanceCallComp(node, name, arguments, Array::ZoneHandle(), 1); 579 new InstanceCallComp(node, name, arguments, Array::ZoneHandle(), 1);
585 ReturnComputation(call); 580 ReturnComputation(call);
586 } 581 }
587 582
588 583
589 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) { 584 void EffectGraphVisitor::VisitStoreIndexedNode(StoreIndexedNode* node) {
590 // This is not a straight instance call to e0.[]=(e1, e2), it is a 585 ArgumentGraphVisitor for_array(owner(), temp_index());
591 // call to
592 //
593 // (a, i, v) { a.[]=(i, v); return v; }(e0, e1, e2)
594 //
595 // Without constructing that function, we simulate it at the IL
596 // level by preallocating a slot for the return value.
597 const Smi& zero = Smi::ZoneHandle(Smi::New(0));
598 AddInstruction(new BindInstr(temp_index(), new ConstantVal(zero)));
599 TempVal* placeholder = new TempVal(temp_index());
600 ArgumentGraphVisitor for_array(owner(), temp_index() + 1);
601 node->array()->Visit(&for_array); 586 node->array()->Visit(&for_array);
602 Append(for_array); 587 Append(for_array);
603 ArgumentGraphVisitor for_index(owner(), for_array.temp_index()); 588 ArgumentGraphVisitor for_index(owner(), for_array.temp_index());
604 node->index_expr()->Visit(&for_index); 589 node->index_expr()->Visit(&for_index);
605 Append(for_index); 590 Append(for_index);
606 ArgumentGraphVisitor for_value(owner(), for_index.temp_index()); 591 ArgumentGraphVisitor for_value(owner(), for_index.temp_index());
607 node->value()->Visit(&for_value); 592 node->value()->Visit(&for_value);
608 Append(for_value); 593 Append(for_value);
609 StoreIndexedComp* store = new StoreIndexedComp(node, 594 StoreIndexedComp* store = new StoreIndexedComp(node,
610 placeholder,
611 for_array.value(), 595 for_array.value(),
612 for_index.value(), 596 for_index.value(),
613 for_value.value()); 597 for_value.value());
614 ReturnComputation(store); 598 ReturnComputation(store);
615 } 599 }
616 600
617 601
618 // <Statement> ::= Sequence { scope: LocalScope 602 // <Statement> ::= Sequence { scope: LocalScope
619 // nodes: <Statement>* 603 // nodes: <Statement>*
620 // label: SourceLabel } 604 // label: SourceLabel }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 751 }
768 752
769 753
770 void FlowGraphPrinter::VisitNativeCall(NativeCallComp* comp) { 754 void FlowGraphPrinter::VisitNativeCall(NativeCallComp* comp) {
771 OS::Print("NativeCall(%s)", comp->native_name().ToCString()); 755 OS::Print("NativeCall(%s)", comp->native_name().ToCString());
772 } 756 }
773 757
774 758
775 void FlowGraphPrinter::VisitStoreIndexed(StoreIndexedComp* comp) { 759 void FlowGraphPrinter::VisitStoreIndexed(StoreIndexedComp* comp) {
776 OS::Print("StoreIndexed("); 760 OS::Print("StoreIndexed(");
777 comp->placeholder()->Accept(this);
778 OS::Print(", ");
779 comp->array()->Accept(this); 761 comp->array()->Accept(this);
780 OS::Print(", "); 762 OS::Print(", ");
781 comp->index()->Accept(this); 763 comp->index()->Accept(this);
782 OS::Print(", "); 764 OS::Print(", ");
783 comp->value()->Accept(this); 765 comp->value()->Accept(this);
784 OS::Print(")"); 766 OS::Print(")");
785 } 767 }
786 768
787 769
788 void FlowGraphPrinter::VisitInstanceSetter(InstanceSetterComp* comp) { 770 void FlowGraphPrinter::VisitInstanceSetter(InstanceSetterComp* comp) {
789 OS::Print("InstanceSetter("); 771 OS::Print("InstanceSetter(");
790 comp->placeholder()->Accept(this);
791 OS::Print(", ");
792 comp->receiver()->Accept(this); 772 comp->receiver()->Accept(this);
793 OS::Print(", "); 773 OS::Print(", ");
794 comp->value()->Accept(this); 774 comp->value()->Accept(this);
795 OS::Print(")"); 775 OS::Print(")");
796 } 776 }
797 777
798 778
799 void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) { 779 void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) {
800 OS::Print("%2d: [join]", instr->block_number()); 780 OS::Print("%2d: [join]", instr->block_number());
801 } 781 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 char* chars = reinterpret_cast<char*>( 841 char* chars = reinterpret_cast<char*>(
862 Isolate::Current()->current_zone()->Allocate(len)); 842 Isolate::Current()->current_zone()->Allocate(len));
863 OS::SNPrint(chars, len, kFormat, function_name, reason); 843 OS::SNPrint(chars, len, kFormat, function_name, reason);
864 const Error& error = Error::Handle( 844 const Error& error = Error::Handle(
865 LanguageError::New(String::Handle(String::New(chars)))); 845 LanguageError::New(String::Handle(String::New(chars))));
866 Isolate::Current()->long_jump_base()->Jump(1, error); 846 Isolate::Current()->long_jump_base()->Jump(1, error);
867 } 847 }
868 848
869 849
870 } // namespace dart 850 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698