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) | |
31 : code_(code.raw()), | 30 : code_(code.raw()), |
32 object_pool_(code.GetObjectPool()), | 31 object_pool_(code.GetObjectPool()), |
33 deopt_info_(TypedData::null()), | 32 deopt_info_(TypedData::null()), |
34 dest_frame_is_allocated_(false), | 33 dest_frame_is_allocated_(false), |
35 dest_frame_(NULL), | 34 dest_frame_(NULL), |
36 dest_frame_size_(0), | 35 dest_frame_size_(0), |
37 source_frame_is_allocated_(false), | 36 source_frame_is_allocated_(false), |
38 source_frame_(NULL), | 37 source_frame_(NULL), |
39 source_frame_size_(0), | 38 source_frame_size_(0), |
40 cpu_registers_(cpu_registers), | 39 cpu_registers_(cpu_registers), |
41 fpu_registers_(fpu_registers), | 40 fpu_registers_(fpu_registers), |
42 num_args_(0), | 41 num_args_(0), |
43 deopt_reason_(ICData::kDeoptUnknown), | 42 deopt_reason_(ICData::kDeoptUnknown), |
44 deopt_flags_(0), | 43 deopt_flags_(0), |
45 thread_(Thread::Current()), | 44 thread_(Thread::Current()), |
46 timeline_event_(NULL), | 45 timeline_event_(NULL), |
47 deferred_slots_(NULL), | 46 deferred_slots_(NULL), |
48 deferred_objects_count_(0), | 47 deferred_objects_count_(0), |
49 deferred_objects_(NULL), | 48 deferred_objects_(NULL) { |
50 is_lazy_deopt_(is_lazy_deopt) { | |
51 const TypedData& deopt_info = TypedData::Handle( | 49 const TypedData& deopt_info = TypedData::Handle( |
52 code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason_, &deopt_flags_)); | 50 code.GetDeoptInfoAtPc(frame->pc(), &deopt_reason_, &deopt_flags_)); |
53 ASSERT(!deopt_info.IsNull()); | 51 ASSERT(!deopt_info.IsNull()); |
54 deopt_info_ = deopt_info.raw(); | 52 deopt_info_ = deopt_info.raw(); |
55 | 53 |
56 const Function& function = Function::Handle(code.function()); | 54 const Function& function = Function::Handle(code.function()); |
57 | 55 |
58 // Do not include incoming arguments if there are optional arguments | 56 // Do not include incoming arguments if there are optional arguments |
59 // (they are copied into local space at method entry). | 57 // (they are copied into local space at method entry). |
60 num_args_ = | 58 num_args_ = |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 644 |
647 virtual intptr_t source_index() const { return object_table_index_; } | 645 virtual intptr_t source_index() const { return object_table_index_; } |
648 virtual DeoptInstr::Kind kind() const { return kPcMarker; } | 646 virtual DeoptInstr::Kind kind() const { return kPcMarker; } |
649 | 647 |
650 virtual const char* ArgumentsToCString() const { | 648 virtual const char* ArgumentsToCString() const { |
651 return Thread::Current()->zone()->PrintToString( | 649 return Thread::Current()->zone()->PrintToString( |
652 "%" Pd "", object_table_index_); | 650 "%" Pd "", object_table_index_); |
653 } | 651 } |
654 | 652 |
655 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { | 653 void Execute(DeoptContext* deopt_context, intptr_t* dest_addr) { |
656 Function& function = Function::Handle(deopt_context->zone()); | 654 *dest_addr = Smi::RawValue(0); |
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()); | |
666 deopt_context->DeferPcMarkerMaterialization( | 655 deopt_context->DeferPcMarkerMaterialization( |
667 object_table_index_, dest_addr); | 656 object_table_index_, dest_addr); |
668 } | 657 } |
669 | 658 |
670 private: | 659 private: |
671 intptr_t object_table_index_; | 660 intptr_t object_table_index_; |
672 | 661 |
673 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); | 662 DISALLOW_COPY_AND_ASSIGN(DeoptPcMarkerInstr); |
674 }; | 663 }; |
675 | 664 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 Smi* offset, | 1294 Smi* offset, |
1306 TypedData* info, | 1295 TypedData* info, |
1307 Smi* reason) { | 1296 Smi* reason) { |
1308 intptr_t i = index * kEntrySize; | 1297 intptr_t i = index * kEntrySize; |
1309 *offset ^= table.At(i); | 1298 *offset ^= table.At(i); |
1310 *info ^= table.At(i + 1); | 1299 *info ^= table.At(i + 1); |
1311 *reason ^= table.At(i + 2); | 1300 *reason ^= table.At(i + 2); |
1312 } | 1301 } |
1313 | 1302 |
1314 } // namespace dart | 1303 } // namespace dart |
OLD | NEW |