Chromium Code Reviews| 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_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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 203 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
| 204 Function& function = Function::Handle(deopt_context->isolate()); | 204 Function& function = Function::Handle(deopt_context->isolate()); |
| 205 function |= deopt_context->ObjectAt(object_table_index_); | 205 function |= deopt_context->ObjectAt(object_table_index_); |
| 206 const Code& code = | 206 const Code& code = |
| 207 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); | 207 Code::Handle(deopt_context->isolate(), function.unoptimized_code()); |
| 208 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); | 208 uword continue_at_pc = code.GetDeoptAfterPcAtDeoptId(deopt_id_); |
| 209 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); | 209 intptr_t* to_addr = deopt_context->GetToFrameAddressAt(to_index); |
| 210 *to_addr = continue_at_pc; | 210 *to_addr = continue_at_pc; |
| 211 } | 211 } |
| 212 | 212 |
| 213 static void GetEncodedValues(intptr_t from_index, | 213 intptr_t object_table_index() const { return object_table_index_; } |
| 214 intptr_t* object_table_index, | 214 intptr_t deopt_id() const { return deopt_id_; } |
| 215 intptr_t* deopt_id) { | |
| 216 *object_table_index = ObjectTableIndex::decode(from_index); | |
| 217 *deopt_id = DeoptId::decode(from_index); | |
| 218 } | |
| 219 | 215 |
| 220 private: | 216 private: |
| 221 static const intptr_t kFieldWidth = kBitsPerWord / 2; | 217 static const intptr_t kFieldWidth = kBitsPerWord / 2; |
| 222 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; | 218 class ObjectTableIndex : public BitField<intptr_t, 0, kFieldWidth> { }; |
| 223 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; | 219 class DeoptId : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; |
| 224 | 220 |
| 225 const intptr_t object_table_index_; | 221 const intptr_t object_table_index_; |
| 226 const intptr_t deopt_id_; | 222 const intptr_t deopt_id_; |
| 227 | 223 |
| 228 DISALLOW_COPY_AND_ASSIGN(DeoptRetAfterAddressInstr); | 224 DISALLOW_COPY_AND_ASSIGN(DeoptRetAfterAddressInstr); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 | 537 |
| 542 virtual const char* ToCString() const { | 538 virtual const char* ToCString() const { |
| 543 const char* format = "suffix %"Pd":%"Pd; | 539 const char* format = "suffix %"Pd":%"Pd; |
| 544 intptr_t len = OS::SNPrint(NULL, 0, format, info_number_, suffix_length_); | 540 intptr_t len = OS::SNPrint(NULL, 0, format, info_number_, suffix_length_); |
| 545 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); | 541 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len + 1); |
| 546 OS::SNPrint(chars, len + 1, format, info_number_, suffix_length_); | 542 OS::SNPrint(chars, len + 1, format, info_number_, suffix_length_); |
| 547 return chars; | 543 return chars; |
| 548 } | 544 } |
| 549 | 545 |
| 550 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { | 546 void Execute(DeoptimizationContext* deopt_context, intptr_t to_index) { |
| 551 // The deoptimization info is uncompresses by translating away suffixes | 547 // The deoptimization info is uncompressed by translating away suffixes |
| 552 // before executing the instructions. | 548 // before executing the instructions. |
| 553 UNREACHABLE(); | 549 UNREACHABLE(); |
| 554 } | 550 } |
| 555 | 551 |
| 556 private: | 552 private: |
| 557 // Static decoder functions in DeoptInstr have access to the bitfield | 553 // Static decoder functions in DeoptInstr have access to the bitfield |
| 558 // definitions. | 554 // definitions. |
| 559 friend class DeoptInstr; | 555 friend class DeoptInstr; |
| 560 | 556 |
| 561 static const intptr_t kFieldWidth = kBitsPerWord / 2; | 557 static const intptr_t kFieldWidth = kBitsPerWord / 2; |
| 562 class InfoNumber : public BitField<intptr_t, 0, kFieldWidth> { }; | 558 class InfoNumber : public BitField<intptr_t, 0, kFieldWidth> { }; |
| 563 class SuffixLength : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; | 559 class SuffixLength : public BitField<intptr_t, kFieldWidth, kFieldWidth> { }; |
| 564 | 560 |
| 565 const intptr_t info_number_; | 561 const intptr_t info_number_; |
| 566 const intptr_t suffix_length_; | 562 const intptr_t suffix_length_; |
| 567 | 563 |
| 568 DISALLOW_COPY_AND_ASSIGN(DeoptSuffixInstr); | 564 DISALLOW_COPY_AND_ASSIGN(DeoptSuffixInstr); |
| 569 }; | 565 }; |
| 570 | 566 |
| 571 | 567 |
| 572 intptr_t DeoptInstr::DecodeSuffix(intptr_t from_index, intptr_t* info_number) { | 568 intptr_t DeoptInstr::DecodeSuffix(intptr_t from_index, intptr_t* info_number) { |
| 573 *info_number = DeoptSuffixInstr::InfoNumber::decode(from_index); | 569 *info_number = DeoptSuffixInstr::InfoNumber::decode(from_index); |
| 574 return DeoptSuffixInstr::SuffixLength::decode(from_index); | 570 return DeoptSuffixInstr::SuffixLength::decode(from_index); |
| 575 } | 571 } |
| 576 | 572 |
| 577 | 573 |
| 578 uword DeoptInstr::GetRetAfterAddress(intptr_t from_index, | 574 uword DeoptInstr::GetRetAfterAddress(DeoptInstr* instr, |
| 579 const Array& object_table, | 575 const Array& object_table, |
| 580 Function* func) { | 576 Function* func) { |
| 577 ASSERT(instr->kind() == kRetAfterAddress); | |
| 578 DeoptRetAfterAddressInstr* ret_after_instr = | |
| 579 static_cast<DeoptRetAfterAddressInstr*>(instr); | |
| 581 ASSERT(!object_table.IsNull()); | 580 ASSERT(!object_table.IsNull()); |
| 582 ASSERT(func != NULL); | 581 ASSERT(func != NULL); |
| 583 intptr_t object_table_index; | 582 *func |= object_table.At(ret_after_instr->object_table_index()); |
|
srdjan
2013/01/28 18:03:58
You need to sync, there is no more |=
Florian Schneider
2013/01/29 12:19:07
Done.
| |
| 584 intptr_t deopt_id; | |
| 585 DeoptRetAfterAddressInstr::GetEncodedValues(from_index, | |
| 586 &object_table_index, | |
| 587 &deopt_id); | |
| 588 *func |= object_table.At(object_table_index); | |
| 589 const Code& code = Code::Handle(func->unoptimized_code()); | 583 const Code& code = Code::Handle(func->unoptimized_code()); |
| 590 return code.GetDeoptAfterPcAtDeoptId(deopt_id); | 584 return code.GetDeoptAfterPcAtDeoptId(ret_after_instr->deopt_id()); |
| 591 } | 585 } |
| 592 | 586 |
| 593 | 587 |
| 594 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { | 588 DeoptInstr* DeoptInstr::Create(intptr_t kind_as_int, intptr_t from_index) { |
| 595 Kind kind = static_cast<Kind>(kind_as_int); | 589 Kind kind = static_cast<Kind>(kind_as_int); |
| 596 switch (kind) { | 590 switch (kind) { |
| 597 case kStackSlot: return new DeoptStackSlotInstr(from_index); | 591 case kStackSlot: return new DeoptStackSlotInstr(from_index); |
| 598 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); | 592 case kDoubleStackSlot: return new DeoptDoubleStackSlotInstr(from_index); |
| 599 case kInt64StackSlot: return new DeoptInt64StackSlotInstr(from_index); | 593 case kInt64StackSlot: return new DeoptInt64StackSlotInstr(from_index); |
| 600 case kRetAfterAddress: return new DeoptRetAfterAddressInstr(from_index); | 594 case kRetAfterAddress: return new DeoptRetAfterAddressInstr(from_index); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 Smi* offset, | 816 Smi* offset, |
| 823 DeoptInfo* info, | 817 DeoptInfo* info, |
| 824 Smi* reason) { | 818 Smi* reason) { |
| 825 intptr_t i = index * kEntrySize; | 819 intptr_t i = index * kEntrySize; |
| 826 *offset |= table.At(i); | 820 *offset |= table.At(i); |
| 827 *info |= table.At(i + 1); | 821 *info |= table.At(i + 1); |
| 828 *reason |= table.At(i + 2); | 822 *reason |= table.At(i + 2); |
| 829 } | 823 } |
| 830 | 824 |
| 831 } // namespace dart | 825 } // namespace dart |
| OLD | NEW |