| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 | 638 |
| 639 cls = Class::New<ObjectPool>(); | 639 cls = Class::New<ObjectPool>(); |
| 640 object_pool_class_ = cls.raw(); | 640 object_pool_class_ = cls.raw(); |
| 641 | 641 |
| 642 cls = Class::New<PcDescriptors>(); | 642 cls = Class::New<PcDescriptors>(); |
| 643 pc_descriptors_class_ = cls.raw(); | 643 pc_descriptors_class_ = cls.raw(); |
| 644 | 644 |
| 645 cls = Class::New<CodeSourceMap>(); | 645 cls = Class::New<CodeSourceMap>(); |
| 646 code_source_map_class_ = cls.raw(); | 646 code_source_map_class_ = cls.raw(); |
| 647 | 647 |
| 648 cls = Class::New<Stackmap>(); | 648 cls = Class::New<StackMap>(); |
| 649 stackmap_class_ = cls.raw(); | 649 stackmap_class_ = cls.raw(); |
| 650 | 650 |
| 651 cls = Class::New<LocalVarDescriptors>(); | 651 cls = Class::New<LocalVarDescriptors>(); |
| 652 var_descriptors_class_ = cls.raw(); | 652 var_descriptors_class_ = cls.raw(); |
| 653 | 653 |
| 654 cls = Class::New<ExceptionHandlers>(); | 654 cls = Class::New<ExceptionHandlers>(); |
| 655 exception_handlers_class_ = cls.raw(); | 655 exception_handlers_class_ = cls.raw(); |
| 656 | 656 |
| 657 cls = Class::New<Context>(); | 657 cls = Class::New<Context>(); |
| 658 context_class_ = cls.raw(); | 658 context_class_ = cls.raw(); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 SET_CLASS_NAME(literal_token, LiteralToken); | 982 SET_CLASS_NAME(literal_token, LiteralToken); |
| 983 SET_CLASS_NAME(token_stream, TokenStream); | 983 SET_CLASS_NAME(token_stream, TokenStream); |
| 984 SET_CLASS_NAME(script, Script); | 984 SET_CLASS_NAME(script, Script); |
| 985 SET_CLASS_NAME(library, LibraryClass); | 985 SET_CLASS_NAME(library, LibraryClass); |
| 986 SET_CLASS_NAME(namespace, Namespace); | 986 SET_CLASS_NAME(namespace, Namespace); |
| 987 SET_CLASS_NAME(code, Code); | 987 SET_CLASS_NAME(code, Code); |
| 988 SET_CLASS_NAME(instructions, Instructions); | 988 SET_CLASS_NAME(instructions, Instructions); |
| 989 SET_CLASS_NAME(object_pool, ObjectPool); | 989 SET_CLASS_NAME(object_pool, ObjectPool); |
| 990 SET_CLASS_NAME(code_source_map, CodeSourceMap); | 990 SET_CLASS_NAME(code_source_map, CodeSourceMap); |
| 991 SET_CLASS_NAME(pc_descriptors, PcDescriptors); | 991 SET_CLASS_NAME(pc_descriptors, PcDescriptors); |
| 992 SET_CLASS_NAME(stackmap, Stackmap); | 992 SET_CLASS_NAME(stackmap, StackMap); |
| 993 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); | 993 SET_CLASS_NAME(var_descriptors, LocalVarDescriptors); |
| 994 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); | 994 SET_CLASS_NAME(exception_handlers, ExceptionHandlers); |
| 995 SET_CLASS_NAME(context, Context); | 995 SET_CLASS_NAME(context, Context); |
| 996 SET_CLASS_NAME(context_scope, ContextScope); | 996 SET_CLASS_NAME(context_scope, ContextScope); |
| 997 SET_CLASS_NAME(singletargetcache, SingleTargetCache); | 997 SET_CLASS_NAME(singletargetcache, SingleTargetCache); |
| 998 SET_CLASS_NAME(unlinkedcall, UnlinkedCall); | 998 SET_CLASS_NAME(unlinkedcall, UnlinkedCall); |
| 999 SET_CLASS_NAME(icdata, ICData); | 999 SET_CLASS_NAME(icdata, ICData); |
| 1000 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); | 1000 SET_CLASS_NAME(megamorphic_cache, MegamorphicCache); |
| 1001 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); | 1001 SET_CLASS_NAME(subtypetestcache, SubtypeTestCache); |
| 1002 SET_CLASS_NAME(api_error, ApiError); | 1002 SET_CLASS_NAME(api_error, ApiError); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 pending_classes.Add(cls); | 1308 pending_classes.Add(cls); |
| 1309 | 1309 |
| 1310 cls = Class::New<ReceivePort>(); | 1310 cls = Class::New<ReceivePort>(); |
| 1311 RegisterPrivateClass(cls, Symbols::_RawReceivePortImpl(), isolate_lib); | 1311 RegisterPrivateClass(cls, Symbols::_RawReceivePortImpl(), isolate_lib); |
| 1312 pending_classes.Add(cls); | 1312 pending_classes.Add(cls); |
| 1313 | 1313 |
| 1314 cls = Class::New<SendPort>(); | 1314 cls = Class::New<SendPort>(); |
| 1315 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); | 1315 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); |
| 1316 pending_classes.Add(cls); | 1316 pending_classes.Add(cls); |
| 1317 | 1317 |
| 1318 const Class& stacktrace_cls = Class::Handle(zone, Class::New<Stacktrace>()); | 1318 const Class& stacktrace_cls = Class::Handle(zone, Class::New<StackTrace>()); |
| 1319 RegisterPrivateClass(stacktrace_cls, Symbols::_StackTrace(), core_lib); | 1319 RegisterPrivateClass(stacktrace_cls, Symbols::_StackTrace(), core_lib); |
| 1320 pending_classes.Add(stacktrace_cls); | 1320 pending_classes.Add(stacktrace_cls); |
| 1321 // Super type set below, after Object is allocated. | 1321 // Super type set below, after Object is allocated. |
| 1322 | 1322 |
| 1323 cls = Class::New<RegExp>(); | 1323 cls = Class::New<RegExp>(); |
| 1324 RegisterPrivateClass(cls, Symbols::_RegExp(), core_lib); | 1324 RegisterPrivateClass(cls, Symbols::_RegExp(), core_lib); |
| 1325 pending_classes.Add(cls); | 1325 pending_classes.Add(cls); |
| 1326 | 1326 |
| 1327 // Initialize the base interfaces used by the core VM classes. | 1327 // Initialize the base interfaces used by the core VM classes. |
| 1328 | 1328 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 cls = Class::New<Float64x2>(); | 1533 cls = Class::New<Float64x2>(); |
| 1534 RegisterClass(cls, Symbols::Float64x2(), lib); | 1534 RegisterClass(cls, Symbols::Float64x2(), lib); |
| 1535 cls.set_num_type_arguments(0); | 1535 cls.set_num_type_arguments(0); |
| 1536 cls.set_num_own_type_arguments(0); | 1536 cls.set_num_own_type_arguments(0); |
| 1537 cls.set_is_prefinalized(); | 1537 cls.set_is_prefinalized(); |
| 1538 pending_classes.Add(cls); | 1538 pending_classes.Add(cls); |
| 1539 object_store->set_float64x2_class(cls); | 1539 object_store->set_float64x2_class(cls); |
| 1540 type = Type::NewNonParameterizedType(cls); | 1540 type = Type::NewNonParameterizedType(cls); |
| 1541 object_store->set_float64x2_type(type); | 1541 object_store->set_float64x2_type(type); |
| 1542 | 1542 |
| 1543 // Set the super type of class Stacktrace to Object type so that the | 1543 // Set the super type of class StackTrace to Object type so that the |
| 1544 // 'toString' method is implemented. | 1544 // 'toString' method is implemented. |
| 1545 type = object_store->object_type(); | 1545 type = object_store->object_type(); |
| 1546 stacktrace_cls.set_super_type(type); | 1546 stacktrace_cls.set_super_type(type); |
| 1547 | 1547 |
| 1548 // Abstract class that represents the Dart class Function. | 1548 // Abstract class that represents the Dart class Function. |
| 1549 cls = Class::New<Instance>(kIllegalCid); | 1549 cls = Class::New<Instance>(kIllegalCid); |
| 1550 cls.set_num_type_arguments(0); | 1550 cls.set_num_type_arguments(0); |
| 1551 cls.set_num_own_type_arguments(0); | 1551 cls.set_num_own_type_arguments(0); |
| 1552 cls.set_is_prefinalized(); | 1552 cls.set_is_prefinalized(); |
| 1553 RegisterClass(cls, Symbols::Function(), core_lib); | 1553 RegisterClass(cls, Symbols::Function(), core_lib); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 | 1726 |
| 1727 cls = Class::New<Bool>(); | 1727 cls = Class::New<Bool>(); |
| 1728 object_store->set_bool_class(cls); | 1728 object_store->set_bool_class(cls); |
| 1729 | 1729 |
| 1730 cls = Class::New<Instance>(kNullCid); | 1730 cls = Class::New<Instance>(kNullCid); |
| 1731 object_store->set_null_class(cls); | 1731 object_store->set_null_class(cls); |
| 1732 | 1732 |
| 1733 cls = Class::New<Capability>(); | 1733 cls = Class::New<Capability>(); |
| 1734 cls = Class::New<ReceivePort>(); | 1734 cls = Class::New<ReceivePort>(); |
| 1735 cls = Class::New<SendPort>(); | 1735 cls = Class::New<SendPort>(); |
| 1736 cls = Class::New<Stacktrace>(); | 1736 cls = Class::New<StackTrace>(); |
| 1737 cls = Class::New<RegExp>(); | 1737 cls = Class::New<RegExp>(); |
| 1738 cls = Class::New<Number>(); | 1738 cls = Class::New<Number>(); |
| 1739 | 1739 |
| 1740 cls = Class::New<WeakProperty>(); | 1740 cls = Class::New<WeakProperty>(); |
| 1741 object_store->set_weak_property_class(cls); | 1741 object_store->set_weak_property_class(cls); |
| 1742 | 1742 |
| 1743 cls = Class::New<MirrorReference>(); | 1743 cls = Class::New<MirrorReference>(); |
| 1744 cls = Class::New<UserTag>(); | 1744 cls = Class::New<UserTag>(); |
| 1745 | 1745 |
| 1746 const Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); | 1746 const Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); |
| (...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 case kCodeCid: | 3364 case kCodeCid: |
| 3365 return Symbols::Code().raw(); | 3365 return Symbols::Code().raw(); |
| 3366 case kInstructionsCid: | 3366 case kInstructionsCid: |
| 3367 return Symbols::Instructions().raw(); | 3367 return Symbols::Instructions().raw(); |
| 3368 case kObjectPoolCid: | 3368 case kObjectPoolCid: |
| 3369 return Symbols::ObjectPool().raw(); | 3369 return Symbols::ObjectPool().raw(); |
| 3370 case kCodeSourceMapCid: | 3370 case kCodeSourceMapCid: |
| 3371 return Symbols::CodeSourceMap().raw(); | 3371 return Symbols::CodeSourceMap().raw(); |
| 3372 case kPcDescriptorsCid: | 3372 case kPcDescriptorsCid: |
| 3373 return Symbols::PcDescriptors().raw(); | 3373 return Symbols::PcDescriptors().raw(); |
| 3374 case kStackmapCid: | 3374 case kStackMapCid: |
| 3375 return Symbols::Stackmap().raw(); | 3375 return Symbols::StackMap().raw(); |
| 3376 case kLocalVarDescriptorsCid: | 3376 case kLocalVarDescriptorsCid: |
| 3377 return Symbols::LocalVarDescriptors().raw(); | 3377 return Symbols::LocalVarDescriptors().raw(); |
| 3378 case kExceptionHandlersCid: | 3378 case kExceptionHandlersCid: |
| 3379 return Symbols::ExceptionHandlers().raw(); | 3379 return Symbols::ExceptionHandlers().raw(); |
| 3380 case kContextCid: | 3380 case kContextCid: |
| 3381 return Symbols::Context().raw(); | 3381 return Symbols::Context().raw(); |
| 3382 case kContextScopeCid: | 3382 case kContextScopeCid: |
| 3383 return Symbols::ContextScope().raw(); | 3383 return Symbols::ContextScope().raw(); |
| 3384 case kSingleTargetCacheCid: | 3384 case kSingleTargetCacheCid: |
| 3385 return Symbols::SingleTargetCache().raw(); | 3385 return Symbols::SingleTargetCache().raw(); |
| (...skipping 8582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11968 | 11968 |
| 11969 | 11969 |
| 11970 // Decode SLEB128 encoded integer. Update byte_index to the next integer. | 11970 // Decode SLEB128 encoded integer. Update byte_index to the next integer. |
| 11971 intptr_t CodeSourceMap::DecodeInteger(intptr_t* byte_index) const { | 11971 intptr_t CodeSourceMap::DecodeInteger(intptr_t* byte_index) const { |
| 11972 NoSafepointScope no_safepoint; | 11972 NoSafepointScope no_safepoint; |
| 11973 const uint8_t* data = raw_ptr()->data(); | 11973 const uint8_t* data = raw_ptr()->data(); |
| 11974 return DecodeSLEB128(data, Length(), byte_index); | 11974 return DecodeSLEB128(data, Length(), byte_index); |
| 11975 } | 11975 } |
| 11976 | 11976 |
| 11977 | 11977 |
| 11978 bool Stackmap::GetBit(intptr_t bit_index) const { | 11978 bool StackMap::GetBit(intptr_t bit_index) const { |
| 11979 ASSERT(InRange(bit_index)); | 11979 ASSERT(InRange(bit_index)); |
| 11980 int byte_index = bit_index >> kBitsPerByteLog2; | 11980 int byte_index = bit_index >> kBitsPerByteLog2; |
| 11981 int bit_remainder = bit_index & (kBitsPerByte - 1); | 11981 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 11982 uint8_t byte_mask = 1U << bit_remainder; | 11982 uint8_t byte_mask = 1U << bit_remainder; |
| 11983 uint8_t byte = raw_ptr()->data()[byte_index]; | 11983 uint8_t byte = raw_ptr()->data()[byte_index]; |
| 11984 return (byte & byte_mask); | 11984 return (byte & byte_mask); |
| 11985 } | 11985 } |
| 11986 | 11986 |
| 11987 | 11987 |
| 11988 void Stackmap::SetBit(intptr_t bit_index, bool value) const { | 11988 void StackMap::SetBit(intptr_t bit_index, bool value) const { |
| 11989 ASSERT(InRange(bit_index)); | 11989 ASSERT(InRange(bit_index)); |
| 11990 int byte_index = bit_index >> kBitsPerByteLog2; | 11990 int byte_index = bit_index >> kBitsPerByteLog2; |
| 11991 int bit_remainder = bit_index & (kBitsPerByte - 1); | 11991 int bit_remainder = bit_index & (kBitsPerByte - 1); |
| 11992 uint8_t byte_mask = 1U << bit_remainder; | 11992 uint8_t byte_mask = 1U << bit_remainder; |
| 11993 NoSafepointScope no_safepoint; | 11993 NoSafepointScope no_safepoint; |
| 11994 uint8_t* byte_addr = UnsafeMutableNonPointer(&raw_ptr()->data()[byte_index]); | 11994 uint8_t* byte_addr = UnsafeMutableNonPointer(&raw_ptr()->data()[byte_index]); |
| 11995 if (value) { | 11995 if (value) { |
| 11996 *byte_addr |= byte_mask; | 11996 *byte_addr |= byte_mask; |
| 11997 } else { | 11997 } else { |
| 11998 *byte_addr &= ~byte_mask; | 11998 *byte_addr &= ~byte_mask; |
| 11999 } | 11999 } |
| 12000 } | 12000 } |
| 12001 | 12001 |
| 12002 | 12002 |
| 12003 RawStackmap* Stackmap::New(intptr_t pc_offset, | 12003 RawStackMap* StackMap::New(intptr_t pc_offset, |
| 12004 BitmapBuilder* bmap, | 12004 BitmapBuilder* bmap, |
| 12005 intptr_t slow_path_bit_count) { | 12005 intptr_t slow_path_bit_count) { |
| 12006 ASSERT(Object::stackmap_class() != Class::null()); | 12006 ASSERT(Object::stackmap_class() != Class::null()); |
| 12007 ASSERT(bmap != NULL); | 12007 ASSERT(bmap != NULL); |
| 12008 Stackmap& result = Stackmap::Handle(); | 12008 StackMap& result = StackMap::Handle(); |
| 12009 // Guard against integer overflow of the instance size computation. | 12009 // Guard against integer overflow of the instance size computation. |
| 12010 intptr_t length = bmap->Length(); | 12010 intptr_t length = bmap->Length(); |
| 12011 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | 12011 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
| 12012 if ((payload_size < 0) || (payload_size > kMaxLengthInBytes)) { | 12012 if ((payload_size < 0) || (payload_size > kMaxLengthInBytes)) { |
| 12013 // This should be caught before we reach here. | 12013 // This should be caught before we reach here. |
| 12014 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n", length); | 12014 FATAL1("Fatal error in StackMap::New: invalid length %" Pd "\n", length); |
| 12015 } | 12015 } |
| 12016 { | 12016 { |
| 12017 // Stackmap data objects are associated with a code object, allocate them | 12017 // StackMap data objects are associated with a code object, allocate them |
| 12018 // in old generation. | 12018 // in old generation. |
| 12019 RawObject* raw = Object::Allocate( | 12019 RawObject* raw = Object::Allocate( |
| 12020 Stackmap::kClassId, Stackmap::InstanceSize(length), Heap::kOld); | 12020 StackMap::kClassId, StackMap::InstanceSize(length), Heap::kOld); |
| 12021 NoSafepointScope no_safepoint; | 12021 NoSafepointScope no_safepoint; |
| 12022 result ^= raw; | 12022 result ^= raw; |
| 12023 result.SetLength(length); | 12023 result.SetLength(length); |
| 12024 } | 12024 } |
| 12025 // When constructing a stackmap we store the pc offset in the stackmap's | 12025 // When constructing a stackmap we store the pc offset in the stackmap's |
| 12026 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc | 12026 // PC. StackMapTableBuilder::FinalizeStackMaps will replace it with the pc |
| 12027 // address. | 12027 // address. |
| 12028 ASSERT(pc_offset >= 0); | 12028 ASSERT(pc_offset >= 0); |
| 12029 result.SetPcOffset(pc_offset); | 12029 result.SetPcOffset(pc_offset); |
| 12030 for (intptr_t i = 0; i < length; ++i) { | 12030 for (intptr_t i = 0; i < length; ++i) { |
| 12031 result.SetBit(i, bmap->Get(i)); | 12031 result.SetBit(i, bmap->Get(i)); |
| 12032 } | 12032 } |
| 12033 result.SetSlowPathBitCount(slow_path_bit_count); | 12033 result.SetSlowPathBitCount(slow_path_bit_count); |
| 12034 return result.raw(); | 12034 return result.raw(); |
| 12035 } | 12035 } |
| 12036 | 12036 |
| 12037 | 12037 |
| 12038 RawStackmap* Stackmap::New(intptr_t length, | 12038 RawStackMap* StackMap::New(intptr_t length, |
| 12039 intptr_t slow_path_bit_count, | 12039 intptr_t slow_path_bit_count, |
| 12040 intptr_t pc_offset) { | 12040 intptr_t pc_offset) { |
| 12041 ASSERT(Object::stackmap_class() != Class::null()); | 12041 ASSERT(Object::stackmap_class() != Class::null()); |
| 12042 Stackmap& result = Stackmap::Handle(); | 12042 StackMap& result = StackMap::Handle(); |
| 12043 // Guard against integer overflow of the instance size computation. | 12043 // Guard against integer overflow of the instance size computation. |
| 12044 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | 12044 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
| 12045 if ((payload_size < 0) || (payload_size > kMaxLengthInBytes)) { | 12045 if ((payload_size < 0) || (payload_size > kMaxLengthInBytes)) { |
| 12046 // This should be caught before we reach here. | 12046 // This should be caught before we reach here. |
| 12047 FATAL1("Fatal error in Stackmap::New: invalid length %" Pd "\n", length); | 12047 FATAL1("Fatal error in StackMap::New: invalid length %" Pd "\n", length); |
| 12048 } | 12048 } |
| 12049 { | 12049 { |
| 12050 // Stackmap data objects are associated with a code object, allocate them | 12050 // StackMap data objects are associated with a code object, allocate them |
| 12051 // in old generation. | 12051 // in old generation. |
| 12052 RawObject* raw = Object::Allocate( | 12052 RawObject* raw = Object::Allocate( |
| 12053 Stackmap::kClassId, Stackmap::InstanceSize(length), Heap::kOld); | 12053 StackMap::kClassId, StackMap::InstanceSize(length), Heap::kOld); |
| 12054 NoSafepointScope no_safepoint; | 12054 NoSafepointScope no_safepoint; |
| 12055 result ^= raw; | 12055 result ^= raw; |
| 12056 result.SetLength(length); | 12056 result.SetLength(length); |
| 12057 } | 12057 } |
| 12058 // When constructing a stackmap we store the pc offset in the stackmap's | 12058 // When constructing a stackmap we store the pc offset in the stackmap's |
| 12059 // PC. StackmapTableBuilder::FinalizeStackmaps will replace it with the pc | 12059 // PC. StackMapTableBuilder::FinalizeStackMaps will replace it with the pc |
| 12060 // address. | 12060 // address. |
| 12061 ASSERT(pc_offset >= 0); | 12061 ASSERT(pc_offset >= 0); |
| 12062 result.SetPcOffset(pc_offset); | 12062 result.SetPcOffset(pc_offset); |
| 12063 result.SetSlowPathBitCount(slow_path_bit_count); | 12063 result.SetSlowPathBitCount(slow_path_bit_count); |
| 12064 return result.raw(); | 12064 return result.raw(); |
| 12065 } | 12065 } |
| 12066 | 12066 |
| 12067 | 12067 |
| 12068 const char* Stackmap::ToCString() const { | 12068 const char* StackMap::ToCString() const { |
| 12069 #define FORMAT "%#05x: " | 12069 #define FORMAT "%#05x: " |
| 12070 if (IsNull()) { | 12070 if (IsNull()) { |
| 12071 return "{null}"; | 12071 return "{null}"; |
| 12072 } else { | 12072 } else { |
| 12073 intptr_t fixed_length = OS::SNPrint(NULL, 0, FORMAT, PcOffset()) + 1; | 12073 intptr_t fixed_length = OS::SNPrint(NULL, 0, FORMAT, PcOffset()) + 1; |
| 12074 Thread* thread = Thread::Current(); | 12074 Thread* thread = Thread::Current(); |
| 12075 // Guard against integer overflow in the computation of alloc_size. | 12075 // Guard against integer overflow in the computation of alloc_size. |
| 12076 // | 12076 // |
| 12077 // TODO(kmillikin): We could just truncate the string if someone | 12077 // TODO(kmillikin): We could just truncate the string if someone |
| 12078 // tries to print a 2 billion plus entry stackmap. | 12078 // tries to print a 2 billion plus entry stackmap. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12263 return raw_ptr()->data()[try_index].handler_pc_offset; | 12263 return raw_ptr()->data()[try_index].handler_pc_offset; |
| 12264 } | 12264 } |
| 12265 | 12265 |
| 12266 | 12266 |
| 12267 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { | 12267 intptr_t ExceptionHandlers::OuterTryIndex(intptr_t try_index) const { |
| 12268 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12268 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 12269 return raw_ptr()->data()[try_index].outer_try_index; | 12269 return raw_ptr()->data()[try_index].outer_try_index; |
| 12270 } | 12270 } |
| 12271 | 12271 |
| 12272 | 12272 |
| 12273 bool ExceptionHandlers::NeedsStacktrace(intptr_t try_index) const { | 12273 bool ExceptionHandlers::NeedsStackTrace(intptr_t try_index) const { |
| 12274 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12274 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 12275 return raw_ptr()->data()[try_index].needs_stacktrace; | 12275 return raw_ptr()->data()[try_index].needs_stacktrace; |
| 12276 } | 12276 } |
| 12277 | 12277 |
| 12278 | 12278 |
| 12279 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { | 12279 bool ExceptionHandlers::HasCatchAll(intptr_t try_index) const { |
| 12280 ASSERT((try_index >= 0) && (try_index < num_entries())); | 12280 ASSERT((try_index >= 0) && (try_index < num_entries())); |
| 12281 return raw_ptr()->data()[try_index].has_catch_all; | 12281 return raw_ptr()->data()[try_index].has_catch_all; |
| 12282 } | 12282 } |
| 12283 | 12283 |
| (...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14385 // store buffer update is not needed here. | 14385 // store buffer update is not needed here. |
| 14386 StorePointer(&raw_ptr()->active_instructions_, instructions.raw()); | 14386 StorePointer(&raw_ptr()->active_instructions_, instructions.raw()); |
| 14387 StoreNonPointer(&raw_ptr()->entry_point_, | 14387 StoreNonPointer(&raw_ptr()->entry_point_, |
| 14388 Instructions::UncheckedEntryPoint(instructions.raw())); | 14388 Instructions::UncheckedEntryPoint(instructions.raw())); |
| 14389 StoreNonPointer(&raw_ptr()->checked_entry_point_, | 14389 StoreNonPointer(&raw_ptr()->checked_entry_point_, |
| 14390 Instructions::CheckedEntryPoint(instructions.raw())); | 14390 Instructions::CheckedEntryPoint(instructions.raw())); |
| 14391 #endif | 14391 #endif |
| 14392 } | 14392 } |
| 14393 | 14393 |
| 14394 | 14394 |
| 14395 RawStackmap* Code::GetStackmap(uint32_t pc_offset, | 14395 RawStackMap* Code::GetStackMap(uint32_t pc_offset, |
| 14396 Array* maps, | 14396 Array* maps, |
| 14397 Stackmap* map) const { | 14397 StackMap* map) const { |
| 14398 // This code is used during iterating frames during a GC and hence it | 14398 // This code is used during iterating frames during a GC and hence it |
| 14399 // should not in turn start a GC. | 14399 // should not in turn start a GC. |
| 14400 NoSafepointScope no_safepoint; | 14400 NoSafepointScope no_safepoint; |
| 14401 if (stackmaps() == Array::null()) { | 14401 if (stackmaps() == Array::null()) { |
| 14402 // No stack maps are present in the code object which means this | 14402 // No stack maps are present in the code object which means this |
| 14403 // frame relies on tagged pointers. | 14403 // frame relies on tagged pointers. |
| 14404 return Stackmap::null(); | 14404 return StackMap::null(); |
| 14405 } | 14405 } |
| 14406 // A stack map is present in the code object, use the stack map to visit | 14406 // A stack map is present in the code object, use the stack map to visit |
| 14407 // frame slots which are marked as having objects. | 14407 // frame slots which are marked as having objects. |
| 14408 *maps = stackmaps(); | 14408 *maps = stackmaps(); |
| 14409 *map = Stackmap::null(); | 14409 *map = StackMap::null(); |
| 14410 for (intptr_t i = 0; i < maps->Length(); i++) { | 14410 for (intptr_t i = 0; i < maps->Length(); i++) { |
| 14411 *map ^= maps->At(i); | 14411 *map ^= maps->At(i); |
| 14412 ASSERT(!map->IsNull()); | 14412 ASSERT(!map->IsNull()); |
| 14413 if (map->PcOffset() == pc_offset) { | 14413 if (map->PcOffset() == pc_offset) { |
| 14414 return map->raw(); // We found a stack map for this frame. | 14414 return map->raw(); // We found a stack map for this frame. |
| 14415 } | 14415 } |
| 14416 } | 14416 } |
| 14417 // If we are missing a stack map, this must either be unoptimized code, or | 14417 // If we are missing a stack map, this must either be unoptimized code, or |
| 14418 // the entry to an osr function. (In which case all stack slots are | 14418 // the entry to an osr function. (In which case all stack slots are |
| 14419 // considered to have tagged pointers.) | 14419 // considered to have tagged pointers.) |
| 14420 // Running with --verify-on-transition should hit this. | 14420 // Running with --verify-on-transition should hit this. |
| 14421 ASSERT(!is_optimized() || | 14421 ASSERT(!is_optimized() || |
| 14422 (pc_offset == UncheckedEntryPoint() - PayloadStart())); | 14422 (pc_offset == UncheckedEntryPoint() - PayloadStart())); |
| 14423 return Stackmap::null(); | 14423 return StackMap::null(); |
| 14424 } | 14424 } |
| 14425 | 14425 |
| 14426 | 14426 |
| 14427 intptr_t Code::GetCallerId(intptr_t inlined_id) const { | 14427 intptr_t Code::GetCallerId(intptr_t inlined_id) const { |
| 14428 if (inlined_id < 0) { | 14428 if (inlined_id < 0) { |
| 14429 return -1; | 14429 return -1; |
| 14430 } | 14430 } |
| 14431 const Array& map = Array::Handle(GetInlinedCallerIdMap()); | 14431 const Array& map = Array::Handle(GetInlinedCallerIdMap()); |
| 14432 if (map.IsNull() || (map.Length() == 0)) { | 14432 if (map.IsNull() || (map.Length() == 0)) { |
| 14433 return -1; | 14433 return -1; |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15191 ASSERT(Object::unhandled_exception_class() != Class::null()); | 15191 ASSERT(Object::unhandled_exception_class() != Class::null()); |
| 15192 UnhandledException& result = UnhandledException::Handle(); | 15192 UnhandledException& result = UnhandledException::Handle(); |
| 15193 { | 15193 { |
| 15194 RawObject* raw = | 15194 RawObject* raw = |
| 15195 Object::Allocate(UnhandledException::kClassId, | 15195 Object::Allocate(UnhandledException::kClassId, |
| 15196 UnhandledException::InstanceSize(), space); | 15196 UnhandledException::InstanceSize(), space); |
| 15197 NoSafepointScope no_safepoint; | 15197 NoSafepointScope no_safepoint; |
| 15198 result ^= raw; | 15198 result ^= raw; |
| 15199 } | 15199 } |
| 15200 result.set_exception(Object::null_instance()); | 15200 result.set_exception(Object::null_instance()); |
| 15201 result.set_stacktrace(Stacktrace::Handle()); | 15201 result.set_stacktrace(StackTrace::Handle()); |
| 15202 return result.raw(); | 15202 return result.raw(); |
| 15203 } | 15203 } |
| 15204 | 15204 |
| 15205 | 15205 |
| 15206 void UnhandledException::set_exception(const Instance& exception) const { | 15206 void UnhandledException::set_exception(const Instance& exception) const { |
| 15207 StorePointer(&raw_ptr()->exception_, exception.raw()); | 15207 StorePointer(&raw_ptr()->exception_, exception.raw()); |
| 15208 } | 15208 } |
| 15209 | 15209 |
| 15210 | 15210 |
| 15211 void UnhandledException::set_stacktrace(const Instance& stacktrace) const { | 15211 void UnhandledException::set_stacktrace(const Instance& stacktrace) const { |
| (...skipping 7045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22257 } | 22257 } |
| 22258 | 22258 |
| 22259 | 22259 |
| 22260 RawClosure* Closure::New() { | 22260 RawClosure* Closure::New() { |
| 22261 RawObject* raw = | 22261 RawObject* raw = |
| 22262 Object::Allocate(Closure::kClassId, Closure::InstanceSize(), Heap::kOld); | 22262 Object::Allocate(Closure::kClassId, Closure::InstanceSize(), Heap::kOld); |
| 22263 return reinterpret_cast<RawClosure*>(raw); | 22263 return reinterpret_cast<RawClosure*>(raw); |
| 22264 } | 22264 } |
| 22265 | 22265 |
| 22266 | 22266 |
| 22267 intptr_t Stacktrace::Length() const { | 22267 intptr_t StackTrace::Length() const { |
| 22268 const Array& code_array = Array::Handle(raw_ptr()->code_array_); | 22268 const Array& code_array = Array::Handle(raw_ptr()->code_array_); |
| 22269 return code_array.Length(); | 22269 return code_array.Length(); |
| 22270 } | 22270 } |
| 22271 | 22271 |
| 22272 | 22272 |
| 22273 RawFunction* Stacktrace::FunctionAtFrame(intptr_t frame_index) const { | 22273 RawFunction* StackTrace::FunctionAtFrame(intptr_t frame_index) const { |
| 22274 const Code& code = Code::Handle(CodeAtFrame(frame_index)); | 22274 const Code& code = Code::Handle(CodeAtFrame(frame_index)); |
| 22275 return code.IsNull() ? Function::null() : code.function(); | 22275 return code.IsNull() ? Function::null() : code.function(); |
| 22276 } | 22276 } |
| 22277 | 22277 |
| 22278 | 22278 |
| 22279 RawCode* Stacktrace::CodeAtFrame(intptr_t frame_index) const { | 22279 RawCode* StackTrace::CodeAtFrame(intptr_t frame_index) const { |
| 22280 const Array& code_array = Array::Handle(raw_ptr()->code_array_); | 22280 const Array& code_array = Array::Handle(raw_ptr()->code_array_); |
| 22281 return reinterpret_cast<RawCode*>(code_array.At(frame_index)); | 22281 return reinterpret_cast<RawCode*>(code_array.At(frame_index)); |
| 22282 } | 22282 } |
| 22283 | 22283 |
| 22284 | 22284 |
| 22285 void Stacktrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const { | 22285 void StackTrace::SetCodeAtFrame(intptr_t frame_index, const Code& code) const { |
| 22286 const Array& code_array = Array::Handle(raw_ptr()->code_array_); | 22286 const Array& code_array = Array::Handle(raw_ptr()->code_array_); |
| 22287 code_array.SetAt(frame_index, code); | 22287 code_array.SetAt(frame_index, code); |
| 22288 } | 22288 } |
| 22289 | 22289 |
| 22290 | 22290 |
| 22291 RawSmi* Stacktrace::PcOffsetAtFrame(intptr_t frame_index) const { | 22291 RawSmi* StackTrace::PcOffsetAtFrame(intptr_t frame_index) const { |
| 22292 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); | 22292 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); |
| 22293 return reinterpret_cast<RawSmi*>(pc_offset_array.At(frame_index)); | 22293 return reinterpret_cast<RawSmi*>(pc_offset_array.At(frame_index)); |
| 22294 } | 22294 } |
| 22295 | 22295 |
| 22296 | 22296 |
| 22297 void Stacktrace::SetPcOffsetAtFrame(intptr_t frame_index, | 22297 void StackTrace::SetPcOffsetAtFrame(intptr_t frame_index, |
| 22298 const Smi& pc_offset) const { | 22298 const Smi& pc_offset) const { |
| 22299 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); | 22299 const Array& pc_offset_array = Array::Handle(raw_ptr()->pc_offset_array_); |
| 22300 pc_offset_array.SetAt(frame_index, pc_offset); | 22300 pc_offset_array.SetAt(frame_index, pc_offset); |
| 22301 } | 22301 } |
| 22302 | 22302 |
| 22303 | 22303 |
| 22304 void Stacktrace::set_code_array(const Array& code_array) const { | 22304 void StackTrace::set_code_array(const Array& code_array) const { |
| 22305 StorePointer(&raw_ptr()->code_array_, code_array.raw()); | 22305 StorePointer(&raw_ptr()->code_array_, code_array.raw()); |
| 22306 } | 22306 } |
| 22307 | 22307 |
| 22308 | 22308 |
| 22309 void Stacktrace::set_pc_offset_array(const Array& pc_offset_array) const { | 22309 void StackTrace::set_pc_offset_array(const Array& pc_offset_array) const { |
| 22310 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); | 22310 StorePointer(&raw_ptr()->pc_offset_array_, pc_offset_array.raw()); |
| 22311 } | 22311 } |
| 22312 | 22312 |
| 22313 | 22313 |
| 22314 void Stacktrace::set_expand_inlined(bool value) const { | 22314 void StackTrace::set_expand_inlined(bool value) const { |
| 22315 StoreNonPointer(&raw_ptr()->expand_inlined_, value); | 22315 StoreNonPointer(&raw_ptr()->expand_inlined_, value); |
| 22316 } | 22316 } |
| 22317 | 22317 |
| 22318 | 22318 |
| 22319 bool Stacktrace::expand_inlined() const { | 22319 bool StackTrace::expand_inlined() const { |
| 22320 return raw_ptr()->expand_inlined_; | 22320 return raw_ptr()->expand_inlined_; |
| 22321 } | 22321 } |
| 22322 | 22322 |
| 22323 | 22323 |
| 22324 RawStacktrace* Stacktrace::New(const Array& code_array, | 22324 RawStackTrace* StackTrace::New(const Array& code_array, |
| 22325 const Array& pc_offset_array, | 22325 const Array& pc_offset_array, |
| 22326 Heap::Space space) { | 22326 Heap::Space space) { |
| 22327 Stacktrace& result = Stacktrace::Handle(); | 22327 StackTrace& result = StackTrace::Handle(); |
| 22328 { | 22328 { |
| 22329 RawObject* raw = Object::Allocate(Stacktrace::kClassId, | 22329 RawObject* raw = Object::Allocate(StackTrace::kClassId, |
| 22330 Stacktrace::InstanceSize(), space); | 22330 StackTrace::InstanceSize(), space); |
| 22331 NoSafepointScope no_safepoint; | 22331 NoSafepointScope no_safepoint; |
| 22332 result ^= raw; | 22332 result ^= raw; |
| 22333 } | 22333 } |
| 22334 result.set_code_array(code_array); | 22334 result.set_code_array(code_array); |
| 22335 result.set_pc_offset_array(pc_offset_array); | 22335 result.set_pc_offset_array(pc_offset_array); |
| 22336 result.set_expand_inlined(true); // default. | 22336 result.set_expand_inlined(true); // default. |
| 22337 return result.raw(); | 22337 return result.raw(); |
| 22338 } | 22338 } |
| 22339 | 22339 |
| 22340 | 22340 |
| 22341 const char* Stacktrace::ToCString() const { | 22341 const char* StackTrace::ToCString() const { |
| 22342 intptr_t idx = 0; | 22342 intptr_t idx = 0; |
| 22343 return ToCStringInternal(&idx); | 22343 return ToCStringInternal(&idx); |
| 22344 } | 22344 } |
| 22345 | 22345 |
| 22346 | 22346 |
| 22347 static intptr_t PrintOneStacktrace(Zone* zone, | 22347 static intptr_t PrintOneStackTrace(Zone* zone, |
| 22348 GrowableArray<char*>* frame_strings, | 22348 GrowableArray<char*>* frame_strings, |
| 22349 uword pc, | 22349 uword pc, |
| 22350 const Function& function, | 22350 const Function& function, |
| 22351 const Code& code, | 22351 const Code& code, |
| 22352 intptr_t frame_index) { | 22352 intptr_t frame_index) { |
| 22353 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); | 22353 const TokenPosition token_pos = code.GetTokenIndexOfPC(pc); |
| 22354 const Script& script = Script::Handle(zone, function.script()); | 22354 const Script& script = Script::Handle(zone, function.script()); |
| 22355 const String& function_name = | 22355 const String& function_name = |
| 22356 String::Handle(zone, function.QualifiedUserVisibleName()); | 22356 String::Handle(zone, function.QualifiedUserVisibleName()); |
| 22357 const String& url = String::Handle( | 22357 const String& url = String::Handle( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 22375 function_name.ToCString(), url.ToCString(), line); | 22375 function_name.ToCString(), url.ToCString(), line); |
| 22376 } else { | 22376 } else { |
| 22377 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s)\n", frame_index, | 22377 chars = OS::SCreate(zone, "#%-6" Pd " %s (%s)\n", frame_index, |
| 22378 function_name.ToCString(), url.ToCString()); | 22378 function_name.ToCString(), url.ToCString()); |
| 22379 } | 22379 } |
| 22380 frame_strings->Add(chars); | 22380 frame_strings->Add(chars); |
| 22381 return strlen(chars); | 22381 return strlen(chars); |
| 22382 } | 22382 } |
| 22383 | 22383 |
| 22384 | 22384 |
| 22385 const char* Stacktrace::ToCStringInternal(intptr_t* frame_index, | 22385 const char* StackTrace::ToCStringInternal(intptr_t* frame_index, |
| 22386 intptr_t max_frames) const { | 22386 intptr_t max_frames) const { |
| 22387 Zone* zone = Thread::Current()->zone(); | 22387 Zone* zone = Thread::Current()->zone(); |
| 22388 Function& function = Function::Handle(); | 22388 Function& function = Function::Handle(); |
| 22389 Code& code = Code::Handle(); | 22389 Code& code = Code::Handle(); |
| 22390 // Iterate through the stack frames and create C string description | 22390 // Iterate through the stack frames and create C string description |
| 22391 // for each frame. | 22391 // for each frame. |
| 22392 intptr_t total_len = 0; | 22392 intptr_t total_len = 0; |
| 22393 GrowableArray<char*> frame_strings; | 22393 GrowableArray<char*> frame_strings; |
| 22394 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { | 22394 for (intptr_t i = 0; (i < Length()) && (*frame_index < max_frames); i++) { |
| 22395 function = FunctionAtFrame(i); | 22395 function = FunctionAtFrame(i); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 22418 for (InlinedFunctionsIterator it(code, pc); | 22418 for (InlinedFunctionsIterator it(code, pc); |
| 22419 !it.Done() && (*frame_index < max_frames); it.Advance()) { | 22419 !it.Done() && (*frame_index < max_frames); it.Advance()) { |
| 22420 function = it.function(); | 22420 function = it.function(); |
| 22421 if (function.is_visible() || FLAG_show_invisible_frames) { | 22421 if (function.is_visible() || FLAG_show_invisible_frames) { |
| 22422 code = it.code(); | 22422 code = it.code(); |
| 22423 ASSERT(function.raw() == code.function()); | 22423 ASSERT(function.raw() == code.function()); |
| 22424 uword pc = it.pc(); | 22424 uword pc = it.pc(); |
| 22425 ASSERT(pc != 0); | 22425 ASSERT(pc != 0); |
| 22426 ASSERT(code.PayloadStart() <= pc); | 22426 ASSERT(code.PayloadStart() <= pc); |
| 22427 ASSERT(pc < (code.PayloadStart() + code.Size())); | 22427 ASSERT(pc < (code.PayloadStart() + code.Size())); |
| 22428 total_len += PrintOneStacktrace(zone, &frame_strings, pc, function, | 22428 total_len += PrintOneStackTrace(zone, &frame_strings, pc, function, |
| 22429 code, *frame_index); | 22429 code, *frame_index); |
| 22430 (*frame_index)++; // To account for inlined frames. | 22430 (*frame_index)++; // To account for inlined frames. |
| 22431 } | 22431 } |
| 22432 } | 22432 } |
| 22433 } else { | 22433 } else { |
| 22434 if (function.is_visible() || FLAG_show_invisible_frames) { | 22434 if (function.is_visible() || FLAG_show_invisible_frames) { |
| 22435 total_len += PrintOneStacktrace(zone, &frame_strings, pc, function, | 22435 total_len += PrintOneStackTrace(zone, &frame_strings, pc, function, |
| 22436 code, *frame_index); | 22436 code, *frame_index); |
| 22437 (*frame_index)++; | 22437 (*frame_index)++; |
| 22438 } | 22438 } |
| 22439 } | 22439 } |
| 22440 } | 22440 } |
| 22441 } | 22441 } |
| 22442 | 22442 |
| 22443 // Now concatenate the frame descriptions into a single C string. | 22443 // Now concatenate the frame descriptions into a single C string. |
| 22444 char* chars = zone->Alloc<char>(total_len + 1); | 22444 char* chars = zone->Alloc<char>(total_len + 1); |
| 22445 intptr_t index = 0; | 22445 intptr_t index = 0; |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22766 return UserTag::null(); | 22766 return UserTag::null(); |
| 22767 } | 22767 } |
| 22768 | 22768 |
| 22769 | 22769 |
| 22770 const char* UserTag::ToCString() const { | 22770 const char* UserTag::ToCString() const { |
| 22771 const String& tag_label = String::Handle(label()); | 22771 const String& tag_label = String::Handle(label()); |
| 22772 return tag_label.ToCString(); | 22772 return tag_label.ToCString(); |
| 22773 } | 22773 } |
| 22774 | 22774 |
| 22775 } // namespace dart | 22775 } // namespace dart |
| OLD | NEW |