| 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 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 return i; | 752 return i; |
| 753 } | 753 } |
| 754 } | 754 } |
| 755 // Add object. | 755 // Add object. |
| 756 const intptr_t result = object_table_.Length(); | 756 const intptr_t result = object_table_.Length(); |
| 757 object_table_.Add(obj); | 757 object_table_.Add(obj); |
| 758 return result; | 758 return result; |
| 759 } | 759 } |
| 760 | 760 |
| 761 | 761 |
| 762 intptr_t DeoptInfoBuilder::CalculateStackIndex(const Location& from_loc) const { |
| 763 return from_loc.stack_index() < 0 ? |
| 764 from_loc.stack_index() + num_args_ : |
| 765 from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1; |
| 766 } |
| 767 |
| 768 |
| 762 void DeoptInfoBuilder::AddReturnAddress(const Function& function, | 769 void DeoptInfoBuilder::AddReturnAddress(const Function& function, |
| 763 intptr_t deopt_id, | 770 intptr_t deopt_id, |
| 764 intptr_t to_index) { | 771 intptr_t to_index) { |
| 765 // Check that deopt_id exists. | 772 // Check that deopt_id exists. |
| 766 // TODO(vegorov): verify after deoptimization targets as well. | 773 // TODO(vegorov): verify after deoptimization targets as well. |
| 767 #ifdef DEBUG | 774 #ifdef DEBUG |
| 768 const Code& code = Code::Handle(function.unoptimized_code()); | 775 const Code& code = Code::Handle(function.unoptimized_code()); |
| 769 ASSERT(Isolate::IsDeoptAfter(deopt_id) || | 776 ASSERT(Isolate::IsDeoptAfter(deopt_id) || |
| 770 (code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt) != 0)); | 777 (code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt) != 0)); |
| 771 #endif | 778 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 800 } else if (value->definition()->representation() == kUnboxedMint) { | 807 } else if (value->definition()->representation() == kUnboxedMint) { |
| 801 deopt_instr = new DeoptInt64FpuRegisterInstr(from_loc.fpu_reg()); | 808 deopt_instr = new DeoptInt64FpuRegisterInstr(from_loc.fpu_reg()); |
| 802 } else if (value->definition()->representation() == kUnboxedFloat32x4) { | 809 } else if (value->definition()->representation() == kUnboxedFloat32x4) { |
| 803 deopt_instr = new DeoptFloat32x4FpuRegisterInstr(from_loc.fpu_reg()); | 810 deopt_instr = new DeoptFloat32x4FpuRegisterInstr(from_loc.fpu_reg()); |
| 804 } else { | 811 } else { |
| 805 ASSERT(value->definition()->representation() == kUnboxedUint32x4); | 812 ASSERT(value->definition()->representation() == kUnboxedUint32x4); |
| 806 deopt_instr = new DeoptUint32x4FpuRegisterInstr(from_loc.fpu_reg()); | 813 deopt_instr = new DeoptUint32x4FpuRegisterInstr(from_loc.fpu_reg()); |
| 807 } | 814 } |
| 808 } else if (from_loc.IsStackSlot()) { | 815 } else if (from_loc.IsStackSlot()) { |
| 809 ASSERT(value->definition()->representation() == kTagged); | 816 ASSERT(value->definition()->representation() == kTagged); |
| 810 intptr_t from_index = (from_loc.stack_index() < 0) ? | 817 intptr_t from_index = CalculateStackIndex(from_loc); |
| 811 from_loc.stack_index() + num_args_ : | |
| 812 from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1; | |
| 813 deopt_instr = new DeoptStackSlotInstr(from_index); | 818 deopt_instr = new DeoptStackSlotInstr(from_index); |
| 814 } else if (from_loc.IsDoubleStackSlot()) { | 819 } else if (from_loc.IsDoubleStackSlot()) { |
| 815 intptr_t from_index = (from_loc.stack_index() < 0) ? | 820 intptr_t from_index = CalculateStackIndex(from_loc); |
| 816 from_loc.stack_index() + num_args_ : | |
| 817 from_loc.stack_index() + num_args_ - kFirstLocalSlotIndex + 1; | |
| 818 if (value->definition()->representation() == kUnboxedDouble) { | 821 if (value->definition()->representation() == kUnboxedDouble) { |
| 819 deopt_instr = new DeoptDoubleStackSlotInstr(from_index); | 822 deopt_instr = new DeoptDoubleStackSlotInstr(from_index); |
| 820 } else { | 823 } else { |
| 821 ASSERT(value->definition()->representation() == kUnboxedMint); | 824 ASSERT(value->definition()->representation() == kUnboxedMint); |
| 822 deopt_instr = new DeoptInt64StackSlotInstr(from_index); | 825 deopt_instr = new DeoptInt64StackSlotInstr(from_index); |
| 823 } | 826 } |
| 827 } else if (from_loc.IsQuadStackSlot()) { |
| 828 intptr_t from_index = CalculateStackIndex(from_loc); |
| 829 if (value->definition()->representation() == kUnboxedFloat32x4) { |
| 830 deopt_instr = new DeoptFloat32x4StackSlotInstr(from_index); |
| 831 } else { |
| 832 ASSERT(value->definition()->representation() == kUnboxedUint32x4); |
| 833 deopt_instr = new DeoptUint32x4StackSlotInstr(from_index); |
| 834 } |
| 824 } else { | 835 } else { |
| 825 UNREACHABLE(); | 836 UNREACHABLE(); |
| 826 } | 837 } |
| 827 ASSERT(to_index == instructions_.length()); | 838 ASSERT(to_index == instructions_.length()); |
| 828 ASSERT(deopt_instr != NULL); | 839 ASSERT(deopt_instr != NULL); |
| 829 instructions_.Add(deopt_instr); | 840 instructions_.Add(deopt_instr); |
| 830 } | 841 } |
| 831 | 842 |
| 832 | 843 |
| 833 void DeoptInfoBuilder::AddCallerFp(intptr_t to_index) { | 844 void DeoptInfoBuilder::AddCallerFp(intptr_t to_index) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 Smi* offset, | 926 Smi* offset, |
| 916 DeoptInfo* info, | 927 DeoptInfo* info, |
| 917 Smi* reason) { | 928 Smi* reason) { |
| 918 intptr_t i = index * kEntrySize; | 929 intptr_t i = index * kEntrySize; |
| 919 *offset ^= table.At(i); | 930 *offset ^= table.At(i); |
| 920 *info ^= table.At(i + 1); | 931 *info ^= table.At(i + 1); |
| 921 *reason ^= table.At(i + 2); | 932 *reason ^= table.At(i + 2); |
| 922 } | 933 } |
| 923 | 934 |
| 924 } // namespace dart | 935 } // namespace dart |
| OLD | NEW |