OLD | NEW |
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_compiler_shared.h" | 5 #include "vm/flow_graph_compiler_shared.h" |
6 | 6 |
7 #include "vm/debugger.h" | 7 #include "vm/debugger.h" |
| 8 #include "vm/il_printer.h" |
8 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
9 #include "vm/intrinsifier.h" | 10 #include "vm/intrinsifier.h" |
10 #include "vm/longjump.h" | 11 #include "vm/longjump.h" |
11 #include "vm/parser.h" | 12 #include "vm/parser.h" |
12 #include "vm/stub_code.h" | 13 #include "vm/stub_code.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 | 16 |
| 17 DECLARE_FLAG(bool, code_comments); |
16 DECLARE_FLAG(bool, enable_type_checks); | 18 DECLARE_FLAG(bool, enable_type_checks); |
17 DECLARE_FLAG(bool, intrinsify); | 19 DECLARE_FLAG(bool, intrinsify); |
18 DECLARE_FLAG(int, optimization_counter_threshold); | 20 DECLARE_FLAG(int, optimization_counter_threshold); |
19 DECLARE_FLAG(bool, trace_functions); | 21 DECLARE_FLAG(bool, trace_functions); |
20 DECLARE_FLAG(bool, report_usage_count); | 22 DECLARE_FLAG(bool, report_usage_count); |
21 | 23 |
22 FlowGraphCompilerShared::FlowGraphCompilerShared( | 24 FlowGraphCompilerShared::FlowGraphCompilerShared( |
23 Assembler* assembler, | 25 Assembler* assembler, |
24 const ParsedFunction& parsed_function, | 26 const ParsedFunction& parsed_function, |
25 const GrowableArray<BlockEntryInstr*>& block_order, | 27 const GrowableArray<BlockEntryInstr*>& block_order, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 Label* is_instance_lbl) { | 320 Label* is_instance_lbl) { |
319 Label unknown; | 321 Label unknown; |
320 GrowableArray<intptr_t> args; | 322 GrowableArray<intptr_t> args; |
321 args.Add(kArray); | 323 args.Add(kArray); |
322 args.Add(kGrowableObjectArray); | 324 args.Add(kGrowableObjectArray); |
323 args.Add(kImmutableArray); | 325 args.Add(kImmutableArray); |
324 CheckClassIds(kClassIdReg, args, is_instance_lbl, &unknown); | 326 CheckClassIds(kClassIdReg, args, is_instance_lbl, &unknown); |
325 assembler()->Bind(&unknown); | 327 assembler()->Bind(&unknown); |
326 } | 328 } |
327 | 329 |
| 330 |
| 331 |
| 332 void FlowGraphCompilerShared::EmitComment(Instruction* instr) { |
| 333 char buffer[80]; |
| 334 BufferFormatter f(buffer, sizeof(buffer)); |
| 335 instr->PrintTo(&f); |
| 336 assembler()->Comment("@%d: %s", instr->cid(), buffer); |
| 337 } |
| 338 |
| 339 |
| 340 void FlowGraphCompilerShared::VisitBlocks() { |
| 341 for (intptr_t i = 0; i < block_order().length(); ++i) { |
| 342 assembler()->Comment("B%d", i); |
| 343 // Compile the block entry. |
| 344 set_current_block(block_order()[i]); |
| 345 current_block()->PrepareEntry(this); |
| 346 Instruction* instr = current_block()->StraightLineSuccessor(); |
| 347 // Compile all successors until an exit, branch, or a block entry. |
| 348 while ((instr != NULL) && !instr->IsBlockEntry()) { |
| 349 if (FLAG_code_comments) EmitComment(instr); |
| 350 ASSERT(instr->locs() != NULL); |
| 351 EmitInstructionPrologue(instr); |
| 352 instr->EmitNativeCode(this); |
| 353 instr = instr->StraightLineSuccessor(); |
| 354 } |
| 355 BlockEntryInstr* successor = |
| 356 (instr == NULL) ? NULL : instr->AsBlockEntry(); |
| 357 if (successor != NULL) { |
| 358 // Block ended with a "goto". We can fall through if it is the |
| 359 // next block in the list. Otherwise, we need a jump. |
| 360 if ((i == block_order().length() - 1) || |
| 361 (block_order()[i + 1] != successor)) { |
| 362 assembler()->jmp(GetBlockLabel(successor)); |
| 363 } |
| 364 } |
| 365 } |
| 366 } |
| 367 |
328 } // namespace dart | 368 } // namespace dart |
329 | 369 |
330 | 370 |
OLD | NEW |