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/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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 FlowGraphCompiler::FlowGraphCompiler( | 33 FlowGraphCompiler::FlowGraphCompiler( |
34 Assembler* assembler, | 34 Assembler* assembler, |
35 const ParsedFunction& parsed_function, | 35 const ParsedFunction& parsed_function, |
36 const GrowableArray<BlockEntryInstr*>& block_order, | 36 const GrowableArray<BlockEntryInstr*>& block_order, |
37 bool is_optimizing) | 37 bool is_optimizing) |
38 : FlowGraphVisitor(block_order), | 38 : FlowGraphVisitor(block_order), |
39 assembler_(assembler), | 39 assembler_(assembler), |
40 parsed_function_(parsed_function), | 40 parsed_function_(parsed_function), |
41 block_info_(block_order.length()), | 41 block_info_(block_order.length()), |
42 current_block_(NULL), | 42 current_block_(NULL), |
43 pc_descriptors_list_(new DescriptorList()), | 43 pc_descriptors_list_(NULL), |
44 exception_handlers_list_(new ExceptionHandlerList()), | 44 exception_handlers_list_(NULL), |
45 is_optimizing_(is_optimizing) { | 45 is_optimizing_(is_optimizing) { |
46 for (int i = 0; i < block_order.length(); ++i) { | 46 } |
| 47 |
| 48 |
| 49 void FlowGraphCompiler::InitCompiler() { |
| 50 pc_descriptors_list_ = new DescriptorList(); |
| 51 exception_handlers_list_ = new ExceptionHandlerList(); |
| 52 block_info_.Clear(); |
| 53 for (int i = 0; i < block_order_.length(); ++i) { |
47 block_info_.Add(new BlockInfo()); | 54 block_info_.Add(new BlockInfo()); |
48 } | 55 } |
49 } | 56 } |
50 | 57 |
51 | 58 |
52 FlowGraphCompiler::~FlowGraphCompiler() { | 59 FlowGraphCompiler::~FlowGraphCompiler() { |
53 // BlockInfos are zone-allocated, so their destructors are not called. | 60 // BlockInfos are zone-allocated, so their destructors are not called. |
54 // Verify the labels explicitly here. | 61 // Verify the labels explicitly here. |
55 for (int i = 0; i < block_info_.length(); ++i) { | 62 for (int i = 0; i < block_info_.length(); ++i) { |
56 ASSERT(!block_info_[i]->label.IsLinked()); | 63 ASSERT(!block_info_[i]->label.IsLinked()); |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 if (!FLAG_trace_functions) { | 1581 if (!FLAG_trace_functions) { |
1575 return Intrinsifier::Intrinsify(parsed_function_.function(), assembler_); | 1582 return Intrinsifier::Intrinsify(parsed_function_.function(), assembler_); |
1576 } | 1583 } |
1577 return false; | 1584 return false; |
1578 } | 1585 } |
1579 | 1586 |
1580 | 1587 |
1581 // TODO(srdjan): Investigate where to put the argument type checks for | 1588 // TODO(srdjan): Investigate where to put the argument type checks for |
1582 // checked mode. | 1589 // checked mode. |
1583 void FlowGraphCompiler::CompileGraph() { | 1590 void FlowGraphCompiler::CompileGraph() { |
1584 TimerScope timer(FLAG_compiler_stats, &CompilerStats::graphcompiler_timer); | 1591 InitCompiler(); |
1585 if (TryIntrinsify()) { | 1592 if (TryIntrinsify()) { |
1586 // Make it patchable: code must have a minimum code size, nop(2) increases | 1593 // Make it patchable: code must have a minimum code size, nop(2) increases |
1587 // the minimum code size appropriately. | 1594 // the minimum code size appropriately. |
1588 __ nop(2); | 1595 __ nop(2); |
1589 __ int3(); | 1596 __ int3(); |
1590 __ jmp(&StubCode::FixCallersTargetLabel()); | 1597 __ jmp(&StubCode::FixCallersTargetLabel()); |
1591 return; | 1598 return; |
1592 } | 1599 } |
1593 // Specialized version of entry code from CodeGenerator::GenerateEntryCode. | 1600 // Specialized version of entry code from CodeGenerator::GenerateEntryCode. |
1594 const Function& function = parsed_function_.function(); | 1601 const Function& function = parsed_function_.function(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 ASSERT(exception_handlers_list_ != NULL); | 1739 ASSERT(exception_handlers_list_ != NULL); |
1733 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( | 1740 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( |
1734 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); | 1741 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); |
1735 code.set_exception_handlers(handlers); | 1742 code.set_exception_handlers(handlers); |
1736 } | 1743 } |
1737 | 1744 |
1738 | 1745 |
1739 } // namespace dart | 1746 } // namespace dart |
1740 | 1747 |
1741 #endif // defined TARGET_ARCH_X64 | 1748 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |