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

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

Issue 10700111: Eliminate the type distinction between BindInstr and DoInstr. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Eliminate an unnecessary virtual function. Created 8 years, 5 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_optimizer.h » ('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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 exit()->set_successor(other_fragment.entry()); 58 exit()->set_successor(other_fragment.entry());
59 exit_ = other_fragment.exit(); 59 exit_ = other_fragment.exit();
60 } 60 }
61 temp_index_ = other_fragment.temp_index(); 61 temp_index_ = other_fragment.temp_index();
62 } 62 }
63 63
64 64
65 UseVal* EffectGraphVisitor::Bind(Computation* computation) { 65 UseVal* EffectGraphVisitor::Bind(Computation* computation) {
66 ASSERT(is_open()); 66 ASSERT(is_open());
67 DeallocateTempIndex(computation->InputCount()); 67 DeallocateTempIndex(computation->InputCount());
68 BindInstr* bind_instr = new BindInstr(computation); 68 BindInstr* bind_instr = new BindInstr(BindInstr::kUsed, computation);
69 bind_instr->set_temp_index(AllocateTempIndex()); 69 bind_instr->set_temp_index(AllocateTempIndex());
70 if (is_empty()) { 70 if (is_empty()) {
71 entry_ = bind_instr; 71 entry_ = bind_instr;
72 } else { 72 } else {
73 exit()->set_successor(bind_instr); 73 exit()->set_successor(bind_instr);
74 } 74 }
75 exit_ = bind_instr; 75 exit_ = bind_instr;
76 return new UseVal(bind_instr); 76 return new UseVal(bind_instr);
77 } 77 }
78 78
79 79
80 void EffectGraphVisitor::Do(Computation* computation) { 80 void EffectGraphVisitor::Do(Computation* computation) {
81 ASSERT(is_open()); 81 ASSERT(is_open());
82 DeallocateTempIndex(computation->InputCount()); 82 DeallocateTempIndex(computation->InputCount());
83 DoInstr* do_instr = new DoInstr(computation); 83 BindInstr* do_instr = new BindInstr(BindInstr::kUnused, computation);
84 if (is_empty()) { 84 if (is_empty()) {
85 entry_ = do_instr; 85 entry_ = do_instr;
86 } else { 86 } else {
87 exit()->set_successor(do_instr); 87 exit()->set_successor(do_instr);
88 } 88 }
89 exit_ = do_instr; 89 exit_ = do_instr;
90 } 90 }
91 91
92 92
93 void EffectGraphVisitor::AddInstruction(Instruction* instruction) { 93 void EffectGraphVisitor::AddInstruction(Instruction* instruction) {
94 ASSERT(is_open()); 94 ASSERT(is_open());
95 ASSERT(!instruction->IsDo()); 95 ASSERT(!instruction->IsDefinition());
96 ASSERT(!instruction->IsBind());
97 DeallocateTempIndex(instruction->InputCount()); 96 DeallocateTempIndex(instruction->InputCount());
98 if (instruction->IsDefinition()) { 97 if (instruction->IsDefinition()) {
99 instruction->AsDefinition()->set_temp_index(AllocateTempIndex()); 98 instruction->AsDefinition()->set_temp_index(AllocateTempIndex());
100 } 99 }
101 if (is_empty()) { 100 if (is_empty()) {
102 entry_ = exit_ = instruction; 101 entry_ = exit_ = instruction;
103 } else { 102 } else {
104 exit()->set_successor(instruction); 103 exit()->set_successor(instruction);
105 exit_ = instruction; 104 exit_ = instruction;
106 } 105 }
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 // environment. 2541 // environment.
2543 Computation* comp = v->AsUse()->definition()->AsBind()->computation(); 2542 Computation* comp = v->AsUse()->definition()->AsBind()->computation();
2544 intptr_t index = comp->AsStoreLocal()->local().BitIndexIn(var_count); 2543 intptr_t index = comp->AsStoreLocal()->local().BitIndexIn(var_count);
2545 current->SetInputAt(i, CopyValue((*env)[index])); 2544 current->SetInputAt(i, CopyValue((*env)[index]));
2546 } 2545 }
2547 } 2546 }
2548 2547
2549 // 2b. Handle LoadLocal and StoreLocal. 2548 // 2b. Handle LoadLocal and StoreLocal.
2550 // For each LoadLocal: Remove it from the graph. 2549 // For each LoadLocal: Remove it from the graph.
2551 // For each StoreLocal: Remove it from the graph and update the environment. 2550 // For each StoreLocal: Remove it from the graph and update the environment.
2552 ASSERT(!current->IsDo() || 2551 BindInstr* bind = current->AsBind();
2553 !current->AsDo()->computation()->IsLoadLocal()); // Not possible. 2552 if (bind != NULL) {
2554 LoadLocalComp* load = NULL; 2553 LoadLocalComp* load = bind->computation()->AsLoadLocal();
2555 if (current->IsBind() && 2554 StoreLocalComp* store = bind->computation()->AsStoreLocal();
2556 current->AsBind()->computation()->IsLoadLocal()) { 2555 if ((load != NULL) || (store != NULL)) {
2557 load = current->AsBind()->computation()->AsLoadLocal(); 2556 intptr_t index;
2558 } 2557 if (store != NULL) {
2559 StoreLocalComp* store = NULL; 2558 index = store->local().BitIndexIn(var_count);
2560 if (current->IsDo() && 2559 // Update renaming environment.
2561 current->AsDo()->computation()->IsStoreLocal()) { 2560 (*env)[index] = store->value();
2562 store = current->AsDo()->computation()->AsStoreLocal(); 2561 } else {
2563 } else if (current->IsBind() && 2562 // The graph construction ensures we do not have an unused LoadLocal
2564 current->AsBind()->computation()->IsStoreLocal()) { 2563 // computation.
2565 store = current->AsBind()->computation()->AsStoreLocal(); 2564 ASSERT(bind->is_used());
2566 } 2565 index = load->local().BitIndexIn(var_count);
2567 2566 }
2568 if (load != NULL) { 2567 // Update expression stack and remove from graph.
2569 ASSERT(current->IsBind()); 2568 if (bind->is_used()) {
2570 // Update expression stack. 2569 env->Add(CopyValue((*env)[index]));
2571 intptr_t index = load->local().BitIndexIn(var_count); 2570 }
2572 env->Add(CopyValue((*env)[index])); 2571 current = current->RemoveFromGraph();
2573 // Remove instruction. 2572 } else {
2574 current = current->RemoveFromGraph(); 2573 // Not a load or store.
2575 } else if (store != NULL) { 2574 if (bind->is_used()) {
2576 // Update renaming environment. 2575 // Assign fresh SSA temporary and update expression stack.
2577 (*env)[store->local().BitIndexIn(var_count)] = store->value(); 2576 bind->set_ssa_temp_index(current_ssa_temp_index_++);
2578 if (current->IsBind()) { 2577 env->Add(new UseVal(bind));
2579 // Update expression stack. 2578 }
2580 intptr_t index = store->local().BitIndexIn(var_count); 2579 current = current->successor();
2581 env->Add(CopyValue((*env)[index]));
2582 } 2580 }
2583 // Remove instruction and update renaming environment.
2584 current = current->RemoveFromGraph();
2585 } else { 2581 } else {
2586 if (current->IsBind()) { 2582 // Not a computation.
2587 // Assign new SSA temporary.
2588 current->AsDefinition()->set_ssa_temp_index(current_ssa_temp_index_++);
2589 // Update expression stack.
2590 env->Add(new UseVal(current->AsDefinition()));
2591 }
2592 current = current->successor(); 2583 current = current->successor();
2593 } 2584 }
2594 } 2585 }
2595 2586
2596 // 3. Process dominated blocks. 2587 // 3. Process dominated blocks.
2597 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) { 2588 for (intptr_t i = 0; i < block_entry->dominated_blocks().length(); ++i) {
2598 BlockEntryInstr* block = block_entry->dominated_blocks()[i]; 2589 BlockEntryInstr* block = block_entry->dominated_blocks()[i];
2599 ZoneGrowableArray<Value*>* new_env = 2590 ZoneGrowableArray<Value*>* new_env =
2600 new ZoneGrowableArray<Value*>(env->length()); 2591 new ZoneGrowableArray<Value*>(env->length());
2601 new_env->AddArray(*env); 2592 new_env->AddArray(*env);
(...skipping 30 matching lines...) Expand all
2632 char* chars = reinterpret_cast<char*>( 2623 char* chars = reinterpret_cast<char*>(
2633 Isolate::Current()->current_zone()->Allocate(len)); 2624 Isolate::Current()->current_zone()->Allocate(len));
2634 OS::SNPrint(chars, len, kFormat, function_name, reason); 2625 OS::SNPrint(chars, len, kFormat, function_name, reason);
2635 const Error& error = Error::Handle( 2626 const Error& error = Error::Handle(
2636 LanguageError::New(String::Handle(String::New(chars)))); 2627 LanguageError::New(String::Handle(String::New(chars))));
2637 Isolate::Current()->long_jump_base()->Jump(1, error); 2628 Isolate::Current()->long_jump_base()->Jump(1, error);
2638 } 2629 }
2639 2630
2640 2631
2641 } // namespace dart 2632 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698