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

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

Issue 15741002: Use a uniform way to emit code for all instructions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_XXX. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX.
6 6
7 #include "vm/flow_graph_compiler.h" 7 #include "vm/flow_graph_compiler.h"
8 8
9 #include "vm/cha.h" 9 #include "vm/cha.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 block_info->set_fallthrough_label(fallthrough_label); 205 block_info->set_fallthrough_label(fallthrough_label);
206 } 206 }
207 207
208 208
209 void FlowGraphCompiler::VisitBlocks() { 209 void FlowGraphCompiler::VisitBlocks() {
210 CompactBlocks(); 210 CompactBlocks();
211 211
212 for (intptr_t i = 0; i < block_order().length(); ++i) { 212 for (intptr_t i = 0; i < block_order().length(); ++i) {
213 // Compile the block entry. 213 // Compile the block entry.
214 BlockEntryInstr* entry = block_order()[i]; 214 BlockEntryInstr* entry = block_order()[i];
215 assembler()->Comment("B%"Pd"", entry->block_id());
216 set_current_block(entry); 215 set_current_block(entry);
217 216
218 if (WasCompacted(entry)) { 217 if (WasCompacted(entry)) {
218 assembler()->Comment("B%"Pd"", entry->block_id());
219 continue; 219 continue;
220 } 220 }
221 221
222 entry->EmitNativeCode(this); 222 EmitInstruction(entry);
223 // Compile all successors until an exit, branch, or a block entry. 223 // Compile all successors in the block.
224 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 224 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
225 Instruction* instr = it.Current(); 225 EmitInstruction(it.Current());
226 if (FLAG_code_comments) EmitComment(instr);
227 if (instr->IsParallelMove()) {
228 parallel_move_resolver_.EmitNativeCode(instr->AsParallelMove());
229 } else {
230 ASSERT(instr->locs() != NULL);
231 EmitInstructionPrologue(instr);
232 ASSERT(pending_deoptimization_env_ == NULL);
233 pending_deoptimization_env_ = instr->env();
234 instr->EmitNativeCode(this);
235 pending_deoptimization_env_ = NULL;
236 EmitInstructionEpilogue(instr);
237 }
238 } 226 }
239 } 227 }
240 set_current_block(NULL); 228 set_current_block(NULL);
241 } 229 }
242 230
243 231
244 void FlowGraphCompiler::Bailout(const char* reason) { 232 void FlowGraphCompiler::Bailout(const char* reason) {
245 const char* kFormat = "FlowGraphCompiler Bailout: %s %s."; 233 const char* kFormat = "FlowGraphCompiler Bailout: %s %s.";
246 const char* function_name = parsed_function().function().ToCString(); 234 const char* function_name = parsed_function().function().ToCString();
247 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 235 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 649
662 650
663 void FlowGraphCompiler::EmitComment(Instruction* instr) { 651 void FlowGraphCompiler::EmitComment(Instruction* instr) {
664 char buffer[256]; 652 char buffer[256];
665 BufferFormatter f(buffer, sizeof(buffer)); 653 BufferFormatter f(buffer, sizeof(buffer));
666 instr->PrintTo(&f); 654 instr->PrintTo(&f);
667 assembler()->Comment("%s", buffer); 655 assembler()->Comment("%s", buffer);
668 } 656 }
669 657
670 658
659 void FlowGraphCompiler::EmitInstruction(Instruction* instr) {
660 if (FLAG_code_comments) {
661 if (instr->IsBlockEntry()) {
662 assembler()->Comment("B%"Pd"", instr->AsBlockEntry()->block_id());
663 } else {
664 EmitComment(instr);
665 }
666 }
667
668 EmitInstructionPrologue(instr);
669 ASSERT(pending_deoptimization_env_ == NULL);
670 pending_deoptimization_env_ = instr->env();
671 instr->EmitNativeCode(this);
672 pending_deoptimization_env_ = NULL;
673 EmitInstructionEpilogue(instr);
674 }
675
676
671 // Allocate a register that is not explicitly blocked. 677 // Allocate a register that is not explicitly blocked.
672 static Register AllocateFreeRegister(bool* blocked_registers) { 678 static Register AllocateFreeRegister(bool* blocked_registers) {
673 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) { 679 for (intptr_t regno = 0; regno < kNumberOfCpuRegisters; regno++) {
674 if (!blocked_registers[regno]) { 680 if (!blocked_registers[regno]) {
675 blocked_registers[regno] = true; 681 blocked_registers[regno] = true;
676 return static_cast<Register>(regno); 682 return static_cast<Register>(regno);
677 } 683 }
678 } 684 }
679 UNREACHABLE(); 685 UNREACHABLE();
680 return kNoRegister; 686 return kNoRegister;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1087
1082 for (int i = 0; i < len; i++) { 1088 for (int i = 0; i < len; i++) {
1083 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), 1089 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i),
1084 &Function::ZoneHandle(ic_data.GetTargetAt(i)), 1090 &Function::ZoneHandle(ic_data.GetTargetAt(i)),
1085 ic_data.GetCountAt(i))); 1091 ic_data.GetCountAt(i)));
1086 } 1092 }
1087 sorted->Sort(HighestCountFirst); 1093 sorted->Sort(HighestCountFirst);
1088 } 1094 }
1089 1095
1090 } // namespace dart 1096 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698