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

Side by Side Diff: vm/flow_graph_compiler_x64.cc

Issue 10407031: Add IR printing into a supplied buffer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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) 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/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
11 #include "vm/ast_printer.h" 11 #include "vm/ast_printer.h"
12 #include "vm/code_descriptors.h" 12 #include "vm/code_descriptors.h"
13 #include "vm/code_generator.h" 13 #include "vm/code_generator.h"
14 #include "vm/debugger.h" 14 #include "vm/debugger.h"
15 #include "vm/disassembler.h" 15 #include "vm/disassembler.h"
16 #include "vm/il_printer.h"
16 #include "vm/intrinsifier.h" 17 #include "vm/intrinsifier.h"
17 #include "vm/longjump.h" 18 #include "vm/longjump.h"
18 #include "vm/object_store.h" 19 #include "vm/object_store.h"
19 #include "vm/parser.h" 20 #include "vm/parser.h"
20 #include "vm/stub_code.h" 21 #include "vm/stub_code.h"
21 22
22 namespace dart { 23 namespace dart {
23 24
24 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
25 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); 26 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function.");
26 DECLARE_FLAG(bool, enable_type_checks); 27 DECLARE_FLAG(bool, enable_type_checks);
27 DECLARE_FLAG(bool, intrinsify); 28 DECLARE_FLAG(bool, intrinsify);
28 DECLARE_FLAG(bool, optimization_counter_threshold); 29 DECLARE_FLAG(bool, optimization_counter_threshold);
29 DECLARE_FLAG(bool, print_ast); 30 DECLARE_FLAG(bool, print_ast);
30 DECLARE_FLAG(bool, report_usage_count); 31 DECLARE_FLAG(bool, report_usage_count);
32 DECLARE_FLAG(bool, code_comments);
31 33
32 34
33 FlowGraphCompiler::FlowGraphCompiler( 35 FlowGraphCompiler::FlowGraphCompiler(
34 Assembler* assembler, 36 Assembler* assembler,
35 const ParsedFunction& parsed_function, 37 const ParsedFunction& parsed_function,
36 const GrowableArray<BlockEntryInstr*>& block_order, 38 const GrowableArray<BlockEntryInstr*>& block_order,
37 bool is_optimizing) 39 bool is_optimizing)
38 : FlowGraphVisitor(block_order), 40 : FlowGraphVisitor(block_order),
39 assembler_(assembler), 41 assembler_(assembler),
40 parsed_function_(parsed_function), 42 parsed_function_(parsed_function),
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 1123
1122 1124
1123 void FlowGraphCompiler::VisitBlocks() { 1125 void FlowGraphCompiler::VisitBlocks() {
1124 for (intptr_t i = 0; i < block_order_.length(); ++i) { 1126 for (intptr_t i = 0; i < block_order_.length(); ++i) {
1125 __ Comment("B%d", i); 1127 __ Comment("B%d", i);
1126 // Compile the block entry. 1128 // Compile the block entry.
1127 current_block_ = block_order_[i]; 1129 current_block_ = block_order_[i];
1128 Instruction* instr = current_block()->Accept(this); 1130 Instruction* instr = current_block()->Accept(this);
1129 // Compile all successors until an exit, branch, or a block entry. 1131 // Compile all successors until an exit, branch, or a block entry.
1130 while ((instr != NULL) && !instr->IsBlockEntry()) { 1132 while ((instr != NULL) && !instr->IsBlockEntry()) {
1131 __ Comment("@%d: instruction", instr->cid()); 1133 if (FLAG_code_comments) EmitComment(instr);
1132 instr = instr->Accept(this); 1134 instr = instr->Accept(this);
1133 } 1135 }
1134 1136
1135 BlockEntryInstr* successor = 1137 BlockEntryInstr* successor =
1136 (instr == NULL) ? NULL : instr->AsBlockEntry(); 1138 (instr == NULL) ? NULL : instr->AsBlockEntry();
1137 if (successor != NULL) { 1139 if (successor != NULL) {
1138 // Block ended with a "goto". We can fall through if it is the 1140 // Block ended with a "goto". We can fall through if it is the
1139 // next block in the list. Otherwise, we need a jump. 1141 // next block in the list. Otherwise, we need a jump.
1140 if ((i == block_order_.length() - 1) || 1142 if ((i == block_order_.length() - 1) ||
1141 (block_order_[i + 1] != successor)) { 1143 (block_order_[i + 1] != successor)) {
1142 __ jmp(&block_info_[successor->postorder_number()]->label); 1144 __ jmp(&block_info_[successor->postorder_number()]->label);
1143 } 1145 }
1144 } 1146 }
1145 } 1147 }
1146 } 1148 }
1147 1149
1148 1150
1151 void FlowGraphCompiler::EmitComment(Instruction* instr) {
1152 char buffer[80];
1153 BufferFormatter f(buffer, sizeof(buffer));
1154 instr->PrintTo(&f);
1155 __ Comment("@%d: %s", instr->cid(), buffer);
1156 }
1157
1158
1149 void FlowGraphCompiler::VisitGraphEntry(GraphEntryInstr* instr) { 1159 void FlowGraphCompiler::VisitGraphEntry(GraphEntryInstr* instr) {
1150 // Nothing to do. 1160 // Nothing to do.
1151 } 1161 }
1152 1162
1153 1163
1154 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) { 1164 void FlowGraphCompiler::VisitJoinEntry(JoinEntryInstr* instr) {
1155 __ Bind(&block_info_[instr->postorder_number()]->label); 1165 __ Bind(&block_info_[instr->postorder_number()]->label);
1156 } 1166 }
1157 1167
1158 1168
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 1714
1705 1715
1706 void FlowGraphCompiler::FinalizeComments(const Code& code) { 1716 void FlowGraphCompiler::FinalizeComments(const Code& code) {
1707 code.set_comments(assembler_->GetCodeComments()); 1717 code.set_comments(assembler_->GetCodeComments());
1708 } 1718 }
1709 1719
1710 1720
1711 } // namespace dart 1721 } // namespace dart
1712 1722
1713 #endif // defined TARGET_ARCH_X64 1723 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « vm/flow_graph_compiler_x64.h ('k') | vm/il_printer.h » ('j') | vm/il_printer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698