| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, | 66 FlowGraphCompiler::FlowGraphCompiler(Assembler* assembler, |
| 67 FlowGraph* flow_graph, | 67 FlowGraph* flow_graph, |
| 68 bool is_optimizing) | 68 bool is_optimizing) |
| 69 : assembler_(assembler), | 69 : assembler_(assembler), |
| 70 parsed_function_(flow_graph->parsed_function()), | 70 parsed_function_(flow_graph->parsed_function()), |
| 71 flow_graph_(*flow_graph), | 71 flow_graph_(*flow_graph), |
| 72 block_order_(*flow_graph->codegen_block_order(is_optimizing)), | 72 block_order_(*flow_graph->CodegenBlockOrder(is_optimizing)), |
| 73 current_block_(NULL), | 73 current_block_(NULL), |
| 74 exception_handlers_list_(NULL), | 74 exception_handlers_list_(NULL), |
| 75 pc_descriptors_list_(NULL), | 75 pc_descriptors_list_(NULL), |
| 76 stackmap_table_builder_( | 76 stackmap_table_builder_( |
| 77 is_optimizing ? new StackmapTableBuilder() : NULL), | 77 is_optimizing ? new StackmapTableBuilder() : NULL), |
| 78 block_info_(block_order_.length()), | 78 block_info_(block_order_.length()), |
| 79 deopt_infos_(), | 79 deopt_infos_(), |
| 80 static_calls_target_table_(GrowableObjectArray::ZoneHandle( | 80 static_calls_target_table_(GrowableObjectArray::ZoneHandle( |
| 81 GrowableObjectArray::New())), | 81 GrowableObjectArray::New())), |
| 82 is_optimizing_(is_optimizing), | 82 is_optimizing_(is_optimizing), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 nonempty_label = GetJumpLabel(block); | 218 nonempty_label = GetJumpLabel(block); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 ASSERT(block_order()[0]->IsGraphEntry()); | 222 ASSERT(block_order()[0]->IsGraphEntry()); |
| 223 BlockInfo* block_info = block_info_[block_order()[0]->postorder_number()]; | 223 BlockInfo* block_info = block_info_[block_order()[0]->postorder_number()]; |
| 224 block_info->set_next_nonempty_label(nonempty_label); | 224 block_info->set_next_nonempty_label(nonempty_label); |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 |
| 228 void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { |
| 229 if (!is_optimizing()) { |
| 230 if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { |
| 231 AssertAssignableInstr* assert = instr->AsAssertAssignable(); |
| 232 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 233 assert->deopt_id(), |
| 234 assert->token_pos()); |
| 235 } else if (instr->IsGuardField() || |
| 236 (instr->CanBecomeDeoptimizationTarget() && !instr->IsGoto())) { |
| 237 // GuardField and instructions that can be deoptimization targets need |
| 238 // to record their deopt id. GotoInstr records its own so that it can |
| 239 // control the placement. |
| 240 AddCurrentDescriptor(PcDescriptors::kDeopt, |
| 241 instr->deopt_id(), |
| 242 Scanner::kDummyTokenIndex); |
| 243 } |
| 244 AllocateRegistersLocally(instr); |
| 245 } else if (instr->MayThrow() && |
| 246 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { |
| 247 // Optimized try-block: Sync locals to fixed stack locations. |
| 248 EmitTrySync(instr, CurrentTryIndex()); |
| 249 } |
| 250 } |
| 251 |
| 252 |
| 228 void FlowGraphCompiler::VisitBlocks() { | 253 void FlowGraphCompiler::VisitBlocks() { |
| 229 CompactBlocks(); | 254 CompactBlocks(); |
| 230 | 255 |
| 231 for (intptr_t i = 0; i < block_order().length(); ++i) { | 256 for (intptr_t i = 0; i < block_order().length(); ++i) { |
| 232 // Compile the block entry. | 257 // Compile the block entry. |
| 233 BlockEntryInstr* entry = block_order()[i]; | 258 BlockEntryInstr* entry = block_order()[i]; |
| 234 assembler()->Comment("B%" Pd "", entry->block_id()); | 259 assembler()->Comment("B%" Pd "", entry->block_id()); |
| 235 set_current_block(entry); | 260 set_current_block(entry); |
| 236 | 261 |
| 237 if (WasCompacted(entry)) { | 262 if (WasCompacted(entry)) { |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 | 1134 |
| 1110 for (int i = 0; i < len; i++) { | 1135 for (int i = 0; i < len; i++) { |
| 1111 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), | 1136 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), |
| 1112 &Function::ZoneHandle(ic_data.GetTargetAt(i)), | 1137 &Function::ZoneHandle(ic_data.GetTargetAt(i)), |
| 1113 ic_data.GetCountAt(i))); | 1138 ic_data.GetCountAt(i))); |
| 1114 } | 1139 } |
| 1115 sorted->Sort(HighestCountFirst); | 1140 sorted->Sort(HighestCountFirst); |
| 1116 } | 1141 } |
| 1117 | 1142 |
| 1118 } // namespace dart | 1143 } // namespace dart |
| OLD | NEW |