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/deopt_instructions.h" | 5 #include "vm/deopt_instructions.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
11 #include "vm/locations.h" | 11 #include "vm/locations.h" |
12 #include "vm/parser.h" | 12 #include "vm/parser.h" |
13 #include "vm/stack_frame.h" | 13 #include "vm/stack_frame.h" |
14 #include "vm/thread.h" | 14 #include "vm/thread.h" |
15 #include "vm/timeline.h" | 15 #include "vm/timeline.h" |
16 | 16 |
17 namespace dart { | 17 namespace dart { |
18 | 18 |
19 DEFINE_FLAG(bool, compress_deopt_info, true, | 19 DEFINE_FLAG(bool, compress_deopt_info, true, |
20 "Compress the size of the deoptimization info for optimized code."); | 20 "Compress the size of the deoptimization info for optimized code."); |
21 DECLARE_FLAG(bool, trace_deoptimization); | 21 DECLARE_FLAG(bool, trace_deoptimization); |
22 DECLARE_FLAG(bool, trace_deoptimization_verbose); | 22 DECLARE_FLAG(bool, trace_deoptimization_verbose); |
23 | 23 |
24 | 24 |
25 DeoptContext::DeoptContext(const StackFrame* frame, | 25 DeoptContext::DeoptContext(const StackFrame* frame, |
26 const Code& code, | 26 const Code& code, |
27 DestFrameOptions dest_options, | 27 DestFrameOptions dest_options, |
28 fpu_register_t* fpu_registers, | 28 fpu_register_t* fpu_registers, |
29 intptr_t* cpu_registers) | 29 intptr_t* cpu_registers, |
| 30 bool is_lazy_deopt) |
30 : code_(code.raw()), | 31 : code_(code.raw()), |
31 object_pool_(code.GetObjectPool()), | 32 object_pool_(code.GetObjectPool()), |
32 deopt_info_(TypedData::null()), | 33 deopt_info_(TypedData::null()), |
33 dest_frame_is_allocated_(false), | 34 dest_frame_is_allocated_(false), |
34 dest_frame_(NULL), | 35 dest_frame_(NULL), |
35 dest_frame_size_(0), | 36 dest_frame_size_(0), |
36 source_frame_is_allocated_(false), | 37 source_frame_is_allocated_(false), |
37 source_frame_(NULL), | 38 source_frame_(NULL), |
38 source_frame_size_(0), | 39 source_frame_size_(0), |
39 cpu_registers_(cpu_registers), | 40 cpu_registers_(cpu_registers), |
40 fpu_registers_(fpu_registers), | 41 fpu_registers_(fpu_registers), |
41 num_args_(0), | 42 num_args_(0), |
42 deopt_reason_(ICData::kDeoptUnknown), | 43 deopt_reason_(ICData::kDeoptUnknown), |
43 deopt_flags_(0), | 44 deopt_flags_(0), |
44 thread_(Thread::Current()), | 45 thread_(Thread::Current()), |
45 timeline_event_(NULL), | 46 timeline_event_(NULL), |
46 deferred_slots_(NULL), | 47 deferred_slots_(NULL), |
47 deferred_objects_count_(0), | 48 deferred_objects_count_(0), |
48 deferred_objects_(NULL) { | 49 deferred_objects_(NULL), |
| 50 is_lazy_deopt_(is_lazy_deopt) { |
49 const TypedData& deopt_info = TypedData::Handle( | 51 const TypedData& deopt_info = TypedData::Handle( |
50 code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason_, &deopt_flags_)); | 52 code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason_, &deopt_flags_)); |
51 ASSERT(!deopt_info.IsNull()); | 53 ASSERT(!deopt_info.IsNull()); |
52 deopt_info_ = deopt_info.raw(); | 54 deopt_info_ = deopt_info.raw(); |
53 | 55 |
54 const Function& function = Function::Handle(code.function()); | 56 const Function& function = Function::Handle(code.function()); |
55 | 57 |
56 // Do not include incoming arguments if there are optional arguments | 58 // Do not include incoming arguments if there are optional arguments |
57 // (they are copied into local space at method entry). | 59 // (they are copied into local space at method entry). |
58 num_args_ = | 60 num_args_ = |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 646 |
645 virtual intptr_t source_index() const { return object_table_index_; } | 647 virtual intptr_t source_index() const { return object_table_index_; } |
646 virtual DeoptInstr::Kind kind() const { return kPcMarker; } | 648 virtual DeoptInstr::Kind kind() const { return kPcMarker; } |
647 | 649 |
648 virtual const char* ArgumentsToCString() const { | 650 virtual const char* ArgumentsToCString() const { |
649 return Thread::Current()->zone()->PrintToString( | 651 return Thread::Current()->zone()->PrintToString( |
650 "%" Pd "", object_table_index_); | 652 "%" Pd "", object_table_index_); |
651 } | 653 } |
652 | 654 |
653 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { | 655 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { |
654 *dest_addr = Smi::RawValue(0); | 656 Function& function = Function::Handle(deopt_context->zone()); |
| 657 function ^= deopt_context->ObjectAt(object_table_index_); |
| 658 if (function.IsNull()) { |
| 659 *reinterpret_cast<RawObject**>(dest_addr) = deopt_context->is_lazy_deopt() |
| 660 ? StubCode::DeoptimizeLazy_entry()->code() |
| 661 : StubCode::Deoptimize_entry()->code(); |
| 662 return; |
| 663 } |
| 664 |
| 665 *dest_addr = reinterpret_cast<intptr_t>(Object::null()); |
655 deopt_context->DeferPcMarkerMaterialization( | 666 deopt_context->DeferPcMarkerMaterialization( |
656 object_table_index_, dest_addr); | 667 object_table_index_, dest_addr); |
657 } | 668 } |
658 | 669 |
659 private: | 670 private: |
660 intptr_t object_table_index_; | 671 intptr_t object_table_index_; |
661 | 672 |
662 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); | 673 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); |
663 }; | 674 }; |
664 | 675 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 Smi* offset, | 1305 Smi* offset, |
1295 TypedData* info, | 1306 TypedData* info, |
1296 Smi* reason) { | 1307 Smi* reason) { |
1297 intptr_t i = index * kEntrySize; | 1308 intptr_t i = index * kEntrySize; |
1298 *offset ^= table.At(i); | 1309 *offset ^= table.At(i); |
1299 *info ^= table.At(i + 1); | 1310 *info ^= table.At(i + 1); |
1300 *reason ^= table.At(i + 2); | 1311 *reason ^= table.At(i + 2); |
1301 } | 1312 } |
1302 | 1313 |
1303 } // namespace dart | 1314 } // namespace dart |
OLD | NEW |