| 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/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 isolate_(Isolate::Current()) { | 34 isolate_(Isolate::Current()) { |
| 35 from_frame_ = isolate_->deopt_frame_copy(); | 35 from_frame_ = isolate_->deopt_frame_copy(); |
| 36 from_frame_size_ = isolate_->deopt_frame_copy_size(); | 36 from_frame_size_ = isolate_->deopt_frame_copy_size(); |
| 37 registers_copy_ = isolate_->deopt_cpu_registers_copy(); | 37 registers_copy_ = isolate_->deopt_cpu_registers_copy(); |
| 38 fpu_registers_copy_ = isolate_->deopt_fpu_registers_copy(); | 38 fpu_registers_copy_ = isolate_->deopt_fpu_registers_copy(); |
| 39 caller_fp_ = GetFromFp(); | 39 caller_fp_ = GetFromFp(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 intptr_t DeoptimizationContext::GetFromFp() const { | 43 intptr_t DeoptimizationContext::GetFromFp() const { |
| 44 return from_frame_[from_frame_size_ - num_args_ - kLastParamSlotIndex]; | 44 return from_frame_[from_frame_size_ - num_args_ - 1 - kParamEndSlotFromFp]; |
| 45 } | 45 } |
| 46 | 46 |
| 47 | 47 |
| 48 intptr_t DeoptimizationContext::GetFromPc() const { | 48 intptr_t DeoptimizationContext::GetFromPc() const { |
| 49 return from_frame_[from_frame_size_ - num_args_ + kPcSlotIndexFromSp]; | 49 return from_frame_[from_frame_size_ - num_args_ + kSavedPcSlotFromSp]; |
| 50 } | 50 } |
| 51 | 51 |
| 52 intptr_t DeoptimizationContext::GetCallerFp() const { | 52 intptr_t DeoptimizationContext::GetCallerFp() const { |
| 53 return caller_fp_; | 53 return caller_fp_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 void DeoptimizationContext::SetCallerFp(intptr_t caller_fp) { | 56 void DeoptimizationContext::SetCallerFp(intptr_t caller_fp) { |
| 57 caller_fp_ = caller_fp; | 57 caller_fp_ = caller_fp; |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 OS::SNPrint(chars, len + 1, format, object_table_index_); | 519 OS::SNPrint(chars, len + 1, format, object_table_index_); |
| 520 return chars; | 520 return chars; |
| 521 } | 521 } |
| 522 | 522 |
| 523 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 523 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
| 524 Function& function = Function::Handle(deopt_context->isolate()); | 524 Function& function = Function::Handle(deopt_context->isolate()); |
| 525 function ^= deopt_context->ObjectAt(object_table_index_); | 525 function ^= deopt_context->ObjectAt(object_table_index_); |
| 526 const Code& code = | 526 const Code& code = |
| 527 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 527 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
| 528 ASSERT(!code.IsNull()); | 528 ASSERT(!code.IsNull()); |
| 529 intptr_t pc_marker = code.EntryPoint() + | 529 const intptr_t pc_marker = |
| 530 Assembler::kOffsetOfSavedPCfromEntrypoint; | 530 code.EntryPoint() + Assembler::kEntryPointToPcMarkerOffset; |
| 531 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 531 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
| 532 *to_addr = pc_marker; | 532 *to_addr = pc_marker; |
| 533 // Increment the deoptimization counter. This effectively increments each | 533 // Increment the deoptimization counter. This effectively increments each |
| 534 // function occurring in the optimized frame. | 534 // function occurring in the optimized frame. |
| 535 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 535 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
| 536 if (FLAG_trace_deoptimization) { | 536 if (FLAG_trace_deoptimization) { |
| 537 OS::PrintErr("Deoptimizing %s (count %d)\n", | 537 OS::PrintErr("Deoptimizing %s (count %d)\n", |
| 538 function.ToFullyQualifiedCString(), | 538 function.ToFullyQualifiedCString(), |
| 539 function.deoptimization_counter()); | 539 function.deoptimization_counter()); |
| 540 } | 540 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // Add object. | 756 // Add object. |
| 757 const intptr_t result = object_table_.Length(); | 757 const intptr_t result = object_table_.Length(); |
| 758 object_table_.Add(obj); | 758 object_table_.Add(obj); |
| 759 return result; | 759 return result; |
| 760 } | 760 } |
| 761 | 761 |
| 762 | 762 |
| 763 intptr_t DeoptInfoBuilder::CalculateStackIndex(const Location& from_loc) const { | 763 intptr_t DeoptInfoBuilder::CalculateStackIndex(const Location& from_loc) const { |
| 764 return from_loc.stack_index() < 0 ? | 764 return from_loc.stack_index() < 0 ? |
| 765 from_loc.stack_index() + num_args_ : | 765 from_loc.stack_index() + num_args_ : |
| 766 from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1; | 766 from_loc.stack_index() + num_args_ - kFirstLocalSlotFromFp + 1; |
| 767 } | 767 } |
| 768 | 768 |
| 769 | 769 |
| 770 void DeoptInfoBuilder::AddReturnAddress(const Function& function, | 770 void DeoptInfoBuilder::AddReturnAddress(const Function& function, |
| 771 intptr_t deopt_id, | 771 intptr_t deopt_id, |
| 772 intptr_t to_index) { | 772 intptr_t to_index) { |
| 773 // Check that deopt_id exists. | 773 // Check that deopt_id exists. |
| 774 // TODO(vegorov): verify after deoptimization targets as well. | 774 // TODO(vegorov): verify after deoptimization targets as well. |
| 775 #ifdef DEBUG | 775 #ifdef DEBUG |
| 776 const Code& code = Code::Handle(function.unoptimized_code()); | 776 const Code& code = Code::Handle(function.unoptimized_code()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 Smi* offset, | 927 Smi* offset, |
| 928 DeoptInfo* info, | 928 DeoptInfo* info, |
| 929 Smi* reason) { | 929 Smi* reason) { |
| 930 intptr_t i = index * kEntrySize; | 930 intptr_t i = index * kEntrySize; |
| 931 *offset ^= table.At(i); | 931 *offset ^= table.At(i); |
| 932 *info ^= table.At(i + 1); | 932 *info ^= table.At(i + 1); |
| 933 *reason ^= table.At(i + 2); | 933 *reason ^= table.At(i + 2); |
| 934 } | 934 } |
| 935 | 935 |
| 936 } // namespace dart | 936 } // namespace dart |
| OLD | NEW |