| 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" |
| 11 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
| 12 #include "vm/deopt_instructions.h" | 12 #include "vm/deopt_instructions.h" |
| 13 #include "vm/flow_graph_allocator.h" | 13 #include "vm/flow_graph_allocator.h" |
| 14 #include "vm/il_printer.h" | 14 #include "vm/il_printer.h" |
| 15 #include "vm/intrinsifier.h" | 15 #include "vm/intrinsifier.h" |
| 16 #include "vm/locations.h" | 16 #include "vm/locations.h" |
| 17 #include "vm/longjump.h" | 17 #include "vm/longjump.h" |
| 18 #include "vm/object_store.h" | 18 #include "vm/object_store.h" |
| 19 #include "vm/parser.h" | 19 #include "vm/parser.h" |
| 20 #include "vm/stack_frame.h" | |
| 21 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
| 22 #include "vm/symbols.h" | 21 #include "vm/symbols.h" |
| 23 | 22 |
| 24 namespace dart { | 23 namespace dart { |
| 25 | 24 |
| 26 DECLARE_FLAG(bool, code_comments); | 25 DECLARE_FLAG(bool, code_comments); |
| 27 DECLARE_FLAG(bool, enable_type_checks); | 26 DECLARE_FLAG(bool, enable_type_checks); |
| 28 DECLARE_FLAG(bool, intrinsify); | 27 DECLARE_FLAG(bool, intrinsify); |
| 29 DECLARE_FLAG(bool, propagate_ic_data); | 28 DECLARE_FLAG(bool, propagate_ic_data); |
| 30 DECLARE_FLAG(bool, report_usage_count); | 29 DECLARE_FLAG(bool, report_usage_count); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 function.token_pos(), | 290 function.token_pos(), |
| 292 LanguageError::kError, | 291 LanguageError::kError, |
| 293 Heap::kNew, | 292 Heap::kNew, |
| 294 "FlowGraphCompiler Bailout: %s %s", | 293 "FlowGraphCompiler Bailout: %s %s", |
| 295 String::Handle(function.name()).ToCString(), | 294 String::Handle(function.name()).ToCString(), |
| 296 reason)); | 295 reason)); |
| 297 Isolate::Current()->long_jump_base()->Jump(1, error); | 296 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 298 } | 297 } |
| 299 | 298 |
| 300 | 299 |
| 301 void FlowGraphCompiler::EmitTrySync(Instruction* instr, intptr_t try_index) { | |
| 302 ASSERT(is_optimizing()); | |
| 303 Environment* env = instr->env(); | |
| 304 CatchBlockEntryInstr* catch_block = | |
| 305 flow_graph().graph_entry()->GetCatchEntry(try_index); | |
| 306 const GrowableArray<Definition*>* idefs = catch_block->initial_definitions(); | |
| 307 | |
| 308 // Construct a ParallelMove instruction for parameters and locals. Skip the | |
| 309 // special locals exception_var and stacktrace_var since they will be filled | |
| 310 // when an exception is thrown. Constant locations are known to be the same | |
| 311 // at all instructions that may throw, and do not need to be materialized. | |
| 312 | |
| 313 // Parameters first. | |
| 314 intptr_t i = 0; | |
| 315 const intptr_t num_non_copied_params = flow_graph().num_non_copied_params(); | |
| 316 ParallelMoveInstr* move_instr = new ParallelMoveInstr(); | |
| 317 for (; i < num_non_copied_params; ++i) { | |
| 318 if ((*idefs)[i]->IsConstant()) continue; // Common constants | |
| 319 Location src = env->LocationAt(i); | |
| 320 intptr_t dest_index = i - num_non_copied_params; | |
| 321 Location dest = Location::StackSlot(dest_index); | |
| 322 move_instr->AddMove(dest, src); | |
| 323 } | |
| 324 | |
| 325 // Process locals. Skip exception_var and stacktrace_var. | |
| 326 intptr_t local_base = kFirstLocalSlotFromFp + num_non_copied_params; | |
| 327 intptr_t ex_idx = local_base - catch_block->exception_var().index(); | |
| 328 intptr_t st_idx = local_base - catch_block->stacktrace_var().index(); | |
| 329 for (; i < flow_graph().variable_count(); ++i) { | |
| 330 if (i == ex_idx || i == st_idx) continue; | |
| 331 if ((*idefs)[i]->IsConstant()) continue; | |
| 332 Location src = env->LocationAt(i); | |
| 333 intptr_t dest_index = i - num_non_copied_params; | |
| 334 Location dest = Location::StackSlot(dest_index); | |
| 335 move_instr->AddMove(dest, src); | |
| 336 // Update safepoint bitmap to indicate that the target location | |
| 337 // now contains a pointer. | |
| 338 instr->locs()->stack_bitmap()->Set(dest_index, true); | |
| 339 } | |
| 340 parallel_move_resolver()->EmitNativeCode(move_instr); | |
| 341 } | |
| 342 | |
| 343 | |
| 344 intptr_t FlowGraphCompiler::StackSize() const { | 300 intptr_t FlowGraphCompiler::StackSize() const { |
| 345 if (is_optimizing_) { | 301 if (is_optimizing_) { |
| 346 return flow_graph_.graph_entry()->spill_slot_count(); | 302 return flow_graph_.graph_entry()->spill_slot_count(); |
| 347 } else { | 303 } else { |
| 348 return parsed_function_.num_stack_locals() + | 304 return parsed_function_.num_stack_locals() + |
| 349 parsed_function_.num_copied_params(); | 305 parsed_function_.num_copied_params(); |
| 350 } | 306 } |
| 351 } | 307 } |
| 352 | 308 |
| 353 | 309 |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 | 1225 |
| 1270 for (int i = 0; i < len; i++) { | 1226 for (int i = 0; i < len; i++) { |
| 1271 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), | 1227 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), |
| 1272 &Function::ZoneHandle(ic_data.GetTargetAt(i)), | 1228 &Function::ZoneHandle(ic_data.GetTargetAt(i)), |
| 1273 ic_data.GetCountAt(i))); | 1229 ic_data.GetCountAt(i))); |
| 1274 } | 1230 } |
| 1275 sorted->Sort(HighestCountFirst); | 1231 sorted->Sort(HighestCountFirst); |
| 1276 } | 1232 } |
| 1277 | 1233 |
| 1278 } // namespace dart | 1234 } // namespace dart |
| OLD | NEW |