| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 Snapshot::Kind); \ | 123 Snapshot::Kind); \ |
| 124 friend class SnapshotReader; \ | 124 friend class SnapshotReader; \ |
| 125 | 125 |
| 126 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \ | 126 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \ |
| 127 OBJECT_IMPLEMENTATION(object, super); \ | 127 OBJECT_IMPLEMENTATION(object, super); \ |
| 128 Raw##object* raw_ptr() const { \ | 128 Raw##object* raw_ptr() const { \ |
| 129 ASSERT(raw() != null()); \ | 129 ASSERT(raw() != null()); \ |
| 130 return raw()->ptr(); \ | 130 return raw()->ptr(); \ |
| 131 } \ | 131 } \ |
| 132 SNAPSHOT_READER_SUPPORT(object) \ | 132 SNAPSHOT_READER_SUPPORT(object) \ |
| 133 friend class DartFrame; \ |
| 133 | 134 |
| 134 class Object { | 135 class Object { |
| 135 public: | 136 public: |
| 136 // Index for Singleton internal VM classes, | 137 // Index for Singleton internal VM classes, |
| 137 // this index is used in snapshots to refer to these classes directly. | 138 // this index is used in snapshots to refer to these classes directly. |
| 138 enum { | 139 enum { |
| 139 kNullObject = 0, | 140 kNullObject = 0, |
| 140 kSentinelObject, | 141 kSentinelObject, |
| 141 kClassClass, | 142 kClassClass, |
| 142 kNullClass, | 143 kNullClass, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 Isolate::Current()->store_buffer()->AddPointer(ptr); | 368 Isolate::Current()->store_buffer()->AddPointer(ptr); |
| 368 } | 369 } |
| 369 } | 370 } |
| 370 | 371 |
| 371 RawObject* raw_; // The raw object reference. | 372 RawObject* raw_; // The raw object reference. |
| 372 | 373 |
| 373 private: | 374 private: |
| 374 static void InitializeObject(uword address, intptr_t size); | 375 static void InitializeObject(uword address, intptr_t size); |
| 375 | 376 |
| 376 cpp_vtable* vtable_address() const { | 377 cpp_vtable* vtable_address() const { |
| 377 return reinterpret_cast<cpp_vtable*>(reinterpret_cast<word>(this)); | 378 uword vtable_addr = reinterpret_cast<uword>(this); |
| 379 return reinterpret_cast<cpp_vtable*>(vtable_addr); |
| 378 } | 380 } |
| 379 | 381 |
| 380 static cpp_vtable handle_vtable_; | 382 static cpp_vtable handle_vtable_; |
| 381 | 383 |
| 382 // The static values below are singletons shared between the different | 384 // The static values below are singletons shared between the different |
| 383 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 385 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| 384 static RawObject* null_; | 386 static RawObject* null_; |
| 385 static RawInstance* sentinel_; | 387 static RawInstance* sentinel_; |
| 386 static RawInstance* transition_sentinel_; | 388 static RawInstance* transition_sentinel_; |
| 387 | 389 |
| (...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 bool IsObject(intptr_t offset) const { | 2071 bool IsObject(intptr_t offset) const { |
| 2070 return InRange(offset) && GetBit(offset); | 2072 return InRange(offset) && GetBit(offset); |
| 2071 } | 2073 } |
| 2072 uword PC() const { return raw_ptr()->pc_; } | 2074 uword PC() const { return raw_ptr()->pc_; } |
| 2073 void SetPC(uword value) const { raw_ptr()->pc_ = value; } | 2075 void SetPC(uword value) const { raw_ptr()->pc_ = value; } |
| 2074 | 2076 |
| 2075 RawCode* GetCode() const { return raw_ptr()->code_; } | 2077 RawCode* GetCode() const { return raw_ptr()->code_; } |
| 2076 void SetCode(const Code& code) const; | 2078 void SetCode(const Code& code) const; |
| 2077 | 2079 |
| 2078 // Return the offset of the highest stack slot that has an object. | 2080 // Return the offset of the highest stack slot that has an object. |
| 2079 intptr_t Maximum() const; | 2081 intptr_t MaximumBitOffset() const { return raw_ptr()->max_set_bit_offset_; } |
| 2080 | 2082 |
| 2081 // Return the offset of the lowest stack slot that has an object. | 2083 // Return the offset of the lowest stack slot that has an object. |
| 2082 intptr_t Minimum() const; | 2084 intptr_t MinimumBitOffset() const { return raw_ptr()->min_set_bit_offset_; } |
| 2083 | 2085 |
| 2084 static intptr_t InstanceSize() { | 2086 static intptr_t InstanceSize() { |
| 2085 ASSERT(sizeof(RawStackmap) == OFFSET_OF(RawStackmap, data_)); | 2087 ASSERT(sizeof(RawStackmap) == OFFSET_OF(RawStackmap, data_)); |
| 2086 return 0; | 2088 return 0; |
| 2087 } | 2089 } |
| 2088 static intptr_t InstanceSize(intptr_t size) { | 2090 static intptr_t InstanceSize(intptr_t size) { |
| 2089 return RoundedAllocationSize(sizeof(RawStackmap) + (size * kWordSize)); | 2091 return RoundedAllocationSize(sizeof(RawStackmap) + (size * kWordSize)); |
| 2090 } | 2092 } |
| 2091 static RawStackmap* New(uword pc, const Code& code, BitmapBuilder* bmap); | 2093 static RawStackmap* New(uword pc, BitmapBuilder* bmap); |
| 2092 | 2094 |
| 2093 private: | 2095 private: |
| 2094 inline intptr_t SizeInBits() const; | 2096 inline intptr_t SizeInBits() const; |
| 2095 | 2097 |
| 2098 void SetMinBitOffset(intptr_t value) const { |
| 2099 raw_ptr()->min_set_bit_offset_ = value; |
| 2100 } |
| 2101 void SetMaxBitOffset(intptr_t value) const { |
| 2102 raw_ptr()->max_set_bit_offset_ = value; |
| 2103 } |
| 2104 |
| 2096 bool InRange(intptr_t offset) const { return offset < SizeInBits(); } | 2105 bool InRange(intptr_t offset) const { return offset < SizeInBits(); } |
| 2097 | 2106 |
| 2098 bool GetBit(intptr_t bit_offset) const; | 2107 bool GetBit(intptr_t bit_offset) const; |
| 2099 void SetBit(intptr_t bit_offset, bool value) const; | 2108 void SetBit(intptr_t bit_offset, bool value) const; |
| 2100 | 2109 |
| 2101 void set_bitmap_size_in_bytes(intptr_t value) const; | 2110 void set_bitmap_size_in_bytes(intptr_t value) const; |
| 2102 void set_pc(uword value) const; | |
| 2103 void set_code(const Code& code) const; | |
| 2104 | 2111 |
| 2105 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); | 2112 HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); |
| 2106 friend class Class; | 2113 friend class Class; |
| 2107 friend class BitmapBuilder; | 2114 friend class BitmapBuilder; |
| 2108 }; | 2115 }; |
| 2109 | 2116 |
| 2110 | 2117 |
| 2111 class ExceptionHandlers : public Object { | 2118 class ExceptionHandlers : public Object { |
| 2112 public: | 2119 public: |
| 2113 intptr_t Length() const; | 2120 intptr_t Length() const; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 return raw_ptr()->pc_descriptors_; | 2196 return raw_ptr()->pc_descriptors_; |
| 2190 } | 2197 } |
| 2191 void set_pc_descriptors(const PcDescriptors& descriptors) const { | 2198 void set_pc_descriptors(const PcDescriptors& descriptors) const { |
| 2192 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); | 2199 StorePointer(&raw_ptr()->pc_descriptors_, descriptors.raw()); |
| 2193 } | 2200 } |
| 2194 | 2201 |
| 2195 RawArray* stackmaps() const { | 2202 RawArray* stackmaps() const { |
| 2196 return raw_ptr()->stackmaps_; | 2203 return raw_ptr()->stackmaps_; |
| 2197 } | 2204 } |
| 2198 void set_stackmaps(const Array& maps) const; | 2205 void set_stackmaps(const Array& maps) const; |
| 2206 RawStackmap* GetStackmap(uword pc, Array* stackmaps, Stackmap* map) const; |
| 2199 | 2207 |
| 2200 RawLocalVarDescriptors* var_descriptors() const { | 2208 RawLocalVarDescriptors* var_descriptors() const { |
| 2201 return raw_ptr()->var_descriptors_; | 2209 return raw_ptr()->var_descriptors_; |
| 2202 } | 2210 } |
| 2203 void set_var_descriptors(const LocalVarDescriptors& value) const { | 2211 void set_var_descriptors(const LocalVarDescriptors& value) const { |
| 2204 StorePointer(&raw_ptr()->var_descriptors_, value.raw()); | 2212 StorePointer(&raw_ptr()->var_descriptors_, value.raw()); |
| 2205 } | 2213 } |
| 2206 | 2214 |
| 2207 RawExceptionHandlers* exception_handlers() const { | 2215 RawExceptionHandlers* exception_handlers() const { |
| 2208 return raw_ptr()->exception_handlers_; | 2216 return raw_ptr()->exception_handlers_; |
| (...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3966 } | 3974 } |
| 3967 | 3975 |
| 3968 | 3976 |
| 3969 intptr_t Stackmap::SizeInBits() const { | 3977 intptr_t Stackmap::SizeInBits() const { |
| 3970 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 3978 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 3971 } | 3979 } |
| 3972 | 3980 |
| 3973 } // namespace dart | 3981 } // namespace dart |
| 3974 | 3982 |
| 3975 #endif // VM_OBJECT_H_ | 3983 #endif // VM_OBJECT_H_ |
| OLD | NEW |