| 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/deopt_instructions.h" | 5 #include "vm/deopt_instructions.h" |
| 6 | 6 |
| 7 #include "vm/assembler_macros.h" | 7 #include "vm/assembler_macros.h" |
| 8 #include "vm/code_patcher.h" | |
| 9 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 10 #include "vm/locations.h" | 9 #include "vm/locations.h" |
| 11 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| 12 | 11 |
| 13 namespace dart { | 12 namespace dart { |
| 14 | 13 |
| 15 DEFINE_FLAG(bool, compress_deopt_info, true, | 14 DEFINE_FLAG(bool, compress_deopt_info, true, |
| 16 "Compress the size of the deoptimization info for optimized code."); | 15 "Compress the size of the deoptimization info for optimized code."); |
| 17 | 16 |
| 18 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, | 17 DeoptimizationContext::DeoptimizationContext(intptr_t* to_frame_start, |
| 19 intptr_t to_frame_size, | 18 intptr_t to_frame_size, |
| 20 const Array& object_table, | 19 const Array& object_table, |
| 21 intptr_t num_args, | 20 intptr_t num_args) |
| 22 DeoptReasonId deopt_reason) | |
| 23 : object_table_(object_table), | 21 : object_table_(object_table), |
| 24 to_frame_(to_frame_start), | 22 to_frame_(to_frame_start), |
| 25 to_frame_size_(to_frame_size), | 23 to_frame_size_(to_frame_size), |
| 26 from_frame_(NULL), | 24 from_frame_(NULL), |
| 27 from_frame_size_(0), | 25 from_frame_size_(0), |
| 28 registers_copy_(NULL), | 26 registers_copy_(NULL), |
| 29 xmm_registers_copy_(NULL), | 27 xmm_registers_copy_(NULL), |
| 30 num_args_(num_args), | 28 num_args_(num_args), |
| 31 deopt_reason_(deopt_reason), | |
| 32 isolate_(Isolate::Current()) { | 29 isolate_(Isolate::Current()) { |
| 33 from_frame_ = isolate_->deopt_frame_copy(); | 30 from_frame_ = isolate_->deopt_frame_copy(); |
| 34 from_frame_size_ = isolate_->deopt_frame_copy_size(); | 31 from_frame_size_ = isolate_->deopt_frame_copy_size(); |
| 35 registers_copy_ = isolate_->deopt_cpu_registers_copy(); | 32 registers_copy_ = isolate_->deopt_cpu_registers_copy(); |
| 36 xmm_registers_copy_ = isolate_->deopt_xmm_registers_copy(); | 33 xmm_registers_copy_ = isolate_->deopt_xmm_registers_copy(); |
| 37 caller_fp_ = GetFromFp(); | 34 caller_fp_ = GetFromFp(); |
| 38 } | 35 } |
| 39 | 36 |
| 40 | 37 |
| 41 intptr_t DeoptimizationContext::GetFromFp() const { | 38 intptr_t DeoptimizationContext::GetFromFp() const { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 249 } |
| 253 | 250 |
| 254 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 251 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
| 255 Function& function = Function::Handle(deopt_context->isolate()); | 252 Function& function = Function::Handle(deopt_context->isolate()); |
| 256 function ^= deopt_context->ObjectAt(object_table_index_); | 253 function ^= deopt_context->ObjectAt(object_table_index_); |
| 257 const Code& code = | 254 const Code& code = |
| 258 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 255 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
| 259 uword continue_at_pc = code.GetDeoptBeforePcAtDeoptId(deopt_id_); | 256 uword continue_at_pc = code.GetDeoptBeforePcAtDeoptId(deopt_id_); |
| 260 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 257 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
| 261 *to_addr = continue_at_pc; | 258 *to_addr = continue_at_pc; |
| 262 | |
| 263 uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); | |
| 264 const ICData& ic_data = ICData::Handle( | |
| 265 CodePatcher::GetInstanceCallIcDataAt(pc)); | |
| 266 if (!ic_data.IsNull()) { | |
| 267 ic_data.set_deopt_reason(deopt_context->deopt_reason()); | |
| 268 } | |
| 269 } | 259 } |
| 270 | 260 |
| 271 private: | 261 private: |
| 272 static const intptr_t kFieldWidth = kBitsPerWord / 2; | 262 static const intptr_t kFieldWidth = kBitsPerWord / 2; |
| 273 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; | 263 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; |
| 274 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; | 264 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; |
| 275 | 265 |
| 276 const intptr_t object_table_index_; | 266 const intptr_t object_table_index_; |
| 277 const intptr_t deopt_id_; | 267 const intptr_t deopt_id_; |
| 278 | 268 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 Smi* offset, | 779 Smi* offset, |
| 790 DeoptInfo* info, | 780 DeoptInfo* info, |
| 791 Smi* reason) { | 781 Smi* reason) { |
| 792 intptr_t i = index * kEntrySize; | 782 intptr_t i = index * kEntrySize; |
| 793 *offset ^= table.At(i); | 783 *offset ^= table.At(i); |
| 794 *info ^= table.At(i + 1); | 784 *info ^= table.At(i + 1); |
| 795 *reason ^= table.At(i + 2); | 785 *reason ^= table.At(i + 2); |
| 796 } | 786 } |
| 797 | 787 |
| 798 } // namespace dart | 788 } // namespace dart |
| OLD | NEW |