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

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

Issue 9616005: Turn CopyTemp and SetTemp into instructions. (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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 void EffectGraphVisitor::VisitIncrOpIndexedNode(IncrOpIndexedNode* node) { 322 void EffectGraphVisitor::VisitIncrOpIndexedNode(IncrOpIndexedNode* node) {
323 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR)); 323 ASSERT((node->kind() == Token::kINCR) || (node->kind() == Token::kDECR));
324 if (node->prefix()) { 324 if (node->prefix()) {
325 Bailout("IncrOpIndexed prefix"); 325 Bailout("IncrOpIndexed prefix");
326 } else { 326 } else {
327 // Leave a placeholder, evaluate receiver and index. 327 // Leave a placeholder, evaluate receiver and index.
328 // t0 <- #0 328 // t0 <- #0
329 // t1 <- ... receiver ... 329 // t1 <- ... receiver ...
330 // t2 <- ... index ... 330 // t2 <- ... index ...
331 const Smi& placeholder = Smi::ZoneHandle(Smi::New(0)); 331 const Smi& placeholder = Smi::ZoneHandle(Smi::New(0));
332 AddInstruction(new BindInstr(temp_index(), new ConstantVal(placeholder))); 332 const int placeholder_index = temp_index();
333 AddInstruction(new BindInstr(placeholder_index,
334 new ConstantVal(placeholder)));
335
333 ArgumentGraphVisitor for_array(owner(), temp_index() + 1); 336 ArgumentGraphVisitor for_array(owner(), temp_index() + 1);
334 node->array()->Visit(&for_array); 337 node->array()->Visit(&for_array);
335 Append(for_array); 338 Append(for_array);
339 ASSERT(for_array.value()->IsTemp());
340 const int array_index = for_array.value()->AsTemp()->index();
341
336 ArgumentGraphVisitor for_index(owner(), for_array.temp_index()); 342 ArgumentGraphVisitor for_index(owner(), for_array.temp_index());
337 node->index()->Visit(&for_index); 343 node->index()->Visit(&for_index);
338 Append(for_index); 344 Append(for_index);
345 ASSERT(for_index.value()->IsTemp());
346 const int index_index = for_index.value()->AsTemp()->index();
339 347
340 // Duplicate the receiver and index values, load the value. 348 // Duplicate the receiver and index values, load the value.
341 // t3 <- Copy(t1) 349 // t3 <- Pick(t1)
342 // t4 <- Copy(t2) 350 // t4 <- Pick(t2)
343 // t3 <- InstanceCall([], t3, t4) 351 // t3 <- InstanceCall([], t3, t4)
344 int next_index = for_index.temp_index(); 352 int next_index = for_index.temp_index();
345 AddInstruction(new BindInstr(next_index, new CopyTempComp(-1))); 353 AddInstruction(new PickTempInstr(next_index, array_index));
346 AddInstruction(new BindInstr(next_index + 1, new CopyTempComp(-1))); 354 AddInstruction(new PickTempInstr(next_index + 1, index_index));
347 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2); 355 ZoneGrowableArray<Value*>* arguments = new ZoneGrowableArray<Value*>(2);
348 arguments->Add(new TempVal(next_index)); 356 arguments->Add(new TempVal(next_index));
349 arguments->Add(new TempVal(next_index + 1)); 357 arguments->Add(new TempVal(next_index + 1));
350 const String& load_name = 358 const String& load_name =
351 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX))); 359 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kINDEX)));
352 InstanceCallComp* load = 360 InstanceCallComp* load =
353 new InstanceCallComp(node->load_id(), node->token_index(), load_name, 361 new InstanceCallComp(node->load_id(), node->token_index(), load_name,
354 arguments, Array::ZoneHandle(), 1); 362 arguments, Array::ZoneHandle(), 1);
355 AddInstruction(new BindInstr(next_index, load)); 363 AddInstruction(new BindInstr(next_index, load));
356 364
357 // Preserve the original value and then increment. 365 // Preserve the original value and then increment.
358 // t0 := t3 366 // t0 := t3
359 // t4 <- #1 367 // t4 <- #1
360 // t3 <- InstanceCall(op, t3, t4) 368 // t3 <- InstanceCall(op, t3, t4)
361 AddInstruction(new DoInstr(new SetTempComp(-3))); 369 AddInstruction(new TuckTempInstr(placeholder_index, next_index));
362 const Smi& one = Smi::ZoneHandle(Smi::New(1)); 370 const Smi& one = Smi::ZoneHandle(Smi::New(1));
363 AddInstruction(new BindInstr(next_index + 1, new ConstantVal(one))); 371 AddInstruction(new BindInstr(next_index + 1, new ConstantVal(one)));
364 arguments = new ZoneGrowableArray<Value*>(2); 372 arguments = new ZoneGrowableArray<Value*>(2);
365 arguments->Add(new TempVal(next_index)); 373 arguments->Add(new TempVal(next_index));
366 arguments->Add(new TempVal(next_index + 1)); 374 arguments->Add(new TempVal(next_index + 1));
367 const String& op_name = String::ZoneHandle(String::NewSymbol( 375 const String& op_name = String::ZoneHandle(String::NewSymbol(
368 (node->kind() == Token::kINCR) ? "+" : "-")); 376 (node->kind() == Token::kINCR) ? "+" : "-"));
369 InstanceCallComp* add = 377 InstanceCallComp* add =
370 new InstanceCallComp(node->operator_id(), node->token_index(), op_name, 378 new InstanceCallComp(node->operator_id(), node->token_index(), op_name,
371 arguments, Array::ZoneHandle(), 2); 379 arguments, Array::ZoneHandle(), 2);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 void FlowGraphPrinter::VisitTemp(TempVal* val) { 807 void FlowGraphPrinter::VisitTemp(TempVal* val) {
800 OS::Print("t%d", val->index()); 808 OS::Print("t%d", val->index());
801 } 809 }
802 810
803 811
804 void FlowGraphPrinter::VisitConstant(ConstantVal* val) { 812 void FlowGraphPrinter::VisitConstant(ConstantVal* val) {
805 OS::Print("#%s", val->instance().ToCString()); 813 OS::Print("#%s", val->instance().ToCString());
806 } 814 }
807 815
808 816
809 void FlowGraphPrinter::VisitCopyTemp(CopyTempComp* comp) {
810 OS::Print("CopyTemp(%d)", comp->index());
811 }
812
813
814 void FlowGraphPrinter::VisitSetTemp(SetTempComp* comp) {
815 OS::Print("SetTemp(%d)", comp->index());
816 }
817
818
819 void FlowGraphPrinter::VisitAssertAssignable(AssertAssignableComp* comp) { 817 void FlowGraphPrinter::VisitAssertAssignable(AssertAssignableComp* comp) {
820 OS::Print("AssertAssignable("); 818 OS::Print("AssertAssignable(");
821 comp->value()->Accept(this); 819 comp->value()->Accept(this);
822 OS::Print(", %s)", comp->type().ToCString()); 820 OS::Print(", %s)", comp->type().ToCString());
823 } 821 }
824 822
825 823
826 void FlowGraphPrinter::VisitInstanceCall(InstanceCallComp* comp) { 824 void FlowGraphPrinter::VisitInstanceCall(InstanceCallComp* comp) {
827 OS::Print("InstanceCall(%s", comp->function_name().ToCString()); 825 OS::Print("InstanceCall(%s", comp->function_name().ToCString());
828 for (int i = 0; i < comp->ArgumentCount(); ++i) { 826 for (int i = 0; i < comp->ArgumentCount(); ++i) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) { 924 void FlowGraphPrinter::VisitJoinEntry(JoinEntryInstr* instr) {
927 OS::Print("%2d: [join]", instr->block_number()); 925 OS::Print("%2d: [join]", instr->block_number());
928 } 926 }
929 927
930 928
931 void FlowGraphPrinter::VisitTargetEntry(TargetEntryInstr* instr) { 929 void FlowGraphPrinter::VisitTargetEntry(TargetEntryInstr* instr) {
932 OS::Print("%2d: [target]", instr->block_number()); 930 OS::Print("%2d: [target]", instr->block_number());
933 } 931 }
934 932
935 933
934 void FlowGraphPrinter::VisitPickTemp(PickTempInstr* instr) {
935 OS::Print(" t%d <- Pick(t%d)", instr->destination(), instr->source());
936 }
937
938
939 void FlowGraphPrinter::VisitTuckTemp(TuckTempInstr* instr) {
940 OS::Print(" t%d := t%d", instr->destination(), instr->source());
941 }
942
943
936 void FlowGraphPrinter::VisitDo(DoInstr* instr) { 944 void FlowGraphPrinter::VisitDo(DoInstr* instr) {
937 OS::Print(" "); 945 OS::Print(" ");
938 instr->computation()->Accept(this); 946 instr->computation()->Accept(this);
939 } 947 }
940 948
941 949
942 void FlowGraphPrinter::VisitBind(BindInstr* instr) { 950 void FlowGraphPrinter::VisitBind(BindInstr* instr) {
943 OS::Print(" t%d <-", instr->temp_index()); 951 OS::Print(" t%d <-", instr->temp_index());
944 instr->computation()->Accept(this); 952 instr->computation()->Accept(this);
945 } 953 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 char* chars = reinterpret_cast<char*>( 996 char* chars = reinterpret_cast<char*>(
989 Isolate::Current()->current_zone()->Allocate(len)); 997 Isolate::Current()->current_zone()->Allocate(len));
990 OS::SNPrint(chars, len, kFormat, function_name, reason); 998 OS::SNPrint(chars, len, kFormat, function_name, reason);
991 const Error& error = Error::Handle( 999 const Error& error = Error::Handle(
992 LanguageError::New(String::Handle(String::New(chars)))); 1000 LanguageError::New(String::Handle(String::New(chars))));
993 Isolate::Current()->long_jump_base()->Jump(1, error); 1001 Isolate::Current()->long_jump_base()->Jump(1, error);
994 } 1002 }
995 1003
996 1004
997 } // namespace dart 1005 } // 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