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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 6762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6773 index += OS::SNPrint((buffer + index), | 6773 index += OS::SNPrint((buffer + index), |
6774 (len - index), | 6774 (len - index), |
6775 kFormat, | 6775 kFormat, |
6776 TryIndex(i), | 6776 TryIndex(i), |
6777 HandlerPC(i)); | 6777 HandlerPC(i)); |
6778 } | 6778 } |
6779 return buffer; | 6779 return buffer; |
6780 } | 6780 } |
6781 | 6781 |
6782 | 6782 |
6783 intptr_t DeoptInfo::Length() const { | 6783 intptr_t DeoptInfo::GetLength() const { |
6784 return Smi::Value(raw_ptr()->length_); | 6784 return Smi::Value(raw_ptr()->length_); |
6785 } | 6785 } |
6786 | 6786 |
6787 | 6787 |
6788 intptr_t DeoptInfo::FromIndex(intptr_t index) const { | 6788 intptr_t DeoptInfo::FromIndex(intptr_t index) const { |
6789 return *(EntryAddr(index, kFromIndex)); | 6789 return *(EntryAddr(index, kFromIndex)); |
6790 } | 6790 } |
6791 | 6791 |
6792 | 6792 |
6793 intptr_t DeoptInfo::Instruction(intptr_t index) const { | 6793 intptr_t DeoptInfo::Instruction(intptr_t index) const { |
6794 return *(EntryAddr(index, kInstruction)); | 6794 return *(EntryAddr(index, kInstruction)); |
6795 } | 6795 } |
6796 | 6796 |
6797 | 6797 |
| 6798 intptr_t DeoptInfo::TranslationLength() const { |
| 6799 intptr_t length = GetLength(); |
| 6800 if (Instruction(length - 1) != DeoptInstr::kSuffix) return length; |
| 6801 |
| 6802 // If the last command is a suffix, add in the length of the suffix and |
| 6803 // do not count the suffix command as a translation command. |
| 6804 intptr_t ignored = 0; |
| 6805 intptr_t suffix_length = |
| 6806 DeoptInstr::DecodeSuffix(FromIndex(length - 1), &ignored); |
| 6807 return length + suffix_length - 1; |
| 6808 } |
| 6809 |
| 6810 |
| 6811 void DeoptInfo::ToInstructions(const Array& table, |
| 6812 GrowableArray<DeoptInstr*>* instructions) const { |
| 6813 ASSERT(instructions->is_empty()); |
| 6814 Smi& offset = Smi::Handle(); |
| 6815 DeoptInfo& info = DeoptInfo::Handle(raw()); |
| 6816 Smi& reason = Smi::Handle(); |
| 6817 intptr_t index = 0; |
| 6818 intptr_t length = TranslationLength(); |
| 6819 while (index < length) { |
| 6820 intptr_t instruction = info.Instruction(index); |
| 6821 intptr_t from_index = info.FromIndex(index); |
| 6822 if (instruction == DeoptInstr::kSuffix) { |
| 6823 // Suffix instructions cause us to 'jump' to another translation, |
| 6824 // changing info, length and index. |
| 6825 intptr_t info_number = 0; |
| 6826 intptr_t suffix_length = |
| 6827 DeoptInstr::DecodeSuffix(from_index, &info_number); |
| 6828 DeoptTable::GetEntry(table, info_number, &offset, &info, &reason); |
| 6829 length = info.TranslationLength(); |
| 6830 index = length - suffix_length; |
| 6831 } else { |
| 6832 instructions->Add(DeoptInstr::Create(instruction, from_index)); |
| 6833 ++index; |
| 6834 } |
| 6835 } |
| 6836 } |
| 6837 |
| 6838 |
6798 const char* DeoptInfo::ToCString() const { | 6839 const char* DeoptInfo::ToCString() const { |
6799 if (Length() == 0) { | 6840 if (GetLength() == 0) { |
6800 return "No DeoptInfo"; | 6841 return "No DeoptInfo"; |
6801 } | 6842 } |
6802 // Convert to DeoptInstr. | 6843 // Convert to DeoptInstr. |
6803 GrowableArray<DeoptInstr*> deopt_instrs(Length()); | 6844 GrowableArray<DeoptInstr*> deopt_instrs(GetLength()); |
6804 for (intptr_t i = 0; i < Length(); i++) { | 6845 for (intptr_t i = 0; i < GetLength(); i++) { |
6805 deopt_instrs.Add(DeoptInstr::Create(Instruction(i), FromIndex(i))); | 6846 deopt_instrs.Add(DeoptInstr::Create(Instruction(i), FromIndex(i))); |
6806 } | 6847 } |
6807 // Compute the buffer size required. | 6848 // Compute the buffer size required. |
6808 intptr_t len = 1; // Trailing '\0'. | 6849 intptr_t len = 1; // Trailing '\0'. |
6809 for (intptr_t i = 0; i < Length(); i++) { | 6850 for (intptr_t i = 0; i < GetLength(); i++) { |
6810 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); | 6851 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); |
6811 } | 6852 } |
6812 // Allocate the buffer. | 6853 // Allocate the buffer. |
6813 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 6854 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
6814 // Layout the fields in the buffer. | 6855 // Layout the fields in the buffer. |
6815 intptr_t index = 0; | 6856 intptr_t index = 0; |
6816 for (intptr_t i = 0; i < Length(); i++) { | 6857 for (intptr_t i = 0; i < GetLength(); i++) { |
6817 index += OS::SNPrint((buffer + index), | 6858 index += OS::SNPrint((buffer + index), |
6818 (len - index), | 6859 (len - index), |
6819 "[%s]", | 6860 "[%s]", |
6820 deopt_instrs[i]->ToCString()); | 6861 deopt_instrs[i]->ToCString()); |
6821 } | 6862 } |
6822 return buffer; | 6863 return buffer; |
6823 } | 6864 } |
6824 | 6865 |
6825 | 6866 |
6826 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) { | 6867 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) { |
(...skipping 5342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12169 } | 12210 } |
12170 return result.raw(); | 12211 return result.raw(); |
12171 } | 12212 } |
12172 | 12213 |
12173 | 12214 |
12174 const char* WeakProperty::ToCString() const { | 12215 const char* WeakProperty::ToCString() const { |
12175 return "_WeakProperty"; | 12216 return "_WeakProperty"; |
12176 } | 12217 } |
12177 | 12218 |
12178 } // namespace dart | 12219 } // namespace dart |
OLD | NEW |