| 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" | 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 202 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
| 203 Function& function = Function::Handle(deopt_context->isolate()); | 203 Function& function = Function::Handle(deopt_context->isolate()); |
| 204 function ^= deopt_context->ObjectAt(object_table_index_); | 204 function ^= deopt_context->ObjectAt(object_table_index_); |
| 205 const Code& code = | 205 const Code& code = |
| 206 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 206 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
| 207 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); | 207 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); |
| 208 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 208 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
| 209 *to_addr = continue_at_pc; | 209 *to_addr = continue_at_pc; |
| 210 } | 210 } |
| 211 | 211 |
| 212 static void GetEncodedValues(intptr_t from_index, |
| 213 intptr_t* object_table_index, |
| 214 intptr_t* deopt_id) { |
| 215 *object_table_index = ObjectTableIndex::decode(from_index); |
| 216 *deopt_id = DeoptId::decode(from_index); |
| 217 } |
| 218 |
| 212 private: | 219 private: |
| 213 static const intptr_t kFieldWidth = kBitsPerWord / 2; | 220 static const intptr_t kFieldWidth = kBitsPerWord / 2; |
| 214 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; | 221 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; |
| 215 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; | 222 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; |
| 216 | 223 |
| 217 const intptr_t object_table_index_; | 224 const intptr_t object_table_index_; |
| 218 const intptr_t deopt_id_; | 225 const intptr_t deopt_id_; |
| 219 | 226 |
| 220 DISALLOW_COPY_AND_ASSIGN(DeoptRetAfterAddressInstr); | 227 DISALLOW_COPY_AND_ASSIGN(DeoptRetAfterAddressInstr); |
| 221 }; | 228 }; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 DISALLOW_COPY_AND_ASSIGN(DeoptSuffixInstr); | 563 DISALLOW_COPY_AND_ASSIGN(DeoptSuffixInstr); |
| 557 }; | 564 }; |
| 558 | 565 |
| 559 | 566 |
| 560 intptr_t DeoptInstr::DecodeSuffix(intptr_t from_index, intptr_t* info_number) { | 567 intptr_t DeoptInstr::DecodeSuffix(intptr_t from_index, intptr_t* info_number) { |
| 561 *info_number = DeoptSuffixInstr::InfoNumber::decode(from_index); | 568 *info_number = DeoptSuffixInstr::InfoNumber::decode(from_index); |
| 562 return DeoptSuffixInstr::SuffixLength::decode(from_index); | 569 return DeoptSuffixInstr::SuffixLength::decode(from_index); |
| 563 } | 570 } |
| 564 | 571 |
| 565 | 572 |
| 573 uword DeoptInstr::GetRetAfterAddress(intptr_t from_index, |
| 574 const Array& object_table, |
| 575 Function* func) { |
| 576 ASSERT(!object_table.IsNull()); |
| 577 ASSERT(func != NULL); |
| 578 intptr_t object_table_index; |
| 579 intptr_t deopt_id; |
| 580 DeoptRetAfterAddressInstr::GetEncodedValues(from_index, |
| 581 &object_table_index, |
| 582 &deopt_id); |
| 583 *func ^= object_table.At(object_table_index); |
| 584 const Code& code = Code::Handle(func->unoptimized_code()); |
| 585 return code.GetDeoptAfterPcAtDeoptId(deopt_id); |
| 586 } |
| 587 |
| 588 |
| 566 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { | 589 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { |
| 567 Kind kind = static_cast<Kind>(kind_as_int); | 590 Kind kind = static_cast<Kind>(kind_as_int); |
| 568 switch (kind) { | 591 switch (kind) { |
| 569 case kStackSlot: return new DeoptStackSlotInstr(from_index); | 592 case kStackSlot: return new DeoptStackSlotInstr(from_index); |
| 570 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); | 593 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); |
| 571 case kInt64StackSlot: return new DeoptInt64StackSlotInstr(from_index); | 594 case kInt64StackSlot: return new DeoptInt64StackSlotInstr(from_index); |
| 572 case kRetAfterAddress: return new DeoptRetAfterAddressInstr(from_index); | 595 case kRetAfterAddress: return new DeoptRetAfterAddressInstr(from_index); |
| 573 case kRetBeforeAddress: return new DeoptRetBeforeAddressInstr(from_index); | 596 case kRetBeforeAddress: return new DeoptRetBeforeAddressInstr(from_index); |
| 574 case kConstant: return new DeoptConstantInstr(from_index); | 597 case kConstant: return new DeoptConstantInstr(from_index); |
| 575 case kRegister: return new DeoptRegisterInstr(from_index); | 598 case kRegister: return new DeoptRegisterInstr(from_index); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 Smi* offset, | 817 Smi* offset, |
| 795 DeoptInfo* info, | 818 DeoptInfo* info, |
| 796 Smi* reason) { | 819 Smi* reason) { |
| 797 intptr_t i = index * kEntrySize; | 820 intptr_t i = index * kEntrySize; |
| 798 *offset ^= table.At(i); | 821 *offset ^= table.At(i); |
| 799 *info ^= table.At(i + 1); | 822 *info ^= table.At(i + 1); |
| 800 *reason ^= table.At(i + 2); | 823 *reason ^= table.At(i + 2); |
| 801 } | 824 } |
| 802 | 825 |
| 803 } // namespace dart | 826 } // namespace dart |
| OLD | NEW |