Chromium Code Reviews| 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/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 135 RawClass* Object::library_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 136 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 136 RawClass* Object::namespace_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 137 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 137 RawClass* Object::code_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 138 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 138 RawClass* Object::instructions_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 139 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 139 RawClass* Object::pc_descriptors_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 140 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 140 RawClass* Object::stackmap_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 141 RawClass* Object::var_descriptors_class_ = | 141 RawClass* Object::var_descriptors_class_ = |
| 142 reinterpret_cast<RawClass*>(RAW_NULL); | 142 reinterpret_cast<RawClass*>(RAW_NULL); |
| 143 RawClass* Object::exception_handlers_class_ = | 143 RawClass* Object::exception_handlers_class_ = |
| 144 reinterpret_cast<RawClass*>(RAW_NULL); | 144 reinterpret_cast<RawClass*>(RAW_NULL); |
| 145 RawClass* Object::deopt_info_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | |
| 146 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 145 RawClass* Object::context_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 147 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 146 RawClass* Object::context_scope_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 148 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 147 RawClass* Object::icdata_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 149 RawClass* Object::megamorphic_cache_class_ = | 148 RawClass* Object::megamorphic_cache_class_ = |
| 150 reinterpret_cast<RawClass*>(RAW_NULL); | 149 reinterpret_cast<RawClass*>(RAW_NULL); |
| 151 RawClass* Object::subtypetestcache_class_ = | 150 RawClass* Object::subtypetestcache_class_ = |
| 152 reinterpret_cast<RawClass*>(RAW_NULL); | 151 reinterpret_cast<RawClass*>(RAW_NULL); |
| 153 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 152 RawClass* Object::api_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 154 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 153 RawClass* Object::language_error_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 155 RawClass* Object::unhandled_exception_class_ = | 154 RawClass* Object::unhandled_exception_class_ = |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 | 551 |
| 553 cls = Class::New<Stackmap>(); | 552 cls = Class::New<Stackmap>(); |
| 554 stackmap_class_ = cls.raw(); | 553 stackmap_class_ = cls.raw(); |
| 555 | 554 |
| 556 cls = Class::New<LocalVarDescriptors>(); | 555 cls = Class::New<LocalVarDescriptors>(); |
| 557 var_descriptors_class_ = cls.raw(); | 556 var_descriptors_class_ = cls.raw(); |
| 558 | 557 |
| 559 cls = Class::New<ExceptionHandlers>(); | 558 cls = Class::New<ExceptionHandlers>(); |
| 560 exception_handlers_class_ = cls.raw(); | 559 exception_handlers_class_ = cls.raw(); |
| 561 | 560 |
| 562 cls = Class::New<DeoptInfo>(); | |
| 563 deopt_info_class_ = cls.raw(); | |
| 564 | |
| 565 cls = Class::New<Context>(); | 561 cls = Class::New<Context>(); |
| 566 context_class_ = cls.raw(); | 562 context_class_ = cls.raw(); |
| 567 | 563 |
| 568 cls = Class::New<ContextScope>(); | 564 cls = Class::New<ContextScope>(); |
| 569 context_scope_class_ = cls.raw(); | 565 context_scope_class_ = cls.raw(); |
| 570 | 566 |
| 571 cls = Class::New<ICData>(); | 567 cls = Class::New<ICData>(); |
| 572 icdata_class_ = cls.raw(); | 568 icdata_class_ = cls.raw(); |
| 573 | 569 |
| 574 cls = Class::New<MegamorphicCache>(); | 570 cls = Class::New<MegamorphicCache>(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 SET_CLASS_NAME(token_stream, TokenStream); | 805 SET_CLASS_NAME(token_stream, TokenStream); |
| 810 SET_CLASS_NAME(script, Script); | 806 SET_CLASS_NAME(script, Script); |
| 811 SET_CLASS_NAME(library, LibraryClass); | 807 SET_CLASS_NAME(library, LibraryClass); |
| 812 SET_CLASS_NAME(namespace, Namespace); | 808 SET_CLASS_NAME(namespace, Namespace); |
| 813 SET_CLASS_NAME(code, Code); | 809 SET_CLASS_NAME(code, Code); |
| 814 SET_CLASS_NAME(instructions, Instructions); | 810 SET_CLASS_NAME(instructions, Instructions); |
| 815 SET_CLASS_NAME(pc_descriptors, PcDescriptors); | 811 SET_CLASS_NAME(pc_descriptors, PcDescriptors); |
| 816 SET_CLASS_NAME(stackmap, Stackmap); | 812 SET_CLASS_NAME(stackmap, Stackmap); |
| 817 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); | 813 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); |
| 818 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); | 814 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); |
| 819 SET_CLASS_NAME(deopt_info, DeoptInfo); | |
| 820 SET_CLASS_NAME(context, Context); | 815 SET_CLASS_NAME(context, Context); |
| 821 SET_CLASS_NAME(context_scope, ContextScope); | 816 SET_CLASS_NAME(context_scope, ContextScope); |
| 822 SET_CLASS_NAME(icdata, ICData); | 817 SET_CLASS_NAME(icdata, ICData); |
| 823 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); | 818 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); |
| 824 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); | 819 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); |
| 825 SET_CLASS_NAME(api_error, ApiError); | 820 SET_CLASS_NAME(api_error, ApiError); |
| 826 SET_CLASS_NAME(language_error, LanguageError); | 821 SET_CLASS_NAME(language_error, LanguageError); |
| 827 SET_CLASS_NAME(unhandled_exception, UnhandledException); | 822 SET_CLASS_NAME(unhandled_exception, UnhandledException); |
| 828 SET_CLASS_NAME(unwind_error, UnwindError); | 823 SET_CLASS_NAME(unwind_error, UnwindError); |
| 829 | 824 |
| (...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3202 case kInstructionsCid: | 3197 case kInstructionsCid: |
| 3203 return Symbols::Instructions().raw(); | 3198 return Symbols::Instructions().raw(); |
| 3204 case kPcDescriptorsCid: | 3199 case kPcDescriptorsCid: |
| 3205 return Symbols::PcDescriptors().raw(); | 3200 return Symbols::PcDescriptors().raw(); |
| 3206 case kStackmapCid: | 3201 case kStackmapCid: |
| 3207 return Symbols::Stackmap().raw(); | 3202 return Symbols::Stackmap().raw(); |
| 3208 case kLocalVarDescriptorsCid: | 3203 case kLocalVarDescriptorsCid: |
| 3209 return Symbols::LocalVarDescriptors().raw(); | 3204 return Symbols::LocalVarDescriptors().raw(); |
| 3210 case kExceptionHandlersCid: | 3205 case kExceptionHandlersCid: |
| 3211 return Symbols::ExceptionHandlers().raw(); | 3206 return Symbols::ExceptionHandlers().raw(); |
| 3212 case kDeoptInfoCid: | |
| 3213 return Symbols::DeoptInfo().raw(); | |
| 3214 case kContextCid: | 3207 case kContextCid: |
| 3215 return Symbols::Context().raw(); | 3208 return Symbols::Context().raw(); |
| 3216 case kContextScopeCid: | 3209 case kContextScopeCid: |
| 3217 return Symbols::ContextScope().raw(); | 3210 return Symbols::ContextScope().raw(); |
| 3218 case kICDataCid: | 3211 case kICDataCid: |
| 3219 return Symbols::ICData().raw(); | 3212 return Symbols::ICData().raw(); |
| 3220 case kMegamorphicCacheCid: | 3213 case kMegamorphicCacheCid: |
| 3221 return Symbols::MegamorphicCache().raw(); | 3214 return Symbols::MegamorphicCache().raw(); |
| 3222 case kSubtypeTestCacheCid: | 3215 case kSubtypeTestCacheCid: |
| 3223 return Symbols::SubtypeTestCache().raw(); | 3216 return Symbols::SubtypeTestCache().raw(); |
| (...skipping 7909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11133 return buffer; | 11126 return buffer; |
| 11134 } | 11127 } |
| 11135 | 11128 |
| 11136 | 11129 |
| 11137 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, | 11130 void ExceptionHandlers::PrintJSONImpl(JSONStream* stream, |
| 11138 bool ref) const { | 11131 bool ref) const { |
| 11139 Object::PrintJSONImpl(stream, ref); | 11132 Object::PrintJSONImpl(stream, ref); |
| 11140 } | 11133 } |
| 11141 | 11134 |
| 11142 | 11135 |
| 11143 intptr_t DeoptInfo::Length() const { | 11136 intptr_t DeoptInfo::FrameSize(const TypedData& packed) { |
| 11144 return Smi::Value(raw_ptr()->length_); | 11137 NoSafepointScope no_safepoint; |
| 11138 typedef ReadStream::Raw<sizeof(intptr_t), intptr_t> Reader; | |
| 11139 ReadStream read_stream(reinterpret_cast<uint8_t*>(packed.DataAddr(0)), | |
| 11140 packed.LengthInBytes()); | |
| 11141 return Reader::Read(&read_stream); | |
| 11145 } | 11142 } |
| 11146 | 11143 |
| 11147 | 11144 |
| 11148 intptr_t DeoptInfo::FromIndex(intptr_t index) const { | 11145 intptr_t DeoptInfo::NumMaterializations( |
| 11149 NoSafepointScope no_safepoint; | 11146 const GrowableArray<DeoptInstr*>& unpacked) { |
| 11150 return *(EntryAddr(index, kFromIndex)); | 11147 intptr_t num = 0; |
| 11148 while (unpacked[num]->kind() == DeoptInstr::kMaterializeObject) { | |
| 11149 num++; | |
| 11150 } | |
| 11151 return num; | |
| 11151 } | 11152 } |
| 11152 | 11153 |
| 11153 | 11154 |
| 11154 intptr_t DeoptInfo::Instruction(intptr_t index) const { | 11155 void DeoptInfo::UnpackInto(const Array& table, |
| 11156 const TypedData& packed, | |
| 11157 GrowableArray<DeoptInstr*>* unpacked, | |
| 11158 intptr_t length) { | |
| 11155 NoSafepointScope no_safepoint; | 11159 NoSafepointScope no_safepoint; |
| 11156 return *(EntryAddr(index, kInstruction)); | 11160 typedef ReadStream::Raw<sizeof(intptr_t), intptr_t> Reader; |
| 11157 } | 11161 ReadStream read_stream(reinterpret_cast<uint8_t*>(packed.DataAddr(0)), |
| 11162 packed.LengthInBytes()); | |
| 11163 const intptr_t frame_size = Reader::Read(&read_stream); // Skip frame size. | |
| 11164 USE(frame_size); | |
| 11158 | 11165 |
| 11166 const intptr_t suffix_length = Reader::Read(&read_stream); | |
| 11167 if (suffix_length != 0) { | |
| 11168 ASSERT(suffix_length > 1); | |
| 11169 const intptr_t info_number = Reader::Read(&read_stream); | |
| 11159 | 11170 |
| 11160 intptr_t DeoptInfo::FrameSize() const { | 11171 TypedData& suffix = TypedData::Handle(); |
| 11161 return TranslationLength() - NumMaterializations(); | 11172 Smi& offset = Smi::Handle(); |
| 11162 } | 11173 Smi& reason_and_flags = Smi::Handle(); |
| 11174 DeoptTable::GetEntry( | |
| 11175 table, info_number, &offset, &suffix, &reason_and_flags); | |
| 11176 UnpackInto(table, suffix, unpacked, suffix_length); | |
| 11177 } | |
| 11163 | 11178 |
| 11164 | 11179 while ((read_stream.PendingBytes() > 0) && |
| 11165 intptr_t DeoptInfo::TranslationLength() const { | 11180 (unpacked->length() < length)) { |
| 11166 intptr_t length = Length(); | 11181 const intptr_t instruction = Reader::Read(&read_stream); |
| 11167 if (Instruction(length - 1) != DeoptInstr::kSuffix) return length; | 11182 const intptr_t from_index = Reader::Read(&read_stream); |
| 11168 | 11183 unpacked->Add(DeoptInstr::Create(instruction, from_index)); |
| 11169 // If the last command is a suffix, add in the length of the suffix and | |
| 11170 // do not count the suffix command as a translation command. | |
| 11171 intptr_t ignored = 0; | |
| 11172 intptr_t suffix_length = | |
| 11173 DeoptInstr::DecodeSuffix(FromIndex(length - 1), &ignored); | |
| 11174 return length + suffix_length - 1; | |
| 11175 } | |
| 11176 | |
| 11177 | |
| 11178 intptr_t DeoptInfo::NumMaterializations() const { | |
| 11179 intptr_t pos = 0; | |
| 11180 while (Instruction(pos) == DeoptInstr::kMaterializeObject) { | |
| 11181 pos++; | |
| 11182 } | |
| 11183 return pos; | |
| 11184 } | |
| 11185 | |
| 11186 | |
| 11187 void DeoptInfo::ToInstructions(const Array& table, | |
| 11188 GrowableArray<DeoptInstr*>* instructions) const { | |
| 11189 ASSERT(instructions->is_empty()); | |
| 11190 Smi& offset = Smi::Handle(); | |
| 11191 DeoptInfo& info = DeoptInfo::Handle(raw()); | |
| 11192 Smi& reason_and_flags = Smi::Handle(); | |
| 11193 intptr_t index = 0; | |
| 11194 intptr_t length = TranslationLength(); | |
| 11195 while (index < length) { | |
| 11196 intptr_t instruction = info.Instruction(index); | |
| 11197 intptr_t from_index = info.FromIndex(index); | |
| 11198 if (instruction == DeoptInstr::kSuffix) { | |
| 11199 // Suffix instructions cause us to 'jump' to another translation, | |
| 11200 // changing info, length and index. | |
| 11201 intptr_t info_number = 0; | |
| 11202 intptr_t suffix_length = | |
| 11203 DeoptInstr::DecodeSuffix(from_index, &info_number); | |
| 11204 DeoptTable::GetEntry( | |
| 11205 table, info_number, &offset, &info, &reason_and_flags); | |
| 11206 length = info.TranslationLength(); | |
| 11207 index = length - suffix_length; | |
| 11208 } else { | |
| 11209 instructions->Add(DeoptInstr::Create(instruction, from_index)); | |
| 11210 ++index; | |
| 11211 } | |
| 11212 } | 11184 } |
| 11213 } | 11185 } |
| 11214 | 11186 |
| 11215 | 11187 |
| 11216 const char* DeoptInfo::ToCString() const { | 11188 void DeoptInfo::Unpack(const Array& table, |
| 11217 if (Length() == 0) { | 11189 const TypedData& packed, |
| 11218 return "No DeoptInfo"; | 11190 GrowableArray<DeoptInstr*>* unpacked) { |
| 11191 ASSERT(unpacked->is_empty()); | |
| 11192 UnpackInto(table, packed, unpacked, kMaxInt32); | |
|
Ivan Posva
2015/04/08 07:12:13
It is not really obvious why kMaxInt32 is being pa
Vyacheslav Egorov (Google)
2015/04/08 13:07:39
Done.
| |
| 11193 | |
| 11194 const intptr_t length = unpacked->length(); | |
|
Florian Schneider
2015/04/08 08:50:04
Add a reverse method to GrowableArray?
Vyacheslav Egorov (Google)
2015/04/08 13:07:39
Done.
| |
| 11195 for (intptr_t i = 0; i < length / 2; i++) { | |
| 11196 intptr_t j = length - 1 - i; | |
| 11197 DeoptInstr* temp = (*unpacked)[i]; | |
| 11198 (*unpacked)[i] = (*unpacked)[j]; | |
| 11199 (*unpacked)[j] = temp; | |
| 11219 } | 11200 } |
| 11220 // Convert to DeoptInstr. | 11201 } |
| 11221 GrowableArray<DeoptInstr*> deopt_instrs(Length()); | 11202 |
| 11222 for (intptr_t i = 0; i < Length(); i++) { | 11203 |
| 11223 deopt_instrs.Add(DeoptInstr::Create(Instruction(i), FromIndex(i))); | 11204 const char* DeoptInfo::ToCString(const Array& deopt_table, |
| 11224 } | 11205 const TypedData& packed) { |
| 11206 GrowableArray<DeoptInstr*> deopt_instrs; | |
| 11207 Unpack(deopt_table, packed, &deopt_instrs); | |
| 11208 | |
| 11225 // Compute the buffer size required. | 11209 // Compute the buffer size required. |
| 11226 intptr_t len = 1; // Trailing '\0'. | 11210 intptr_t len = 1; // Trailing '\0'. |
| 11227 for (intptr_t i = 0; i < Length(); i++) { | 11211 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
| 11228 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); | 11212 len += OS::SNPrint(NULL, 0, "[%s]", deopt_instrs[i]->ToCString()); |
| 11229 } | 11213 } |
| 11214 | |
| 11230 // Allocate the buffer. | 11215 // Allocate the buffer. |
| 11231 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 11216 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 11217 | |
| 11232 // Layout the fields in the buffer. | 11218 // Layout the fields in the buffer. |
| 11233 intptr_t index = 0; | 11219 intptr_t index = 0; |
| 11234 for (intptr_t i = 0; i < Length(); i++) { | 11220 for (intptr_t i = 0; i < deopt_instrs.length(); i++) { |
| 11235 index += OS::SNPrint((buffer + index), | 11221 index += OS::SNPrint((buffer + index), |
| 11236 (len - index), | 11222 (len - index), |
| 11237 "[%s]", | 11223 "[%s]", |
| 11238 deopt_instrs[i]->ToCString()); | 11224 deopt_instrs[i]->ToCString()); |
| 11239 } | 11225 } |
| 11226 | |
| 11240 return buffer; | 11227 return buffer; |
| 11241 } | 11228 } |
| 11242 | 11229 |
| 11243 | 11230 |
| 11244 // Returns a bool so it can be asserted. | 11231 // Returns a bool so it can be asserted. |
| 11245 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original, | 11232 bool DeoptInfo::VerifyDecompression(const GrowableArray<DeoptInstr*>& original, |
| 11246 const Array& deopt_table) const { | 11233 const Array& deopt_table, |
| 11247 intptr_t length = TranslationLength(); | 11234 const TypedData& packed) { |
| 11248 GrowableArray<DeoptInstr*> unpacked(length); | 11235 GrowableArray<DeoptInstr*> unpacked; |
| 11249 ToInstructions(deopt_table, &unpacked); | 11236 Unpack(deopt_table, packed, &unpacked); |
| 11250 ASSERT(unpacked.length() == original.length()); | 11237 ASSERT(unpacked.length() == original.length()); |
| 11251 for (intptr_t i = 0; i < unpacked.length(); ++i) { | 11238 for (intptr_t i = 0; i < unpacked.length(); ++i) { |
| 11252 ASSERT(unpacked[i]->Equals(*original[i])); | 11239 ASSERT(unpacked[i]->Equals(*original[i])); |
| 11253 } | 11240 } |
| 11254 return true; | 11241 return true; |
| 11255 } | 11242 } |
| 11256 | 11243 |
| 11257 | 11244 |
| 11258 void DeoptInfo::PrintJSONImpl(JSONStream* stream, bool ref) const { | |
| 11259 Object::PrintJSONImpl(stream, ref); | |
| 11260 } | |
| 11261 | |
| 11262 | |
| 11263 RawDeoptInfo* DeoptInfo::New(intptr_t num_commands) { | |
| 11264 ASSERT(Object::deopt_info_class() != Class::null()); | |
| 11265 if ((num_commands < 0) || (num_commands > kMaxElements)) { | |
| 11266 FATAL1("Fatal error in DeoptInfo::New(): invalid num_commands %" Pd "\n", | |
| 11267 num_commands); | |
| 11268 } | |
| 11269 DeoptInfo& result = DeoptInfo::Handle(); | |
| 11270 { | |
| 11271 uword size = DeoptInfo::InstanceSize(num_commands); | |
| 11272 RawObject* raw = Object::Allocate(DeoptInfo::kClassId, | |
| 11273 size, | |
| 11274 Heap::kOld); | |
| 11275 NoSafepointScope no_safepoint; | |
| 11276 result ^= raw; | |
| 11277 result.SetLength(num_commands); | |
| 11278 } | |
| 11279 return result.raw(); | |
| 11280 } | |
| 11281 | |
| 11282 | |
| 11283 void DeoptInfo::SetLength(intptr_t value) const { | |
| 11284 // This is only safe because we create a new Smi, which does not cause | |
| 11285 // heap allocation. | |
| 11286 StoreSmi(&raw_ptr()->length_, Smi::New(value)); | |
| 11287 } | |
| 11288 | |
| 11289 | |
| 11290 void DeoptInfo::SetAt(intptr_t index, | |
| 11291 intptr_t instr_kind, | |
| 11292 intptr_t from_index) const { | |
| 11293 NoSafepointScope no_safepoint; | |
| 11294 *(EntryAddr(index, kInstruction)) = instr_kind; | |
| 11295 *(EntryAddr(index, kFromIndex)) = from_index; | |
| 11296 } | |
| 11297 | |
| 11298 | |
| 11299 const char* ICData::ToCString() const { | 11245 const char* ICData::ToCString() const { |
| 11300 const char* kFormat = "ICData target:'%s' num-args: %" Pd | 11246 const char* kFormat = "ICData target:'%s' num-args: %" Pd |
| 11301 " num-checks: %" Pd ""; | 11247 " num-checks: %" Pd ""; |
| 11302 const String& name = String::Handle(target_name()); | 11248 const String& name = String::Handle(target_name()); |
| 11303 const intptr_t num_args = NumArgsTested(); | 11249 const intptr_t num_args = NumArgsTested(); |
| 11304 const intptr_t num_checks = NumberOfChecks(); | 11250 const intptr_t num_checks = NumberOfChecks(); |
| 11305 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), | 11251 intptr_t len = OS::SNPrint(NULL, 0, kFormat, name.ToCString(), |
| 11306 num_args, num_checks) + 1; | 11252 num_args, num_checks) + 1; |
| 11307 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 11253 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 11308 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); | 11254 OS::SNPrint(chars, len, kFormat, name.ToCString(), num_args, num_checks); |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12101 } | 12047 } |
| 12102 #endif // DEBUG | 12048 #endif // DEBUG |
| 12103 } | 12049 } |
| 12104 | 12050 |
| 12105 | 12051 |
| 12106 bool Code::HasBreakpoint() const { | 12052 bool Code::HasBreakpoint() const { |
| 12107 return Isolate::Current()->debugger()->HasBreakpoint(*this); | 12053 return Isolate::Current()->debugger()->HasBreakpoint(*this); |
| 12108 } | 12054 } |
| 12109 | 12055 |
| 12110 | 12056 |
| 12111 RawDeoptInfo* Code::GetDeoptInfoAtPc(uword pc, | 12057 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
| 12112 ICData::DeoptReasonId* deopt_reason, | 12058 ICData::DeoptReasonId* deopt_reason, |
| 12113 uint32_t* deopt_flags) const { | 12059 uint32_t* deopt_flags) const { |
| 12114 ASSERT(is_optimized()); | 12060 ASSERT(is_optimized()); |
| 12115 const Instructions& instrs = Instructions::Handle(instructions()); | 12061 const Instructions& instrs = Instructions::Handle(instructions()); |
| 12116 uword code_entry = instrs.EntryPoint(); | 12062 uword code_entry = instrs.EntryPoint(); |
| 12117 const Array& table = Array::Handle(deopt_info_array()); | 12063 const Array& table = Array::Handle(deopt_info_array()); |
|
Ivan Posva
2015/04/08 07:12:13
Please add a TODO here to consider removing the ta
Vyacheslav Egorov (Google)
2015/04/08 13:07:39
Done.
Though this structure needs random access,
| |
| 12118 ASSERT(!table.IsNull()); | 12064 ASSERT(!table.IsNull()); |
| 12119 // Linear search for the PC offset matching the target PC. | 12065 // Linear search for the PC offset matching the target PC. |
| 12120 intptr_t length = DeoptTable::GetLength(table); | 12066 intptr_t length = DeoptTable::GetLength(table); |
| 12121 Smi& offset = Smi::Handle(); | 12067 Smi& offset = Smi::Handle(); |
| 12122 Smi& reason_and_flags = Smi::Handle(); | 12068 Smi& reason_and_flags = Smi::Handle(); |
| 12123 DeoptInfo& info = DeoptInfo::Handle(); | 12069 TypedData& info = TypedData::Handle(); |
| 12124 for (intptr_t i = 0; i < length; ++i) { | 12070 for (intptr_t i = 0; i < length; ++i) { |
| 12125 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); | 12071 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); |
| 12126 if (pc == (code_entry + offset.Value())) { | 12072 if (pc == (code_entry + offset.Value())) { |
| 12127 ASSERT(!info.IsNull()); | 12073 ASSERT(!info.IsNull()); |
| 12128 *deopt_reason = DeoptTable::ReasonField::decode(reason_and_flags.Value()); | 12074 *deopt_reason = DeoptTable::ReasonField::decode(reason_and_flags.Value()); |
| 12129 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); | 12075 *deopt_flags = DeoptTable::FlagsField::decode(reason_and_flags.Value()); |
| 12130 return info.raw(); | 12076 return info.raw(); |
| 12131 } | 12077 } |
| 12132 } | 12078 } |
| 12133 *deopt_reason = ICData::kDeoptUnknown; | 12079 *deopt_reason = ICData::kDeoptUnknown; |
| 12134 return DeoptInfo::null(); | 12080 return TypedData::null(); |
| 12135 } | 12081 } |
| 12136 | 12082 |
| 12137 | 12083 |
| 12138 intptr_t Code::BinarySearchInSCallTable(uword pc) const { | 12084 intptr_t Code::BinarySearchInSCallTable(uword pc) const { |
| 12139 NoSafepointScope no_safepoint; | 12085 NoSafepointScope no_safepoint; |
| 12140 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); | 12086 const Array& table = Array::Handle(raw_ptr()->static_calls_target_table_); |
| 12141 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); | 12087 RawObject* key = reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); |
| 12142 intptr_t imin = 0; | 12088 intptr_t imin = 0; |
| 12143 intptr_t imax = table.Length() / kSCallTableEntryLength; | 12089 intptr_t imax = table.Length() / kSCallTableEntryLength; |
| 12144 while (imax >= imin) { | 12090 while (imax >= imin) { |
| (...skipping 8580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20725 return tag_label.ToCString(); | 20671 return tag_label.ToCString(); |
| 20726 } | 20672 } |
| 20727 | 20673 |
| 20728 | 20674 |
| 20729 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20675 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20730 Instance::PrintJSONImpl(stream, ref); | 20676 Instance::PrintJSONImpl(stream, ref); |
| 20731 } | 20677 } |
| 20732 | 20678 |
| 20733 | 20679 |
| 20734 } // namespace dart | 20680 } // namespace dart |
| OLD | NEW |