| 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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
| 6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 11 matching lines...) Expand all Loading... |
| 22 #include "vm/raw_object.h" | 22 #include "vm/raw_object.h" |
| 23 #include "vm/report.h" | 23 #include "vm/report.h" |
| 24 #include "vm/scanner.h" | 24 #include "vm/scanner.h" |
| 25 #include "vm/tags.h" | 25 #include "vm/tags.h" |
| 26 #include "vm/thread.h" | 26 #include "vm/thread.h" |
| 27 #include "vm/token_position.h" | 27 #include "vm/token_position.h" |
| 28 | 28 |
| 29 namespace dart { | 29 namespace dart { |
| 30 | 30 |
| 31 // Forward declarations. | 31 // Forward declarations. |
| 32 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 32 #define DEFINE_FORWARD_DECLARATION(clazz) class clazz; |
| 33 class clazz; | |
| 34 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 33 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
| 35 #undef DEFINE_FORWARD_DECLARATION | 34 #undef DEFINE_FORWARD_DECLARATION |
| 36 class Api; | 35 class Api; |
| 37 class ArgumentsDescriptor; | 36 class ArgumentsDescriptor; |
| 38 class Assembler; | 37 class Assembler; |
| 39 class Closure; | 38 class Closure; |
| 40 class Code; | 39 class Code; |
| 41 class DisassemblyFormatter; | 40 class DisassemblyFormatter; |
| 42 class DeoptInstr; | 41 class DeoptInstr; |
| 43 class FinalizablePersistentHandle; | 42 class FinalizablePersistentHandle; |
| 44 class LocalScope; | 43 class LocalScope; |
| 45 | 44 |
| 46 #define REUSABLE_FORWARD_DECLARATION(name) \ | 45 #define REUSABLE_FORWARD_DECLARATION(name) class Reusable##name##HandleScope; |
| 47 class Reusable##name##HandleScope; | |
| 48 REUSABLE_HANDLE_LIST(REUSABLE_FORWARD_DECLARATION) | 46 REUSABLE_HANDLE_LIST(REUSABLE_FORWARD_DECLARATION) |
| 49 #undef REUSABLE_FORWARD_DECLARATION | 47 #undef REUSABLE_FORWARD_DECLARATION |
| 50 | 48 |
| 51 class Symbols; | 49 class Symbols; |
| 52 | 50 |
| 53 #if defined(DEBUG) | 51 #if defined(DEBUG) |
| 54 #define CHECK_HANDLE() CheckHandle(); | 52 #define CHECK_HANDLE() CheckHandle(); |
| 55 #else | 53 #else |
| 56 #define CHECK_HANDLE() | 54 #define CHECK_HANDLE() |
| 57 #endif | 55 #endif |
| 58 | 56 |
| 59 #define BASE_OBJECT_IMPLEMENTATION(object, super) \ | 57 #define BASE_OBJECT_IMPLEMENTATION(object, super) \ |
| 60 public: /* NOLINT */ \ | 58 public: /* NOLINT */ \ |
| 61 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ | 59 Raw##object* raw() const { return reinterpret_cast<Raw##object*>(raw_); } \ |
| 62 bool Is##object() const { return true; } \ | 60 bool Is##object() const { return true; } \ |
| 63 static object& Handle(Zone* zone, Raw##object* raw_ptr) { \ | 61 static object& Handle(Zone* zone, Raw##object* raw_ptr) { \ |
| 64 object* obj = \ | 62 object* obj = reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ |
| 65 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ | |
| 66 initializeHandle(obj, raw_ptr); \ | 63 initializeHandle(obj, raw_ptr); \ |
| 67 return *obj; \ | 64 return *obj; \ |
| 68 } \ | 65 } \ |
| 69 static object& Handle() { \ | 66 static object& Handle() { \ |
| 70 return Handle(Thread::Current()->zone(), object::null()); \ | 67 return Handle(Thread::Current()->zone(), object::null()); \ |
| 71 } \ | 68 } \ |
| 72 static object& Handle(Zone* zone) { \ | 69 static object& Handle(Zone* zone) { return Handle(zone, object::null()); } \ |
| 73 return Handle(zone, object::null()); \ | |
| 74 } \ | |
| 75 static object& Handle(Raw##object* raw_ptr) { \ | 70 static object& Handle(Raw##object* raw_ptr) { \ |
| 76 return Handle(Thread::Current()->zone(), raw_ptr); \ | 71 return Handle(Thread::Current()->zone(), raw_ptr); \ |
| 77 } \ | 72 } \ |
| 78 static object& CheckedHandle(Zone* zone, RawObject* raw_ptr) { \ | 73 static object& CheckedHandle(Zone* zone, RawObject* raw_ptr) { \ |
| 79 object* obj = \ | 74 object* obj = reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ |
| 80 reinterpret_cast<object*>(VMHandles::AllocateHandle(zone)); \ | |
| 81 initializeHandle(obj, raw_ptr); \ | 75 initializeHandle(obj, raw_ptr); \ |
| 82 if (!obj->Is##object()) { \ | 76 if (!obj->Is##object()) { \ |
| 83 FATAL2("Handle check failed: saw %s expected %s", \ | 77 FATAL2("Handle check failed: saw %s expected %s", obj->ToCString(), \ |
| 84 obj->ToCString(), #object); \ | 78 #object); \ |
| 85 } \ | 79 } \ |
| 86 return *obj; \ | 80 return *obj; \ |
| 87 } \ | 81 } \ |
| 88 static object& CheckedHandle(RawObject* raw_ptr) { \ | 82 static object& CheckedHandle(RawObject* raw_ptr) { \ |
| 89 return CheckedHandle(Thread::Current()->zone(), raw_ptr); \ | 83 return CheckedHandle(Thread::Current()->zone(), raw_ptr); \ |
| 90 } \ | 84 } \ |
| 91 static object& ZoneHandle(Zone* zone, Raw##object* raw_ptr) { \ | 85 static object& ZoneHandle(Zone* zone, Raw##object* raw_ptr) { \ |
| 92 object* obj = reinterpret_cast<object*>( \ | 86 object* obj = \ |
| 93 VMHandles::AllocateZoneHandle(zone)); \ | 87 reinterpret_cast<object*>(VMHandles::AllocateZoneHandle(zone)); \ |
| 94 initializeHandle(obj, raw_ptr); \ | 88 initializeHandle(obj, raw_ptr); \ |
| 95 return *obj; \ | 89 return *obj; \ |
| 96 } \ | 90 } \ |
| 97 static object* ReadOnlyHandle() { \ | 91 static object* ReadOnlyHandle() { \ |
| 98 object* obj = reinterpret_cast<object*>( \ | 92 object* obj = reinterpret_cast<object*>(Dart::AllocateReadOnlyHandle()); \ |
| 99 Dart::AllocateReadOnlyHandle()); \ | |
| 100 initializeHandle(obj, object::null()); \ | 93 initializeHandle(obj, object::null()); \ |
| 101 return obj; \ | 94 return obj; \ |
| 102 } \ | 95 } \ |
| 103 static object& ZoneHandle(Zone* zone) { \ | 96 static object& ZoneHandle(Zone* zone) { \ |
| 104 return ZoneHandle(zone, object::null()); \ | 97 return ZoneHandle(zone, object::null()); \ |
| 105 } \ | 98 } \ |
| 106 static object& ZoneHandle() { \ | 99 static object& ZoneHandle() { \ |
| 107 return ZoneHandle(Thread::Current()->zone(), object::null()); \ | 100 return ZoneHandle(Thread::Current()->zone(), object::null()); \ |
| 108 } \ | 101 } \ |
| 109 static object& ZoneHandle(Raw##object* raw_ptr) { \ | 102 static object& ZoneHandle(Raw##object* raw_ptr) { \ |
| 110 return ZoneHandle(Thread::Current()->zone(), raw_ptr); \ | 103 return ZoneHandle(Thread::Current()->zone(), raw_ptr); \ |
| 111 } \ | 104 } \ |
| 112 static object& CheckedZoneHandle(Zone* zone, RawObject* raw_ptr) { \ | 105 static object& CheckedZoneHandle(Zone* zone, RawObject* raw_ptr) { \ |
| 113 object* obj = reinterpret_cast<object*>( \ | 106 object* obj = \ |
| 114 VMHandles::AllocateZoneHandle(zone)); \ | 107 reinterpret_cast<object*>(VMHandles::AllocateZoneHandle(zone)); \ |
| 115 initializeHandle(obj, raw_ptr); \ | 108 initializeHandle(obj, raw_ptr); \ |
| 116 if (!obj->Is##object()) { \ | 109 if (!obj->Is##object()) { \ |
| 117 FATAL2("Handle check failed: saw %s expected %s", \ | 110 FATAL2("Handle check failed: saw %s expected %s", obj->ToCString(), \ |
| 118 obj->ToCString(), #object); \ | 111 #object); \ |
| 119 } \ | 112 } \ |
| 120 return *obj; \ | 113 return *obj; \ |
| 121 } \ | 114 } \ |
| 122 static object& CheckedZoneHandle(RawObject* raw_ptr) { \ | 115 static object& CheckedZoneHandle(RawObject* raw_ptr) { \ |
| 123 return CheckedZoneHandle(Thread::Current()->zone(), raw_ptr); \ | 116 return CheckedZoneHandle(Thread::Current()->zone(), raw_ptr); \ |
| 124 } \ | 117 } \ |
| 125 /* T::Cast cannot be applied to a null Object, because the object vtable */ \ | 118 /* T::Cast cannot be applied to a null Object, because the object vtable */ \ |
| 126 /* is not setup for type T, although some methods are supposed to work */ \ | 119 /* is not setup for type T, although some methods are supposed to work */ \ |
| 127 /* with null, for example Instance::Equals(). */ \ | 120 /* with null, for example Instance::Equals(). */ \ |
| 128 static const object& Cast(const Object& obj) { \ | 121 static const object& Cast(const Object& obj) { \ |
| 129 ASSERT(obj.Is##object()); \ | 122 ASSERT(obj.Is##object()); \ |
| 130 return reinterpret_cast<const object&>(obj); \ | 123 return reinterpret_cast<const object&>(obj); \ |
| 131 } \ | 124 } \ |
| 132 static Raw##object* RawCast(RawObject* raw) { \ | 125 static Raw##object* RawCast(RawObject* raw) { \ |
| 133 ASSERT(Object::Handle(raw).Is##object()); \ | 126 ASSERT(Object::Handle(raw).Is##object()); \ |
| 134 return reinterpret_cast<Raw##object*>(raw); \ | 127 return reinterpret_cast<Raw##object*>(raw); \ |
| 135 } \ | 128 } \ |
| 136 static Raw##object* null() { \ | 129 static Raw##object* null() { \ |
| 137 return reinterpret_cast<Raw##object*>(Object::null()); \ | 130 return reinterpret_cast<Raw##object*>(Object::null()); \ |
| 138 } \ | 131 } \ |
| 139 virtual const char* ToCString() const; \ | 132 virtual const char* ToCString() const; \ |
| 140 static const ClassId kClassId = k##object##Cid; \ | 133 static const ClassId kClassId = k##object##Cid; \ |
| 141 private: /* NOLINT */ \ | 134 \ |
| 135 private: /* NOLINT */ \ |
| 142 /* Initialize the handle based on the raw_ptr in the presence of null. */ \ | 136 /* Initialize the handle based on the raw_ptr in the presence of null. */ \ |
| 143 static void initializeHandle(object* obj, RawObject* raw_ptr) { \ | 137 static void initializeHandle(object* obj, RawObject* raw_ptr) { \ |
| 144 if (raw_ptr != Object::null()) { \ | 138 if (raw_ptr != Object::null()) { \ |
| 145 obj->SetRaw(raw_ptr); \ | 139 obj->SetRaw(raw_ptr); \ |
| 146 } else { \ | 140 } else { \ |
| 147 obj->raw_ = Object::null(); \ | 141 obj->raw_ = Object::null(); \ |
| 148 object fake_object; \ | 142 object fake_object; \ |
| 149 obj->set_vtable(fake_object.vtable()); \ | 143 obj->set_vtable(fake_object.vtable()); \ |
| 150 } \ | 144 } \ |
| 151 } \ | 145 } \ |
| 152 /* Disallow allocation, copy constructors and override super assignment. */ \ | 146 /* Disallow allocation, copy constructors and override super assignment. */ \ |
| 153 public: /* NOLINT */ \ | 147 public: /* NOLINT */ \ |
| 154 void operator delete(void* pointer) { \ | 148 void operator delete(void* pointer) { UNREACHABLE(); } \ |
| 155 UNREACHABLE(); \ | 149 \ |
| 156 } \ | 150 private: /* NOLINT */ \ |
| 157 private: /* NOLINT */ \ | |
| 158 void* operator new(size_t size); \ | 151 void* operator new(size_t size); \ |
| 159 object(const object& value); \ | 152 object(const object& value); \ |
| 160 void operator=(Raw##super* value); \ | 153 void operator=(Raw##super* value); \ |
| 161 void operator=(const object& value); \ | 154 void operator=(const object& value); \ |
| 162 void operator=(const super& value); \ | 155 void operator=(const super& value); |
| 163 | 156 |
| 164 // Conditionally include object_service.cc functionality in the vtable to avoid | 157 // Conditionally include object_service.cc functionality in the vtable to avoid |
| 165 // link errors like the following: | 158 // link errors like the following: |
| 166 // | 159 // |
| 167 // object.o:(.rodata._ZTVN4....E[_ZTVN4...E]+0x278): | 160 // object.o:(.rodata._ZTVN4....E[_ZTVN4...E]+0x278): |
| 168 // undefined reference to | 161 // undefined reference to |
| 169 // `dart::Instance::PrintSharedInstanceJSON(dart::JSONObject*, bool) const'. | 162 // `dart::Instance::PrintSharedInstanceJSON(dart::JSONObject*, bool) const'. |
| 170 // | 163 // |
| 171 #ifndef PRODUCT | 164 #ifndef PRODUCT |
| 172 #define OBJECT_SERVICE_SUPPORT(object) \ | 165 #define OBJECT_SERVICE_SUPPORT(object) \ |
| 173 protected: /* NOLINT */ \ | 166 protected: /* NOLINT */ \ |
| 174 /* Object is printed as JSON into stream. If ref is true only a header */ \ | 167 /* Object is printed as JSON into stream. If ref is true only a header */ \ |
| 175 /* with an object id is printed. If ref is false the object is fully */ \ | 168 /* with an object id is printed. If ref is false the object is fully */ \ |
| 176 /* printed. */ \ | 169 /* printed. */ \ |
| 177 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; \ | 170 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; \ |
| 178 virtual const char* JSONType() const { \ | 171 virtual const char* JSONType() const { return "" #object; } |
| 179 return ""#object; \ | |
| 180 } | |
| 181 #else | 172 #else |
| 182 #define OBJECT_SERVICE_SUPPORT(object) \ | 173 #define OBJECT_SERVICE_SUPPORT(object) protected: /* NOLINT */ |
| 183 protected: /* NOLINT */ | 174 #endif // !PRODUCT |
| 184 #endif // !PRODUCT | |
| 185 | 175 |
| 186 #define SNAPSHOT_READER_SUPPORT(object) \ | 176 #define SNAPSHOT_READER_SUPPORT(object) \ |
| 187 static Raw##object* ReadFrom(SnapshotReader* reader, \ | 177 static Raw##object* ReadFrom(SnapshotReader* reader, intptr_t object_id, \ |
| 188 intptr_t object_id, \ | 178 intptr_t tags, Snapshot::Kind, \ |
| 189 intptr_t tags, \ | |
| 190 Snapshot::Kind, \ | |
| 191 bool as_reference); \ | 179 bool as_reference); \ |
| 192 friend class SnapshotReader; \ | 180 friend class SnapshotReader; |
| 193 | 181 |
| 194 #define OBJECT_IMPLEMENTATION(object, super) \ | 182 #define OBJECT_IMPLEMENTATION(object, super) \ |
| 195 public: /* NOLINT */ \ | 183 public: /* NOLINT */ \ |
| 196 void operator=(Raw##object* value) { \ | 184 void operator=(Raw##object* value) { initializeHandle(this, value); } \ |
| 197 initializeHandle(this, value); \ | |
| 198 } \ | |
| 199 void operator^=(RawObject* value) { \ | 185 void operator^=(RawObject* value) { \ |
| 200 initializeHandle(this, value); \ | 186 initializeHandle(this, value); \ |
| 201 ASSERT(IsNull() || Is##object()); \ | 187 ASSERT(IsNull() || Is##object()); \ |
| 202 } \ | 188 } \ |
| 203 protected: /* NOLINT */ \ | 189 \ |
| 190 protected: /* NOLINT */ \ |
| 204 object() : super() {} \ | 191 object() : super() {} \ |
| 205 BASE_OBJECT_IMPLEMENTATION(object, super) \ | 192 BASE_OBJECT_IMPLEMENTATION(object, super) \ |
| 206 OBJECT_SERVICE_SUPPORT(object) | 193 OBJECT_SERVICE_SUPPORT(object) |
| 207 | 194 |
| 208 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \ | 195 #define HEAP_OBJECT_IMPLEMENTATION(object, super) \ |
| 209 OBJECT_IMPLEMENTATION(object, super); \ | 196 OBJECT_IMPLEMENTATION(object, super); \ |
| 210 const Raw##object* raw_ptr() const { \ | 197 const Raw##object* raw_ptr() const { \ |
| 211 ASSERT(raw() != null()); \ | 198 ASSERT(raw() != null()); \ |
| 212 return raw()->ptr(); \ | 199 return raw()->ptr(); \ |
| 213 } \ | 200 } \ |
| 214 SNAPSHOT_READER_SUPPORT(object) \ | 201 SNAPSHOT_READER_SUPPORT(object) \ |
| 215 friend class StackFrame; \ | 202 friend class StackFrame; \ |
| 216 friend class Thread; \ | 203 friend class Thread; |
| 217 | 204 |
| 218 // This macro is used to denote types that do not have a sub-type. | 205 // This macro is used to denote types that do not have a sub-type. |
| 219 #define FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super) \ | 206 #define FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super) \ |
| 220 public: /* NOLINT */ \ | 207 public: /* NOLINT */ \ |
| 221 void operator=(Raw##object* value) { \ | 208 void operator=(Raw##object* value) { \ |
| 222 raw_ = value; \ | 209 raw_ = value; \ |
| 223 CHECK_HANDLE(); \ | 210 CHECK_HANDLE(); \ |
| 224 } \ | 211 } \ |
| 225 void operator^=(RawObject* value) { \ | 212 void operator^=(RawObject* value) { \ |
| 226 raw_ = value; \ | 213 raw_ = value; \ |
| 227 CHECK_HANDLE(); \ | 214 CHECK_HANDLE(); \ |
| 228 } \ | 215 } \ |
| 229 private: /* NOLINT */ \ | 216 \ |
| 217 private: /* NOLINT */ \ |
| 230 object() : super() {} \ | 218 object() : super() {} \ |
| 231 BASE_OBJECT_IMPLEMENTATION(object, super) \ | 219 BASE_OBJECT_IMPLEMENTATION(object, super) \ |
| 232 OBJECT_SERVICE_SUPPORT(object) \ | 220 OBJECT_SERVICE_SUPPORT(object) \ |
| 233 const Raw##object* raw_ptr() const { \ | 221 const Raw##object* raw_ptr() const { \ |
| 234 ASSERT(raw() != null()); \ | 222 ASSERT(raw() != null()); \ |
| 235 return raw()->ptr(); \ | 223 return raw()->ptr(); \ |
| 236 } \ | 224 } \ |
| 237 static intptr_t NextFieldOffset() { \ | 225 static intptr_t NextFieldOffset() { return -kWordSize; } \ |
| 238 return -kWordSize; \ | |
| 239 } \ | |
| 240 SNAPSHOT_READER_SUPPORT(rettype) \ | 226 SNAPSHOT_READER_SUPPORT(rettype) \ |
| 241 friend class StackFrame; \ | 227 friend class StackFrame; \ |
| 242 friend class Thread; \ | 228 friend class Thread; |
| 243 | 229 |
| 244 #define FINAL_HEAP_OBJECT_IMPLEMENTATION(object, super) \ | 230 #define FINAL_HEAP_OBJECT_IMPLEMENTATION(object, super) \ |
| 245 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, object, super) \ | 231 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, object, super) |
| 246 | 232 |
| 247 #define MINT_OBJECT_IMPLEMENTATION(object, rettype, super) \ | 233 #define MINT_OBJECT_IMPLEMENTATION(object, rettype, super) \ |
| 248 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super) \ | 234 FINAL_HEAP_OBJECT_IMPLEMENTATION_HELPER(object, rettype, super) |
| 249 | 235 |
| 250 class Object { | 236 class Object { |
| 251 public: | 237 public: |
| 252 virtual ~Object() { } | 238 virtual ~Object() {} |
| 253 | 239 |
| 254 RawObject* raw() const { return raw_; } | 240 RawObject* raw() const { return raw_; } |
| 255 void operator=(RawObject* value) { | 241 void operator=(RawObject* value) { initializeHandle(this, value); } |
| 256 initializeHandle(this, value); | |
| 257 } | |
| 258 | 242 |
| 259 uword CompareAndSwapTags(uword old_tags, uword new_tags) const { | 243 uword CompareAndSwapTags(uword old_tags, uword new_tags) const { |
| 260 return AtomicOperations::CompareAndSwapWord( | 244 return AtomicOperations::CompareAndSwapWord(&raw()->ptr()->tags_, old_tags, |
| 261 &raw()->ptr()->tags_, old_tags, new_tags); | 245 new_tags); |
| 262 } | 246 } |
| 263 bool IsCanonical() const { | 247 bool IsCanonical() const { return raw()->IsCanonical(); } |
| 264 return raw()->IsCanonical(); | 248 void SetCanonical() const { raw()->SetCanonical(); } |
| 265 } | 249 void ClearCanonical() const { raw()->ClearCanonical(); } |
| 266 void SetCanonical() const { | |
| 267 raw()->SetCanonical(); | |
| 268 } | |
| 269 void ClearCanonical() const { | |
| 270 raw()->ClearCanonical(); | |
| 271 } | |
| 272 intptr_t GetClassId() const { | 250 intptr_t GetClassId() const { |
| 273 return !raw()->IsHeapObject() ? | 251 return !raw()->IsHeapObject() ? static_cast<intptr_t>(kSmiCid) |
| 274 static_cast<intptr_t>(kSmiCid) : raw()->GetClassId(); | 252 : raw()->GetClassId(); |
| 275 } | 253 } |
| 276 inline RawClass* clazz() const; | 254 inline RawClass* clazz() const; |
| 277 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); } | 255 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); } |
| 278 | 256 |
| 279 // Class testers. | 257 // Class testers. |
| 280 #define DEFINE_CLASS_TESTER(clazz) \ | 258 #define DEFINE_CLASS_TESTER(clazz) \ |
| 281 virtual bool Is##clazz() const { return false; } | 259 virtual bool Is##clazz() const { return false; } |
| 282 CLASS_LIST_FOR_HANDLES(DEFINE_CLASS_TESTER); | 260 CLASS_LIST_FOR_HANDLES(DEFINE_CLASS_TESTER); |
| 283 #undef DEFINE_CLASS_TESTER | 261 #undef DEFINE_CLASS_TESTER |
| 284 | 262 |
| 285 bool IsNull() const { return raw_ == null_; } | 263 bool IsNull() const { return raw_ == null_; } |
| 286 | 264 |
| 287 // Matches Object.toString on instances (except String::ToCString, bug 20583). | 265 // Matches Object.toString on instances (except String::ToCString, bug 20583). |
| 288 virtual const char* ToCString() const { | 266 virtual const char* ToCString() const { |
| 289 if (IsNull()) { | 267 if (IsNull()) { |
| 290 return "null"; | 268 return "null"; |
| 291 } else { | 269 } else { |
| 292 return "Object"; | 270 return "Object"; |
| 293 } | 271 } |
| 294 } | 272 } |
| 295 | 273 |
| 296 #ifndef PRODUCT | 274 #ifndef PRODUCT |
| 297 void PrintJSON(JSONStream* stream, bool ref = true) const; | 275 void PrintJSON(JSONStream* stream, bool ref = true) const; |
| 298 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; | 276 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; |
| 299 virtual const char* JSONType() const { | 277 virtual const char* JSONType() const { return IsNull() ? "null" : "Object"; } |
| 300 return IsNull() ? "null" : "Object"; | |
| 301 } | |
| 302 #endif | 278 #endif |
| 303 | 279 |
| 304 // Returns the name that is used to identify an object in the | 280 // Returns the name that is used to identify an object in the |
| 305 // namespace dictionary. | 281 // namespace dictionary. |
| 306 // Object::DictionaryName() returns String::null(). Only subclasses | 282 // Object::DictionaryName() returns String::null(). Only subclasses |
| 307 // of Object that need to be entered in the library and library prefix | 283 // of Object that need to be entered in the library and library prefix |
| 308 // namespaces need to provide an implementation. | 284 // namespaces need to provide an implementation. |
| 309 virtual RawString* DictionaryName() const; | 285 virtual RawString* DictionaryName() const; |
| 310 | 286 |
| 311 bool IsNew() const { return raw()->IsNewObject(); } | 287 bool IsNew() const { return raw()->IsNewObject(); } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 326 bool IsReadOnlyHandle() const; | 302 bool IsReadOnlyHandle() const; |
| 327 | 303 |
| 328 bool IsNotTemporaryScopedHandle() const; | 304 bool IsNotTemporaryScopedHandle() const; |
| 329 | 305 |
| 330 static Object& Handle(Zone* zone, RawObject* raw_ptr) { | 306 static Object& Handle(Zone* zone, RawObject* raw_ptr) { |
| 331 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(zone)); | 307 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(zone)); |
| 332 initializeHandle(obj, raw_ptr); | 308 initializeHandle(obj, raw_ptr); |
| 333 return *obj; | 309 return *obj; |
| 334 } | 310 } |
| 335 static Object* ReadOnlyHandle() { | 311 static Object* ReadOnlyHandle() { |
| 336 Object* obj = reinterpret_cast<Object*>( | 312 Object* obj = reinterpret_cast<Object*>(Dart::AllocateReadOnlyHandle()); |
| 337 Dart::AllocateReadOnlyHandle()); | |
| 338 initializeHandle(obj, Object::null()); | 313 initializeHandle(obj, Object::null()); |
| 339 return obj; | 314 return obj; |
| 340 } | 315 } |
| 341 | 316 |
| 342 static Object& Handle() { | 317 static Object& Handle() { return Handle(Thread::Current()->zone(), null_); } |
| 343 return Handle(Thread::Current()->zone(), null_); | |
| 344 } | |
| 345 | 318 |
| 346 static Object& Handle(Zone* zone) { | 319 static Object& Handle(Zone* zone) { return Handle(zone, null_); } |
| 347 return Handle(zone, null_); | |
| 348 } | |
| 349 | 320 |
| 350 static Object& Handle(RawObject* raw_ptr) { | 321 static Object& Handle(RawObject* raw_ptr) { |
| 351 return Handle(Thread::Current()->zone(), raw_ptr); | 322 return Handle(Thread::Current()->zone(), raw_ptr); |
| 352 } | 323 } |
| 353 | 324 |
| 354 static Object& ZoneHandle(Zone* zone, RawObject* raw_ptr) { | 325 static Object& ZoneHandle(Zone* zone, RawObject* raw_ptr) { |
| 355 Object* obj = reinterpret_cast<Object*>( | 326 Object* obj = |
| 356 VMHandles::AllocateZoneHandle(zone)); | 327 reinterpret_cast<Object*>(VMHandles::AllocateZoneHandle(zone)); |
| 357 initializeHandle(obj, raw_ptr); | 328 initializeHandle(obj, raw_ptr); |
| 358 return *obj; | 329 return *obj; |
| 359 } | 330 } |
| 360 | 331 |
| 361 static Object& ZoneHandle() { | 332 static Object& ZoneHandle() { |
| 362 return ZoneHandle(Thread::Current()->zone(), null_); | 333 return ZoneHandle(Thread::Current()->zone(), null_); |
| 363 } | 334 } |
| 364 | 335 |
| 365 static Object& ZoneHandle(RawObject* raw_ptr) { | 336 static Object& ZoneHandle(RawObject* raw_ptr) { |
| 366 return ZoneHandle(Thread::Current()->zone(), raw_ptr); | 337 return ZoneHandle(Thread::Current()->zone(), raw_ptr); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 534 |
| 564 static intptr_t InstanceSize() { | 535 static intptr_t InstanceSize() { |
| 565 return RoundedAllocationSize(sizeof(RawObject)); | 536 return RoundedAllocationSize(sizeof(RawObject)); |
| 566 } | 537 } |
| 567 | 538 |
| 568 static void VerifyBuiltinVtables(); | 539 static void VerifyBuiltinVtables(); |
| 569 | 540 |
| 570 static const ClassId kClassId = kObjectCid; | 541 static const ClassId kClassId = kObjectCid; |
| 571 | 542 |
| 572 // Different kinds of type tests. | 543 // Different kinds of type tests. |
| 573 enum TypeTestKind { | 544 enum TypeTestKind { kIsSubtypeOf = 0, kIsMoreSpecificThan }; |
| 574 kIsSubtypeOf = 0, | |
| 575 kIsMoreSpecificThan | |
| 576 }; | |
| 577 | 545 |
| 578 // Different kinds of name visibility. | 546 // Different kinds of name visibility. |
| 579 enum NameVisibility { | 547 enum NameVisibility { |
| 580 // Internal names are the true names of classes, fields, | 548 // Internal names are the true names of classes, fields, |
| 581 // etc. inside the vm. These names include privacy suffixes, | 549 // etc. inside the vm. These names include privacy suffixes, |
| 582 // getter prefixes, and trailing dots on unnamed constructors. | 550 // getter prefixes, and trailing dots on unnamed constructors. |
| 583 // | 551 // |
| 584 // The names of core implementation classes (like _OneByteString) | 552 // The names of core implementation classes (like _OneByteString) |
| 585 // are preserved as well. | 553 // are preserved as well. |
| 586 // | 554 // |
| (...skipping 25 matching lines...) Expand all Loading... |
| 612 // _MyClass@6b3832b. -> _MyClass | 580 // _MyClass@6b3832b. -> _MyClass |
| 613 // _MyClass@6b3832b.named -> _MyClass.named | 581 // _MyClass@6b3832b.named -> _MyClass.named |
| 614 // _OneByteString -> String (remapped) | 582 // _OneByteString -> String (remapped) |
| 615 kUserVisibleName | 583 kUserVisibleName |
| 616 }; | 584 }; |
| 617 | 585 |
| 618 protected: | 586 protected: |
| 619 // Used for extracting the C++ vtable during bringup. | 587 // Used for extracting the C++ vtable during bringup. |
| 620 Object() : raw_(null_) {} | 588 Object() : raw_(null_) {} |
| 621 | 589 |
| 622 uword raw_value() const { | 590 uword raw_value() const { return reinterpret_cast<uword>(raw()); } |
| 623 return reinterpret_cast<uword>(raw()); | |
| 624 } | |
| 625 | 591 |
| 626 inline void SetRaw(RawObject* value); | 592 inline void SetRaw(RawObject* value); |
| 627 void CheckHandle() const; | 593 void CheckHandle() const; |
| 628 | 594 |
| 629 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); } | 595 cpp_vtable vtable() const { return bit_copy<cpp_vtable>(*this); } |
| 630 void set_vtable(cpp_vtable value) { *vtable_address() = value; } | 596 void set_vtable(cpp_vtable value) { *vtable_address() = value; } |
| 631 | 597 |
| 632 static RawObject* Allocate(intptr_t cls_id, | 598 static RawObject* Allocate(intptr_t cls_id, intptr_t size, Heap::Space space); |
| 633 intptr_t size, | |
| 634 Heap::Space space); | |
| 635 | 599 |
| 636 static intptr_t RoundedAllocationSize(intptr_t size) { | 600 static intptr_t RoundedAllocationSize(intptr_t size) { |
| 637 return Utils::RoundUp(size, kObjectAlignment); | 601 return Utils::RoundUp(size, kObjectAlignment); |
| 638 } | 602 } |
| 639 | 603 |
| 640 bool Contains(uword addr) const { return raw()->Contains(addr); } | 604 bool Contains(uword addr) const { return raw()->Contains(addr); } |
| 641 | 605 |
| 642 // Start of field mutator guards. | 606 // Start of field mutator guards. |
| 643 // | 607 // |
| 644 // All writes to heap objects should ultimately pass through one of the | 608 // All writes to heap objects should ultimately pass through one of the |
| 645 // methods below or their counterparts in RawObject, to ensure that the | 609 // methods below or their counterparts in RawObject, to ensure that the |
| 646 // write barrier is correctly applied. | 610 // write barrier is correctly applied. |
| 647 | 611 |
| 648 template<typename type> | 612 template <typename type> |
| 649 void StorePointer(type const* addr, type value) const { | 613 void StorePointer(type const* addr, type value) const { |
| 650 raw()->StorePointer(addr, value); | 614 raw()->StorePointer(addr, value); |
| 651 } | 615 } |
| 652 | 616 |
| 653 // Store a range of pointers [from, from + count) into [to, to + count). | 617 // Store a range of pointers [from, from + count) into [to, to + count). |
| 654 // TODO(koda): Use this to fix Object::Clone's broken store buffer logic. | 618 // TODO(koda): Use this to fix Object::Clone's broken store buffer logic. |
| 655 void StorePointers(RawObject* const* to, | 619 void StorePointers(RawObject* const* to, |
| 656 RawObject* const* from, | 620 RawObject* const* from, |
| 657 intptr_t count) { | 621 intptr_t count) { |
| 658 ASSERT(Contains(reinterpret_cast<uword>(to))); | 622 ASSERT(Contains(reinterpret_cast<uword>(to))); |
| 659 if (raw()->IsNewObject()) { | 623 if (raw()->IsNewObject()) { |
| 660 memmove(const_cast<RawObject**>(to), from, count * kWordSize); | 624 memmove(const_cast<RawObject**>(to), from, count * kWordSize); |
| 661 } else { | 625 } else { |
| 662 for (intptr_t i = 0; i < count; ++i) { | 626 for (intptr_t i = 0; i < count; ++i) { |
| 663 StorePointer(&to[i], from[i]); | 627 StorePointer(&to[i], from[i]); |
| 664 } | 628 } |
| 665 } | 629 } |
| 666 } | 630 } |
| 667 | 631 |
| 668 // Use for storing into an explicitly Smi-typed field of an object | 632 // Use for storing into an explicitly Smi-typed field of an object |
| 669 // (i.e., both the previous and new value are Smis). | 633 // (i.e., both the previous and new value are Smis). |
| 670 void StoreSmi(RawSmi* const* addr, RawSmi* value) const { | 634 void StoreSmi(RawSmi* const* addr, RawSmi* value) const { |
| 671 raw()->StoreSmi(addr, value); | 635 raw()->StoreSmi(addr, value); |
| 672 } | 636 } |
| 673 | 637 |
| 674 template<typename FieldType> | 638 template <typename FieldType> |
| 675 void StoreSimd128(const FieldType* addr, simd128_value_t value) const { | 639 void StoreSimd128(const FieldType* addr, simd128_value_t value) const { |
| 676 ASSERT(Contains(reinterpret_cast<uword>(addr))); | 640 ASSERT(Contains(reinterpret_cast<uword>(addr))); |
| 677 value.writeTo(const_cast<FieldType*>(addr)); | 641 value.writeTo(const_cast<FieldType*>(addr)); |
| 678 } | 642 } |
| 679 | 643 |
| 680 // Needs two template arguments to allow assigning enums to fixed-size ints. | 644 // Needs two template arguments to allow assigning enums to fixed-size ints. |
| 681 template<typename FieldType, typename ValueType> | 645 template <typename FieldType, typename ValueType> |
| 682 void StoreNonPointer(const FieldType* addr, ValueType value) const { | 646 void StoreNonPointer(const FieldType* addr, ValueType value) const { |
| 683 // Can't use Contains, as it uses tags_, which is set through this method. | 647 // Can't use Contains, as it uses tags_, which is set through this method. |
| 684 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(raw())); | 648 ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(raw())); |
| 685 *const_cast<FieldType*>(addr) = value; | 649 *const_cast<FieldType*>(addr) = value; |
| 686 } | 650 } |
| 687 | 651 |
| 688 // Provides non-const access to non-pointer fields within the object. Such | 652 // Provides non-const access to non-pointer fields within the object. Such |
| 689 // access does not need a write barrier, but it is *not* GC-safe, since the | 653 // access does not need a write barrier, but it is *not* GC-safe, since the |
| 690 // object might move, hence must be fully contained within a NoSafepointScope. | 654 // object might move, hence must be fully contained within a NoSafepointScope. |
| 691 template<typename FieldType> | 655 template <typename FieldType> |
| 692 FieldType* UnsafeMutableNonPointer(const FieldType* addr) const { | 656 FieldType* UnsafeMutableNonPointer(const FieldType* addr) const { |
| 693 // Allow pointers at the end of variable-length data, and disallow pointers | 657 // Allow pointers at the end of variable-length data, and disallow pointers |
| 694 // within the header word. | 658 // within the header word. |
| 695 ASSERT(Contains(reinterpret_cast<uword>(addr) - 1) && | 659 ASSERT(Contains(reinterpret_cast<uword>(addr) - 1) && |
| 696 Contains(reinterpret_cast<uword>(addr) - kWordSize)); | 660 Contains(reinterpret_cast<uword>(addr) - kWordSize)); |
| 697 // At least check that there is a NoSafepointScope and hope it's big enough. | 661 // At least check that there is a NoSafepointScope and hope it's big enough. |
| 698 ASSERT(Thread::Current()->no_safepoint_scope_depth() > 0); | 662 ASSERT(Thread::Current()->no_safepoint_scope_depth() > 0); |
| 699 return const_cast<FieldType*>(addr); | 663 return const_cast<FieldType*>(addr); |
| 700 } | 664 } |
| 701 | 665 |
| 702 // Fail at link time if StoreNonPointer or UnsafeMutableNonPointer is | 666 // Fail at link time if StoreNonPointer or UnsafeMutableNonPointer is |
| 703 // instantiated with an object pointer type. | 667 // instantiated with an object pointer type. |
| 704 #define STORE_NON_POINTER_ILLEGAL_TYPE(type) \ | 668 #define STORE_NON_POINTER_ILLEGAL_TYPE(type) \ |
| 705 template<typename ValueType> \ | 669 template <typename ValueType> \ |
| 706 void StoreNonPointer(Raw##type* const* addr, ValueType value) const { \ | 670 void StoreNonPointer(Raw##type* const* addr, ValueType value) const { \ |
| 707 UnimplementedMethod(); \ | 671 UnimplementedMethod(); \ |
| 708 } \ | 672 } \ |
| 709 Raw##type** UnsafeMutableNonPointer(Raw##type* const* addr) const { \ | 673 Raw##type** UnsafeMutableNonPointer(Raw##type* const* addr) const { \ |
| 710 UnimplementedMethod(); \ | 674 UnimplementedMethod(); \ |
| 711 return NULL; \ | 675 return NULL; \ |
| 712 } | 676 } |
| 713 | 677 |
| 714 CLASS_LIST(STORE_NON_POINTER_ILLEGAL_TYPE); | 678 CLASS_LIST(STORE_NON_POINTER_ILLEGAL_TYPE); |
| 715 void UnimplementedMethod() const; | 679 void UnimplementedMethod() const; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 return reinterpret_cast<cpp_vtable*>(vtable_addr); | 725 return reinterpret_cast<cpp_vtable*>(vtable_addr); |
| 762 } | 726 } |
| 763 | 727 |
| 764 static cpp_vtable handle_vtable_; | 728 static cpp_vtable handle_vtable_; |
| 765 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; | 729 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; |
| 766 | 730 |
| 767 // The static values below are singletons shared between the different | 731 // The static values below are singletons shared between the different |
| 768 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 732 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
| 769 static RawObject* null_; | 733 static RawObject* null_; |
| 770 | 734 |
| 771 static RawClass* class_class_; // Class of the Class vm object. | 735 static RawClass* class_class_; // Class of the Class vm object. |
| 772 static RawClass* dynamic_class_; // Class of the 'dynamic' type. | 736 static RawClass* dynamic_class_; // Class of the 'dynamic' type. |
| 773 static RawClass* void_class_; // Class of the 'void' type. | 737 static RawClass* void_class_; // Class of the 'void' type. |
| 774 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. | 738 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. |
| 775 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. | 739 static RawClass* type_arguments_class_; // Class of TypeArguments vm object. |
| 776 static RawClass* patch_class_class_; // Class of the PatchClass vm object. | 740 static RawClass* patch_class_class_; // Class of the PatchClass vm object. |
| 777 static RawClass* function_class_; // Class of the Function vm object. | 741 static RawClass* function_class_; // Class of the Function vm object. |
| 778 static RawClass* closure_data_class_; // Class of ClosureData vm obj. | 742 static RawClass* closure_data_class_; // Class of ClosureData vm obj. |
| 779 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj. | 743 static RawClass* redirection_data_class_; // Class of RedirectionData vm obj. |
| 780 static RawClass* field_class_; // Class of the Field vm object. | 744 static RawClass* field_class_; // Class of the Field vm object. |
| 781 static RawClass* literal_token_class_; // Class of LiteralToken vm object. | 745 static RawClass* literal_token_class_; // Class of LiteralToken vm object. |
| 782 static RawClass* token_stream_class_; // Class of the TokenStream vm object. | 746 static RawClass* token_stream_class_; // Class of the TokenStream vm object. |
| 783 static RawClass* script_class_; // Class of the Script vm object. | 747 static RawClass* script_class_; // Class of the Script vm object. |
| 784 static RawClass* library_class_; // Class of the Library vm object. | 748 static RawClass* library_class_; // Class of the Library vm object. |
| 785 static RawClass* namespace_class_; // Class of Namespace vm object. | 749 static RawClass* namespace_class_; // Class of Namespace vm object. |
| 786 static RawClass* code_class_; // Class of the Code vm object. | 750 static RawClass* code_class_; // Class of the Code vm object. |
| 787 static RawClass* instructions_class_; // Class of the Instructions vm object. | 751 static RawClass* instructions_class_; // Class of the Instructions vm object. |
| 788 static RawClass* object_pool_class_; // Class of the ObjectPool vm object. | 752 static RawClass* object_pool_class_; // Class of the ObjectPool vm object. |
| 789 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. | 753 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. |
| 790 static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object. | 754 static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object. |
| 791 static RawClass* stackmap_class_; // Class of Stackmap vm object. | 755 static RawClass* stackmap_class_; // Class of Stackmap vm object. |
| 792 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. | 756 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. |
| 793 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. | 757 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. |
| 794 static RawClass* deopt_info_class_; // Class of DeoptInfo. | 758 static RawClass* deopt_info_class_; // Class of DeoptInfo. |
| 795 static RawClass* context_class_; // Class of the Context vm object. | 759 static RawClass* context_class_; // Class of the Context vm object. |
| 796 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 760 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
| 797 static RawClass* singletargetcache_class_; // Class of SingleTargetCache. | 761 static RawClass* singletargetcache_class_; // Class of SingleTargetCache. |
| 798 static RawClass* unlinkedcall_class_; // Class of UnlinkedCall. | 762 static RawClass* unlinkedcall_class_; // Class of UnlinkedCall. |
| 799 static RawClass* icdata_class_; // Class of ICData. | 763 static RawClass* icdata_class_; // Class of ICData. |
| 800 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. | 764 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. |
| 801 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. | 765 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. |
| 802 static RawClass* api_error_class_; // Class of ApiError. | 766 static RawClass* api_error_class_; // Class of ApiError. |
| 803 static RawClass* language_error_class_; // Class of LanguageError. | 767 static RawClass* language_error_class_; // Class of LanguageError. |
| 804 static RawClass* unhandled_exception_class_; // Class of UnhandledException. | 768 static RawClass* unhandled_exception_class_; // Class of UnhandledException. |
| 805 static RawClass* unwind_error_class_; // Class of UnwindError. | 769 static RawClass* unwind_error_class_; // Class of UnwindError. |
| 806 | 770 |
| 807 // The static values below are read-only handle pointers for singleton | 771 // The static values below are read-only handle pointers for singleton |
| 808 // objects that are shared between the different isolates. | 772 // objects that are shared between the different isolates. |
| 809 static Object* null_object_; | 773 static Object* null_object_; |
| 810 static Array* null_array_; | 774 static Array* null_array_; |
| 811 static String* null_string_; | 775 static String* null_string_; |
| 812 static Instance* null_instance_; | 776 static Instance* null_instance_; |
| 813 static TypeArguments* null_type_arguments_; | 777 static TypeArguments* null_type_arguments_; |
| 814 static Array* empty_array_; | 778 static Array* empty_array_; |
| 815 static Array* zero_array_; | 779 static Array* zero_array_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 841 friend class SnapshotReader; | 805 friend class SnapshotReader; |
| 842 friend class InstanceDeserializationCluster; | 806 friend class InstanceDeserializationCluster; |
| 843 friend class OneByteString; | 807 friend class OneByteString; |
| 844 friend class TwoByteString; | 808 friend class TwoByteString; |
| 845 friend class ExternalOneByteString; | 809 friend class ExternalOneByteString; |
| 846 friend class ExternalTwoByteString; | 810 friend class ExternalTwoByteString; |
| 847 friend class Thread; | 811 friend class Thread; |
| 848 | 812 |
| 849 #define REUSABLE_FRIEND_DECLARATION(name) \ | 813 #define REUSABLE_FRIEND_DECLARATION(name) \ |
| 850 friend class Reusable##name##HandleScope; | 814 friend class Reusable##name##HandleScope; |
| 851 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) | 815 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) |
| 852 #undef REUSABLE_FRIEND_DECLARATION | 816 #undef REUSABLE_FRIEND_DECLARATION |
| 853 | 817 |
| 854 DISALLOW_ALLOCATION(); | 818 DISALLOW_ALLOCATION(); |
| 855 DISALLOW_COPY_AND_ASSIGN(Object); | 819 DISALLOW_COPY_AND_ASSIGN(Object); |
| 856 }; | 820 }; |
| 857 | 821 |
| 858 | 822 |
| 859 class PassiveObject : public Object { | 823 class PassiveObject : public Object { |
| 860 public: | 824 public: |
| 861 void operator=(RawObject* value) { | 825 void operator=(RawObject* value) { raw_ = value; } |
| 862 raw_ = value; | 826 void operator^=(RawObject* value) { raw_ = value; } |
| 863 } | |
| 864 void operator^=(RawObject* value) { | |
| 865 raw_ = value; | |
| 866 } | |
| 867 | 827 |
| 868 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) { | 828 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) { |
| 869 PassiveObject* obj = reinterpret_cast<PassiveObject*>( | 829 PassiveObject* obj = |
| 870 VMHandles::AllocateHandle(zone)); | 830 reinterpret_cast<PassiveObject*>(VMHandles::AllocateHandle(zone)); |
| 871 obj->raw_ = raw_ptr; | 831 obj->raw_ = raw_ptr; |
| 872 obj->set_vtable(0); | 832 obj->set_vtable(0); |
| 873 return *obj; | 833 return *obj; |
| 874 } | 834 } |
| 875 static PassiveObject& Handle(RawObject* raw_ptr) { | 835 static PassiveObject& Handle(RawObject* raw_ptr) { |
| 876 return Handle(Thread::Current()->zone(), raw_ptr); | 836 return Handle(Thread::Current()->zone(), raw_ptr); |
| 877 } | 837 } |
| 878 static PassiveObject& Handle() { | 838 static PassiveObject& Handle() { |
| 879 return Handle(Thread::Current()->zone(), Object::null()); | 839 return Handle(Thread::Current()->zone(), Object::null()); |
| 880 } | 840 } |
| 881 static PassiveObject& Handle(Zone* zone) { | 841 static PassiveObject& Handle(Zone* zone) { |
| 882 return Handle(zone, Object::null()); | 842 return Handle(zone, Object::null()); |
| 883 } | 843 } |
| 884 static PassiveObject& ZoneHandle(Zone* zone, RawObject* raw_ptr) { | 844 static PassiveObject& ZoneHandle(Zone* zone, RawObject* raw_ptr) { |
| 885 PassiveObject* obj = reinterpret_cast<PassiveObject*>( | 845 PassiveObject* obj = |
| 886 VMHandles::AllocateZoneHandle(zone)); | 846 reinterpret_cast<PassiveObject*>(VMHandles::AllocateZoneHandle(zone)); |
| 887 obj->raw_ = raw_ptr; | 847 obj->raw_ = raw_ptr; |
| 888 obj->set_vtable(0); | 848 obj->set_vtable(0); |
| 889 return *obj; | 849 return *obj; |
| 890 } | 850 } |
| 891 static PassiveObject& ZoneHandle(RawObject* raw_ptr) { | 851 static PassiveObject& ZoneHandle(RawObject* raw_ptr) { |
| 892 return ZoneHandle(Thread::Current()->zone(), raw_ptr); | 852 return ZoneHandle(Thread::Current()->zone(), raw_ptr); |
| 893 } | 853 } |
| 894 static PassiveObject& ZoneHandle() { | 854 static PassiveObject& ZoneHandle() { |
| 895 return ZoneHandle(Thread::Current()->zone(), Object::null()); | 855 return ZoneHandle(Thread::Current()->zone(), Object::null()); |
| 896 } | 856 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 // class C<R> extends B<R, int> | 947 // class C<R> extends B<R, int> |
| 988 // C.DeclarationType() --> C [R, int, R] | 948 // C.DeclarationType() --> C [R, int, R] |
| 989 RawAbstractType* DeclarationType() const; | 949 RawAbstractType* DeclarationType() const; |
| 990 | 950 |
| 991 RawLibrary* library() const { return raw_ptr()->library_; } | 951 RawLibrary* library() const { return raw_ptr()->library_; } |
| 992 void set_library(const Library& value) const; | 952 void set_library(const Library& value) const; |
| 993 | 953 |
| 994 // The type parameters (and their bounds) are specified as an array of | 954 // The type parameters (and their bounds) are specified as an array of |
| 995 // TypeParameter. | 955 // TypeParameter. |
| 996 RawTypeArguments* type_parameters() const { | 956 RawTypeArguments* type_parameters() const { |
| 997 return raw_ptr()->type_parameters_; | 957 return raw_ptr()->type_parameters_; |
| 998 } | 958 } |
| 999 void set_type_parameters(const TypeArguments& value) const; | 959 void set_type_parameters(const TypeArguments& value) const; |
| 1000 intptr_t NumTypeParameters(Thread* thread) const; | 960 intptr_t NumTypeParameters(Thread* thread) const; |
| 1001 intptr_t NumTypeParameters() const { | 961 intptr_t NumTypeParameters() const { |
| 1002 return NumTypeParameters(Thread::Current()); | 962 return NumTypeParameters(Thread::Current()); |
| 1003 } | 963 } |
| 1004 static intptr_t type_parameters_offset() { | 964 static intptr_t type_parameters_offset() { |
| 1005 return OFFSET_OF(RawClass, type_parameters_); | 965 return OFFSET_OF(RawClass, type_parameters_); |
| 1006 } | 966 } |
| 1007 | 967 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 // Check if this class represents the 'void' class. | 1063 // Check if this class represents the 'void' class. |
| 1104 bool IsVoidClass() const { return id() == kVoidCid; } | 1064 bool IsVoidClass() const { return id() == kVoidCid; } |
| 1105 | 1065 |
| 1106 // Check if this class represents the 'Object' class. | 1066 // Check if this class represents the 'Object' class. |
| 1107 bool IsObjectClass() const { return id() == kInstanceCid; } | 1067 bool IsObjectClass() const { return id() == kInstanceCid; } |
| 1108 | 1068 |
| 1109 // Check if this class represents the 'Function' class. | 1069 // Check if this class represents the 'Function' class. |
| 1110 bool IsDartFunctionClass() const; | 1070 bool IsDartFunctionClass() const; |
| 1111 | 1071 |
| 1112 // Check if this class represents the 'Closure' class. | 1072 // Check if this class represents the 'Closure' class. |
| 1113 bool IsClosureClass() const { return id() == kClosureCid; } | 1073 bool IsClosureClass() const { return id() == kClosureCid; } |
| 1114 static bool IsClosureClass(RawClass* cls) { | 1074 static bool IsClosureClass(RawClass* cls) { |
| 1115 NoSafepointScope no_safepoint; | 1075 NoSafepointScope no_safepoint; |
| 1116 return cls->ptr()->id_ == kClosureCid; | 1076 return cls->ptr()->id_ == kClosureCid; |
| 1117 } | 1077 } |
| 1118 | 1078 |
| 1119 // Check if this class represents a typedef class. | 1079 // Check if this class represents a typedef class. |
| 1120 bool IsTypedefClass() const { | 1080 bool IsTypedefClass() const { return signature_function() != Object::null(); } |
| 1121 return signature_function() != Object::null(); | |
| 1122 } | |
| 1123 | 1081 |
| 1124 static bool IsInFullSnapshot(RawClass* cls) { | 1082 static bool IsInFullSnapshot(RawClass* cls) { |
| 1125 NoSafepointScope no_safepoint; | 1083 NoSafepointScope no_safepoint; |
| 1126 return cls->ptr()->library_->ptr()->is_in_fullsnapshot_; | 1084 return cls->ptr()->library_->ptr()->is_in_fullsnapshot_; |
| 1127 } | 1085 } |
| 1128 | 1086 |
| 1129 // Check the subtype relationship. | 1087 // Check the subtype relationship. |
| 1130 bool IsSubtypeOf(const TypeArguments& type_arguments, | 1088 bool IsSubtypeOf(const TypeArguments& type_arguments, |
| 1131 const Class& other, | 1089 const Class& other, |
| 1132 const TypeArguments& other_type_arguments, | 1090 const TypeArguments& other_type_arguments, |
| 1133 Error* bound_error, | 1091 Error* bound_error, |
| 1134 TrailPtr bound_trail, | 1092 TrailPtr bound_trail, |
| 1135 Heap::Space space) const { | 1093 Heap::Space space) const { |
| 1136 return TypeTest(kIsSubtypeOf, | 1094 return TypeTest(kIsSubtypeOf, type_arguments, other, other_type_arguments, |
| 1137 type_arguments, | 1095 bound_error, bound_trail, space); |
| 1138 other, | |
| 1139 other_type_arguments, | |
| 1140 bound_error, | |
| 1141 bound_trail, | |
| 1142 space); | |
| 1143 } | 1096 } |
| 1144 | 1097 |
| 1145 // Check the 'more specific' relationship. | 1098 // Check the 'more specific' relationship. |
| 1146 bool IsMoreSpecificThan(const TypeArguments& type_arguments, | 1099 bool IsMoreSpecificThan(const TypeArguments& type_arguments, |
| 1147 const Class& other, | 1100 const Class& other, |
| 1148 const TypeArguments& other_type_arguments, | 1101 const TypeArguments& other_type_arguments, |
| 1149 Error* bound_error, | 1102 Error* bound_error, |
| 1150 TrailPtr bound_trail, | 1103 TrailPtr bound_trail, |
| 1151 Heap::Space space) const { | 1104 Heap::Space space) const { |
| 1152 return TypeTest(kIsMoreSpecificThan, | 1105 return TypeTest(kIsMoreSpecificThan, type_arguments, other, |
| 1153 type_arguments, | 1106 other_type_arguments, bound_error, bound_trail, space); |
| 1154 other, | |
| 1155 other_type_arguments, | |
| 1156 bound_error, | |
| 1157 bound_trail, | |
| 1158 space); | |
| 1159 } | 1107 } |
| 1160 | 1108 |
| 1161 // Check if this is the top level class. | 1109 // Check if this is the top level class. |
| 1162 bool IsTopLevel() const; | 1110 bool IsTopLevel() const; |
| 1163 | 1111 |
| 1164 bool IsPrivate() const; | 1112 bool IsPrivate() const; |
| 1165 | 1113 |
| 1166 // Returns an array of instance and static fields defined by this class. | 1114 // Returns an array of instance and static fields defined by this class. |
| 1167 RawArray* fields() const { return raw_ptr()->fields_; } | 1115 RawArray* fields() const { return raw_ptr()->fields_; } |
| 1168 void SetFields(const Array& value) const; | 1116 void SetFields(const Array& value) const; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 RawField* LookupInstanceFieldAllowPrivate(const String& name) const; | 1154 RawField* LookupInstanceFieldAllowPrivate(const String& name) const; |
| 1207 RawField* LookupStaticFieldAllowPrivate(const String& name) const; | 1155 RawField* LookupStaticFieldAllowPrivate(const String& name) const; |
| 1208 | 1156 |
| 1209 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const; | 1157 RawLibraryPrefix* LookupLibraryPrefix(const String& name) const; |
| 1210 | 1158 |
| 1211 // Returns an instance of Double or Double::null(). | 1159 // Returns an instance of Double or Double::null(). |
| 1212 // 'index' points to either: | 1160 // 'index' points to either: |
| 1213 // - constants_list_ position of found element, or | 1161 // - constants_list_ position of found element, or |
| 1214 // - constants_list_ position where new canonical can be inserted. | 1162 // - constants_list_ position where new canonical can be inserted. |
| 1215 RawDouble* LookupCanonicalDouble(Zone* zone, | 1163 RawDouble* LookupCanonicalDouble(Zone* zone, |
| 1216 double value, intptr_t* index) const; | 1164 double value, |
| 1165 intptr_t* index) const; |
| 1217 RawMint* LookupCanonicalMint(Zone* zone, | 1166 RawMint* LookupCanonicalMint(Zone* zone, |
| 1218 int64_t value, intptr_t* index) const; | 1167 int64_t value, |
| 1168 intptr_t* index) const; |
| 1219 RawBigint* LookupCanonicalBigint(Zone* zone, | 1169 RawBigint* LookupCanonicalBigint(Zone* zone, |
| 1220 const Bigint& value, intptr_t* index) const; | 1170 const Bigint& value, |
| 1171 intptr_t* index) const; |
| 1221 // The methods above are more efficient than this generic one. | 1172 // The methods above are more efficient than this generic one. |
| 1222 RawInstance* LookupCanonicalInstance(Zone* zone, | 1173 RawInstance* LookupCanonicalInstance(Zone* zone, const Instance& value) const; |
| 1223 const Instance& value) const; | |
| 1224 | 1174 |
| 1225 RawInstance* InsertCanonicalConstant(Zone* zone, | 1175 RawInstance* InsertCanonicalConstant(Zone* zone, |
| 1226 const Instance& constant) const; | 1176 const Instance& constant) const; |
| 1227 void InsertCanonicalNumber(Zone* zone, | 1177 void InsertCanonicalNumber(Zone* zone, |
| 1228 intptr_t index, | 1178 intptr_t index, |
| 1229 const Number& constant) const; | 1179 const Number& constant) const; |
| 1230 | 1180 |
| 1231 void RehashConstants(Zone* zone) const; | 1181 void RehashConstants(Zone* zone) const; |
| 1232 | 1182 |
| 1233 static intptr_t InstanceSize() { | 1183 static intptr_t InstanceSize() { |
| 1234 return RoundedAllocationSize(sizeof(RawClass)); | 1184 return RoundedAllocationSize(sizeof(RawClass)); |
| 1235 } | 1185 } |
| 1236 | 1186 |
| 1237 bool is_implemented() const { | 1187 bool is_implemented() const { |
| 1238 return ImplementedBit::decode(raw_ptr()->state_bits_); | 1188 return ImplementedBit::decode(raw_ptr()->state_bits_); |
| 1239 } | 1189 } |
| 1240 void set_is_implemented() const; | 1190 void set_is_implemented() const; |
| 1241 | 1191 |
| 1242 bool is_abstract() const { | 1192 bool is_abstract() const { |
| 1243 return AbstractBit::decode(raw_ptr()->state_bits_); | 1193 return AbstractBit::decode(raw_ptr()->state_bits_); |
| 1244 } | 1194 } |
| 1245 void set_is_abstract() const; | 1195 void set_is_abstract() const; |
| 1246 | 1196 |
| 1247 bool is_type_finalized() const { | 1197 bool is_type_finalized() const { |
| 1248 return TypeFinalizedBit::decode(raw_ptr()->state_bits_); | 1198 return TypeFinalizedBit::decode(raw_ptr()->state_bits_); |
| 1249 } | 1199 } |
| 1250 void set_is_type_finalized() const; | 1200 void set_is_type_finalized() const; |
| 1251 | 1201 |
| 1252 bool is_patch() const { | 1202 bool is_patch() const { return PatchBit::decode(raw_ptr()->state_bits_); } |
| 1253 return PatchBit::decode(raw_ptr()->state_bits_); | |
| 1254 } | |
| 1255 void set_is_patch() const; | 1203 void set_is_patch() const; |
| 1256 | 1204 |
| 1257 bool is_synthesized_class() const { | 1205 bool is_synthesized_class() const { |
| 1258 return SynthesizedClassBit::decode(raw_ptr()->state_bits_); | 1206 return SynthesizedClassBit::decode(raw_ptr()->state_bits_); |
| 1259 } | 1207 } |
| 1260 void set_is_synthesized_class() const; | 1208 void set_is_synthesized_class() const; |
| 1261 | 1209 |
| 1262 bool is_enum_class() const { | 1210 bool is_enum_class() const { return EnumBit::decode(raw_ptr()->state_bits_); } |
| 1263 return EnumBit::decode(raw_ptr()->state_bits_); | |
| 1264 } | |
| 1265 void set_is_enum_class() const; | 1211 void set_is_enum_class() const; |
| 1266 | 1212 |
| 1267 bool is_finalized() const { | 1213 bool is_finalized() const { |
| 1268 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) | 1214 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) == |
| 1269 == RawClass::kFinalized; | 1215 RawClass::kFinalized; |
| 1270 } | 1216 } |
| 1271 void set_is_finalized() const; | 1217 void set_is_finalized() const; |
| 1272 | 1218 |
| 1273 bool is_prefinalized() const { | 1219 bool is_prefinalized() const { |
| 1274 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) | 1220 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) == |
| 1275 == RawClass::kPreFinalized; | 1221 RawClass::kPreFinalized; |
| 1276 } | 1222 } |
| 1277 | 1223 |
| 1278 void set_is_prefinalized() const; | 1224 void set_is_prefinalized() const; |
| 1279 | 1225 |
| 1280 bool is_refinalize_after_patch() const { | 1226 bool is_refinalize_after_patch() const { |
| 1281 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) | 1227 return ClassFinalizedBits::decode(raw_ptr()->state_bits_) == |
| 1282 == RawClass::kRefinalizeAfterPatch; | 1228 RawClass::kRefinalizeAfterPatch; |
| 1283 } | 1229 } |
| 1284 | 1230 |
| 1285 void SetRefinalizeAfterPatch() const; | 1231 void SetRefinalizeAfterPatch() const; |
| 1286 void ResetFinalization() const; | 1232 void ResetFinalization() const; |
| 1287 | 1233 |
| 1288 bool is_marked_for_parsing() const { | 1234 bool is_marked_for_parsing() const { |
| 1289 return MarkedForParsingBit::decode(raw_ptr()->state_bits_); | 1235 return MarkedForParsingBit::decode(raw_ptr()->state_bits_); |
| 1290 } | 1236 } |
| 1291 void set_is_marked_for_parsing() const; | 1237 void set_is_marked_for_parsing() const; |
| 1292 void reset_is_marked_for_parsing() const; | 1238 void reset_is_marked_for_parsing() const; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1312 bool is_cycle_free() const { | 1258 bool is_cycle_free() const { |
| 1313 return CycleFreeBit::decode(raw_ptr()->state_bits_); | 1259 return CycleFreeBit::decode(raw_ptr()->state_bits_); |
| 1314 } | 1260 } |
| 1315 void set_is_cycle_free() const; | 1261 void set_is_cycle_free() const; |
| 1316 | 1262 |
| 1317 bool is_allocated() const { | 1263 bool is_allocated() const { |
| 1318 return IsAllocatedBit::decode(raw_ptr()->state_bits_); | 1264 return IsAllocatedBit::decode(raw_ptr()->state_bits_); |
| 1319 } | 1265 } |
| 1320 void set_is_allocated(bool value) const; | 1266 void set_is_allocated(bool value) const; |
| 1321 | 1267 |
| 1322 uint16_t num_native_fields() const { | 1268 uint16_t num_native_fields() const { return raw_ptr()->num_native_fields_; } |
| 1323 return raw_ptr()->num_native_fields_; | |
| 1324 } | |
| 1325 void set_num_native_fields(uint16_t value) const { | 1269 void set_num_native_fields(uint16_t value) const { |
| 1326 StoreNonPointer(&raw_ptr()->num_native_fields_, value); | 1270 StoreNonPointer(&raw_ptr()->num_native_fields_, value); |
| 1327 } | 1271 } |
| 1328 | 1272 |
| 1329 RawCode* allocation_stub() const { | 1273 RawCode* allocation_stub() const { return raw_ptr()->allocation_stub_; } |
| 1330 return raw_ptr()->allocation_stub_; | |
| 1331 } | |
| 1332 void set_allocation_stub(const Code& value) const; | 1274 void set_allocation_stub(const Code& value) const; |
| 1333 | 1275 |
| 1334 void DisableAllocationStub() const; | 1276 void DisableAllocationStub() const; |
| 1335 | 1277 |
| 1336 RawArray* constants() const; | 1278 RawArray* constants() const; |
| 1337 void set_constants(const Array& value) const; | 1279 void set_constants(const Array& value) const; |
| 1338 | 1280 |
| 1339 intptr_t FindInvocationDispatcherFunctionIndex(const Function& needle) const; | 1281 intptr_t FindInvocationDispatcherFunctionIndex(const Function& needle) const; |
| 1340 RawFunction* InvocationDispatcherFunctionFromIndex(intptr_t idx) const; | 1282 RawFunction* InvocationDispatcherFunctionFromIndex(intptr_t idx) const; |
| 1341 | 1283 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1355 // error object if evaluating the expression fails. The method has | 1297 // error object if evaluating the expression fails. The method has |
| 1356 // the formal parameters given in param_names, and is invoked with | 1298 // the formal parameters given in param_names, and is invoked with |
| 1357 // the argument values given in param_values. | 1299 // the argument values given in param_values. |
| 1358 RawObject* Evaluate(const String& expr, | 1300 RawObject* Evaluate(const String& expr, |
| 1359 const Array& param_names, | 1301 const Array& param_names, |
| 1360 const Array& param_values) const; | 1302 const Array& param_values) const; |
| 1361 | 1303 |
| 1362 RawError* EnsureIsFinalized(Thread* thread) const; | 1304 RawError* EnsureIsFinalized(Thread* thread) const; |
| 1363 | 1305 |
| 1364 // Allocate a class used for VM internal objects. | 1306 // Allocate a class used for VM internal objects. |
| 1365 template <class FakeObject> static RawClass* New(); | 1307 template <class FakeObject> |
| 1308 static RawClass* New(); |
| 1366 | 1309 |
| 1367 // Allocate instance classes. | 1310 // Allocate instance classes. |
| 1368 static RawClass* New(const Library& lib, | 1311 static RawClass* New(const Library& lib, |
| 1369 const String& name, | 1312 const String& name, |
| 1370 const Script& script, | 1313 const Script& script, |
| 1371 TokenPosition token_pos); | 1314 TokenPosition token_pos); |
| 1372 static RawClass* NewNativeWrapper(const Library& library, | 1315 static RawClass* NewNativeWrapper(const Library& library, |
| 1373 const String& name, | 1316 const String& name, |
| 1374 int num_fields); | 1317 int num_fields); |
| 1375 | 1318 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 | 1359 |
| 1417 private: | 1360 private: |
| 1418 bool CanReloadFinalized(const Class& replacement, | 1361 bool CanReloadFinalized(const Class& replacement, |
| 1419 IsolateReloadContext* context) const; | 1362 IsolateReloadContext* context) const; |
| 1420 bool CanReloadPreFinalized(const Class& replacement, | 1363 bool CanReloadPreFinalized(const Class& replacement, |
| 1421 IsolateReloadContext* context) const; | 1364 IsolateReloadContext* context) const; |
| 1422 | 1365 |
| 1423 // Tells whether instances need morphing for reload. | 1366 // Tells whether instances need morphing for reload. |
| 1424 bool RequiresInstanceMorphing(const Class& replacement) const; | 1367 bool RequiresInstanceMorphing(const Class& replacement) const; |
| 1425 | 1368 |
| 1426 template <class FakeObject> static RawClass* NewCommon(intptr_t index); | 1369 template <class FakeObject> |
| 1370 static RawClass* NewCommon(intptr_t index); |
| 1427 | 1371 |
| 1428 enum MemberKind { | 1372 enum MemberKind { |
| 1429 kAny = 0, | 1373 kAny = 0, |
| 1430 kStatic, | 1374 kStatic, |
| 1431 kInstance, | 1375 kInstance, |
| 1432 kInstanceAllowAbstract, | 1376 kInstanceAllowAbstract, |
| 1433 kConstructor, | 1377 kConstructor, |
| 1434 kFactory, | 1378 kFactory, |
| 1435 }; | 1379 }; |
| 1436 enum StateBits { | 1380 enum StateBits { |
| 1437 kConstBit = 0, | 1381 kConstBit = 0, |
| 1438 kImplementedBit = 1, | 1382 kImplementedBit = 1, |
| 1439 kTypeFinalizedBit = 2, | 1383 kTypeFinalizedBit = 2, |
| 1440 kClassFinalizedPos = 3, | 1384 kClassFinalizedPos = 3, |
| 1441 kClassFinalizedSize = 2, | 1385 kClassFinalizedSize = 2, |
| 1442 kAbstractBit = kClassFinalizedPos + kClassFinalizedSize, // = 5 | 1386 kAbstractBit = kClassFinalizedPos + kClassFinalizedSize, // = 5 |
| 1443 kPatchBit = 6, | 1387 kPatchBit = 6, |
| 1444 kSynthesizedClassBit = 7, | 1388 kSynthesizedClassBit = 7, |
| 1445 kMarkedForParsingBit = 8, | 1389 kMarkedForParsingBit = 8, |
| 1446 kMixinAppAliasBit = 9, | 1390 kMixinAppAliasBit = 9, |
| 1447 kMixinTypeAppliedBit = 10, | 1391 kMixinTypeAppliedBit = 10, |
| 1448 kFieldsMarkedNullableBit = 11, | 1392 kFieldsMarkedNullableBit = 11, |
| 1449 kCycleFreeBit = 12, | 1393 kCycleFreeBit = 12, |
| 1450 kEnumBit = 13, | 1394 kEnumBit = 13, |
| 1451 kIsAllocatedBit = 15, | 1395 kIsAllocatedBit = 15, |
| 1452 }; | 1396 }; |
| 1453 class ConstBit : public BitField<uint16_t, bool, kConstBit, 1> {}; | 1397 class ConstBit : public BitField<uint16_t, bool, kConstBit, 1> {}; |
| 1454 class ImplementedBit : public BitField<uint16_t, bool, kImplementedBit, 1> {}; | 1398 class ImplementedBit : public BitField<uint16_t, bool, kImplementedBit, 1> {}; |
| 1455 class TypeFinalizedBit : | 1399 class TypeFinalizedBit |
| 1456 public BitField<uint16_t, bool, kTypeFinalizedBit, 1> {}; | 1400 : public BitField<uint16_t, bool, kTypeFinalizedBit, 1> {}; |
| 1457 class ClassFinalizedBits : public BitField<uint16_t, | 1401 class ClassFinalizedBits : public BitField<uint16_t, |
| 1458 RawClass::ClassFinalizedState, | 1402 RawClass::ClassFinalizedState, |
| 1459 kClassFinalizedPos, | 1403 kClassFinalizedPos, |
| 1460 kClassFinalizedSize> {}; | 1404 kClassFinalizedSize> {}; |
| 1461 class AbstractBit : public BitField<uint16_t, bool, kAbstractBit, 1> {}; | 1405 class AbstractBit : public BitField<uint16_t, bool, kAbstractBit, 1> {}; |
| 1462 class PatchBit : public BitField<uint16_t, bool, kPatchBit, 1> {}; | 1406 class PatchBit : public BitField<uint16_t, bool, kPatchBit, 1> {}; |
| 1463 class SynthesizedClassBit : | 1407 class SynthesizedClassBit |
| 1464 public BitField<uint16_t, bool, kSynthesizedClassBit, 1> {}; | 1408 : public BitField<uint16_t, bool, kSynthesizedClassBit, 1> {}; |
| 1465 class MarkedForParsingBit : | 1409 class MarkedForParsingBit |
| 1466 public BitField<uint16_t, bool, kMarkedForParsingBit, 1> {}; | 1410 : public BitField<uint16_t, bool, kMarkedForParsingBit, 1> {}; |
| 1467 class MixinAppAliasBit : | 1411 class MixinAppAliasBit |
| 1468 public BitField<uint16_t, bool, kMixinAppAliasBit, 1> {}; | 1412 : public BitField<uint16_t, bool, kMixinAppAliasBit, 1> {}; |
| 1469 class MixinTypeAppliedBit : | 1413 class MixinTypeAppliedBit |
| 1470 public BitField<uint16_t, bool, kMixinTypeAppliedBit, 1> {}; | 1414 : public BitField<uint16_t, bool, kMixinTypeAppliedBit, 1> {}; |
| 1471 class FieldsMarkedNullableBit : | 1415 class FieldsMarkedNullableBit |
| 1472 public BitField<uint16_t, bool, kFieldsMarkedNullableBit, 1> {}; | 1416 : public BitField<uint16_t, bool, kFieldsMarkedNullableBit, 1> {}; |
| 1473 class CycleFreeBit : public BitField<uint16_t, bool, kCycleFreeBit, 1> {}; | 1417 class CycleFreeBit : public BitField<uint16_t, bool, kCycleFreeBit, 1> {}; |
| 1474 class EnumBit : public BitField<uint16_t, bool, kEnumBit, 1> {}; | 1418 class EnumBit : public BitField<uint16_t, bool, kEnumBit, 1> {}; |
| 1475 class IsAllocatedBit : public BitField<uint16_t, bool, kIsAllocatedBit, 1> {}; | 1419 class IsAllocatedBit : public BitField<uint16_t, bool, kIsAllocatedBit, 1> {}; |
| 1476 | 1420 |
| 1477 void set_name(const String& value) const; | 1421 void set_name(const String& value) const; |
| 1478 void set_user_name(const String& value) const; | 1422 void set_user_name(const String& value) const; |
| 1479 RawString* GenerateUserVisibleName() const; | 1423 RawString* GenerateUserVisibleName() const; |
| 1480 void set_state_bits(intptr_t bits) const; | 1424 void set_state_bits(intptr_t bits) const; |
| 1481 | 1425 |
| 1482 void set_canonical_type(const Type& value) const; | 1426 void set_canonical_type(const Type& value) const; |
| 1483 RawType* canonical_type() const; | 1427 RawType* canonical_type() const; |
| 1484 | 1428 |
| 1485 RawArray* invocation_dispatcher_cache() const; | 1429 RawArray* invocation_dispatcher_cache() const; |
| 1486 void set_invocation_dispatcher_cache(const Array& cache) const; | 1430 void set_invocation_dispatcher_cache(const Array& cache) const; |
| 1487 RawFunction* CreateInvocationDispatcher(const String& target_name, | 1431 RawFunction* CreateInvocationDispatcher(const String& target_name, |
| 1488 const Array& args_desc, | 1432 const Array& args_desc, |
| 1489 RawFunction::Kind kind) const; | 1433 RawFunction::Kind kind) const; |
| 1490 | 1434 |
| 1491 void CalculateFieldOffsets() const; | 1435 void CalculateFieldOffsets() const; |
| 1492 | 1436 |
| 1493 // functions_hash_table is in use iff there are at least this many functions. | 1437 // functions_hash_table is in use iff there are at least this many functions. |
| 1494 static const intptr_t kFunctionLookupHashTreshold = 16; | 1438 static const intptr_t kFunctionLookupHashTreshold = 16; |
| 1495 | 1439 |
| 1496 // Initial value for the cached number of type arguments. | 1440 // Initial value for the cached number of type arguments. |
| 1497 static const intptr_t kUnknownNumTypeArguments = -1; | 1441 static const intptr_t kUnknownNumTypeArguments = -1; |
| 1498 | 1442 |
| 1499 int16_t num_type_arguments() const { | 1443 int16_t num_type_arguments() const { return raw_ptr()->num_type_arguments_; } |
| 1500 return raw_ptr()->num_type_arguments_; | |
| 1501 } | |
| 1502 void set_num_type_arguments(intptr_t value) const; | 1444 void set_num_type_arguments(intptr_t value) const; |
| 1503 static intptr_t num_type_arguments_offset() { | 1445 static intptr_t num_type_arguments_offset() { |
| 1504 return OFFSET_OF(RawClass, num_type_arguments_); | 1446 return OFFSET_OF(RawClass, num_type_arguments_); |
| 1505 } | 1447 } |
| 1506 | 1448 |
| 1507 int16_t num_own_type_arguments() const { | 1449 int16_t num_own_type_arguments() const { |
| 1508 return raw_ptr()->num_own_type_arguments_; | 1450 return raw_ptr()->num_own_type_arguments_; |
| 1509 } | 1451 } |
| 1510 void set_num_own_type_arguments(intptr_t value) const; | 1452 void set_num_own_type_arguments(intptr_t value) const; |
| 1511 | 1453 |
| 1512 // Assigns empty array to all raw class array fields. | 1454 // Assigns empty array to all raw class array fields. |
| 1513 void InitEmptyFields(); | 1455 void InitEmptyFields(); |
| 1514 | 1456 |
| 1515 static RawFunction* CheckFunctionType(const Function& func, MemberKind kind); | 1457 static RawFunction* CheckFunctionType(const Function& func, MemberKind kind); |
| 1516 RawFunction* LookupFunction(const String& name, MemberKind kind) const; | 1458 RawFunction* LookupFunction(const String& name, MemberKind kind) const; |
| 1517 RawFunction* LookupFunctionAllowPrivate(const String& name, | 1459 RawFunction* LookupFunctionAllowPrivate(const String& name, |
| 1518 MemberKind kind) const; | 1460 MemberKind kind) const; |
| 1519 RawField* LookupField(const String& name, MemberKind kind) const; | 1461 RawField* LookupField(const String& name, MemberKind kind) const; |
| 1520 | 1462 |
| 1521 RawFunction* LookupAccessorFunction(const char* prefix, | 1463 RawFunction* LookupAccessorFunction(const char* prefix, |
| 1522 intptr_t prefix_length, | 1464 intptr_t prefix_length, |
| 1523 const String& name) const; | 1465 const String& name) const; |
| 1524 | 1466 |
| 1525 // Allocate an instance class which has a VM implementation. | 1467 // Allocate an instance class which has a VM implementation. |
| 1526 template <class FakeInstance> static RawClass* New(intptr_t id); | 1468 template <class FakeInstance> |
| 1469 static RawClass* New(intptr_t id); |
| 1527 | 1470 |
| 1528 // Helper that calls 'Class::New<Instance>(kIllegalCid)'. | 1471 // Helper that calls 'Class::New<Instance>(kIllegalCid)'. |
| 1529 static RawClass* NewInstanceClass(); | 1472 static RawClass* NewInstanceClass(); |
| 1530 | 1473 |
| 1531 // Check the subtype or 'more specific' relationship. | 1474 // Check the subtype or 'more specific' relationship. |
| 1532 bool TypeTest(TypeTestKind test_kind, | 1475 bool TypeTest(TypeTestKind test_kind, |
| 1533 const TypeArguments& type_arguments, | 1476 const TypeArguments& type_arguments, |
| 1534 const Class& other, | 1477 const Class& other, |
| 1535 const TypeArguments& other_type_arguments, | 1478 const TypeArguments& other_type_arguments, |
| 1536 Error* bound_error, | 1479 Error* bound_error, |
| 1537 TrailPtr bound_trail, | 1480 TrailPtr bound_trail, |
| 1538 Heap::Space space) const; | 1481 Heap::Space space) const; |
| 1539 | 1482 |
| 1540 static bool TypeTestNonRecursive( | 1483 static bool TypeTestNonRecursive(const Class& cls, |
| 1541 const Class& cls, | 1484 TypeTestKind test_kind, |
| 1542 TypeTestKind test_kind, | 1485 const TypeArguments& type_arguments, |
| 1543 const TypeArguments& type_arguments, | 1486 const Class& other, |
| 1544 const Class& other, | 1487 const TypeArguments& other_type_arguments, |
| 1545 const TypeArguments& other_type_arguments, | 1488 Error* bound_error, |
| 1546 Error* bound_error, | 1489 TrailPtr bound_trail, |
| 1547 TrailPtr bound_trail, | 1490 Heap::Space space); |
| 1548 Heap::Space space); | |
| 1549 | 1491 |
| 1550 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); | 1492 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); |
| 1551 friend class AbstractType; | 1493 friend class AbstractType; |
| 1552 friend class Instance; | 1494 friend class Instance; |
| 1553 friend class Object; | 1495 friend class Object; |
| 1554 friend class Type; | 1496 friend class Type; |
| 1555 friend class Intrinsifier; | 1497 friend class Intrinsifier; |
| 1556 friend class Precompiler; | 1498 friend class Precompiler; |
| 1557 }; | 1499 }; |
| 1558 | 1500 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 class TypeArguments : public Object { | 1535 class TypeArguments : public Object { |
| 1594 public: | 1536 public: |
| 1595 // We use 30 bits for the hash code so hashes in a snapshot taken on a | 1537 // We use 30 bits for the hash code so hashes in a snapshot taken on a |
| 1596 // 64-bit architecture stay in Smi range when loaded on a 32-bit | 1538 // 64-bit architecture stay in Smi range when loaded on a 32-bit |
| 1597 // architecture. | 1539 // architecture. |
| 1598 static const intptr_t kHashBits = 30; | 1540 static const intptr_t kHashBits = 30; |
| 1599 | 1541 |
| 1600 intptr_t Length() const; | 1542 intptr_t Length() const; |
| 1601 RawAbstractType* TypeAt(intptr_t index) const; | 1543 RawAbstractType* TypeAt(intptr_t index) const; |
| 1602 static intptr_t type_at_offset(intptr_t index) { | 1544 static intptr_t type_at_offset(intptr_t index) { |
| 1603 return OFFSET_OF_RETURNED_VALUE( | 1545 return OFFSET_OF_RETURNED_VALUE(RawTypeArguments, types) + |
| 1604 RawTypeArguments, types) + index * kWordSize; | 1546 index * kWordSize; |
| 1605 } | 1547 } |
| 1606 void SetTypeAt(intptr_t index, const AbstractType& value) const; | 1548 void SetTypeAt(intptr_t index, const AbstractType& value) const; |
| 1607 | 1549 |
| 1608 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". | 1550 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, Smi>". |
| 1609 RawString* Name() const { | 1551 RawString* Name() const { return SubvectorName(0, Length(), kInternalName); } |
| 1610 return SubvectorName(0, Length(), kInternalName); | |
| 1611 } | |
| 1612 | 1552 |
| 1613 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". | 1553 // The name of this type argument vector, e.g. "<T, dynamic, List<T>, int>". |
| 1614 // Names of internal classes are mapped to their public interfaces. | 1554 // Names of internal classes are mapped to their public interfaces. |
| 1615 RawString* UserVisibleName() const { | 1555 RawString* UserVisibleName() const { |
| 1616 return SubvectorName(0, Length(), kUserVisibleName); | 1556 return SubvectorName(0, Length(), kUserVisibleName); |
| 1617 } | 1557 } |
| 1618 | 1558 |
| 1619 // Check if the subvector of length 'len' starting at 'from_index' of this | 1559 // Check if the subvector of length 'len' starting at 'from_index' of this |
| 1620 // type argument vector consists solely of DynamicType. | 1560 // type argument vector consists solely of DynamicType. |
| 1621 bool IsRaw(intptr_t from_index, intptr_t len) const { | 1561 bool IsRaw(intptr_t from_index, intptr_t len) const { |
| 1622 return IsDynamicTypes(false, from_index, len); | 1562 return IsDynamicTypes(false, from_index, len); |
| 1623 } | 1563 } |
| 1624 | 1564 |
| 1625 // Check if this type argument vector would consist solely of DynamicType if | 1565 // Check if this type argument vector would consist solely of DynamicType if |
| 1626 // it was instantiated from a raw (null) instantiator, i.e. consider each type | 1566 // it was instantiated from a raw (null) instantiator, i.e. consider each type |
| 1627 // parameter as it would be first instantiated from a vector of dynamic types. | 1567 // parameter as it would be first instantiated from a vector of dynamic types. |
| 1628 // Consider only a prefix of length 'len'. | 1568 // Consider only a prefix of length 'len'. |
| 1629 bool IsRawInstantiatedRaw(intptr_t len) const { | 1569 bool IsRawInstantiatedRaw(intptr_t len) const { |
| 1630 return IsDynamicTypes(true, 0, len); | 1570 return IsDynamicTypes(true, 0, len); |
| 1631 } | 1571 } |
| 1632 | 1572 |
| 1633 // Check the subtype relationship, considering only a subvector of length | 1573 // Check the subtype relationship, considering only a subvector of length |
| 1634 // 'len' starting at 'from_index'. | 1574 // 'len' starting at 'from_index'. |
| 1635 bool IsSubtypeOf(const TypeArguments& other, | 1575 bool IsSubtypeOf(const TypeArguments& other, |
| 1636 intptr_t from_index, | 1576 intptr_t from_index, |
| 1637 intptr_t len, | 1577 intptr_t len, |
| 1638 Error* bound_error, | 1578 Error* bound_error, |
| 1639 TrailPtr bound_trail, | 1579 TrailPtr bound_trail, |
| 1640 Heap::Space space) const { | 1580 Heap::Space space) const { |
| 1641 return TypeTest(kIsSubtypeOf, other, from_index, len, | 1581 return TypeTest(kIsSubtypeOf, other, from_index, len, bound_error, |
| 1642 bound_error, bound_trail, space); | 1582 bound_trail, space); |
| 1643 } | 1583 } |
| 1644 | 1584 |
| 1645 // Check the 'more specific' relationship, considering only a subvector of | 1585 // Check the 'more specific' relationship, considering only a subvector of |
| 1646 // length 'len' starting at 'from_index'. | 1586 // length 'len' starting at 'from_index'. |
| 1647 bool IsMoreSpecificThan(const TypeArguments& other, | 1587 bool IsMoreSpecificThan(const TypeArguments& other, |
| 1648 intptr_t from_index, | 1588 intptr_t from_index, |
| 1649 intptr_t len, | 1589 intptr_t len, |
| 1650 Error* bound_error, | 1590 Error* bound_error, |
| 1651 TrailPtr bound_trail, | 1591 TrailPtr bound_trail, |
| 1652 Heap::Space space) const { | 1592 Heap::Space space) const { |
| 1653 return TypeTest(kIsMoreSpecificThan, other, from_index, len, | 1593 return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error, |
| 1654 bound_error, bound_trail, space); | 1594 bound_trail, space); |
| 1655 } | 1595 } |
| 1656 | 1596 |
| 1657 // Check if the vectors are equal (they may be null). | 1597 // Check if the vectors are equal (they may be null). |
| 1658 bool Equals(const TypeArguments& other) const { | 1598 bool Equals(const TypeArguments& other) const { |
| 1659 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length()); | 1599 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length()); |
| 1660 } | 1600 } |
| 1661 | 1601 |
| 1662 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const { | 1602 bool IsEquivalent(const TypeArguments& other, TrailPtr trail = NULL) const { |
| 1663 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail); | 1603 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail); |
| 1664 } | 1604 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1686 // Return true if this vector contains a recursive type argument. | 1626 // Return true if this vector contains a recursive type argument. |
| 1687 bool IsRecursive() const; | 1627 bool IsRecursive() const; |
| 1688 | 1628 |
| 1689 // Clone this type argument vector and clone all unfinalized type arguments. | 1629 // Clone this type argument vector and clone all unfinalized type arguments. |
| 1690 // Finalized type arguments are shared. | 1630 // Finalized type arguments are shared. |
| 1691 RawTypeArguments* CloneUnfinalized() const; | 1631 RawTypeArguments* CloneUnfinalized() const; |
| 1692 | 1632 |
| 1693 // Clone this type argument vector and clone all uninstantiated type | 1633 // Clone this type argument vector and clone all uninstantiated type |
| 1694 // arguments, changing the class owner of type parameters. | 1634 // arguments, changing the class owner of type parameters. |
| 1695 // Instantiated type arguments are shared. | 1635 // Instantiated type arguments are shared. |
| 1696 RawTypeArguments* CloneUninstantiated( | 1636 RawTypeArguments* CloneUninstantiated(const Class& new_owner, |
| 1697 const Class& new_owner, TrailPtr trail = NULL) const; | 1637 TrailPtr trail = NULL) const; |
| 1698 | 1638 |
| 1699 // Canonicalize only if instantiated, otherwise returns 'this'. | 1639 // Canonicalize only if instantiated, otherwise returns 'this'. |
| 1700 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; | 1640 RawTypeArguments* Canonicalize(TrailPtr trail = NULL) const; |
| 1701 | 1641 |
| 1702 // Returns a formatted list of occuring type arguments with their URI. | 1642 // Returns a formatted list of occuring type arguments with their URI. |
| 1703 RawString* EnumerateURIs() const; | 1643 RawString* EnumerateURIs() const; |
| 1704 | 1644 |
| 1705 // Return 'this' if this type argument vector is instantiated, i.e. if it does | 1645 // Return 'this' if this type argument vector is instantiated, i.e. if it does |
| 1706 // not refer to type parameters. Otherwise, return a new type argument vector | 1646 // not refer to type parameters. Otherwise, return a new type argument vector |
| 1707 // where each reference to a type parameter is replaced with the corresponding | 1647 // where each reference to a type parameter is replaced with the corresponding |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1738 OFFSET_OF_RETURNED_VALUE(RawTypeArguments, types)); | 1678 OFFSET_OF_RETURNED_VALUE(RawTypeArguments, types)); |
| 1739 return 0; | 1679 return 0; |
| 1740 } | 1680 } |
| 1741 | 1681 |
| 1742 static intptr_t InstanceSize(intptr_t len) { | 1682 static intptr_t InstanceSize(intptr_t len) { |
| 1743 // Ensure that the types() is not adding to the object size, which includes | 1683 // Ensure that the types() is not adding to the object size, which includes |
| 1744 // 3 fields: instantiations_, length_ and hash_. | 1684 // 3 fields: instantiations_, length_ and hash_. |
| 1745 ASSERT(sizeof(RawTypeArguments) == | 1685 ASSERT(sizeof(RawTypeArguments) == |
| 1746 (sizeof(RawObject) + (kNumFields * kWordSize))); | 1686 (sizeof(RawObject) + (kNumFields * kWordSize))); |
| 1747 ASSERT(0 <= len && len <= kMaxElements); | 1687 ASSERT(0 <= len && len <= kMaxElements); |
| 1748 return RoundedAllocationSize( | 1688 return RoundedAllocationSize(sizeof(RawTypeArguments) + |
| 1749 sizeof(RawTypeArguments) + (len * kBytesPerElement)); | 1689 (len * kBytesPerElement)); |
| 1750 } | 1690 } |
| 1751 | 1691 |
| 1752 intptr_t Hash() const; | 1692 intptr_t Hash() const; |
| 1753 | 1693 |
| 1754 static RawTypeArguments* New(intptr_t len, Heap::Space space = Heap::kOld); | 1694 static RawTypeArguments* New(intptr_t len, Heap::Space space = Heap::kOld); |
| 1755 | 1695 |
| 1756 private: | 1696 private: |
| 1757 intptr_t ComputeHash() const; | 1697 intptr_t ComputeHash() const; |
| 1758 void SetHash(intptr_t value) const; | 1698 void SetHash(intptr_t value) const; |
| 1759 | 1699 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 return RoundedAllocationSize(sizeof(RawPatchClass)); | 1744 return RoundedAllocationSize(sizeof(RawPatchClass)); |
| 1805 } | 1745 } |
| 1806 static bool IsInFullSnapshot(RawPatchClass* cls) { | 1746 static bool IsInFullSnapshot(RawPatchClass* cls) { |
| 1807 NoSafepointScope no_safepoint; | 1747 NoSafepointScope no_safepoint; |
| 1808 return Class::IsInFullSnapshot(cls->ptr()->patched_class_); | 1748 return Class::IsInFullSnapshot(cls->ptr()->patched_class_); |
| 1809 } | 1749 } |
| 1810 | 1750 |
| 1811 static RawPatchClass* New(const Class& patched_class, | 1751 static RawPatchClass* New(const Class& patched_class, |
| 1812 const Class& origin_class); | 1752 const Class& origin_class); |
| 1813 | 1753 |
| 1814 static RawPatchClass* New(const Class& patched_class, | 1754 static RawPatchClass* New(const Class& patched_class, const Script& source); |
| 1815 const Script& source); | |
| 1816 | 1755 |
| 1817 private: | 1756 private: |
| 1818 void set_patched_class(const Class& value) const; | 1757 void set_patched_class(const Class& value) const; |
| 1819 void set_origin_class(const Class& value) const; | 1758 void set_origin_class(const Class& value) const; |
| 1820 void set_script(const Script& value) const; | 1759 void set_script(const Script& value) const; |
| 1821 | 1760 |
| 1822 static RawPatchClass* New(); | 1761 static RawPatchClass* New(); |
| 1823 | 1762 |
| 1824 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); | 1763 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); |
| 1825 friend class Class; | 1764 friend class Class; |
| 1826 }; | 1765 }; |
| 1827 | 1766 |
| 1828 | 1767 |
| 1829 class SingleTargetCache : public Object { | 1768 class SingleTargetCache : public Object { |
| 1830 public: | 1769 public: |
| 1831 RawCode* target() const { return raw_ptr()->target_; } | 1770 RawCode* target() const { return raw_ptr()->target_; } |
| 1832 void set_target(const Code& target) const; | 1771 void set_target(const Code& target) const; |
| 1833 static intptr_t target_offset() { | 1772 static intptr_t target_offset() { |
| 1834 return OFFSET_OF(RawSingleTargetCache, target_); | 1773 return OFFSET_OF(RawSingleTargetCache, target_); |
| 1835 } | 1774 } |
| 1836 | 1775 |
| 1837 #define DEFINE_NON_POINTER_FIELD_ACCESSORS(type, name) \ | 1776 #define DEFINE_NON_POINTER_FIELD_ACCESSORS(type, name) \ |
| 1838 type name() const { return raw_ptr()->name##_; } \ | 1777 type name() const { return raw_ptr()->name##_; } \ |
| 1839 void set_##name(type value) const { \ | 1778 void set_##name(type value) const { \ |
| 1840 StoreNonPointer(&raw_ptr()->name##_, value); \ | 1779 StoreNonPointer(&raw_ptr()->name##_, value); \ |
| 1841 } \ | 1780 } \ |
| 1842 static intptr_t name##_offset() { \ | 1781 static intptr_t name##_offset() { \ |
| 1843 return OFFSET_OF(RawSingleTargetCache, name##_); \ | 1782 return OFFSET_OF(RawSingleTargetCache, name##_); \ |
| 1844 } \ | 1783 } |
| 1845 | 1784 |
| 1846 DEFINE_NON_POINTER_FIELD_ACCESSORS(uword, entry_point); | 1785 DEFINE_NON_POINTER_FIELD_ACCESSORS(uword, entry_point); |
| 1847 DEFINE_NON_POINTER_FIELD_ACCESSORS(intptr_t, lower_limit); | 1786 DEFINE_NON_POINTER_FIELD_ACCESSORS(intptr_t, lower_limit); |
| 1848 DEFINE_NON_POINTER_FIELD_ACCESSORS(intptr_t, upper_limit); | 1787 DEFINE_NON_POINTER_FIELD_ACCESSORS(intptr_t, upper_limit); |
| 1849 #undef DEFINE_NON_POINTER_FIELD_ACCESSORS | 1788 #undef DEFINE_NON_POINTER_FIELD_ACCESSORS |
| 1850 | 1789 |
| 1851 static intptr_t InstanceSize() { | 1790 static intptr_t InstanceSize() { |
| 1852 return RoundedAllocationSize(sizeof(RawSingleTargetCache)); | 1791 return RoundedAllocationSize(sizeof(RawSingleTargetCache)); |
| 1853 } | 1792 } |
| 1854 | 1793 |
| 1855 static RawSingleTargetCache* New(); | 1794 static RawSingleTargetCache* New(); |
| 1856 | 1795 |
| 1857 private: | 1796 private: |
| 1858 FINAL_HEAP_OBJECT_IMPLEMENTATION(SingleTargetCache, Object); | 1797 FINAL_HEAP_OBJECT_IMPLEMENTATION(SingleTargetCache, Object); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1885 // copy the ICData in a child object, thus freezing it during background | 1824 // copy the ICData in a child object, thus freezing it during background |
| 1886 // compilation. Code may contain only original ICData objects. | 1825 // compilation. Code may contain only original ICData objects. |
| 1887 class ICData : public Object { | 1826 class ICData : public Object { |
| 1888 public: | 1827 public: |
| 1889 RawFunction* Owner() const; | 1828 RawFunction* Owner() const; |
| 1890 | 1829 |
| 1891 RawICData* Original() const; | 1830 RawICData* Original() const; |
| 1892 | 1831 |
| 1893 void SetOriginal(const ICData& value) const; | 1832 void SetOriginal(const ICData& value) const; |
| 1894 | 1833 |
| 1895 bool IsOriginal() const { | 1834 bool IsOriginal() const { return Original() == this->raw(); } |
| 1896 return Original() == this->raw(); | |
| 1897 } | |
| 1898 | 1835 |
| 1899 RawString* target_name() const { | 1836 RawString* target_name() const { return raw_ptr()->target_name_; } |
| 1900 return raw_ptr()->target_name_; | |
| 1901 } | |
| 1902 | 1837 |
| 1903 RawArray* arguments_descriptor() const { | 1838 RawArray* arguments_descriptor() const { return raw_ptr()->args_descriptor_; } |
| 1904 return raw_ptr()->args_descriptor_; | |
| 1905 } | |
| 1906 | 1839 |
| 1907 intptr_t NumArgsTested() const; | 1840 intptr_t NumArgsTested() const; |
| 1908 | 1841 |
| 1909 intptr_t deopt_id() const { | 1842 intptr_t deopt_id() const { |
| 1910 #if defined(DART_PRECOMPILED_RUNTIME) | 1843 #if defined(DART_PRECOMPILED_RUNTIME) |
| 1911 UNREACHABLE(); | 1844 UNREACHABLE(); |
| 1912 return -1; | 1845 return -1; |
| 1913 #else | 1846 #else |
| 1914 return raw_ptr()->deopt_id_; | 1847 return raw_ptr()->deopt_id_; |
| 1915 #endif | 1848 #endif |
| 1916 } | 1849 } |
| 1917 | 1850 |
| 1918 bool IsImmutable() const; | 1851 bool IsImmutable() const; |
| 1919 | 1852 |
| 1920 void Reset(Zone* zone) const; | 1853 void Reset(Zone* zone) const; |
| 1921 void ResetSwitchable(Zone* zone) const; | 1854 void ResetSwitchable(Zone* zone) const; |
| 1922 | 1855 |
| 1923 // Note: only deopts with reasons before Unknown in this list are recorded in | 1856 // Note: only deopts with reasons before Unknown in this list are recorded in |
| 1924 // the ICData. All other reasons are used purely for informational messages | 1857 // the ICData. All other reasons are used purely for informational messages |
| 1925 // printed during deoptimization itself. | 1858 // printed during deoptimization itself. |
| 1926 #define DEOPT_REASONS(V) \ | 1859 #define DEOPT_REASONS(V) \ |
| 1927 V(BinarySmiOp) \ | 1860 V(BinarySmiOp) \ |
| 1928 V(BinaryMintOp) \ | 1861 V(BinaryMintOp) \ |
| 1929 V(DoubleToSmi) \ | 1862 V(DoubleToSmi) \ |
| 1930 V(CheckSmi) \ | 1863 V(CheckSmi) \ |
| 1931 V(Unknown) \ | 1864 V(Unknown) \ |
| 1932 V(PolymorphicInstanceCallTestFail) \ | 1865 V(PolymorphicInstanceCallTestFail) \ |
| 1933 V(UnaryMintOp) \ | 1866 V(UnaryMintOp) \ |
| 1934 V(BinaryDoubleOp) \ | 1867 V(BinaryDoubleOp) \ |
| 1935 V(UnaryOp) \ | 1868 V(UnaryOp) \ |
| 1936 V(UnboxInteger) \ | 1869 V(UnboxInteger) \ |
| 1937 V(CheckClass) \ | 1870 V(CheckClass) \ |
| 1938 V(CheckArrayBound) \ | 1871 V(CheckArrayBound) \ |
| 1939 V(AtCall) \ | 1872 V(AtCall) \ |
| 1940 V(GuardField) \ | 1873 V(GuardField) \ |
| 1941 V(TestCids) \ | 1874 V(TestCids) \ |
| 1942 V(NumReasons) \ | 1875 V(NumReasons) |
| 1943 | 1876 |
| 1944 enum DeoptReasonId { | 1877 enum DeoptReasonId { |
| 1945 #define DEFINE_ENUM_LIST(name) kDeopt##name, | 1878 #define DEFINE_ENUM_LIST(name) kDeopt##name, |
| 1946 DEOPT_REASONS(DEFINE_ENUM_LIST) | 1879 DEOPT_REASONS(DEFINE_ENUM_LIST) |
| 1947 #undef DEFINE_ENUM_LIST | 1880 #undef DEFINE_ENUM_LIST |
| 1948 }; | 1881 }; |
| 1949 | 1882 |
| 1950 static const intptr_t kLastRecordedDeoptReason = kDeoptUnknown - 1; | 1883 static const intptr_t kLastRecordedDeoptReason = kDeoptUnknown - 1; |
| 1951 | 1884 |
| 1952 enum DeoptFlags { | 1885 enum DeoptFlags { |
| 1953 // Deoptimization is caused by an optimistically hoisted instruction. | 1886 // Deoptimization is caused by an optimistically hoisted instruction. |
| 1954 kHoisted = 1 << 0, | 1887 kHoisted = 1 << 0, |
| 1955 | 1888 |
| 1956 // Deoptimization is caused by an optimistically generalized bounds check. | 1889 // Deoptimization is caused by an optimistically generalized bounds check. |
| 1957 kGeneralized = 1 << 1 | 1890 kGeneralized = 1 << 1 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1978 } | 1911 } |
| 1979 | 1912 |
| 1980 static intptr_t target_name_offset() { | 1913 static intptr_t target_name_offset() { |
| 1981 return OFFSET_OF(RawICData, target_name_); | 1914 return OFFSET_OF(RawICData, target_name_); |
| 1982 } | 1915 } |
| 1983 | 1916 |
| 1984 static intptr_t state_bits_offset() { | 1917 static intptr_t state_bits_offset() { |
| 1985 return OFFSET_OF(RawICData, state_bits_); | 1918 return OFFSET_OF(RawICData, state_bits_); |
| 1986 } | 1919 } |
| 1987 | 1920 |
| 1988 static intptr_t NumArgsTestedShift() { | 1921 static intptr_t NumArgsTestedShift() { return kNumArgsTestedPos; } |
| 1989 return kNumArgsTestedPos; | |
| 1990 } | |
| 1991 | 1922 |
| 1992 static intptr_t NumArgsTestedMask() { | 1923 static intptr_t NumArgsTestedMask() { |
| 1993 return ((1 << kNumArgsTestedSize) - 1) << kNumArgsTestedPos; | 1924 return ((1 << kNumArgsTestedSize) - 1) << kNumArgsTestedPos; |
| 1994 } | 1925 } |
| 1995 | 1926 |
| 1996 static intptr_t arguments_descriptor_offset() { | 1927 static intptr_t arguments_descriptor_offset() { |
| 1997 return OFFSET_OF(RawICData, args_descriptor_); | 1928 return OFFSET_OF(RawICData, args_descriptor_); |
| 1998 } | 1929 } |
| 1999 | 1930 |
| 2000 static intptr_t ic_data_offset() { | 1931 static intptr_t ic_data_offset() { return OFFSET_OF(RawICData, ic_data_); } |
| 2001 return OFFSET_OF(RawICData, ic_data_); | |
| 2002 } | |
| 2003 | 1932 |
| 2004 static intptr_t owner_offset() { | 1933 static intptr_t owner_offset() { return OFFSET_OF(RawICData, owner_); } |
| 2005 return OFFSET_OF(RawICData, owner_); | |
| 2006 } | |
| 2007 | 1934 |
| 2008 // Replaces entry |index| with the sentinel. | 1935 // Replaces entry |index| with the sentinel. |
| 2009 void WriteSentinelAt(intptr_t index) const; | 1936 void WriteSentinelAt(intptr_t index) const; |
| 2010 | 1937 |
| 2011 // Clears the count for entry |index|. | 1938 // Clears the count for entry |index|. |
| 2012 void ClearCountAt(intptr_t index) const; | 1939 void ClearCountAt(intptr_t index) const; |
| 2013 | 1940 |
| 2014 // Clear all entries with the sentinel value (but will preserve initial | 1941 // Clear all entries with the sentinel value (but will preserve initial |
| 2015 // smi smi checks). | 1942 // smi smi checks). |
| 2016 void ClearWithSentinel() const; | 1943 void ClearWithSentinel() const; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 intptr_t GetCountAt(intptr_t index) const; | 2002 intptr_t GetCountAt(intptr_t index) const; |
| 2076 intptr_t AggregateCount() const; | 2003 intptr_t AggregateCount() const; |
| 2077 | 2004 |
| 2078 // Returns this->raw() if num_args_tested == 1 and arg_nr == 1, otherwise | 2005 // Returns this->raw() if num_args_tested == 1 and arg_nr == 1, otherwise |
| 2079 // returns a new ICData object containing only unique arg_nr checks. | 2006 // returns a new ICData object containing only unique arg_nr checks. |
| 2080 // Returns only used entries. | 2007 // Returns only used entries. |
| 2081 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; | 2008 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; |
| 2082 RawICData* AsUnaryClassChecks() const { | 2009 RawICData* AsUnaryClassChecks() const { |
| 2083 return AsUnaryClassChecksForArgNr(0); | 2010 return AsUnaryClassChecksForArgNr(0); |
| 2084 } | 2011 } |
| 2085 RawICData* AsUnaryClassChecksForCid( | 2012 RawICData* AsUnaryClassChecksForCid(intptr_t cid, |
| 2086 intptr_t cid, const Function& target) const; | 2013 const Function& target) const; |
| 2087 | 2014 |
| 2088 // Returns ICData with aggregated receiver count, sorted by highest count. | 2015 // Returns ICData with aggregated receiver count, sorted by highest count. |
| 2089 // Smi not first!! (the convention for ICData used in code generation is that | 2016 // Smi not first!! (the convention for ICData used in code generation is that |
| 2090 // Smi check is first) | 2017 // Smi check is first) |
| 2091 // Used for printing and optimizations. | 2018 // Used for printing and optimizations. |
| 2092 RawICData* AsUnaryClassChecksSortedByCount() const; | 2019 RawICData* AsUnaryClassChecksSortedByCount() const; |
| 2093 | 2020 |
| 2094 // Consider only used entries. | 2021 // Consider only used entries. |
| 2095 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; | 2022 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; |
| 2096 bool AllReceiversAreNumbers() const; | 2023 bool AllReceiversAreNumbers() const; |
| 2097 bool HasOneTarget() const; | 2024 bool HasOneTarget() const; |
| 2098 bool HasOnlyDispatcherTargets() const; | 2025 bool HasOnlyDispatcherTargets() const; |
| 2099 bool HasReceiverClassId(intptr_t class_id) const; | 2026 bool HasReceiverClassId(intptr_t class_id) const; |
| 2100 | 2027 |
| 2101 static RawICData* New(const Function& owner, | 2028 static RawICData* New(const Function& owner, |
| 2102 const String& target_name, | 2029 const String& target_name, |
| 2103 const Array& arguments_descriptor, | 2030 const Array& arguments_descriptor, |
| 2104 intptr_t deopt_id, | 2031 intptr_t deopt_id, |
| 2105 intptr_t num_args_tested, | 2032 intptr_t num_args_tested, |
| 2106 bool is_static_call); | 2033 bool is_static_call); |
| 2107 static RawICData* NewFrom(const ICData& from, intptr_t num_args_tested); | 2034 static RawICData* NewFrom(const ICData& from, intptr_t num_args_tested); |
| 2108 | 2035 |
| 2109 // Generates a new ICData with descriptor and data array copied (deep clone). | 2036 // Generates a new ICData with descriptor and data array copied (deep clone). |
| 2110 static RawICData* Clone(const ICData& from); | 2037 static RawICData* Clone(const ICData& from); |
| 2111 | 2038 |
| 2112 static intptr_t TestEntryLengthFor(intptr_t num_args); | 2039 static intptr_t TestEntryLengthFor(intptr_t num_args); |
| 2113 | 2040 |
| 2114 static intptr_t TargetIndexFor(intptr_t num_args) { | 2041 static intptr_t TargetIndexFor(intptr_t num_args) { return num_args; } |
| 2115 return num_args; | 2042 static intptr_t CodeIndexFor(intptr_t num_args) { return num_args; } |
| 2116 } | |
| 2117 static intptr_t CodeIndexFor(intptr_t num_args) { | |
| 2118 return num_args; | |
| 2119 } | |
| 2120 | 2043 |
| 2121 static intptr_t CountIndexFor(intptr_t num_args) { | 2044 static intptr_t CountIndexFor(intptr_t num_args) { return (num_args + 1); } |
| 2122 return (num_args + 1); | |
| 2123 } | |
| 2124 static intptr_t EntryPointIndexFor(intptr_t num_args) { | 2045 static intptr_t EntryPointIndexFor(intptr_t num_args) { |
| 2125 return (num_args + 1); | 2046 return (num_args + 1); |
| 2126 } | 2047 } |
| 2127 | 2048 |
| 2128 bool IsUsedAt(intptr_t i) const; | 2049 bool IsUsedAt(intptr_t i) const; |
| 2129 | 2050 |
| 2130 void GetUsedCidsForTwoArgs(GrowableArray<intptr_t>* first, | 2051 void GetUsedCidsForTwoArgs(GrowableArray<intptr_t>* first, |
| 2131 GrowableArray<intptr_t>* second) const; | 2052 GrowableArray<intptr_t>* second) const; |
| 2132 | 2053 |
| 2133 void PrintToJSONArray(const JSONArray& jsarray, | 2054 void PrintToJSONArray(const JSONArray& jsarray, |
| 2134 TokenPosition token_pos) const; | 2055 TokenPosition token_pos) const; |
| 2135 | 2056 |
| 2136 // Initialize the preallocated empty ICData entry arrays. | 2057 // Initialize the preallocated empty ICData entry arrays. |
| 2137 static void InitOnce(); | 2058 static void InitOnce(); |
| 2138 | 2059 |
| 2139 enum { | 2060 enum { kCachedICDataArrayCount = 4 }; |
| 2140 kCachedICDataArrayCount = 4 | |
| 2141 }; | |
| 2142 | 2061 |
| 2143 #if defined(TAG_IC_DATA) | 2062 #if defined(TAG_IC_DATA) |
| 2144 void set_tag(intptr_t value) const; | 2063 void set_tag(intptr_t value) const; |
| 2145 intptr_t tag() const { return raw_ptr()->tag_; } | 2064 intptr_t tag() const { return raw_ptr()->tag_; } |
| 2146 #endif | 2065 #endif |
| 2147 | 2066 |
| 2148 void SetIsStaticCall(bool static_call) const; | 2067 void SetIsStaticCall(bool static_call) const; |
| 2149 bool is_static_call() const; | 2068 bool is_static_call() const; |
| 2150 | 2069 |
| 2151 private: | 2070 private: |
| 2152 static RawICData* New(); | 2071 static RawICData* New(); |
| 2153 | 2072 |
| 2154 RawArray* ic_data() const { | 2073 RawArray* ic_data() const { return raw_ptr()->ic_data_; } |
| 2155 return raw_ptr()->ic_data_; | |
| 2156 } | |
| 2157 | 2074 |
| 2158 void set_owner(const Function& value) const; | 2075 void set_owner(const Function& value) const; |
| 2159 void set_target_name(const String& value) const; | 2076 void set_target_name(const String& value) const; |
| 2160 void set_arguments_descriptor(const Array& value) const; | 2077 void set_arguments_descriptor(const Array& value) const; |
| 2161 void set_deopt_id(intptr_t value) const; | 2078 void set_deopt_id(intptr_t value) const; |
| 2162 void SetNumArgsTested(intptr_t value) const; | 2079 void SetNumArgsTested(intptr_t value) const; |
| 2163 void set_ic_data_array(const Array& value) const; | 2080 void set_ic_data_array(const Array& value) const; |
| 2164 void set_state_bits(uint32_t bits) const; | 2081 void set_state_bits(uint32_t bits) const; |
| 2165 | 2082 |
| 2166 bool ValidateInterceptor(const Function& target) const; | 2083 bool ValidateInterceptor(const Function& target) const; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 } | 2166 } |
| 2250 | 2167 |
| 2251 // Build a string of the form '(T, {B b, C c}) => R' representing the | 2168 // Build a string of the form '(T, {B b, C c}) => R' representing the |
| 2252 // user visible signature of the given function. In this example, T and R are | 2169 // user visible signature of the given function. In this example, T and R are |
| 2253 // type parameters of class C, the owner of the function, also called the | 2170 // type parameters of class C, the owner of the function, also called the |
| 2254 // scope class of the function type. | 2171 // scope class of the function type. |
| 2255 // Implicit parameters are hidden, as well as the prefix denoting the | 2172 // Implicit parameters are hidden, as well as the prefix denoting the |
| 2256 // scope class and its type parameters. | 2173 // scope class and its type parameters. |
| 2257 RawString* UserVisibleSignature() const { | 2174 RawString* UserVisibleSignature() const { |
| 2258 const bool instantiate = false; | 2175 const bool instantiate = false; |
| 2259 return BuildSignature( | 2176 return BuildSignature(instantiate, kUserVisibleName, |
| 2260 instantiate, kUserVisibleName, TypeArguments::Handle()); | 2177 TypeArguments::Handle()); |
| 2261 } | 2178 } |
| 2262 | 2179 |
| 2263 // Build a string of the form '(A, {B b, C c}) => D' representing the | 2180 // Build a string of the form '(A, {B b, C c}) => D' representing the |
| 2264 // signature of the given function, where all generic types (e.g. '<T, R>' in | 2181 // signature of the given function, where all generic types (e.g. '<T, R>' in |
| 2265 // 'C<T, R>(T, {B b, C c}) => R') are instantiated using the given | 2182 // 'C<T, R>(T, {B b, C c}) => R') are instantiated using the given |
| 2266 // instantiator type argument vector of a C instance (e.g. '<A, D>'). | 2183 // instantiator type argument vector of a C instance (e.g. '<A, D>'). |
| 2267 RawString* InstantiatedSignatureFrom(const TypeArguments& instantiator, | 2184 RawString* InstantiatedSignatureFrom(const TypeArguments& instantiator, |
| 2268 NameVisibility name_visibility) const { | 2185 NameVisibility name_visibility) const { |
| 2269 const bool instantiate = true; | 2186 const bool instantiate = true; |
| 2270 return BuildSignature(instantiate, name_visibility, instantiator); | 2187 return BuildSignature(instantiate, name_visibility, instantiator); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2306 // Parameter names are valid for all valid parameter indices, and are not | 2223 // Parameter names are valid for all valid parameter indices, and are not |
| 2307 // limited to named optional parameters. | 2224 // limited to named optional parameters. |
| 2308 RawString* ParameterNameAt(intptr_t index) const; | 2225 RawString* ParameterNameAt(intptr_t index) const; |
| 2309 void SetParameterNameAt(intptr_t index, const String& value) const; | 2226 void SetParameterNameAt(intptr_t index, const String& value) const; |
| 2310 RawArray* parameter_names() const { return raw_ptr()->parameter_names_; } | 2227 RawArray* parameter_names() const { return raw_ptr()->parameter_names_; } |
| 2311 void set_parameter_names(const Array& value) const; | 2228 void set_parameter_names(const Array& value) const; |
| 2312 | 2229 |
| 2313 // The type parameters (and their bounds) are specified as an array of | 2230 // The type parameters (and their bounds) are specified as an array of |
| 2314 // TypeParameter. | 2231 // TypeParameter. |
| 2315 RawTypeArguments* type_parameters() const { | 2232 RawTypeArguments* type_parameters() const { |
| 2316 return raw_ptr()->type_parameters_; | 2233 return raw_ptr()->type_parameters_; |
| 2317 } | 2234 } |
| 2318 void set_type_parameters(const TypeArguments& value) const; | 2235 void set_type_parameters(const TypeArguments& value) const; |
| 2319 intptr_t NumTypeParameters(Thread* thread) const; | 2236 intptr_t NumTypeParameters(Thread* thread) const; |
| 2320 | 2237 |
| 2321 // Return a TypeParameter if the type_name is a type parameter of this | 2238 // Return a TypeParameter if the type_name is a type parameter of this |
| 2322 // function or of one of its parent functions. | 2239 // function or of one of its parent functions. |
| 2323 // Unless NULL, adjust function_level accordingly (in and out parameter). | 2240 // Unless NULL, adjust function_level accordingly (in and out parameter). |
| 2324 // Return null otherwise. | 2241 // Return null otherwise. |
| 2325 RawTypeParameter* LookupTypeParameter(const String& type_name, | 2242 RawTypeParameter* LookupTypeParameter(const String& type_name, |
| 2326 intptr_t* function_level) const; | 2243 intptr_t* function_level) const; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2340 | 2257 |
| 2341 // Disables optimized code and switches to unoptimized code (or the lazy | 2258 // Disables optimized code and switches to unoptimized code (or the lazy |
| 2342 // compilation stub). | 2259 // compilation stub). |
| 2343 void SwitchToLazyCompiledUnoptimizedCode() const; | 2260 void SwitchToLazyCompiledUnoptimizedCode() const; |
| 2344 | 2261 |
| 2345 // Compiles unoptimized code (if necessary) and attaches it to the function. | 2262 // Compiles unoptimized code (if necessary) and attaches it to the function. |
| 2346 void EnsureHasCompiledUnoptimizedCode() const; | 2263 void EnsureHasCompiledUnoptimizedCode() const; |
| 2347 | 2264 |
| 2348 // Return the most recently compiled and installed code for this function. | 2265 // Return the most recently compiled and installed code for this function. |
| 2349 // It is not the only Code object that points to this function. | 2266 // It is not the only Code object that points to this function. |
| 2350 RawCode* CurrentCode() const { | 2267 RawCode* CurrentCode() const { return raw_ptr()->code_; } |
| 2351 return raw_ptr()->code_; | |
| 2352 } | |
| 2353 | 2268 |
| 2354 RawCode* unoptimized_code() const { | 2269 RawCode* unoptimized_code() const { |
| 2355 #if defined(DART_PRECOMPILED_RUNTIME) | 2270 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2356 return static_cast<RawCode*>(Object::null()); | 2271 return static_cast<RawCode*>(Object::null()); |
| 2357 #else | 2272 #else |
| 2358 return raw_ptr()->unoptimized_code_; | 2273 return raw_ptr()->unoptimized_code_; |
| 2359 #endif | 2274 #endif |
| 2360 } | 2275 } |
| 2361 void set_unoptimized_code(const Code& value) const; | 2276 void set_unoptimized_code(const Code& value) const; |
| 2362 bool HasCode() const; | 2277 bool HasCode() const; |
| 2363 | 2278 |
| 2364 static intptr_t code_offset() { | 2279 static intptr_t code_offset() { return OFFSET_OF(RawFunction, code_); } |
| 2365 return OFFSET_OF(RawFunction, code_); | |
| 2366 } | |
| 2367 | 2280 |
| 2368 static intptr_t entry_point_offset() { | 2281 static intptr_t entry_point_offset() { |
| 2369 return OFFSET_OF(RawFunction, entry_point_); | 2282 return OFFSET_OF(RawFunction, entry_point_); |
| 2370 } | 2283 } |
| 2371 | 2284 |
| 2372 virtual intptr_t Hash() const; | 2285 virtual intptr_t Hash() const; |
| 2373 | 2286 |
| 2374 // Returns true if there is at least one debugger breakpoint | 2287 // Returns true if there is at least one debugger breakpoint |
| 2375 // set in this function. | 2288 // set in this function. |
| 2376 bool HasBreakpoint() const; | 2289 bool HasBreakpoint() const; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2499 #endif | 2412 #endif |
| 2500 } | 2413 } |
| 2501 void set_token_pos(TokenPosition value) const; | 2414 void set_token_pos(TokenPosition value) const; |
| 2502 | 2415 |
| 2503 TokenPosition end_token_pos() const { | 2416 TokenPosition end_token_pos() const { |
| 2504 #if defined(DART_PRECOMPILED_RUNTIME) | 2417 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2505 return TokenPosition(); | 2418 return TokenPosition(); |
| 2506 #else | 2419 #else |
| 2507 return raw_ptr()->end_token_pos_; | 2420 return raw_ptr()->end_token_pos_; |
| 2508 #endif | 2421 #endif |
| 2509 } | 2422 } |
| 2510 void set_end_token_pos(TokenPosition value) const { | 2423 void set_end_token_pos(TokenPosition value) const { |
| 2511 #if defined(DART_PRECOMPILED_RUNTIME) | 2424 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2512 UNREACHABLE(); | 2425 UNREACHABLE(); |
| 2513 #else | 2426 #else |
| 2514 StoreNonPointer(&raw_ptr()->end_token_pos_, value); | 2427 StoreNonPointer(&raw_ptr()->end_token_pos_, value); |
| 2515 #endif | 2428 #endif |
| 2516 } | 2429 } |
| 2517 | 2430 |
| 2518 intptr_t num_fixed_parameters() const { | 2431 intptr_t num_fixed_parameters() const { |
| 2519 return raw_ptr()->num_fixed_parameters_; | 2432 return raw_ptr()->num_fixed_parameters_; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 bool HasCompatibleParametersWith(const Function& other, | 2606 bool HasCompatibleParametersWith(const Function& other, |
| 2694 Error* bound_error) const; | 2607 Error* bound_error) const; |
| 2695 | 2608 |
| 2696 // Returns true if the type of this function is a subtype of the type of | 2609 // Returns true if the type of this function is a subtype of the type of |
| 2697 // the other function. | 2610 // the other function. |
| 2698 bool IsSubtypeOf(const TypeArguments& type_arguments, | 2611 bool IsSubtypeOf(const TypeArguments& type_arguments, |
| 2699 const Function& other, | 2612 const Function& other, |
| 2700 const TypeArguments& other_type_arguments, | 2613 const TypeArguments& other_type_arguments, |
| 2701 Error* bound_error, | 2614 Error* bound_error, |
| 2702 Heap::Space space) const { | 2615 Heap::Space space) const { |
| 2703 return TypeTest(kIsSubtypeOf, | 2616 return TypeTest(kIsSubtypeOf, type_arguments, other, other_type_arguments, |
| 2704 type_arguments, | 2617 bound_error, space); |
| 2705 other, | |
| 2706 other_type_arguments, | |
| 2707 bound_error, | |
| 2708 space); | |
| 2709 } | 2618 } |
| 2710 | 2619 |
| 2711 // Returns true if the type of this function is more specific than the type of | 2620 // Returns true if the type of this function is more specific than the type of |
| 2712 // the other function. | 2621 // the other function. |
| 2713 bool IsMoreSpecificThan(const TypeArguments& type_arguments, | 2622 bool IsMoreSpecificThan(const TypeArguments& type_arguments, |
| 2714 const Function& other, | 2623 const Function& other, |
| 2715 const TypeArguments& other_type_arguments, | 2624 const TypeArguments& other_type_arguments, |
| 2716 Error* bound_error, | 2625 Error* bound_error, |
| 2717 Heap::Space space) const { | 2626 Heap::Space space) const { |
| 2718 return TypeTest(kIsMoreSpecificThan, | 2627 return TypeTest(kIsMoreSpecificThan, type_arguments, other, |
| 2719 type_arguments, | 2628 other_type_arguments, bound_error, space); |
| 2720 other, | |
| 2721 other_type_arguments, | |
| 2722 bound_error, | |
| 2723 space); | |
| 2724 } | 2629 } |
| 2725 | 2630 |
| 2726 // Check the subtype or 'more specific' relationship. | 2631 // Check the subtype or 'more specific' relationship. |
| 2727 bool TypeTest(TypeTestKind test_kind, | 2632 bool TypeTest(TypeTestKind test_kind, |
| 2728 const TypeArguments& type_arguments, | 2633 const TypeArguments& type_arguments, |
| 2729 const Function& other, | 2634 const Function& other, |
| 2730 const TypeArguments& other_type_arguments, | 2635 const TypeArguments& other_type_arguments, |
| 2731 Error* bound_error, | 2636 Error* bound_error, |
| 2732 Heap::Space space) const; | 2637 Heap::Space space) const; |
| 2733 | 2638 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 | 2684 |
| 2780 // Returns true if this function represents an implicit instance closure | 2685 // Returns true if this function represents an implicit instance closure |
| 2781 // function. | 2686 // function. |
| 2782 bool IsImplicitInstanceClosureFunction() const { | 2687 bool IsImplicitInstanceClosureFunction() const { |
| 2783 return !is_static() && IsImplicitClosureFunction(); | 2688 return !is_static() && IsImplicitClosureFunction(); |
| 2784 } | 2689 } |
| 2785 | 2690 |
| 2786 bool IsConstructorClosureFunction() const; | 2691 bool IsConstructorClosureFunction() const; |
| 2787 | 2692 |
| 2788 // Returns true if this function represents a local function. | 2693 // Returns true if this function represents a local function. |
| 2789 bool IsLocalFunction() const { | 2694 bool IsLocalFunction() const { return parent_function() != Function::null(); } |
| 2790 return parent_function() != Function::null(); | |
| 2791 } | |
| 2792 | 2695 |
| 2793 // Returns true if this function represents a signature function without code. | 2696 // Returns true if this function represents a signature function without code. |
| 2794 bool IsSignatureFunction() const { | 2697 bool IsSignatureFunction() const { |
| 2795 return kind() == RawFunction::kSignatureFunction; | 2698 return kind() == RawFunction::kSignatureFunction; |
| 2796 } | 2699 } |
| 2797 static bool IsSignatureFunction(RawFunction* function) { | 2700 static bool IsSignatureFunction(RawFunction* function) { |
| 2798 NoSafepointScope no_safepoint; | 2701 NoSafepointScope no_safepoint; |
| 2799 return KindBits::decode(function->ptr()->kind_tag_) == | 2702 return KindBits::decode(function->ptr()->kind_tag_) == |
| 2800 RawFunction::kSignatureFunction; | 2703 RawFunction::kSignatureFunction; |
| 2801 } | 2704 } |
| 2802 | 2705 |
| 2803 bool IsAsyncFunction() const { | 2706 bool IsAsyncFunction() const { return modifier() == RawFunction::kAsync; } |
| 2804 return modifier() == RawFunction::kAsync; | |
| 2805 } | |
| 2806 | 2707 |
| 2807 bool IsAsyncClosure() const { | 2708 bool IsAsyncClosure() const { |
| 2808 return is_generated_body() && | 2709 return is_generated_body() && |
| 2809 Function::Handle(parent_function()).IsAsyncFunction(); | 2710 Function::Handle(parent_function()).IsAsyncFunction(); |
| 2810 } | 2711 } |
| 2811 | 2712 |
| 2812 bool IsGenerator() const { | 2713 bool IsGenerator() const { |
| 2813 return (modifier() & RawFunction::kGeneratorBit) != 0; | 2714 return (modifier() & RawFunction::kGeneratorBit) != 0; |
| 2814 } | 2715 } |
| 2815 | 2716 |
| 2816 bool IsSyncGenerator() const { | 2717 bool IsSyncGenerator() const { return modifier() == RawFunction::kSyncGen; } |
| 2817 return modifier() == RawFunction::kSyncGen; | |
| 2818 } | |
| 2819 | 2718 |
| 2820 bool IsSyncGenClosure() const { | 2719 bool IsSyncGenClosure() const { |
| 2821 return is_generated_body() && | 2720 return is_generated_body() && |
| 2822 Function::Handle(parent_function()).IsSyncGenerator(); | 2721 Function::Handle(parent_function()).IsSyncGenerator(); |
| 2823 } | 2722 } |
| 2824 | 2723 |
| 2825 bool IsGeneratorClosure() const { | 2724 bool IsGeneratorClosure() const { |
| 2826 return is_generated_body() && | 2725 return is_generated_body() && |
| 2827 Function::Handle(parent_function()).IsGenerator(); | 2726 Function::Handle(parent_function()).IsGenerator(); |
| 2828 } | 2727 } |
| 2829 | 2728 |
| 2830 bool IsAsyncGenerator() const { | 2729 bool IsAsyncGenerator() const { return modifier() == RawFunction::kAsyncGen; } |
| 2831 return modifier() == RawFunction::kAsyncGen; | |
| 2832 } | |
| 2833 | 2730 |
| 2834 bool IsAsyncGenClosure() const { | 2731 bool IsAsyncGenClosure() const { |
| 2835 return is_generated_body() && | 2732 return is_generated_body() && |
| 2836 Function::Handle(parent_function()).IsAsyncGenerator(); | 2733 Function::Handle(parent_function()).IsAsyncGenerator(); |
| 2837 } | 2734 } |
| 2838 | 2735 |
| 2839 bool IsAsyncOrGenerator() const { | 2736 bool IsAsyncOrGenerator() const { |
| 2840 return modifier() != RawFunction::kNoModifier; | 2737 return modifier() != RawFunction::kNoModifier; |
| 2841 } | 2738 } |
| 2842 | 2739 |
| 2843 static intptr_t InstanceSize() { | 2740 static intptr_t InstanceSize() { |
| 2844 return RoundedAllocationSize(sizeof(RawFunction)); | 2741 return RoundedAllocationSize(sizeof(RawFunction)); |
| 2845 } | 2742 } |
| 2846 | 2743 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2911 } | 2808 } |
| 2912 bool was_compiled() const { | 2809 bool was_compiled() const { |
| 2913 #if defined(DART_PRECOMPILED_RUNTIME) | 2810 #if defined(DART_PRECOMPILED_RUNTIME) |
| 2914 UNREACHABLE(); | 2811 UNREACHABLE(); |
| 2915 return true; | 2812 return true; |
| 2916 #else | 2813 #else |
| 2917 return raw_ptr()->was_compiled_ == 1; | 2814 return raw_ptr()->was_compiled_ == 1; |
| 2918 #endif | 2815 #endif |
| 2919 } | 2816 } |
| 2920 | 2817 |
| 2921 // static: Considered during class-side or top-level resolution rather than | 2818 // static: Considered during class-side or top-level resolution rather than |
| 2922 // instance-side resolution. | 2819 // instance-side resolution. |
| 2923 // const: Valid target of a const constructor call. | 2820 // const: Valid target of a const constructor call. |
| 2924 // abstract: Skipped during instance-side resolution. | 2821 // abstract: Skipped during instance-side resolution. |
| 2925 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private | 2822 // reflectable: Enumerated by mirrors, invocable by mirrors. False for private |
| 2926 // functions of dart: libraries. | 2823 // functions of dart: libraries. |
| 2927 // debuggable: Valid location of a breakpoint. Synthetic code is not | 2824 // debuggable: Valid location of a breakpoint. Synthetic code is not |
| 2928 // debuggable. | 2825 // debuggable. |
| 2929 // visible: Frame is included in stack traces. Synthetic code such as | 2826 // visible: Frame is included in stack traces. Synthetic code such as |
| 2930 // dispatchers is not visible. Synthetic code that can trigger | 2827 // dispatchers is not visible. Synthetic code that can trigger |
| 2931 // exceptions such as the outer async functions that create Futures | 2828 // exceptions such as the outer async functions that create Futures |
| 2932 // is visible. | 2829 // is visible. |
| 2933 // optimizable: Candidate for going through the optimizing compiler. False for | 2830 // optimizable: Candidate for going through the optimizing compiler. False for |
| 2934 // some functions known to be execute infrequently and functions | 2831 // some functions known to be execute infrequently and functions |
| 2935 // which have been de-optimized too many times. | 2832 // which have been de-optimized too many times. |
| 2936 // instrinsic: Has a hand-written assembly prologue. | 2833 // instrinsic: Has a hand-written assembly prologue. |
| 2937 // inlinable: Candidate for inlining. False for functions with features we | 2834 // inlinable: Candidate for inlining. False for functions with features we |
| 2938 // don't support during inlining (e.g., optional parameters), | 2835 // don't support during inlining (e.g., optional parameters), |
| 2939 // functions which are too big, etc. | 2836 // functions which are too big, etc. |
| 2940 // native: Bridge to C/C++ code. | 2837 // native: Bridge to C/C++ code. |
| 2941 // redirecting: Redirecting generative or factory constructor. | 2838 // redirecting: Redirecting generative or factory constructor. |
| 2942 // external: Just a declaration that expects to be defined in another patch | 2839 // external: Just a declaration that expects to be defined in another patch |
| 2943 // file. | 2840 // file. |
| 2944 | 2841 |
| 2945 #define FOR_EACH_FUNCTION_KIND_BIT(V) \ | 2842 #define FOR_EACH_FUNCTION_KIND_BIT(V) \ |
| 2946 V(Static, is_static) \ | 2843 V(Static, is_static) \ |
| 2947 V(Const, is_const) \ | 2844 V(Const, is_const) \ |
| 2948 V(Abstract, is_abstract) \ | 2845 V(Abstract, is_abstract) \ |
| 2949 V(Reflectable, is_reflectable) \ | 2846 V(Reflectable, is_reflectable) \ |
| 2950 V(Visible, is_visible) \ | 2847 V(Visible, is_visible) \ |
| 2951 V(Debuggable, is_debuggable) \ | 2848 V(Debuggable, is_debuggable) \ |
| 2952 V(Optimizable, is_optimizable) \ | 2849 V(Optimizable, is_optimizable) \ |
| 2953 V(Inlinable, is_inlinable) \ | 2850 V(Inlinable, is_inlinable) \ |
| 2954 V(Intrinsic, is_intrinsic) \ | 2851 V(Intrinsic, is_intrinsic) \ |
| 2955 V(Native, is_native) \ | 2852 V(Native, is_native) \ |
| 2956 V(Redirecting, is_redirecting) \ | 2853 V(Redirecting, is_redirecting) \ |
| 2957 V(External, is_external) \ | 2854 V(External, is_external) \ |
| 2958 V(AllowsHoistingCheckClass, allows_hoisting_check_class) \ | 2855 V(AllowsHoistingCheckClass, allows_hoisting_check_class) \ |
| 2959 V(AllowsBoundsCheckGeneralization, allows_bounds_check_generalization) \ | 2856 V(AllowsBoundsCheckGeneralization, allows_bounds_check_generalization) \ |
| 2960 V(GeneratedBody, is_generated_body) \ | 2857 V(GeneratedBody, is_generated_body) \ |
| 2961 V(AlwaysInline, always_inline) \ | 2858 V(AlwaysInline, always_inline) \ |
| 2962 V(PolymorphicTarget, is_polymorphic_target) \ | 2859 V(PolymorphicTarget, is_polymorphic_target) |
| 2963 | 2860 |
| 2964 #define DEFINE_ACCESSORS(name, accessor_name) \ | 2861 #define DEFINE_ACCESSORS(name, accessor_name) \ |
| 2965 void set_##accessor_name(bool value) const { \ | 2862 void set_##accessor_name(bool value) const { \ |
| 2966 set_kind_tag(name##Bit::update(value, raw_ptr()->kind_tag_)); \ | 2863 set_kind_tag(name##Bit::update(value, raw_ptr()->kind_tag_)); \ |
| 2967 } \ | 2864 } \ |
| 2968 bool accessor_name() const { \ | 2865 bool accessor_name() const { return name##Bit::decode(raw_ptr()->kind_tag_); } |
| 2969 return name##Bit::decode(raw_ptr()->kind_tag_); \ | 2866 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS) |
| 2970 } | |
| 2971 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_ACCESSORS) | |
| 2972 #undef DEFINE_ACCESSORS | 2867 #undef DEFINE_ACCESSORS |
| 2973 | 2868 |
| 2974 private: | 2869 private: |
| 2975 void set_ic_data_array(const Array& value) const; | 2870 void set_ic_data_array(const Array& value) const; |
| 2976 void SetInstructionsSafe(const Code& value) const; | 2871 void SetInstructionsSafe(const Code& value) const; |
| 2977 | 2872 |
| 2978 enum KindTagBits { | 2873 enum KindTagBits { |
| 2979 kKindTagPos = 0, | 2874 kKindTagPos = 0, |
| 2980 kKindTagSize = 4, | 2875 kKindTagSize = 4, |
| 2981 kRecognizedTagPos = kKindTagPos + kKindTagSize, | 2876 kRecognizedTagPos = kKindTagPos + kKindTagSize, |
| 2982 kRecognizedTagSize = 9, | 2877 kRecognizedTagSize = 9, |
| 2983 kModifierPos = kRecognizedTagPos + kRecognizedTagSize, | 2878 kModifierPos = kRecognizedTagPos + kRecognizedTagSize, |
| 2984 kModifierSize = 2, | 2879 kModifierSize = 2, |
| 2985 kLastModifierBitPos = kModifierPos + (kModifierSize - 1), | 2880 kLastModifierBitPos = kModifierPos + (kModifierSize - 1), |
| 2986 // Single bit sized fields start here. | 2881 // Single bit sized fields start here. |
| 2987 #define DECLARE_BIT(name, _) k##name##Bit, | 2882 #define DECLARE_BIT(name, _) k##name##Bit, |
| 2988 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT) | 2883 FOR_EACH_FUNCTION_KIND_BIT(DECLARE_BIT) |
| 2989 #undef DECLARE_BIT | 2884 #undef DECLARE_BIT |
| 2990 kNumTagBits | 2885 kNumTagBits |
| 2991 }; | 2886 }; |
| 2992 | 2887 |
| 2993 COMPILE_ASSERT( | 2888 COMPILE_ASSERT(MethodRecognizer::kNumRecognizedMethods < |
| 2994 MethodRecognizer::kNumRecognizedMethods < (1 << kRecognizedTagSize)); | 2889 (1 << kRecognizedTagSize)); |
| 2995 COMPILE_ASSERT( | 2890 COMPILE_ASSERT(kNumTagBits <= |
| 2996 kNumTagBits <= | 2891 (kBitsPerByte * |
| 2997 (kBitsPerByte * sizeof(static_cast<RawFunction*>(0)->kind_tag_))); | 2892 sizeof(static_cast<RawFunction*>(0)->kind_tag_))); |
| 2998 | 2893 |
| 2999 class KindBits : | 2894 class KindBits : public BitField<uint32_t, |
| 3000 public BitField<uint32_t, RawFunction::Kind, kKindTagPos, kKindTagSize> {}; | 2895 RawFunction::Kind, |
| 2896 kKindTagPos, |
| 2897 kKindTagSize> {}; |
| 3001 | 2898 |
| 3002 class RecognizedBits : public BitField<uint32_t, | 2899 class RecognizedBits : public BitField<uint32_t, |
| 3003 MethodRecognizer::Kind, | 2900 MethodRecognizer::Kind, |
| 3004 kRecognizedTagPos, | 2901 kRecognizedTagPos, |
| 3005 kRecognizedTagSize> {}; | 2902 kRecognizedTagSize> {}; |
| 3006 class ModifierBits : public BitField<uint32_t, | 2903 class ModifierBits : public BitField<uint32_t, |
| 3007 RawFunction::AsyncModifier, | 2904 RawFunction::AsyncModifier, |
| 3008 kModifierPos, | 2905 kModifierPos, |
| 3009 kModifierSize> {}; | 2906 kModifierSize> {}; |
| 3010 | 2907 |
| 3011 #define DEFINE_BIT(name, _) \ | 2908 #define DEFINE_BIT(name, _) \ |
| 3012 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {}; | 2909 class name##Bit : public BitField<uint32_t, bool, k##name##Bit, 1> {}; |
| 3013 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) | 2910 FOR_EACH_FUNCTION_KIND_BIT(DEFINE_BIT) |
| 3014 #undef DEFINE_BIT | 2911 #undef DEFINE_BIT |
| 3015 | 2912 |
| 3016 void set_name(const String& value) const; | 2913 void set_name(const String& value) const; |
| 3017 void set_kind(RawFunction::Kind value) const; | 2914 void set_kind(RawFunction::Kind value) const; |
| 3018 void set_parent_function(const Function& value) const; | 2915 void set_parent_function(const Function& value) const; |
| 3019 void set_owner(const Object& value) const; | 2916 void set_owner(const Object& value) const; |
| 3020 RawFunction* implicit_closure_function() const; | 2917 RawFunction* implicit_closure_function() const; |
| 3021 void set_implicit_closure_function(const Function& value) const; | 2918 void set_implicit_closure_function(const Function& value) const; |
| 3022 RawInstance* implicit_static_closure() const; | 2919 RawInstance* implicit_static_closure() const; |
| 3023 void set_implicit_static_closure(const Instance& closure) const; | 2920 void set_implicit_static_closure(const Instance& closure) const; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 FINAL_HEAP_OBJECT_IMPLEMENTATION(Function, Object); | 2954 FINAL_HEAP_OBJECT_IMPLEMENTATION(Function, Object); |
| 3058 friend class Class; | 2955 friend class Class; |
| 3059 friend class SnapshotWriter; | 2956 friend class SnapshotWriter; |
| 3060 friend class Parser; // For set_eval_script. | 2957 friend class Parser; // For set_eval_script. |
| 3061 // RawFunction::VisitFunctionPointers accesses the private constructor of | 2958 // RawFunction::VisitFunctionPointers accesses the private constructor of |
| 3062 // Function. | 2959 // Function. |
| 3063 friend class RawFunction; | 2960 friend class RawFunction; |
| 3064 }; | 2961 }; |
| 3065 | 2962 |
| 3066 | 2963 |
| 3067 class ClosureData: public Object { | 2964 class ClosureData : public Object { |
| 3068 public: | 2965 public: |
| 3069 static intptr_t InstanceSize() { | 2966 static intptr_t InstanceSize() { |
| 3070 return RoundedAllocationSize(sizeof(RawClosureData)); | 2967 return RoundedAllocationSize(sizeof(RawClosureData)); |
| 3071 } | 2968 } |
| 3072 | 2969 |
| 3073 private: | 2970 private: |
| 3074 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; } | 2971 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; } |
| 3075 void set_context_scope(const ContextScope& value) const; | 2972 void set_context_scope(const ContextScope& value) const; |
| 3076 | 2973 |
| 3077 // Enclosing function of this local function. | 2974 // Enclosing function of this local function. |
| 3078 RawFunction* parent_function() const { return raw_ptr()->parent_function_; } | 2975 RawFunction* parent_function() const { return raw_ptr()->parent_function_; } |
| 3079 void set_parent_function(const Function& value) const; | 2976 void set_parent_function(const Function& value) const; |
| 3080 | 2977 |
| 3081 // Signature type of this closure function. | 2978 // Signature type of this closure function. |
| 3082 RawType* signature_type() const { return raw_ptr()->signature_type_; } | 2979 RawType* signature_type() const { return raw_ptr()->signature_type_; } |
| 3083 void set_signature_type(const Type& value) const; | 2980 void set_signature_type(const Type& value) const; |
| 3084 | 2981 |
| 3085 RawInstance* implicit_static_closure() const { | 2982 RawInstance* implicit_static_closure() const { return raw_ptr()->closure_; } |
| 3086 return raw_ptr()->closure_; | |
| 3087 } | |
| 3088 void set_implicit_static_closure(const Instance& closure) const; | 2983 void set_implicit_static_closure(const Instance& closure) const; |
| 3089 | 2984 |
| 3090 static RawClosureData* New(); | 2985 static RawClosureData* New(); |
| 3091 | 2986 |
| 3092 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object); | 2987 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object); |
| 3093 friend class Class; | 2988 friend class Class; |
| 3094 friend class Function; | 2989 friend class Function; |
| 3095 friend class HeapProfiler; | 2990 friend class HeapProfiler; |
| 3096 }; | 2991 }; |
| 3097 | 2992 |
| 3098 | 2993 |
| 3099 class RedirectionData: public Object { | 2994 class RedirectionData : public Object { |
| 3100 public: | 2995 public: |
| 3101 static intptr_t InstanceSize() { | 2996 static intptr_t InstanceSize() { |
| 3102 return RoundedAllocationSize(sizeof(RawRedirectionData)); | 2997 return RoundedAllocationSize(sizeof(RawRedirectionData)); |
| 3103 } | 2998 } |
| 3104 | 2999 |
| 3105 private: | 3000 private: |
| 3106 // The type specifies the class and type arguments of the target constructor. | 3001 // The type specifies the class and type arguments of the target constructor. |
| 3107 RawType* type() const { return raw_ptr()->type_; } | 3002 RawType* type() const { return raw_ptr()->type_; } |
| 3108 void set_type(const Type& value) const; | 3003 void set_type(const Type& value) const; |
| 3109 | 3004 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3187 | 3082 |
| 3188 inline RawInstance* StaticValue() const; | 3083 inline RawInstance* StaticValue() const; |
| 3189 inline void SetStaticValue(const Instance& value, | 3084 inline void SetStaticValue(const Instance& value, |
| 3190 bool save_initial_value = false) const; | 3085 bool save_initial_value = false) const; |
| 3191 | 3086 |
| 3192 RawClass* Owner() const; | 3087 RawClass* Owner() const; |
| 3193 RawClass* Origin() const; // Either mixin class, or same as owner(). | 3088 RawClass* Origin() const; // Either mixin class, or same as owner(). |
| 3194 RawScript* Script() const; | 3089 RawScript* Script() const; |
| 3195 RawObject* RawOwner() const; | 3090 RawObject* RawOwner() const; |
| 3196 | 3091 |
| 3197 RawAbstractType* type() const { return raw_ptr()->type_; } | 3092 RawAbstractType* type() const { return raw_ptr()->type_; } |
| 3198 // Used by class finalizer, otherwise initialized in constructor. | 3093 // Used by class finalizer, otherwise initialized in constructor. |
| 3199 void SetFieldType(const AbstractType& value) const; | 3094 void SetFieldType(const AbstractType& value) const; |
| 3200 | 3095 |
| 3201 static intptr_t InstanceSize() { | 3096 static intptr_t InstanceSize() { |
| 3202 return RoundedAllocationSize(sizeof(RawField)); | 3097 return RoundedAllocationSize(sizeof(RawField)); |
| 3203 } | 3098 } |
| 3204 | 3099 |
| 3205 static RawField* New(const String& name, | 3100 static RawField* New(const String& name, |
| 3206 bool is_static, | 3101 bool is_static, |
| 3207 bool is_final, | 3102 bool is_final, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3235 | 3130 |
| 3236 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 3131 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
| 3237 | 3132 |
| 3238 bool has_initializer() const { | 3133 bool has_initializer() const { |
| 3239 return HasInitializerBit::decode(raw_ptr()->kind_bits_); | 3134 return HasInitializerBit::decode(raw_ptr()->kind_bits_); |
| 3240 } | 3135 } |
| 3241 // Called by parser after allocating field. | 3136 // Called by parser after allocating field. |
| 3242 void set_has_initializer(bool has_initializer) const { | 3137 void set_has_initializer(bool has_initializer) const { |
| 3243 ASSERT(IsOriginal()); | 3138 ASSERT(IsOriginal()); |
| 3244 ASSERT(Thread::Current()->IsMutatorThread()); | 3139 ASSERT(Thread::Current()->IsMutatorThread()); |
| 3245 set_kind_bits(HasInitializerBit::update(has_initializer, | 3140 set_kind_bits( |
| 3246 raw_ptr()->kind_bits_)); | 3141 HasInitializerBit::update(has_initializer, raw_ptr()->kind_bits_)); |
| 3247 } | 3142 } |
| 3248 | 3143 |
| 3249 // Return class id that any non-null value read from this field is guaranteed | 3144 // Return class id that any non-null value read from this field is guaranteed |
| 3250 // to have or kDynamicCid if such class id is not known. | 3145 // to have or kDynamicCid if such class id is not known. |
| 3251 // Stores to this field must update this information hence the name. | 3146 // Stores to this field must update this information hence the name. |
| 3252 intptr_t guarded_cid() const { | 3147 intptr_t guarded_cid() const { |
| 3253 #if defined(DEGUG) | 3148 #if defined(DEGUG) |
| 3254 Thread* thread = Thread::Current(); | 3149 Thread* thread = Thread::Current(); |
| 3255 ASSERT(!IsOriginal() || thread->IsMutator() || thread->IsAtSafepoint()); | 3150 ASSERT(!IsOriginal() || thread->IsMutator() || thread->IsAtSafepoint()); |
| 3256 #endif | 3151 #endif |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3283 } | 3178 } |
| 3284 | 3179 |
| 3285 bool needs_length_check() const { | 3180 bool needs_length_check() const { |
| 3286 const bool r = guarded_list_length() >= Field::kUnknownFixedLength; | 3181 const bool r = guarded_list_length() >= Field::kUnknownFixedLength; |
| 3287 ASSERT(!r || is_final()); | 3182 ASSERT(!r || is_final()); |
| 3288 return r; | 3183 return r; |
| 3289 } | 3184 } |
| 3290 | 3185 |
| 3291 const char* GuardedPropertiesAsCString() const; | 3186 const char* GuardedPropertiesAsCString() const; |
| 3292 | 3187 |
| 3293 intptr_t UnboxedFieldCid() const { | 3188 intptr_t UnboxedFieldCid() const { return guarded_cid(); } |
| 3294 return guarded_cid(); | |
| 3295 } | |
| 3296 | 3189 |
| 3297 bool is_unboxing_candidate() const { | 3190 bool is_unboxing_candidate() const { |
| 3298 return UnboxingCandidateBit::decode(raw_ptr()->kind_bits_); | 3191 return UnboxingCandidateBit::decode(raw_ptr()->kind_bits_); |
| 3299 } | 3192 } |
| 3300 // Default 'true', set to false once optimizing compiler determines it should | 3193 // Default 'true', set to false once optimizing compiler determines it should |
| 3301 // be boxed. | 3194 // be boxed. |
| 3302 void set_is_unboxing_candidate(bool b) const { | 3195 void set_is_unboxing_candidate(bool b) const { |
| 3303 ASSERT(IsOriginal()); | 3196 ASSERT(IsOriginal()); |
| 3304 set_kind_bits(UnboxingCandidateBit::update(b, raw_ptr()->kind_bits_)); | 3197 set_kind_bits(UnboxingCandidateBit::update(b, raw_ptr()->kind_bits_)); |
| 3305 } | 3198 } |
| 3306 | 3199 |
| 3307 static bool IsExternalizableCid(intptr_t cid); | 3200 static bool IsExternalizableCid(intptr_t cid); |
| 3308 | 3201 |
| 3309 enum { | 3202 enum { |
| 3310 kUnknownLengthOffset = -1, | 3203 kUnknownLengthOffset = -1, |
| 3311 kUnknownFixedLength = -1, | 3204 kUnknownFixedLength = -1, |
| 3312 kNoFixedLength = -2, | 3205 kNoFixedLength = -2, |
| 3313 }; | 3206 }; |
| 3314 // Returns false if any value read from this field is guaranteed to be | 3207 // Returns false if any value read from this field is guaranteed to be |
| 3315 // not null. | 3208 // not null. |
| 3316 // Internally we is_nullable_ field contains either kNullCid (nullable) or | 3209 // Internally we is_nullable_ field contains either kNullCid (nullable) or |
| 3317 // any other value (non-nullable) instead of boolean. This is done to simplify | 3210 // any other value (non-nullable) instead of boolean. This is done to simplify |
| 3318 // guarding sequence in the generated code. | 3211 // guarding sequence in the generated code. |
| 3319 bool is_nullable() const { | 3212 bool is_nullable() const { return raw_ptr()->is_nullable_ == kNullCid; } |
| 3320 return raw_ptr()->is_nullable_ == kNullCid; | |
| 3321 } | |
| 3322 void set_is_nullable(bool val) const { | 3213 void set_is_nullable(bool val) const { |
| 3323 ASSERT(Thread::Current()->IsMutatorThread()); | 3214 ASSERT(Thread::Current()->IsMutatorThread()); |
| 3324 StoreNonPointer(&raw_ptr()->is_nullable_, val ? kNullCid : kIllegalCid); | 3215 StoreNonPointer(&raw_ptr()->is_nullable_, val ? kNullCid : kIllegalCid); |
| 3325 } | 3216 } |
| 3326 static intptr_t is_nullable_offset() { | 3217 static intptr_t is_nullable_offset() { |
| 3327 return OFFSET_OF(RawField, is_nullable_); | 3218 return OFFSET_OF(RawField, is_nullable_); |
| 3328 } | 3219 } |
| 3329 | 3220 |
| 3330 // Record store of the given value into this field. May trigger | 3221 // Record store of the given value into this field. May trigger |
| 3331 // deoptimization of dependent optimized code. | 3222 // deoptimization of dependent optimized code. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 kStaticBit, | 3292 kStaticBit, |
| 3402 kFinalBit, | 3293 kFinalBit, |
| 3403 kHasInitializerBit, | 3294 kHasInitializerBit, |
| 3404 kUnboxingCandidateBit, | 3295 kUnboxingCandidateBit, |
| 3405 kReflectableBit, | 3296 kReflectableBit, |
| 3406 kDoubleInitializedBit, | 3297 kDoubleInitializedBit, |
| 3407 }; | 3298 }; |
| 3408 class ConstBit : public BitField<uint8_t, bool, kConstBit, 1> {}; | 3299 class ConstBit : public BitField<uint8_t, bool, kConstBit, 1> {}; |
| 3409 class StaticBit : public BitField<uint8_t, bool, kStaticBit, 1> {}; | 3300 class StaticBit : public BitField<uint8_t, bool, kStaticBit, 1> {}; |
| 3410 class FinalBit : public BitField<uint8_t, bool, kFinalBit, 1> {}; | 3301 class FinalBit : public BitField<uint8_t, bool, kFinalBit, 1> {}; |
| 3411 class HasInitializerBit : | 3302 class HasInitializerBit |
| 3412 public BitField<uint8_t, bool, kHasInitializerBit, 1> {}; | 3303 : public BitField<uint8_t, bool, kHasInitializerBit, 1> {}; |
| 3413 class UnboxingCandidateBit : | 3304 class UnboxingCandidateBit |
| 3414 public BitField<uint8_t, bool, kUnboxingCandidateBit, 1> {}; | 3305 : public BitField<uint8_t, bool, kUnboxingCandidateBit, 1> {}; |
| 3415 class ReflectableBit : public BitField<uint8_t, bool, kReflectableBit, 1> {}; | 3306 class ReflectableBit : public BitField<uint8_t, bool, kReflectableBit, 1> {}; |
| 3416 class DoubleInitializedBit : | 3307 class DoubleInitializedBit |
| 3417 public BitField<uint8_t, bool, kDoubleInitializedBit, 1> {}; | 3308 : public BitField<uint8_t, bool, kDoubleInitializedBit, 1> {}; |
| 3418 | 3309 |
| 3419 // Update guarded cid and guarded length for this field. Returns true, if | 3310 // Update guarded cid and guarded length for this field. Returns true, if |
| 3420 // deoptimization of dependent code is required. | 3311 // deoptimization of dependent code is required. |
| 3421 bool UpdateGuardedCidAndLength(const Object& value) const; | 3312 bool UpdateGuardedCidAndLength(const Object& value) const; |
| 3422 | 3313 |
| 3423 // Force this field's guard to be dynamic and deoptimize dependent code. | 3314 // Force this field's guard to be dynamic and deoptimize dependent code. |
| 3424 void ForceDynamicGuardedCidAndLength() const; | 3315 void ForceDynamicGuardedCidAndLength() const; |
| 3425 | 3316 |
| 3426 void set_name(const String& value) const; | 3317 void set_name(const String& value) const; |
| 3427 void set_is_static(bool is_static) const { | 3318 void set_is_static(bool is_static) const { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 | 3371 |
| 3481 class TokenStream : public Object { | 3372 class TokenStream : public Object { |
| 3482 public: | 3373 public: |
| 3483 RawGrowableObjectArray* TokenObjects() const; | 3374 RawGrowableObjectArray* TokenObjects() const; |
| 3484 void SetTokenObjects(const GrowableObjectArray& value) const; | 3375 void SetTokenObjects(const GrowableObjectArray& value) const; |
| 3485 | 3376 |
| 3486 RawExternalTypedData* GetStream() const; | 3377 RawExternalTypedData* GetStream() const; |
| 3487 void SetStream(const ExternalTypedData& stream) const; | 3378 void SetStream(const ExternalTypedData& stream) const; |
| 3488 | 3379 |
| 3489 RawString* GenerateSource() const; | 3380 RawString* GenerateSource() const; |
| 3490 RawString* GenerateSource(TokenPosition start, | 3381 RawString* GenerateSource(TokenPosition start, TokenPosition end) const; |
| 3491 TokenPosition end) const; | |
| 3492 intptr_t ComputeSourcePosition(TokenPosition tok_pos) const; | 3382 intptr_t ComputeSourcePosition(TokenPosition tok_pos) const; |
| 3493 | 3383 |
| 3494 RawString* PrivateKey() const; | 3384 RawString* PrivateKey() const; |
| 3495 | 3385 |
| 3496 static const intptr_t kBytesPerElement = 1; | 3386 static const intptr_t kBytesPerElement = 1; |
| 3497 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3387 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 3498 | 3388 |
| 3499 static intptr_t InstanceSize() { | 3389 static intptr_t InstanceSize() { |
| 3500 return RoundedAllocationSize(sizeof(RawTokenStream)); | 3390 return RoundedAllocationSize(sizeof(RawTokenStream)); |
| 3501 } | 3391 } |
| 3502 | 3392 |
| 3503 static RawTokenStream* New(intptr_t length); | 3393 static RawTokenStream* New(intptr_t length); |
| 3504 static RawTokenStream* New(const String& source, | 3394 static RawTokenStream* New(const String& source, |
| 3505 const String& private_key, | 3395 const String& private_key, |
| 3506 bool use_shared_tokens); | 3396 bool use_shared_tokens); |
| 3507 | 3397 |
| 3508 static void OpenSharedTokenList(Isolate* isolate); | 3398 static void OpenSharedTokenList(Isolate* isolate); |
| 3509 static void CloseSharedTokenList(Isolate* isolate); | 3399 static void CloseSharedTokenList(Isolate* isolate); |
| 3510 | 3400 |
| 3511 // The class Iterator encapsulates iteration over the tokens | 3401 // The class Iterator encapsulates iteration over the tokens |
| 3512 // in a TokenStream object. | 3402 // in a TokenStream object. |
| 3513 class Iterator : ValueObject { | 3403 class Iterator : ValueObject { |
| 3514 public: | 3404 public: |
| 3515 enum StreamType { | 3405 enum StreamType { kNoNewlines, kAllTokens }; |
| 3516 kNoNewlines, | |
| 3517 kAllTokens | |
| 3518 }; | |
| 3519 | 3406 |
| 3520 Iterator(Zone* zone, | 3407 Iterator(Zone* zone, |
| 3521 const TokenStream& tokens, | 3408 const TokenStream& tokens, |
| 3522 TokenPosition token_pos, | 3409 TokenPosition token_pos, |
| 3523 Iterator::StreamType stream_type = kNoNewlines); | 3410 Iterator::StreamType stream_type = kNoNewlines); |
| 3524 | 3411 |
| 3525 void SetStream(const TokenStream& tokens, TokenPosition token_pos); | 3412 void SetStream(const TokenStream& tokens, TokenPosition token_pos); |
| 3526 bool IsValid() const; | 3413 bool IsValid() const; |
| 3527 | 3414 |
| 3528 inline Token::Kind CurrentTokenKind() const { | 3415 inline Token::Kind CurrentTokenKind() const { return cur_token_kind_; } |
| 3529 return cur_token_kind_; | |
| 3530 } | |
| 3531 | 3416 |
| 3532 Token::Kind LookaheadTokenKind(intptr_t num_tokens); | 3417 Token::Kind LookaheadTokenKind(intptr_t num_tokens); |
| 3533 | 3418 |
| 3534 TokenPosition CurrentPosition() const; | 3419 TokenPosition CurrentPosition() const; |
| 3535 void SetCurrentPosition(TokenPosition token_pos); | 3420 void SetCurrentPosition(TokenPosition token_pos); |
| 3536 | 3421 |
| 3537 void Advance(); | 3422 void Advance(); |
| 3538 | 3423 |
| 3539 RawObject* CurrentToken() const; | 3424 RawObject* CurrentToken() const; |
| 3540 RawString* CurrentLiteral() const; | 3425 RawString* CurrentLiteral() const; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3559 intptr_t cur_token_obj_index_; | 3444 intptr_t cur_token_obj_index_; |
| 3560 Iterator::StreamType stream_type_; | 3445 Iterator::StreamType stream_type_; |
| 3561 }; | 3446 }; |
| 3562 | 3447 |
| 3563 private: | 3448 private: |
| 3564 void SetPrivateKey(const String& value) const; | 3449 void SetPrivateKey(const String& value) const; |
| 3565 | 3450 |
| 3566 static RawTokenStream* New(); | 3451 static RawTokenStream* New(); |
| 3567 static void DataFinalizer(void* isolate_callback_data, | 3452 static void DataFinalizer(void* isolate_callback_data, |
| 3568 Dart_WeakPersistentHandle handle, | 3453 Dart_WeakPersistentHandle handle, |
| 3569 void *peer); | 3454 void* peer); |
| 3570 | 3455 |
| 3571 FINAL_HEAP_OBJECT_IMPLEMENTATION(TokenStream, Object); | 3456 FINAL_HEAP_OBJECT_IMPLEMENTATION(TokenStream, Object); |
| 3572 friend class Class; | 3457 friend class Class; |
| 3573 }; | 3458 }; |
| 3574 | 3459 |
| 3575 | 3460 |
| 3576 class Script : public Object { | 3461 class Script : public Object { |
| 3577 public: | 3462 public: |
| 3578 RawString* url() const { return raw_ptr()->url_; } | 3463 RawString* url() const { return raw_ptr()->url_; } |
| 3579 | 3464 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3593 // The load time in milliseconds since epoch. | 3478 // The load time in milliseconds since epoch. |
| 3594 int64_t load_timestamp() const { return raw_ptr()->load_timestamp_; } | 3479 int64_t load_timestamp() const { return raw_ptr()->load_timestamp_; } |
| 3595 | 3480 |
| 3596 RawArray* compile_time_constants() const { | 3481 RawArray* compile_time_constants() const { |
| 3597 return raw_ptr()->compile_time_constants_; | 3482 return raw_ptr()->compile_time_constants_; |
| 3598 } | 3483 } |
| 3599 void set_compile_time_constants(const Array& value) const; | 3484 void set_compile_time_constants(const Array& value) const; |
| 3600 | 3485 |
| 3601 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } | 3486 RawTokenStream* tokens() const { return raw_ptr()->tokens_; } |
| 3602 | 3487 |
| 3603 void Tokenize(const String& private_key, | 3488 void Tokenize(const String& private_key, bool use_shared_tokens = true) const; |
| 3604 bool use_shared_tokens = true) const; | |
| 3605 | 3489 |
| 3606 RawLibrary* FindLibrary() const; | 3490 RawLibrary* FindLibrary() const; |
| 3607 RawString* GetLine(intptr_t line_number, | 3491 RawString* GetLine(intptr_t line_number, |
| 3608 Heap::Space space = Heap::kNew) const; | 3492 Heap::Space space = Heap::kNew) const; |
| 3609 RawString* GetSnippet(intptr_t from_line, | 3493 RawString* GetSnippet(intptr_t from_line, |
| 3610 intptr_t from_column, | 3494 intptr_t from_column, |
| 3611 intptr_t to_line, | 3495 intptr_t to_line, |
| 3612 intptr_t to_column) const; | 3496 intptr_t to_column) const; |
| 3613 | 3497 |
| 3614 void SetLocationOffset(intptr_t line_offset, intptr_t col_offset) const; | 3498 void SetLocationOffset(intptr_t line_offset, intptr_t col_offset) const; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3662 bool HasNext() const { return next_ix_ < size_; } | 3546 bool HasNext() const { return next_ix_ < size_; } |
| 3663 | 3547 |
| 3664 // Returns next non-null raw object. | 3548 // Returns next non-null raw object. |
| 3665 RawObject* GetNext(); | 3549 RawObject* GetNext(); |
| 3666 | 3550 |
| 3667 private: | 3551 private: |
| 3668 void MoveToNextObject(); | 3552 void MoveToNextObject(); |
| 3669 | 3553 |
| 3670 const Array& array_; | 3554 const Array& array_; |
| 3671 const int size_; // Number of elements to iterate over. | 3555 const int size_; // Number of elements to iterate over. |
| 3672 int next_ix_; // Index of next element. | 3556 int next_ix_; // Index of next element. |
| 3673 | 3557 |
| 3674 friend class ClassDictionaryIterator; | 3558 friend class ClassDictionaryIterator; |
| 3675 friend class LibraryPrefixIterator; | 3559 friend class LibraryPrefixIterator; |
| 3676 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator); | 3560 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator); |
| 3677 }; | 3561 }; |
| 3678 | 3562 |
| 3679 | 3563 |
| 3680 class ClassDictionaryIterator : public DictionaryIterator { | 3564 class ClassDictionaryIterator : public DictionaryIterator { |
| 3681 public: | 3565 public: |
| 3682 enum IterationKind { | 3566 enum IterationKind { |
| 3683 // TODO(hausner): fix call sites that use kIteratePrivate. There is only | 3567 // TODO(hausner): fix call sites that use kIteratePrivate. There is only |
| 3684 // one top-level class per library left, not an array to iterate over. | 3568 // one top-level class per library left, not an array to iterate over. |
| 3685 kIteratePrivate, | 3569 kIteratePrivate, |
| 3686 kNoIteratePrivate | 3570 kNoIteratePrivate |
| 3687 }; | 3571 }; |
| 3688 | 3572 |
| 3689 ClassDictionaryIterator(const Library& library, | 3573 ClassDictionaryIterator(const Library& library, |
| 3690 IterationKind kind = kNoIteratePrivate); | 3574 IterationKind kind = kNoIteratePrivate); |
| 3691 | 3575 |
| 3692 bool HasNext() const { | 3576 bool HasNext() const { |
| 3693 return (next_ix_ < size_) || !toplevel_class_.IsNull(); | 3577 return (next_ix_ < size_) || !toplevel_class_.IsNull(); |
| 3694 } | 3578 } |
| 3695 | 3579 |
| 3696 // Returns a non-null raw class. | 3580 // Returns a non-null raw class. |
| 3697 RawClass* GetNextClass(); | 3581 RawClass* GetNextClass(); |
| 3698 | 3582 |
| 3699 private: | 3583 private: |
| 3700 void MoveToNextClass(); | 3584 void MoveToNextClass(); |
| 3701 | 3585 |
| 3702 Class& toplevel_class_; | 3586 Class& toplevel_class_; |
| 3703 | 3587 |
| 3704 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); | 3588 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); |
| 3705 }; | 3589 }; |
| 3706 | 3590 |
| 3707 | 3591 |
| 3708 class LibraryPrefixIterator : public DictionaryIterator { | 3592 class LibraryPrefixIterator : public DictionaryIterator { |
| 3709 public: | 3593 public: |
| 3710 explicit LibraryPrefixIterator(const Library& library); | 3594 explicit LibraryPrefixIterator(const Library& library); |
| 3711 RawLibraryPrefix* GetNext(); | 3595 RawLibraryPrefix* GetNext(); |
| 3596 |
| 3712 private: | 3597 private: |
| 3713 void Advance(); | 3598 void Advance(); |
| 3714 DISALLOW_COPY_AND_ASSIGN(LibraryPrefixIterator); | 3599 DISALLOW_COPY_AND_ASSIGN(LibraryPrefixIterator); |
| 3715 }; | 3600 }; |
| 3716 | 3601 |
| 3717 | 3602 |
| 3718 class Library : public Object { | 3603 class Library : public Object { |
| 3719 public: | 3604 public: |
| 3720 RawString* name() const { return raw_ptr()->name_; } | 3605 RawString* name() const { return raw_ptr()->name_; } |
| 3721 void SetName(const String& name) const; | 3606 void SetName(const String& name) const; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3797 RawObject* ResolveName(const String& name) const; | 3682 RawObject* ResolveName(const String& name) const; |
| 3798 | 3683 |
| 3799 void AddAnonymousClass(const Class& cls) const; | 3684 void AddAnonymousClass(const Class& cls) const; |
| 3800 | 3685 |
| 3801 void AddExport(const Namespace& ns) const; | 3686 void AddExport(const Namespace& ns) const; |
| 3802 | 3687 |
| 3803 void AddClassMetadata(const Class& cls, | 3688 void AddClassMetadata(const Class& cls, |
| 3804 const Object& tl_owner, | 3689 const Object& tl_owner, |
| 3805 TokenPosition token_pos) const; | 3690 TokenPosition token_pos) const; |
| 3806 void AddFieldMetadata(const Field& field, TokenPosition token_pos) const; | 3691 void AddFieldMetadata(const Field& field, TokenPosition token_pos) const; |
| 3807 void AddFunctionMetadata(const Function& func, | 3692 void AddFunctionMetadata(const Function& func, TokenPosition token_pos) const; |
| 3808 TokenPosition token_pos) const; | |
| 3809 void AddLibraryMetadata(const Object& tl_owner, | 3693 void AddLibraryMetadata(const Object& tl_owner, |
| 3810 TokenPosition token_pos) const; | 3694 TokenPosition token_pos) const; |
| 3811 void AddTypeParameterMetadata(const TypeParameter& param, | 3695 void AddTypeParameterMetadata(const TypeParameter& param, |
| 3812 TokenPosition token_pos) const; | 3696 TokenPosition token_pos) const; |
| 3813 RawObject* GetMetadata(const Object& obj) const; | 3697 RawObject* GetMetadata(const Object& obj) const; |
| 3814 | 3698 |
| 3815 RawClass* toplevel_class() const { | 3699 RawClass* toplevel_class() const { return raw_ptr()->toplevel_class_; } |
| 3816 return raw_ptr()->toplevel_class_; | |
| 3817 } | |
| 3818 void set_toplevel_class(const Class& value) const; | 3700 void set_toplevel_class(const Class& value) const; |
| 3819 | 3701 |
| 3820 RawGrowableObjectArray* patch_classes() const { | 3702 RawGrowableObjectArray* patch_classes() const { |
| 3821 return raw_ptr()->patch_classes_; | 3703 return raw_ptr()->patch_classes_; |
| 3822 } | 3704 } |
| 3823 | 3705 |
| 3824 // Library imports. | 3706 // Library imports. |
| 3825 RawArray* imports() const { return raw_ptr()->imports_; } | 3707 RawArray* imports() const { return raw_ptr()->imports_; } |
| 3826 RawArray* exports() const { return raw_ptr()->exports_; } | 3708 RawArray* exports() const { return raw_ptr()->exports_; } |
| 3827 void AddImport(const Namespace& ns) const; | 3709 void AddImport(const Namespace& ns) const; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3859 | 3741 |
| 3860 intptr_t index() const { return raw_ptr()->index_; } | 3742 intptr_t index() const { return raw_ptr()->index_; } |
| 3861 void set_index(intptr_t value) const { | 3743 void set_index(intptr_t value) const { |
| 3862 StoreNonPointer(&raw_ptr()->index_, value); | 3744 StoreNonPointer(&raw_ptr()->index_, value); |
| 3863 } | 3745 } |
| 3864 | 3746 |
| 3865 void Register(Thread* thread) const; | 3747 void Register(Thread* thread) const; |
| 3866 static void RegisterLibraries(Thread* thread, | 3748 static void RegisterLibraries(Thread* thread, |
| 3867 const GrowableObjectArray& libs); | 3749 const GrowableObjectArray& libs); |
| 3868 | 3750 |
| 3869 bool IsDebuggable() const { | 3751 bool IsDebuggable() const { return raw_ptr()->debuggable_; } |
| 3870 return raw_ptr()->debuggable_; | |
| 3871 } | |
| 3872 void set_debuggable(bool value) const { | 3752 void set_debuggable(bool value) const { |
| 3873 StoreNonPointer(&raw_ptr()->debuggable_, value); | 3753 StoreNonPointer(&raw_ptr()->debuggable_, value); |
| 3874 } | 3754 } |
| 3875 | 3755 |
| 3876 bool is_dart_scheme() const { | 3756 bool is_dart_scheme() const { return raw_ptr()->is_dart_scheme_; } |
| 3877 return raw_ptr()->is_dart_scheme_; | |
| 3878 } | |
| 3879 void set_is_dart_scheme(bool value) const { | 3757 void set_is_dart_scheme(bool value) const { |
| 3880 StoreNonPointer(&raw_ptr()->is_dart_scheme_, value); | 3758 StoreNonPointer(&raw_ptr()->is_dart_scheme_, value); |
| 3881 } | 3759 } |
| 3882 | 3760 |
| 3883 bool IsCoreLibrary() const { | 3761 bool IsCoreLibrary() const { return raw() == CoreLibrary(); } |
| 3884 return raw() == CoreLibrary(); | |
| 3885 } | |
| 3886 | 3762 |
| 3887 inline intptr_t UrlHash() const; | 3763 inline intptr_t UrlHash() const; |
| 3888 | 3764 |
| 3889 static RawLibrary* LookupLibrary(Thread* thread, const String& url); | 3765 static RawLibrary* LookupLibrary(Thread* thread, const String& url); |
| 3890 static RawLibrary* GetLibrary(intptr_t index); | 3766 static RawLibrary* GetLibrary(intptr_t index); |
| 3891 | 3767 |
| 3892 static void InitCoreLibrary(Isolate* isolate); | 3768 static void InitCoreLibrary(Isolate* isolate); |
| 3893 static void InitNativeWrappersLibrary(Isolate* isolate); | 3769 static void InitNativeWrappersLibrary(Isolate* isolate); |
| 3894 | 3770 |
| 3895 static RawLibrary* AsyncLibrary(); | 3771 static RawLibrary* AsyncLibrary(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3923 // helper methods and classes. Allow look up of private classes. | 3799 // helper methods and classes. Allow look up of private classes. |
| 3924 static RawClass* LookupCoreClass(const String& class_name); | 3800 static RawClass* LookupCoreClass(const String& class_name); |
| 3925 | 3801 |
| 3926 | 3802 |
| 3927 // Return Function::null() if function does not exist in libs. | 3803 // Return Function::null() if function does not exist in libs. |
| 3928 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, | 3804 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, |
| 3929 const char* class_name, | 3805 const char* class_name, |
| 3930 const char* function_name); | 3806 const char* function_name); |
| 3931 | 3807 |
| 3932 // Character used to indicate a private identifier. | 3808 // Character used to indicate a private identifier. |
| 3933 static const char kPrivateIdentifierStart = '_'; | 3809 static const char kPrivateIdentifierStart = '_'; |
| 3934 | 3810 |
| 3935 // Character used to separate private identifiers from | 3811 // Character used to separate private identifiers from |
| 3936 // the library-specific key. | 3812 // the library-specific key. |
| 3937 static const char kPrivateKeySeparator = '@'; | 3813 static const char kPrivateKeySeparator = '@'; |
| 3938 | 3814 |
| 3939 void CheckReload(const Library& replacement, | 3815 void CheckReload(const Library& replacement, |
| 3940 IsolateReloadContext* context) const; | 3816 IsolateReloadContext* context) const; |
| 3941 | 3817 |
| 3942 private: | 3818 private: |
| 3943 static const int kInitialImportsCapacity = 4; | 3819 static const int kInitialImportsCapacity = 4; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3962 void InvalidateResolvedName(const String& name) const; | 3838 void InvalidateResolvedName(const String& name) const; |
| 3963 void InvalidateResolvedNamesCache() const; | 3839 void InvalidateResolvedNamesCache() const; |
| 3964 | 3840 |
| 3965 RawArray* exported_names() const { return raw_ptr()->exported_names_; } | 3841 RawArray* exported_names() const { return raw_ptr()->exported_names_; } |
| 3966 bool LookupExportedNamesCache(const String& name, Object* obj) const; | 3842 bool LookupExportedNamesCache(const String& name, Object* obj) const; |
| 3967 void AddToExportedNamesCache(const String& name, const Object& obj) const; | 3843 void AddToExportedNamesCache(const String& name, const Object& obj) const; |
| 3968 | 3844 |
| 3969 | 3845 |
| 3970 void InitImportList() const; | 3846 void InitImportList() const; |
| 3971 void GrowDictionary(const Array& dict, intptr_t dict_size) const; | 3847 void GrowDictionary(const Array& dict, intptr_t dict_size) const; |
| 3972 static RawLibrary* NewLibraryHelper(const String& url, | 3848 static RawLibrary* NewLibraryHelper(const String& url, bool import_core_lib); |
| 3973 bool import_core_lib); | 3849 RawObject* LookupEntry(const String& name, intptr_t* index) const; |
| 3974 RawObject* LookupEntry(const String& name, intptr_t *index) const; | |
| 3975 | 3850 |
| 3976 void AllocatePrivateKey() const; | 3851 void AllocatePrivateKey() const; |
| 3977 | 3852 |
| 3978 RawString* MakeMetadataName(const Object& obj) const; | 3853 RawString* MakeMetadataName(const Object& obj) const; |
| 3979 RawField* GetMetadataField(const String& metaname) const; | 3854 RawField* GetMetadataField(const String& metaname) const; |
| 3980 void AddMetadata(const Object& owner, | 3855 void AddMetadata(const Object& owner, |
| 3981 const String& name, | 3856 const String& name, |
| 3982 TokenPosition token_pos) const; | 3857 TokenPosition token_pos) const; |
| 3983 | 3858 |
| 3984 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); | 3859 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4033 // which is stored in a typed data array (info_array). | 3908 // which is stored in a typed data array (info_array). |
| 4034 class ObjectPool : public Object { | 3909 class ObjectPool : public Object { |
| 4035 public: | 3910 public: |
| 4036 enum EntryType { | 3911 enum EntryType { |
| 4037 kTaggedObject, | 3912 kTaggedObject, |
| 4038 kImmediate, | 3913 kImmediate, |
| 4039 kNativeEntry, | 3914 kNativeEntry, |
| 4040 }; | 3915 }; |
| 4041 | 3916 |
| 4042 struct Entry { | 3917 struct Entry { |
| 4043 Entry() : raw_value_(), type_() { } | 3918 Entry() : raw_value_(), type_() {} |
| 4044 explicit Entry(const Object* obj) : obj_(obj), type_(kTaggedObject) { } | 3919 explicit Entry(const Object* obj) : obj_(obj), type_(kTaggedObject) {} |
| 4045 Entry(uword value, EntryType info) : raw_value_(value), type_(info) { } | 3920 Entry(uword value, EntryType info) : raw_value_(value), type_(info) {} |
| 4046 union { | 3921 union { |
| 4047 const Object* obj_; | 3922 const Object* obj_; |
| 4048 uword raw_value_; | 3923 uword raw_value_; |
| 4049 }; | 3924 }; |
| 4050 EntryType type_; | 3925 EntryType type_; |
| 4051 }; | 3926 }; |
| 4052 | 3927 |
| 4053 intptr_t Length() const { | 3928 intptr_t Length() const { return raw_ptr()->length_; } |
| 4054 return raw_ptr()->length_; | |
| 4055 } | |
| 4056 void SetLength(intptr_t value) const { | 3929 void SetLength(intptr_t value) const { |
| 4057 StoreNonPointer(&raw_ptr()->length_, value); | 3930 StoreNonPointer(&raw_ptr()->length_, value); |
| 4058 } | 3931 } |
| 4059 | 3932 |
| 4060 RawTypedData* info_array() const { | 3933 RawTypedData* info_array() const { return raw_ptr()->info_array_; } |
| 4061 return raw_ptr()->info_array_; | |
| 4062 } | |
| 4063 | 3934 |
| 4064 void set_info_array(const TypedData& info_array) const; | 3935 void set_info_array(const TypedData& info_array) const; |
| 4065 | 3936 |
| 4066 static intptr_t length_offset() { return OFFSET_OF(RawObjectPool, length_); } | 3937 static intptr_t length_offset() { return OFFSET_OF(RawObjectPool, length_); } |
| 4067 static intptr_t data_offset() { | 3938 static intptr_t data_offset() { |
| 4068 return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data); | 3939 return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data); |
| 4069 } | 3940 } |
| 4070 static intptr_t element_offset(intptr_t index) { | 3941 static intptr_t element_offset(intptr_t index) { |
| 4071 return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data) | 3942 return OFFSET_OF_RETURNED_VALUE(RawObjectPool, data) + |
| 4072 + kBytesPerElement * index; | 3943 kBytesPerElement * index; |
| 4073 } | 3944 } |
| 4074 | 3945 |
| 4075 EntryType InfoAt(intptr_t index) const; | 3946 EntryType InfoAt(intptr_t index) const; |
| 4076 | 3947 |
| 4077 RawObject* ObjectAt(intptr_t index) const { | 3948 RawObject* ObjectAt(intptr_t index) const { |
| 4078 ASSERT(InfoAt(index) == kTaggedObject); | 3949 ASSERT(InfoAt(index) == kTaggedObject); |
| 4079 return EntryAddr(index)->raw_obj_; | 3950 return EntryAddr(index)->raw_obj_; |
| 4080 } | 3951 } |
| 4081 void SetObjectAt(intptr_t index, const Object& obj) const { | 3952 void SetObjectAt(intptr_t index, const Object& obj) const { |
| 4082 ASSERT(InfoAt(index) == kTaggedObject); | 3953 ASSERT(InfoAt(index) == kTaggedObject); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4098 return 0; | 3969 return 0; |
| 4099 } | 3970 } |
| 4100 | 3971 |
| 4101 static const intptr_t kBytesPerElement = sizeof(RawObjectPool::Entry); | 3972 static const intptr_t kBytesPerElement = sizeof(RawObjectPool::Entry); |
| 4102 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3973 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 4103 | 3974 |
| 4104 static intptr_t InstanceSize(intptr_t len) { | 3975 static intptr_t InstanceSize(intptr_t len) { |
| 4105 // Ensure that variable length data is not adding to the object length. | 3976 // Ensure that variable length data is not adding to the object length. |
| 4106 ASSERT(sizeof(RawObjectPool) == (sizeof(RawObject) + (2 * kWordSize))); | 3977 ASSERT(sizeof(RawObjectPool) == (sizeof(RawObject) + (2 * kWordSize))); |
| 4107 ASSERT(0 <= len && len <= kMaxElements); | 3978 ASSERT(0 <= len && len <= kMaxElements); |
| 4108 return RoundedAllocationSize( | 3979 return RoundedAllocationSize(sizeof(RawObjectPool) + |
| 4109 sizeof(RawObjectPool) + (len * kBytesPerElement)); | 3980 (len * kBytesPerElement)); |
| 4110 } | 3981 } |
| 4111 | 3982 |
| 4112 static RawObjectPool* New(intptr_t len); | 3983 static RawObjectPool* New(intptr_t len); |
| 4113 | 3984 |
| 4114 // Returns the pool index from the offset relative to a tagged RawObjectPool*, | 3985 // Returns the pool index from the offset relative to a tagged RawObjectPool*, |
| 4115 // adjusting for the tag-bit. | 3986 // adjusting for the tag-bit. |
| 4116 static intptr_t IndexFromOffset(intptr_t offset) { | 3987 static intptr_t IndexFromOffset(intptr_t offset) { |
| 4117 ASSERT(Utils::IsAligned(offset + kHeapObjectTag, kWordSize)); | 3988 ASSERT(Utils::IsAligned(offset + kHeapObjectTag, kWordSize)); |
| 4118 return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement; | 3989 return (offset + kHeapObjectTag - data_offset()) / kBytesPerElement; |
| 4119 } | 3990 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4136 friend class RawObjectPool; | 4007 friend class RawObjectPool; |
| 4137 }; | 4008 }; |
| 4138 | 4009 |
| 4139 | 4010 |
| 4140 class Instructions : public Object { | 4011 class Instructions : public Object { |
| 4141 public: | 4012 public: |
| 4142 // Excludes HeaderSize(). | 4013 // Excludes HeaderSize(). |
| 4143 intptr_t size() const { return abs(raw_ptr()->size_); } | 4014 intptr_t size() const { return abs(raw_ptr()->size_); } |
| 4144 bool HasSingleEntryPoint() const { return raw_ptr()->size_ >= 0; } | 4015 bool HasSingleEntryPoint() const { return raw_ptr()->size_ >= 0; } |
| 4145 | 4016 |
| 4146 uword PayloadStart() const { | 4017 uword PayloadStart() const { return PayloadStart(raw()); } |
| 4147 return PayloadStart(raw()); | 4018 uword CheckedEntryPoint() const { return CheckedEntryPoint(raw()); } |
| 4148 } | 4019 uword UncheckedEntryPoint() const { return UncheckedEntryPoint(raw()); } |
| 4149 uword CheckedEntryPoint() const { | |
| 4150 return CheckedEntryPoint(raw()); | |
| 4151 } | |
| 4152 uword UncheckedEntryPoint() const { | |
| 4153 return UncheckedEntryPoint(raw()); | |
| 4154 } | |
| 4155 static uword PayloadStart(RawInstructions* instr) { | 4020 static uword PayloadStart(RawInstructions* instr) { |
| 4156 return reinterpret_cast<uword>(instr->ptr()) + HeaderSize(); | 4021 return reinterpret_cast<uword>(instr->ptr()) + HeaderSize(); |
| 4157 } | 4022 } |
| 4158 | 4023 |
| 4159 #if defined(TARGET_ARCH_IA32) | 4024 #if defined(TARGET_ARCH_IA32) |
| 4160 static const intptr_t kCheckedEntryOffset = 0; | 4025 static const intptr_t kCheckedEntryOffset = 0; |
| 4161 static const intptr_t kUncheckedEntryOffset = 0; | 4026 static const intptr_t kUncheckedEntryOffset = 0; |
| 4162 #elif defined(TARGET_ARCH_X64) | 4027 #elif defined(TARGET_ARCH_X64) |
| 4163 static const intptr_t kCheckedEntryOffset = 16; | 4028 static const intptr_t kCheckedEntryOffset = 16; |
| 4164 static const intptr_t kUncheckedEntryOffset = 38; | 4029 static const intptr_t kUncheckedEntryOffset = 38; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4186 return entry; | 4051 return entry; |
| 4187 } | 4052 } |
| 4188 static uword UncheckedEntryPoint(RawInstructions* instr) { | 4053 static uword UncheckedEntryPoint(RawInstructions* instr) { |
| 4189 uword entry = PayloadStart(instr); | 4054 uword entry = PayloadStart(instr); |
| 4190 if (instr->ptr()->size_ < 0) { | 4055 if (instr->ptr()->size_ < 0) { |
| 4191 entry += kUncheckedEntryOffset; | 4056 entry += kUncheckedEntryOffset; |
| 4192 } | 4057 } |
| 4193 return entry; | 4058 return entry; |
| 4194 } | 4059 } |
| 4195 | 4060 |
| 4196 static const intptr_t kMaxElements = (kMaxInt32 - | 4061 static const intptr_t kMaxElements = |
| 4197 (sizeof(RawInstructions) + | 4062 (kMaxInt32 - (sizeof(RawInstructions) + sizeof(RawObject) + |
| 4198 sizeof(RawObject) + | 4063 (2 * OS::kMaxPreferredCodeAlignment))); |
| 4199 (2 * OS::kMaxPreferredCodeAlignment))); | |
| 4200 | 4064 |
| 4201 static intptr_t InstanceSize() { | 4065 static intptr_t InstanceSize() { |
| 4202 ASSERT(sizeof(RawInstructions) == | 4066 ASSERT(sizeof(RawInstructions) == |
| 4203 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); | 4067 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); |
| 4204 return 0; | 4068 return 0; |
| 4205 } | 4069 } |
| 4206 | 4070 |
| 4207 static intptr_t InstanceSize(intptr_t size) { | 4071 static intptr_t InstanceSize(intptr_t size) { |
| 4208 intptr_t instructions_size = Utils::RoundUp(size, | 4072 intptr_t instructions_size = |
| 4209 OS::PreferredCodeAlignment()); | 4073 Utils::RoundUp(size, OS::PreferredCodeAlignment()); |
| 4210 intptr_t result = instructions_size + HeaderSize(); | 4074 intptr_t result = instructions_size + HeaderSize(); |
| 4211 ASSERT(result % OS::PreferredCodeAlignment() == 0); | 4075 ASSERT(result % OS::PreferredCodeAlignment() == 0); |
| 4212 return result; | 4076 return result; |
| 4213 } | 4077 } |
| 4214 | 4078 |
| 4215 static intptr_t HeaderSize() { | 4079 static intptr_t HeaderSize() { |
| 4216 intptr_t alignment = OS::PreferredCodeAlignment(); | 4080 intptr_t alignment = OS::PreferredCodeAlignment(); |
| 4217 return Utils::RoundUp(sizeof(RawInstructions), alignment); | 4081 return Utils::RoundUp(sizeof(RawInstructions), alignment); |
| 4218 } | 4082 } |
| 4219 | 4083 |
| 4220 static RawInstructions* FromPayloadStart(uword payload_start) { | 4084 static RawInstructions* FromPayloadStart(uword payload_start) { |
| 4221 return reinterpret_cast<RawInstructions*>( | 4085 return reinterpret_cast<RawInstructions*>(payload_start - HeaderSize() + |
| 4222 payload_start - HeaderSize() + kHeapObjectTag); | 4086 kHeapObjectTag); |
| 4223 } | 4087 } |
| 4224 | 4088 |
| 4225 bool Equals(const Instructions& other) const { | 4089 bool Equals(const Instructions& other) const { |
| 4226 if (size() != other.size()) { | 4090 if (size() != other.size()) { |
| 4227 return false; | 4091 return false; |
| 4228 } | 4092 } |
| 4229 NoSafepointScope no_safepoint; | 4093 NoSafepointScope no_safepoint; |
| 4230 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(size())) == 0; | 4094 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(size())) == 0; |
| 4231 } | 4095 } |
| 4232 | 4096 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 4260 RawLocalVarDescriptors::VarInfo* info) const; | 4124 RawLocalVarDescriptors::VarInfo* info) const; |
| 4261 | 4125 |
| 4262 void GetInfo(intptr_t var_index, RawLocalVarDescriptors::VarInfo* info) const; | 4126 void GetInfo(intptr_t var_index, RawLocalVarDescriptors::VarInfo* info) const; |
| 4263 | 4127 |
| 4264 static const intptr_t kBytesPerElement = | 4128 static const intptr_t kBytesPerElement = |
| 4265 sizeof(RawLocalVarDescriptors::VarInfo); | 4129 sizeof(RawLocalVarDescriptors::VarInfo); |
| 4266 static const intptr_t kMaxElements = RawLocalVarDescriptors::kMaxIndex; | 4130 static const intptr_t kMaxElements = RawLocalVarDescriptors::kMaxIndex; |
| 4267 | 4131 |
| 4268 static intptr_t InstanceSize() { | 4132 static intptr_t InstanceSize() { |
| 4269 ASSERT(sizeof(RawLocalVarDescriptors) == | 4133 ASSERT(sizeof(RawLocalVarDescriptors) == |
| 4270 OFFSET_OF_RETURNED_VALUE(RawLocalVarDescriptors, names)); | 4134 OFFSET_OF_RETURNED_VALUE(RawLocalVarDescriptors, names)); |
| 4271 return 0; | 4135 return 0; |
| 4272 } | 4136 } |
| 4273 static intptr_t InstanceSize(intptr_t len) { | 4137 static intptr_t InstanceSize(intptr_t len) { |
| 4274 ASSERT(0 <= len && len <= kMaxElements); | 4138 ASSERT(0 <= len && len <= kMaxElements); |
| 4275 return RoundedAllocationSize(sizeof(RawLocalVarDescriptors) | 4139 return RoundedAllocationSize( |
| 4276 + (len * kWordSize) // RawStrings for names. | 4140 sizeof(RawLocalVarDescriptors) + |
| 4141 (len * kWordSize) // RawStrings for names. |
| 4277 + (len * sizeof(RawLocalVarDescriptors::VarInfo))); | 4142 + (len * sizeof(RawLocalVarDescriptors::VarInfo))); |
| 4278 } | 4143 } |
| 4279 | 4144 |
| 4280 static RawLocalVarDescriptors* New(intptr_t num_variables); | 4145 static RawLocalVarDescriptors* New(intptr_t num_variables); |
| 4281 | 4146 |
| 4282 static const char* KindToCString(RawLocalVarDescriptors::VarInfoKind kind); | 4147 static const char* KindToCString(RawLocalVarDescriptors::VarInfoKind kind); |
| 4283 | 4148 |
| 4284 private: | 4149 private: |
| 4285 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); | 4150 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); |
| 4286 friend class Class; | 4151 friend class Class; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4325 class Iterator : ValueObject { | 4190 class Iterator : ValueObject { |
| 4326 public: | 4191 public: |
| 4327 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask) | 4192 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask) |
| 4328 : descriptors_(descriptors), | 4193 : descriptors_(descriptors), |
| 4329 kind_mask_(kind_mask), | 4194 kind_mask_(kind_mask), |
| 4330 byte_index_(0), | 4195 byte_index_(0), |
| 4331 cur_pc_offset_(0), | 4196 cur_pc_offset_(0), |
| 4332 cur_kind_(0), | 4197 cur_kind_(0), |
| 4333 cur_deopt_id_(0), | 4198 cur_deopt_id_(0), |
| 4334 cur_token_pos_(0), | 4199 cur_token_pos_(0), |
| 4335 cur_try_index_(0) { | 4200 cur_try_index_(0) {} |
| 4336 } | |
| 4337 | 4201 |
| 4338 bool MoveNext() { | 4202 bool MoveNext() { |
| 4339 // Moves to record that matches kind_mask_. | 4203 // Moves to record that matches kind_mask_. |
| 4340 while (byte_index_ < descriptors_.Length()) { | 4204 while (byte_index_ < descriptors_.Length()) { |
| 4341 int32_t merged_kind_try = descriptors_.DecodeInteger(&byte_index_); | 4205 int32_t merged_kind_try = descriptors_.DecodeInteger(&byte_index_); |
| 4342 cur_kind_ = | 4206 cur_kind_ = |
| 4343 RawPcDescriptors::MergedKindTry::DecodeKind(merged_kind_try); | 4207 RawPcDescriptors::MergedKindTry::DecodeKind(merged_kind_try); |
| 4344 cur_try_index_ = | 4208 cur_try_index_ = |
| 4345 RawPcDescriptors::MergedKindTry::DecodeTryIndex(merged_kind_try); | 4209 RawPcDescriptors::MergedKindTry::DecodeTryIndex(merged_kind_try); |
| 4346 | 4210 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4440 static void Dump(const CodeSourceMap& code_source_map, | 4304 static void Dump(const CodeSourceMap& code_source_map, |
| 4441 const Code& code, | 4305 const Code& code, |
| 4442 const Function& function); | 4306 const Function& function); |
| 4443 | 4307 |
| 4444 class Iterator : ValueObject { | 4308 class Iterator : ValueObject { |
| 4445 public: | 4309 public: |
| 4446 explicit Iterator(const CodeSourceMap& code_source_map) | 4310 explicit Iterator(const CodeSourceMap& code_source_map) |
| 4447 : code_source_map_(code_source_map), | 4311 : code_source_map_(code_source_map), |
| 4448 byte_index_(0), | 4312 byte_index_(0), |
| 4449 cur_pc_offset_(0), | 4313 cur_pc_offset_(0), |
| 4450 cur_token_pos_(0) { | 4314 cur_token_pos_(0) {} |
| 4451 } | |
| 4452 | 4315 |
| 4453 bool MoveNext() { | 4316 bool MoveNext() { |
| 4454 // Moves to the next record. | 4317 // Moves to the next record. |
| 4455 while (byte_index_ < code_source_map_.Length()) { | 4318 while (byte_index_ < code_source_map_.Length()) { |
| 4456 cur_pc_offset_ += code_source_map_.DecodeInteger(&byte_index_); | 4319 cur_pc_offset_ += code_source_map_.DecodeInteger(&byte_index_); |
| 4457 cur_token_pos_ += code_source_map_.DecodeInteger(&byte_index_); | 4320 cur_token_pos_ += code_source_map_.DecodeInteger(&byte_index_); |
| 4458 | 4321 |
| 4459 return true; | 4322 return true; |
| 4460 } | 4323 } |
| 4461 return false; | 4324 return false; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4521 | 4384 |
| 4522 static const intptr_t kMaxLengthInBytes = kSmiMax; | 4385 static const intptr_t kMaxLengthInBytes = kSmiMax; |
| 4523 | 4386 |
| 4524 static intptr_t InstanceSize() { | 4387 static intptr_t InstanceSize() { |
| 4525 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); | 4388 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); |
| 4526 return 0; | 4389 return 0; |
| 4527 } | 4390 } |
| 4528 static intptr_t InstanceSize(intptr_t length) { | 4391 static intptr_t InstanceSize(intptr_t length) { |
| 4529 ASSERT(length >= 0); | 4392 ASSERT(length >= 0); |
| 4530 // The stackmap payload is in an array of bytes. | 4393 // The stackmap payload is in an array of bytes. |
| 4531 intptr_t payload_size = | 4394 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
| 4532 Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | |
| 4533 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size); | 4395 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size); |
| 4534 } | 4396 } |
| 4535 static RawStackmap* New(intptr_t pc_offset, | 4397 static RawStackmap* New(intptr_t pc_offset, |
| 4536 BitmapBuilder* bmap, | 4398 BitmapBuilder* bmap, |
| 4537 intptr_t register_bit_count); | 4399 intptr_t register_bit_count); |
| 4538 | 4400 |
| 4539 static RawStackmap* New(intptr_t length, | 4401 static RawStackmap* New(intptr_t length, |
| 4540 intptr_t register_bit_count, | 4402 intptr_t register_bit_count, |
| 4541 intptr_t pc_offset); | 4403 intptr_t pc_offset); |
| 4542 | 4404 |
| 4543 private: | 4405 private: |
| 4544 void SetLength(intptr_t length) const { | 4406 void SetLength(intptr_t length) const { |
| 4545 StoreNonPointer(&raw_ptr()->length_, length); | 4407 StoreNonPointer(&raw_ptr()->length_, length); |
| 4546 } | 4408 } |
| 4547 | 4409 |
| 4548 bool InRange(intptr_t index) const { return index < Length(); } | 4410 bool InRange(intptr_t index) const { return index < Length(); } |
| 4549 | 4411 |
| 4550 bool GetBit(intptr_t bit_index) const; | 4412 bool GetBit(intptr_t bit_index) const; |
| 4551 void SetBit(intptr_t bit_index, bool value) const; | 4413 void SetBit(intptr_t bit_index, bool value) const; |
| 4552 | 4414 |
| 4553 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); | 4415 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); |
| 4554 friend class BitmapBuilder; | 4416 friend class BitmapBuilder; |
| 4555 friend class Class; | 4417 friend class Class; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4580 bool HasCatchAll(intptr_t try_index) const; | 4442 bool HasCatchAll(intptr_t try_index) const; |
| 4581 | 4443 |
| 4582 static intptr_t InstanceSize() { | 4444 static intptr_t InstanceSize() { |
| 4583 ASSERT(sizeof(RawExceptionHandlers) == | 4445 ASSERT(sizeof(RawExceptionHandlers) == |
| 4584 OFFSET_OF_RETURNED_VALUE(RawExceptionHandlers, data)); | 4446 OFFSET_OF_RETURNED_VALUE(RawExceptionHandlers, data)); |
| 4585 return 0; | 4447 return 0; |
| 4586 } | 4448 } |
| 4587 static intptr_t InstanceSize(intptr_t len) { | 4449 static intptr_t InstanceSize(intptr_t len) { |
| 4588 return RoundedAllocationSize( | 4450 return RoundedAllocationSize( |
| 4589 sizeof(RawExceptionHandlers) + | 4451 sizeof(RawExceptionHandlers) + |
| 4590 (len * sizeof(RawExceptionHandlers::HandlerInfo))); | 4452 (len * sizeof(RawExceptionHandlers::HandlerInfo))); |
| 4591 } | 4453 } |
| 4592 | 4454 |
| 4593 static RawExceptionHandlers* New(intptr_t num_handlers); | 4455 static RawExceptionHandlers* New(intptr_t num_handlers); |
| 4594 static RawExceptionHandlers* New(const Array& handled_types_data); | 4456 static RawExceptionHandlers* New(const Array& handled_types_data); |
| 4595 | 4457 |
| 4596 // We would have a VisitPointers function here to traverse the | 4458 // We would have a VisitPointers function here to traverse the |
| 4597 // exception handler table to visit objects if any in the table. | 4459 // exception handler table to visit objects if any in the table. |
| 4598 | 4460 |
| 4599 private: | 4461 private: |
| 4600 // Pick somewhat arbitrary maximum number of exception handlers | 4462 // Pick somewhat arbitrary maximum number of exception handlers |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4631 static intptr_t NumMaterializations(const GrowableArray<DeoptInstr*>&); | 4493 static intptr_t NumMaterializations(const GrowableArray<DeoptInstr*>&); |
| 4632 | 4494 |
| 4633 // Unpack the entire translation into an array of deoptimization | 4495 // Unpack the entire translation into an array of deoptimization |
| 4634 // instructions. This copies any shared suffixes into the array. | 4496 // instructions. This copies any shared suffixes into the array. |
| 4635 static void Unpack(const Array& table, | 4497 static void Unpack(const Array& table, |
| 4636 const TypedData& packed, | 4498 const TypedData& packed, |
| 4637 GrowableArray<DeoptInstr*>* instructions); | 4499 GrowableArray<DeoptInstr*>* instructions); |
| 4638 | 4500 |
| 4639 // Size of the frame part of the translation not counting kMaterializeObject | 4501 // Size of the frame part of the translation not counting kMaterializeObject |
| 4640 // instructions in the prefix. | 4502 // instructions in the prefix. |
| 4641 static const char* ToCString(const Array& table, | 4503 static const char* ToCString(const Array& table, const TypedData& packed); |
| 4642 const TypedData& packed); | |
| 4643 | 4504 |
| 4644 // Returns true iff decompression yields the same instructions as the | 4505 // Returns true iff decompression yields the same instructions as the |
| 4645 // original. | 4506 // original. |
| 4646 static bool VerifyDecompression(const GrowableArray<DeoptInstr*>& original, | 4507 static bool VerifyDecompression(const GrowableArray<DeoptInstr*>& original, |
| 4647 const Array& deopt_table, | 4508 const Array& deopt_table, |
| 4648 const TypedData& packed); | 4509 const TypedData& packed); |
| 4649 | 4510 |
| 4650 | 4511 |
| 4651 private: | 4512 private: |
| 4652 static void UnpackInto(const Array& table, | 4513 static void UnpackInto(const Array& table, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 } | 4547 } |
| 4687 | 4548 |
| 4688 intptr_t pointer_offsets_length() const { | 4549 intptr_t pointer_offsets_length() const { |
| 4689 return PtrOffBits::decode(raw_ptr()->state_bits_); | 4550 return PtrOffBits::decode(raw_ptr()->state_bits_); |
| 4690 } | 4551 } |
| 4691 | 4552 |
| 4692 bool is_optimized() const { | 4553 bool is_optimized() const { |
| 4693 return OptimizedBit::decode(raw_ptr()->state_bits_); | 4554 return OptimizedBit::decode(raw_ptr()->state_bits_); |
| 4694 } | 4555 } |
| 4695 void set_is_optimized(bool value) const; | 4556 void set_is_optimized(bool value) const; |
| 4696 bool is_alive() const { | 4557 bool is_alive() const { return AliveBit::decode(raw_ptr()->state_bits_); } |
| 4697 return AliveBit::decode(raw_ptr()->state_bits_); | |
| 4698 } | |
| 4699 void set_is_alive(bool value) const; | 4558 void set_is_alive(bool value) const; |
| 4700 | 4559 |
| 4701 uword PayloadStart() const { | 4560 uword PayloadStart() const { |
| 4702 const Instructions& instr = Instructions::Handle(instructions()); | 4561 const Instructions& instr = Instructions::Handle(instructions()); |
| 4703 return instr.PayloadStart(); | 4562 return instr.PayloadStart(); |
| 4704 } | 4563 } |
| 4705 uword UncheckedEntryPoint() const { | 4564 uword UncheckedEntryPoint() const { |
| 4706 const Instructions& instr = Instructions::Handle(instructions()); | 4565 const Instructions& instr = Instructions::Handle(instructions()); |
| 4707 return instr.UncheckedEntryPoint(); | 4566 return instr.UncheckedEntryPoint(); |
| 4708 } | 4567 } |
| 4709 uword CheckedEntryPoint() const { | 4568 uword CheckedEntryPoint() const { |
| 4710 const Instructions& instr = Instructions::Handle(instructions()); | 4569 const Instructions& instr = Instructions::Handle(instructions()); |
| 4711 return instr.CheckedEntryPoint(); | 4570 return instr.CheckedEntryPoint(); |
| 4712 } | 4571 } |
| 4713 intptr_t Size() const { | 4572 intptr_t Size() const { |
| 4714 const Instructions& instr = Instructions::Handle(instructions()); | 4573 const Instructions& instr = Instructions::Handle(instructions()); |
| 4715 return instr.size(); | 4574 return instr.size(); |
| 4716 } | 4575 } |
| 4717 RawObjectPool* GetObjectPool() const { | 4576 RawObjectPool* GetObjectPool() const { return object_pool(); } |
| 4718 return object_pool(); | |
| 4719 } | |
| 4720 bool ContainsInstructionAt(uword addr) const { | 4577 bool ContainsInstructionAt(uword addr) const { |
| 4721 const Instructions& instr = Instructions::Handle(instructions()); | 4578 const Instructions& instr = Instructions::Handle(instructions()); |
| 4722 const uword offset = addr - instr.PayloadStart(); | 4579 const uword offset = addr - instr.PayloadStart(); |
| 4723 return offset < static_cast<uword>(instr.size()); | 4580 return offset < static_cast<uword>(instr.size()); |
| 4724 } | 4581 } |
| 4725 | 4582 |
| 4726 // Returns true if there is a debugger breakpoint set in this code object. | 4583 // Returns true if there is a debugger breakpoint set in this code object. |
| 4727 bool HasBreakpoint() const; | 4584 bool HasBreakpoint() const; |
| 4728 | 4585 |
| 4729 RawPcDescriptors* pc_descriptors() const { | 4586 RawPcDescriptors* pc_descriptors() const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4761 RawArray* deopt_info_array() const { | 4618 RawArray* deopt_info_array() const { |
| 4762 #if defined(DART_PRECOMPILED_RUNTIME) | 4619 #if defined(DART_PRECOMPILED_RUNTIME) |
| 4763 UNREACHABLE(); | 4620 UNREACHABLE(); |
| 4764 return NULL; | 4621 return NULL; |
| 4765 #else | 4622 #else |
| 4766 return raw_ptr()->deopt_info_array_; | 4623 return raw_ptr()->deopt_info_array_; |
| 4767 #endif | 4624 #endif |
| 4768 } | 4625 } |
| 4769 void set_deopt_info_array(const Array& array) const; | 4626 void set_deopt_info_array(const Array& array) const; |
| 4770 | 4627 |
| 4771 RawArray* stackmaps() const { | 4628 RawArray* stackmaps() const { return raw_ptr()->stackmaps_; } |
| 4772 return raw_ptr()->stackmaps_; | |
| 4773 } | |
| 4774 void set_stackmaps(const Array& maps) const; | 4629 void set_stackmaps(const Array& maps) const; |
| 4775 RawStackmap* GetStackmap( | 4630 RawStackmap* GetStackmap(uint32_t pc_offset, |
| 4776 uint32_t pc_offset, Array* stackmaps, Stackmap* map) const; | 4631 Array* stackmaps, |
| 4632 Stackmap* map) const; |
| 4777 | 4633 |
| 4778 enum { | 4634 enum { |
| 4779 kSCallTableOffsetEntry = 0, | 4635 kSCallTableOffsetEntry = 0, |
| 4780 kSCallTableFunctionEntry = 1, | 4636 kSCallTableFunctionEntry = 1, |
| 4781 kSCallTableCodeEntry = 2, | 4637 kSCallTableCodeEntry = 2, |
| 4782 kSCallTableEntryLength = 3, | 4638 kSCallTableEntryLength = 3, |
| 4783 }; | 4639 }; |
| 4784 | 4640 |
| 4785 void set_static_calls_target_table(const Array& value) const; | 4641 void set_static_calls_target_table(const Array& value) const; |
| 4786 RawArray* static_calls_target_table() const { | 4642 RawArray* static_calls_target_table() const { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4817 | 4673 |
| 4818 intptr_t PCOffsetAt(intptr_t idx) const; | 4674 intptr_t PCOffsetAt(intptr_t idx) const; |
| 4819 RawString* CommentAt(intptr_t idx) const; | 4675 RawString* CommentAt(intptr_t idx) const; |
| 4820 | 4676 |
| 4821 private: | 4677 private: |
| 4822 explicit Comments(const Array& comments); | 4678 explicit Comments(const Array& comments); |
| 4823 | 4679 |
| 4824 // Layout of entries describing comments. | 4680 // Layout of entries describing comments. |
| 4825 enum { | 4681 enum { |
| 4826 kPCOffsetEntry = 0, // PC offset to a comment as a Smi. | 4682 kPCOffsetEntry = 0, // PC offset to a comment as a Smi. |
| 4827 kCommentEntry, // Comment text as a String. | 4683 kCommentEntry, // Comment text as a String. |
| 4828 kNumberOfEntries | 4684 kNumberOfEntries |
| 4829 }; | 4685 }; |
| 4830 | 4686 |
| 4831 const Array& comments_; | 4687 const Array& comments_; |
| 4832 | 4688 |
| 4833 friend class Code; | 4689 friend class Code; |
| 4834 | 4690 |
| 4835 DISALLOW_COPY_AND_ASSIGN(Comments); | 4691 DISALLOW_COPY_AND_ASSIGN(Comments); |
| 4836 }; | 4692 }; |
| 4837 | 4693 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4907 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw()); | 4763 StorePointer(&raw_ptr()->exception_handlers_, handlers.raw()); |
| 4908 } | 4764 } |
| 4909 | 4765 |
| 4910 // TODO(turnidge): Consider dropping this function and making | 4766 // TODO(turnidge): Consider dropping this function and making |
| 4911 // everybody use owner(). Currently this function is misused - even | 4767 // everybody use owner(). Currently this function is misused - even |
| 4912 // while generating the snapshot. | 4768 // while generating the snapshot. |
| 4913 RawFunction* function() const { | 4769 RawFunction* function() const { |
| 4914 return reinterpret_cast<RawFunction*>(raw_ptr()->owner_); | 4770 return reinterpret_cast<RawFunction*>(raw_ptr()->owner_); |
| 4915 } | 4771 } |
| 4916 | 4772 |
| 4917 RawObject* owner() const { | 4773 RawObject* owner() const { return raw_ptr()->owner_; } |
| 4918 return raw_ptr()->owner_; | |
| 4919 } | |
| 4920 | 4774 |
| 4921 void set_owner(const Function& function) const { | 4775 void set_owner(const Function& function) const { |
| 4922 ASSERT(function.IsOld()); | 4776 ASSERT(function.IsOld()); |
| 4923 StorePointer(&raw_ptr()->owner_, | 4777 StorePointer(&raw_ptr()->owner_, |
| 4924 reinterpret_cast<RawObject*>(function.raw())); | 4778 reinterpret_cast<RawObject*>(function.raw())); |
| 4925 } | 4779 } |
| 4926 | 4780 |
| 4927 void set_owner(const Class& cls) { | 4781 void set_owner(const Class& cls) { |
| 4928 ASSERT(cls.IsOld()); | 4782 ASSERT(cls.IsOld()); |
| 4929 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(cls.raw())); | 4783 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(cls.raw())); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4983 | 4837 |
| 4984 void DisableStubCode() const; | 4838 void DisableStubCode() const; |
| 4985 | 4839 |
| 4986 void Enable() const { | 4840 void Enable() const { |
| 4987 if (!IsDisabled()) return; | 4841 if (!IsDisabled()) return; |
| 4988 ASSERT(Thread::Current()->IsMutatorThread()); | 4842 ASSERT(Thread::Current()->IsMutatorThread()); |
| 4989 ASSERT(instructions() != active_instructions()); | 4843 ASSERT(instructions() != active_instructions()); |
| 4990 SetActiveInstructions(Instructions::Handle(instructions())); | 4844 SetActiveInstructions(Instructions::Handle(instructions())); |
| 4991 } | 4845 } |
| 4992 | 4846 |
| 4993 bool IsDisabled() const { | 4847 bool IsDisabled() const { return instructions() != active_instructions(); } |
| 4994 return instructions() != active_instructions(); | |
| 4995 } | |
| 4996 | 4848 |
| 4997 private: | 4849 private: |
| 4998 void set_state_bits(intptr_t bits) const; | 4850 void set_state_bits(intptr_t bits) const; |
| 4999 | 4851 |
| 5000 void set_object_pool(RawObjectPool* object_pool) const { | 4852 void set_object_pool(RawObjectPool* object_pool) const { |
| 5001 StorePointer(&raw_ptr()->object_pool_, object_pool); | 4853 StorePointer(&raw_ptr()->object_pool_, object_pool); |
| 5002 } | 4854 } |
| 5003 | 4855 |
| 5004 friend class RawObject; // For RawObject::SizeFromClass(). | 4856 friend class RawObject; // For RawObject::SizeFromClass(). |
| 5005 friend class RawCode; | 4857 friend class RawCode; |
| 5006 enum { | 4858 enum { |
| 5007 kOptimizedBit = 0, | 4859 kOptimizedBit = 0, |
| 5008 kAliveBit = 1, | 4860 kAliveBit = 1, |
| 5009 kPtrOffBit = 2, | 4861 kPtrOffBit = 2, |
| 5010 kPtrOffSize = 30, | 4862 kPtrOffSize = 30, |
| 5011 }; | 4863 }; |
| 5012 | 4864 |
| 5013 class OptimizedBit : public BitField<int32_t, bool, kOptimizedBit, 1> {}; | 4865 class OptimizedBit : public BitField<int32_t, bool, kOptimizedBit, 1> {}; |
| 5014 class AliveBit : public BitField<int32_t, bool, kAliveBit, 1> {}; | 4866 class AliveBit : public BitField<int32_t, bool, kAliveBit, 1> {}; |
| 5015 class PtrOffBits : | 4867 class PtrOffBits |
| 5016 public BitField<int32_t, intptr_t, kPtrOffBit, kPtrOffSize> {}; | 4868 : public BitField<int32_t, intptr_t, kPtrOffBit, kPtrOffSize> {}; |
| 5017 | 4869 |
| 5018 class SlowFindRawCodeVisitor : public FindObjectVisitor { | 4870 class SlowFindRawCodeVisitor : public FindObjectVisitor { |
| 5019 public: | 4871 public: |
| 5020 explicit SlowFindRawCodeVisitor(uword pc) : pc_(pc) { } | 4872 explicit SlowFindRawCodeVisitor(uword pc) : pc_(pc) {} |
| 5021 virtual ~SlowFindRawCodeVisitor() { } | 4873 virtual ~SlowFindRawCodeVisitor() {} |
| 5022 | 4874 |
| 5023 // Check if object matches find condition. | 4875 // Check if object matches find condition. |
| 5024 virtual bool FindObject(RawObject* obj) const; | 4876 virtual bool FindObject(RawObject* obj) const; |
| 5025 | 4877 |
| 5026 private: | 4878 private: |
| 5027 const uword pc_; | 4879 const uword pc_; |
| 5028 | 4880 |
| 5029 DISALLOW_COPY_AND_ASSIGN(SlowFindRawCodeVisitor); | 4881 DISALLOW_COPY_AND_ASSIGN(SlowFindRawCodeVisitor); |
| 5030 }; | 4882 }; |
| 5031 | 4883 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5194 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 5046 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 5195 | 5047 |
| 5196 static intptr_t InstanceSize() { | 5048 static intptr_t InstanceSize() { |
| 5197 ASSERT(sizeof(RawContextScope) == | 5049 ASSERT(sizeof(RawContextScope) == |
| 5198 OFFSET_OF_RETURNED_VALUE(RawContextScope, data)); | 5050 OFFSET_OF_RETURNED_VALUE(RawContextScope, data)); |
| 5199 return 0; | 5051 return 0; |
| 5200 } | 5052 } |
| 5201 | 5053 |
| 5202 static intptr_t InstanceSize(intptr_t len) { | 5054 static intptr_t InstanceSize(intptr_t len) { |
| 5203 ASSERT(0 <= len && len <= kMaxElements); | 5055 ASSERT(0 <= len && len <= kMaxElements); |
| 5204 return RoundedAllocationSize( | 5056 return RoundedAllocationSize(sizeof(RawContextScope) + |
| 5205 sizeof(RawContextScope) + (len * kBytesPerElement)); | 5057 (len * kBytesPerElement)); |
| 5206 } | 5058 } |
| 5207 | 5059 |
| 5208 static RawContextScope* New(intptr_t num_variables, bool is_implicit); | 5060 static RawContextScope* New(intptr_t num_variables, bool is_implicit); |
| 5209 | 5061 |
| 5210 private: | 5062 private: |
| 5211 void set_num_variables(intptr_t num_variables) const { | 5063 void set_num_variables(intptr_t num_variables) const { |
| 5212 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); | 5064 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); |
| 5213 } | 5065 } |
| 5214 | 5066 |
| 5215 void set_is_implicit(bool is_implicit) const { | 5067 void set_is_implicit(bool is_implicit) const { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5232 static const intptr_t kInitialCapacity = 16; | 5084 static const intptr_t kInitialCapacity = 16; |
| 5233 static const intptr_t kSpreadFactor = 7; | 5085 static const intptr_t kSpreadFactor = 7; |
| 5234 static const double kLoadFactor; | 5086 static const double kLoadFactor; |
| 5235 | 5087 |
| 5236 RawArray* buckets() const; | 5088 RawArray* buckets() const; |
| 5237 void set_buckets(const Array& buckets) const; | 5089 void set_buckets(const Array& buckets) const; |
| 5238 | 5090 |
| 5239 intptr_t mask() const; | 5091 intptr_t mask() const; |
| 5240 void set_mask(intptr_t mask) const; | 5092 void set_mask(intptr_t mask) const; |
| 5241 | 5093 |
| 5242 RawString* target_name() const { | 5094 RawString* target_name() const { return raw_ptr()->target_name_; } |
| 5243 return raw_ptr()->target_name_; | |
| 5244 } | |
| 5245 | 5095 |
| 5246 RawArray* arguments_descriptor() const { | 5096 RawArray* arguments_descriptor() const { return raw_ptr()->args_descriptor_; } |
| 5247 return raw_ptr()->args_descriptor_; | |
| 5248 } | |
| 5249 | 5097 |
| 5250 intptr_t filled_entry_count() const; | 5098 intptr_t filled_entry_count() const; |
| 5251 void set_filled_entry_count(intptr_t num) const; | 5099 void set_filled_entry_count(intptr_t num) const; |
| 5252 | 5100 |
| 5253 static intptr_t buckets_offset() { | 5101 static intptr_t buckets_offset() { |
| 5254 return OFFSET_OF(RawMegamorphicCache, buckets_); | 5102 return OFFSET_OF(RawMegamorphicCache, buckets_); |
| 5255 } | 5103 } |
| 5256 static intptr_t mask_offset() { | 5104 static intptr_t mask_offset() { |
| 5257 return OFFSET_OF(RawMegamorphicCache, mask_); | 5105 return OFFSET_OF(RawMegamorphicCache, mask_); |
| 5258 } | 5106 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5300 }; | 5148 }; |
| 5301 | 5149 |
| 5302 | 5150 |
| 5303 class SubtypeTestCache : public Object { | 5151 class SubtypeTestCache : public Object { |
| 5304 public: | 5152 public: |
| 5305 enum Entries { | 5153 enum Entries { |
| 5306 kInstanceClassIdOrFunction = 0, | 5154 kInstanceClassIdOrFunction = 0, |
| 5307 kInstanceTypeArguments = 1, | 5155 kInstanceTypeArguments = 1, |
| 5308 kInstantiatorTypeArguments = 2, | 5156 kInstantiatorTypeArguments = 2, |
| 5309 kTestResult = 3, | 5157 kTestResult = 3, |
| 5310 kTestEntryLength = 4, | 5158 kTestEntryLength = 4, |
| 5311 }; | 5159 }; |
| 5312 | 5160 |
| 5313 intptr_t NumberOfChecks() const; | 5161 intptr_t NumberOfChecks() const; |
| 5314 void AddCheck(const Object& instance_class_id_or_function, | 5162 void AddCheck(const Object& instance_class_id_or_function, |
| 5315 const TypeArguments& instance_type_arguments, | 5163 const TypeArguments& instance_type_arguments, |
| 5316 const TypeArguments& instantiator_type_arguments, | 5164 const TypeArguments& instantiator_type_arguments, |
| 5317 const Bool& test_result) const; | 5165 const Bool& test_result) const; |
| 5318 void GetCheck(intptr_t ix, | 5166 void GetCheck(intptr_t ix, |
| 5319 Object* instance_class_id_or_function, | 5167 Object* instance_class_id_or_function, |
| 5320 TypeArguments* instance_type_arguments, | 5168 TypeArguments* instance_type_arguments, |
| 5321 TypeArguments* instantiator_type_arguments, | 5169 TypeArguments* instantiator_type_arguments, |
| 5322 Bool* test_result) const; | 5170 Bool* test_result) const; |
| 5323 | 5171 |
| 5324 static RawSubtypeTestCache* New(); | 5172 static RawSubtypeTestCache* New(); |
| 5325 | 5173 |
| 5326 static intptr_t InstanceSize() { | 5174 static intptr_t InstanceSize() { |
| 5327 return RoundedAllocationSize(sizeof(RawSubtypeTestCache)); | 5175 return RoundedAllocationSize(sizeof(RawSubtypeTestCache)); |
| 5328 } | 5176 } |
| 5329 | 5177 |
| 5330 static intptr_t cache_offset() { | 5178 static intptr_t cache_offset() { |
| 5331 return OFFSET_OF(RawSubtypeTestCache, cache_); | 5179 return OFFSET_OF(RawSubtypeTestCache, cache_); |
| 5332 } | 5180 } |
| 5333 | 5181 |
| 5334 private: | 5182 private: |
| 5335 RawArray* cache() const { | 5183 RawArray* cache() const { return raw_ptr()->cache_; } |
| 5336 return raw_ptr()->cache_; | |
| 5337 } | |
| 5338 | 5184 |
| 5339 void set_cache(const Array& value) const; | 5185 void set_cache(const Array& value) const; |
| 5340 | 5186 |
| 5341 intptr_t TestEntryLength() const; | 5187 intptr_t TestEntryLength() const; |
| 5342 | 5188 |
| 5343 FINAL_HEAP_OBJECT_IMPLEMENTATION(SubtypeTestCache, Object); | 5189 FINAL_HEAP_OBJECT_IMPLEMENTATION(SubtypeTestCache, Object); |
| 5344 friend class Class; | 5190 friend class Class; |
| 5345 }; | 5191 }; |
| 5346 | 5192 |
| 5347 | 5193 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5390 return RoundedAllocationSize(sizeof(RawLanguageError)); | 5236 return RoundedAllocationSize(sizeof(RawLanguageError)); |
| 5391 } | 5237 } |
| 5392 | 5238 |
| 5393 // A null script means no source and a negative token_pos means no position. | 5239 // A null script means no source and a negative token_pos means no position. |
| 5394 static RawLanguageError* NewFormatted(const Error& prev_error, | 5240 static RawLanguageError* NewFormatted(const Error& prev_error, |
| 5395 const Script& script, | 5241 const Script& script, |
| 5396 TokenPosition token_pos, | 5242 TokenPosition token_pos, |
| 5397 bool report_after_token, | 5243 bool report_after_token, |
| 5398 Report::Kind kind, | 5244 Report::Kind kind, |
| 5399 Heap::Space space, | 5245 Heap::Space space, |
| 5400 const char* format, ...) | 5246 const char* format, |
| 5401 PRINTF_ATTRIBUTE(7, 8); | 5247 ...) PRINTF_ATTRIBUTE(7, 8); |
| 5402 | 5248 |
| 5403 static RawLanguageError* NewFormattedV(const Error& prev_error, | 5249 static RawLanguageError* NewFormattedV(const Error& prev_error, |
| 5404 const Script& script, | 5250 const Script& script, |
| 5405 TokenPosition token_pos, | 5251 TokenPosition token_pos, |
| 5406 bool report_after_token, | 5252 bool report_after_token, |
| 5407 Report::Kind kind, | 5253 Report::Kind kind, |
| 5408 Heap::Space space, | 5254 Heap::Space space, |
| 5409 const char* format, va_list args); | 5255 const char* format, |
| 5256 va_list args); |
| 5410 | 5257 |
| 5411 static RawLanguageError* New(const String& formatted_message, | 5258 static RawLanguageError* New(const String& formatted_message, |
| 5412 Report::Kind kind = Report::kError, | 5259 Report::Kind kind = Report::kError, |
| 5413 Heap::Space space = Heap::kNew); | 5260 Heap::Space space = Heap::kNew); |
| 5414 | 5261 |
| 5415 virtual const char* ToErrorCString() const; | 5262 virtual const char* ToErrorCString() const; |
| 5416 | 5263 |
| 5417 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 5264 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
| 5418 | 5265 |
| 5419 private: | 5266 private: |
| 5420 RawError* previous_error() const { | 5267 RawError* previous_error() const { return raw_ptr()->previous_error_; } |
| 5421 return raw_ptr()->previous_error_; | |
| 5422 } | |
| 5423 void set_previous_error(const Error& value) const; | 5268 void set_previous_error(const Error& value) const; |
| 5424 | 5269 |
| 5425 RawScript* script() const { return raw_ptr()->script_; } | 5270 RawScript* script() const { return raw_ptr()->script_; } |
| 5426 void set_script(const Script& value) const; | 5271 void set_script(const Script& value) const; |
| 5427 | 5272 |
| 5428 void set_token_pos(TokenPosition value) const; | 5273 void set_token_pos(TokenPosition value) const; |
| 5429 | 5274 |
| 5430 bool report_after_token() const { return raw_ptr()->report_after_token_; } | 5275 bool report_after_token() const { return raw_ptr()->report_after_token_; } |
| 5431 void set_report_after_token(bool value); | 5276 void set_report_after_token(bool value); |
| 5432 | 5277 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5540 | 5385 |
| 5541 // Returns true if all fields are OK for canonicalization. | 5386 // Returns true if all fields are OK for canonicalization. |
| 5542 virtual bool CheckAndCanonicalizeFields(Thread* thread, | 5387 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
| 5543 const char** error_str) const; | 5388 const char** error_str) const; |
| 5544 | 5389 |
| 5545 #if defined(DEBUG) | 5390 #if defined(DEBUG) |
| 5546 // Check if instance is canonical. | 5391 // Check if instance is canonical. |
| 5547 virtual bool CheckIsCanonical(Thread* thread) const; | 5392 virtual bool CheckIsCanonical(Thread* thread) const; |
| 5548 #endif // DEBUG | 5393 #endif // DEBUG |
| 5549 | 5394 |
| 5550 RawObject* GetField(const Field& field) const { | 5395 RawObject* GetField(const Field& field) const { return *FieldAddr(field); } |
| 5551 return *FieldAddr(field); | |
| 5552 } | |
| 5553 | 5396 |
| 5554 void SetField(const Field& field, const Object& value) const { | 5397 void SetField(const Field& field, const Object& value) const { |
| 5555 field.RecordStore(value); | 5398 field.RecordStore(value); |
| 5556 StorePointer(FieldAddr(field), value.raw()); | 5399 StorePointer(FieldAddr(field), value.raw()); |
| 5557 } | 5400 } |
| 5558 | 5401 |
| 5559 RawAbstractType* GetType() const; | 5402 RawAbstractType* GetType() const; |
| 5560 | 5403 |
| 5561 virtual RawTypeArguments* GetTypeArguments() const; | 5404 virtual RawTypeArguments* GetTypeArguments() const; |
| 5562 virtual void SetTypeArguments(const TypeArguments& value) const; | 5405 virtual void SetTypeArguments(const TypeArguments& value) const; |
| 5563 | 5406 |
| 5564 // Check if the type of this instance is a subtype of the given type. | 5407 // Check if the type of this instance is a subtype of the given type. |
| 5565 bool IsInstanceOf(const AbstractType& type, | 5408 bool IsInstanceOf(const AbstractType& type, |
| 5566 const TypeArguments& type_instantiator, | 5409 const TypeArguments& type_instantiator, |
| 5567 Error* bound_error) const; | 5410 Error* bound_error) const; |
| 5568 | 5411 |
| 5569 bool IsValidNativeIndex(int index) const { | 5412 bool IsValidNativeIndex(int index) const { |
| 5570 return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_)); | 5413 return ((index >= 0) && (index < clazz()->ptr()->num_native_fields_)); |
| 5571 } | 5414 } |
| 5572 | 5415 |
| 5573 intptr_t* NativeFieldsDataAddr() const; | 5416 intptr_t* NativeFieldsDataAddr() const; |
| 5574 inline intptr_t GetNativeField(int index) const; | 5417 inline intptr_t GetNativeField(int index) const; |
| 5575 inline void GetNativeFields(uint16_t num_fields, | 5418 inline void GetNativeFields(uint16_t num_fields, |
| 5576 intptr_t* field_values) const; | 5419 intptr_t* field_values) const; |
| 5577 void SetNativeFields(uint16_t num_fields, | 5420 void SetNativeFields(uint16_t num_fields, const intptr_t* field_values) const; |
| 5578 const intptr_t* field_values) const; | |
| 5579 | 5421 |
| 5580 uint16_t NumNativeFields() const { | 5422 uint16_t NumNativeFields() const { |
| 5581 return clazz()->ptr()->num_native_fields_; | 5423 return clazz()->ptr()->num_native_fields_; |
| 5582 } | 5424 } |
| 5583 | 5425 |
| 5584 void SetNativeField(int index, intptr_t value) const; | 5426 void SetNativeField(int index, intptr_t value) const; |
| 5585 | 5427 |
| 5586 // If the instance is a callable object, i.e. a closure or the instance of a | 5428 // If the instance is a callable object, i.e. a closure or the instance of a |
| 5587 // class implementing a 'call' method, return true and set the function | 5429 // class implementing a 'call' method, return true and set the function |
| 5588 // (if not NULL) to call. | 5430 // (if not NULL) to call. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5625 return FieldAddrAtOffset(field.Offset()); | 5467 return FieldAddrAtOffset(field.Offset()); |
| 5626 } | 5468 } |
| 5627 RawObject** NativeFieldsAddr() const { | 5469 RawObject** NativeFieldsAddr() const { |
| 5628 return FieldAddrAtOffset(sizeof(RawObject)); | 5470 return FieldAddrAtOffset(sizeof(RawObject)); |
| 5629 } | 5471 } |
| 5630 void SetFieldAtOffset(intptr_t offset, const Object& value) const { | 5472 void SetFieldAtOffset(intptr_t offset, const Object& value) const { |
| 5631 StorePointer(FieldAddrAtOffset(offset), value.raw()); | 5473 StorePointer(FieldAddrAtOffset(offset), value.raw()); |
| 5632 } | 5474 } |
| 5633 bool IsValidFieldOffset(intptr_t offset) const; | 5475 bool IsValidFieldOffset(intptr_t offset) const; |
| 5634 | 5476 |
| 5635 static intptr_t NextFieldOffset() { | 5477 static intptr_t NextFieldOffset() { return sizeof(RawInstance); } |
| 5636 return sizeof(RawInstance); | |
| 5637 } | |
| 5638 | 5478 |
| 5639 // The follwoing raw methods are used for morphing. | 5479 // The follwoing raw methods are used for morphing. |
| 5640 // They are needed due to the extraction of the class in IsValidFieldOffset. | 5480 // They are needed due to the extraction of the class in IsValidFieldOffset. |
| 5641 RawObject** RawFieldAddrAtOffset(intptr_t offset) const { | 5481 RawObject** RawFieldAddrAtOffset(intptr_t offset) const { |
| 5642 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset); | 5482 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset); |
| 5643 } | 5483 } |
| 5644 RawObject* RawGetFieldAtOffset(intptr_t offset) const { | 5484 RawObject* RawGetFieldAtOffset(intptr_t offset) const { |
| 5645 return *RawFieldAddrAtOffset(offset); | 5485 return *RawFieldAddrAtOffset(offset); |
| 5646 } | 5486 } |
| 5647 void RawSetFieldAtOffset(intptr_t offset, const Object& value) const { | 5487 void RawSetFieldAtOffset(intptr_t offset, const Object& value) const { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5775 // Return a clone of this unfinalized type or the type itself if it is | 5615 // Return a clone of this unfinalized type or the type itself if it is |
| 5776 // already finalized. Apply recursively to type arguments, i.e. finalized | 5616 // already finalized. Apply recursively to type arguments, i.e. finalized |
| 5777 // type arguments of an unfinalized type are not cloned, but shared. | 5617 // type arguments of an unfinalized type are not cloned, but shared. |
| 5778 virtual RawAbstractType* CloneUnfinalized() const; | 5618 virtual RawAbstractType* CloneUnfinalized() const; |
| 5779 | 5619 |
| 5780 // Return a clone of this uninstantiated type where all references to type | 5620 // Return a clone of this uninstantiated type where all references to type |
| 5781 // parameters are replaced with references to type parameters of the same name | 5621 // parameters are replaced with references to type parameters of the same name |
| 5782 // but belonging to the new owner class. | 5622 // but belonging to the new owner class. |
| 5783 // Apply recursively to type arguments, i.e. instantiated type arguments of | 5623 // Apply recursively to type arguments, i.e. instantiated type arguments of |
| 5784 // an uninstantiated type are not cloned, but shared. | 5624 // an uninstantiated type are not cloned, but shared. |
| 5785 virtual RawAbstractType* CloneUninstantiated( | 5625 virtual RawAbstractType* CloneUninstantiated(const Class& new_owner, |
| 5786 const Class& new_owner, TrailPtr trail = NULL) const; | 5626 TrailPtr trail = NULL) const; |
| 5787 | 5627 |
| 5788 virtual RawInstance* CheckAndCanonicalize(Thread* thread, | 5628 virtual RawInstance* CheckAndCanonicalize(Thread* thread, |
| 5789 const char** error_str) const { | 5629 const char** error_str) const { |
| 5790 return Canonicalize(); | 5630 return Canonicalize(); |
| 5791 } | 5631 } |
| 5792 | 5632 |
| 5793 // Return the canonical version of this type. | 5633 // Return the canonical version of this type. |
| 5794 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5634 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5795 | 5635 |
| 5796 #if defined(DEBUG) | 5636 #if defined(DEBUG) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 5814 // the trail and return false. | 5654 // the trail and return false. |
| 5815 bool TestAndAddToTrail(TrailPtr* trail) const; | 5655 bool TestAndAddToTrail(TrailPtr* trail) const; |
| 5816 | 5656 |
| 5817 // Return true if the pair <receiver, buddy> is contained in the trail. | 5657 // Return true if the pair <receiver, buddy> is contained in the trail. |
| 5818 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, | 5658 // Otherwise, if the trail is null, allocate a trail, add the pair <receiver, |
| 5819 // buddy> to the trail and return false. | 5659 // buddy> to the trail and return false. |
| 5820 // The receiver may be added several times, each time with a different buddy. | 5660 // The receiver may be added several times, each time with a different buddy. |
| 5821 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; | 5661 bool TestAndAddBuddyToTrail(TrailPtr* trail, const AbstractType& buddy) const; |
| 5822 | 5662 |
| 5823 // The name of this type, including the names of its type arguments, if any. | 5663 // The name of this type, including the names of its type arguments, if any. |
| 5824 virtual RawString* Name() const { | 5664 virtual RawString* Name() const { return BuildName(kInternalName); } |
| 5825 return BuildName(kInternalName); | |
| 5826 } | |
| 5827 | 5665 |
| 5828 // The name of this type, including the names of its type arguments, if any. | 5666 // The name of this type, including the names of its type arguments, if any. |
| 5829 // Names of internal classes are mapped to their public interfaces. | 5667 // Names of internal classes are mapped to their public interfaces. |
| 5830 virtual RawString* UserVisibleName() const { | 5668 virtual RawString* UserVisibleName() const { |
| 5831 return BuildName(kUserVisibleName); | 5669 return BuildName(kUserVisibleName); |
| 5832 } | 5670 } |
| 5833 | 5671 |
| 5834 // Returns a formatted list of occuring types with their URI. | 5672 // Returns a formatted list of occuring types with their URI. |
| 5835 virtual RawString* EnumerateURIs() const; | 5673 virtual RawString* EnumerateURIs() const; |
| 5836 | 5674 |
| 5837 virtual intptr_t Hash() const; | 5675 virtual intptr_t Hash() const; |
| 5838 | 5676 |
| 5839 // The name of this type's class, i.e. without the type argument names of this | 5677 // The name of this type's class, i.e. without the type argument names of this |
| 5840 // type. | 5678 // type. |
| 5841 RawString* ClassName() const; | 5679 RawString* ClassName() const; |
| 5842 | 5680 |
| 5843 // Check if this type represents the 'dynamic' type or if it is malformed, | 5681 // Check if this type represents the 'dynamic' type or if it is malformed, |
| 5844 // since a malformed type is mapped to 'dynamic'. | 5682 // since a malformed type is mapped to 'dynamic'. |
| 5845 // Call IsMalformed() first, if distinction is required. | 5683 // Call IsMalformed() first, if distinction is required. |
| 5846 bool IsDynamicType() const; | 5684 bool IsDynamicType() const; |
| 5847 | 5685 |
| 5848 // Check if this type represents the 'void' type. | 5686 // Check if this type represents the 'void' type. |
| 5849 bool IsVoidType() const; | 5687 bool IsVoidType() const; |
| 5850 | 5688 |
| 5851 // Check if this type represents the 'Null' type. | 5689 // Check if this type represents the 'Null' type. |
| 5852 bool IsNullType() const; | 5690 bool IsNullType() const; |
| 5853 | 5691 |
| 5854 bool IsObjectType() const { | 5692 bool IsObjectType() const { |
| 5855 return !IsFunctionType() && | 5693 return !IsFunctionType() && HasResolvedTypeClass() && |
| 5856 HasResolvedTypeClass() && | 5694 Class::Handle(type_class()).IsObjectClass(); |
| 5857 Class::Handle(type_class()).IsObjectClass(); | |
| 5858 } | 5695 } |
| 5859 | 5696 |
| 5860 // Check if this type represents the 'bool' type. | 5697 // Check if this type represents the 'bool' type. |
| 5861 bool IsBoolType() const; | 5698 bool IsBoolType() const; |
| 5862 | 5699 |
| 5863 // Check if this type represents the 'int' type. | 5700 // Check if this type represents the 'int' type. |
| 5864 bool IsIntType() const; | 5701 bool IsIntType() const; |
| 5865 | 5702 |
| 5866 // Check if this type represents the 'double' type. | 5703 // Check if this type represents the 'double' type. |
| 5867 bool IsDoubleType() const; | 5704 bool IsDoubleType() const; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5896 TrailPtr bound_trail, | 5733 TrailPtr bound_trail, |
| 5897 Heap::Space space) const { | 5734 Heap::Space space) const { |
| 5898 return TypeTest(kIsSubtypeOf, other, bound_error, bound_trail, space); | 5735 return TypeTest(kIsSubtypeOf, other, bound_error, bound_trail, space); |
| 5899 } | 5736 } |
| 5900 | 5737 |
| 5901 // Check the 'more specific' relationship. | 5738 // Check the 'more specific' relationship. |
| 5902 bool IsMoreSpecificThan(const AbstractType& other, | 5739 bool IsMoreSpecificThan(const AbstractType& other, |
| 5903 Error* bound_error, | 5740 Error* bound_error, |
| 5904 TrailPtr bound_trail, | 5741 TrailPtr bound_trail, |
| 5905 Heap::Space space) const { | 5742 Heap::Space space) const { |
| 5906 return TypeTest(kIsMoreSpecificThan, other, | 5743 return TypeTest(kIsMoreSpecificThan, other, bound_error, bound_trail, |
| 5907 bound_error, bound_trail, space); | 5744 space); |
| 5908 } | 5745 } |
| 5909 | 5746 |
| 5910 private: | 5747 private: |
| 5911 // Check the subtype or 'more specific' relationship. | 5748 // Check the subtype or 'more specific' relationship. |
| 5912 bool TypeTest(TypeTestKind test_kind, | 5749 bool TypeTest(TypeTestKind test_kind, |
| 5913 const AbstractType& other, | 5750 const AbstractType& other, |
| 5914 Error* bound_error, | 5751 Error* bound_error, |
| 5915 TrailPtr bound_trail, | 5752 TrailPtr bound_trail, |
| 5916 Heap::Space space) const; | 5753 Heap::Space space) const; |
| 5917 | 5754 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5933 // | 5770 // |
| 5934 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as | 5771 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as |
| 5935 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not | 5772 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not |
| 5936 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. | 5773 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. |
| 5937 class Type : public AbstractType { | 5774 class Type : public AbstractType { |
| 5938 public: | 5775 public: |
| 5939 static intptr_t type_class_id_offset() { | 5776 static intptr_t type_class_id_offset() { |
| 5940 return OFFSET_OF(RawType, type_class_id_); | 5777 return OFFSET_OF(RawType, type_class_id_); |
| 5941 } | 5778 } |
| 5942 virtual bool IsFinalized() const { | 5779 virtual bool IsFinalized() const { |
| 5943 return | 5780 return (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) || |
| 5944 (raw_ptr()->type_state_ == RawType::kFinalizedInstantiated) || | 5781 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated); |
| 5945 (raw_ptr()->type_state_ == RawType::kFinalizedUninstantiated); | |
| 5946 } | 5782 } |
| 5947 virtual void SetIsFinalized() const; | 5783 virtual void SetIsFinalized() const; |
| 5948 void ResetIsFinalized() const; // Ignore current state and set again. | 5784 void ResetIsFinalized() const; // Ignore current state and set again. |
| 5949 virtual bool IsBeingFinalized() const { | 5785 virtual bool IsBeingFinalized() const { |
| 5950 return raw_ptr()->type_state_ == RawType::kBeingFinalized; | 5786 return raw_ptr()->type_state_ == RawType::kBeingFinalized; |
| 5951 } | 5787 } |
| 5952 virtual void SetIsBeingFinalized() const; | 5788 virtual void SetIsBeingFinalized() const; |
| 5953 virtual bool IsMalformed() const; | 5789 virtual bool IsMalformed() const; |
| 5954 virtual bool IsMalbounded() const; | 5790 virtual bool IsMalbounded() const; |
| 5955 virtual bool IsMalformedOrMalbounded() const; | 5791 virtual bool IsMalformedOrMalbounded() const; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5977 virtual bool IsFunctionType() const { | 5813 virtual bool IsFunctionType() const { |
| 5978 return signature() != Function::null(); | 5814 return signature() != Function::null(); |
| 5979 } | 5815 } |
| 5980 virtual RawAbstractType* InstantiateFrom( | 5816 virtual RawAbstractType* InstantiateFrom( |
| 5981 const TypeArguments& instantiator_type_arguments, | 5817 const TypeArguments& instantiator_type_arguments, |
| 5982 Error* bound_error, | 5818 Error* bound_error, |
| 5983 TrailPtr instantiation_trail, | 5819 TrailPtr instantiation_trail, |
| 5984 TrailPtr bound_trail, | 5820 TrailPtr bound_trail, |
| 5985 Heap::Space space) const; | 5821 Heap::Space space) const; |
| 5986 virtual RawAbstractType* CloneUnfinalized() const; | 5822 virtual RawAbstractType* CloneUnfinalized() const; |
| 5987 virtual RawAbstractType* CloneUninstantiated( | 5823 virtual RawAbstractType* CloneUninstantiated(const Class& new_owner, |
| 5988 const Class& new_owner, | 5824 TrailPtr trail = NULL) const; |
| 5989 TrailPtr trail = NULL) const; | |
| 5990 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5825 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 5991 #if defined(DEBUG) | 5826 #if defined(DEBUG) |
| 5992 // Check if type is canonical. | 5827 // Check if type is canonical. |
| 5993 virtual bool CheckIsCanonical(Thread* thread) const; | 5828 virtual bool CheckIsCanonical(Thread* thread) const; |
| 5994 #endif // DEBUG | 5829 #endif // DEBUG |
| 5995 virtual RawString* EnumerateURIs() const; | 5830 virtual RawString* EnumerateURIs() const; |
| 5996 | 5831 |
| 5997 virtual intptr_t Hash() const; | 5832 virtual intptr_t Hash() const; |
| 5998 | 5833 |
| 5999 static intptr_t InstanceSize() { | 5834 static intptr_t InstanceSize() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6100 virtual RawClass* type_class() const { | 5935 virtual RawClass* type_class() const { |
| 6101 return AbstractType::Handle(type()).type_class(); | 5936 return AbstractType::Handle(type()).type_class(); |
| 6102 } | 5937 } |
| 6103 virtual RawTypeArguments* arguments() const { | 5938 virtual RawTypeArguments* arguments() const { |
| 6104 return AbstractType::Handle(type()).arguments(); | 5939 return AbstractType::Handle(type()).arguments(); |
| 6105 } | 5940 } |
| 6106 virtual TokenPosition token_pos() const { | 5941 virtual TokenPosition token_pos() const { |
| 6107 return AbstractType::Handle(type()).token_pos(); | 5942 return AbstractType::Handle(type()).token_pos(); |
| 6108 } | 5943 } |
| 6109 virtual bool IsInstantiated(TrailPtr trail = NULL) const; | 5944 virtual bool IsInstantiated(TrailPtr trail = NULL) const; |
| 6110 virtual bool IsEquivalent(const Instance& other, | 5945 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 6111 TrailPtr trail = NULL) const; | |
| 6112 virtual bool IsRecursive() const { return true; } | 5946 virtual bool IsRecursive() const { return true; } |
| 6113 virtual RawTypeRef* InstantiateFrom( | 5947 virtual RawTypeRef* InstantiateFrom( |
| 6114 const TypeArguments& instantiator_type_arguments, | 5948 const TypeArguments& instantiator_type_arguments, |
| 6115 Error* bound_error, | 5949 Error* bound_error, |
| 6116 TrailPtr instantiation_trail, | 5950 TrailPtr instantiation_trail, |
| 6117 TrailPtr bound_trail, | 5951 TrailPtr bound_trail, |
| 6118 Heap::Space space) const; | 5952 Heap::Space space) const; |
| 6119 virtual RawTypeRef* CloneUninstantiated( | 5953 virtual RawTypeRef* CloneUninstantiated(const Class& new_owner, |
| 6120 const Class& new_owner, | 5954 TrailPtr trail = NULL) const; |
| 6121 TrailPtr trail = NULL) const; | |
| 6122 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; | 5955 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const; |
| 6123 #if defined(DEBUG) | 5956 #if defined(DEBUG) |
| 6124 // Check if typeref is canonical. | 5957 // Check if typeref is canonical. |
| 6125 virtual bool CheckIsCanonical(Thread* thread) const; | 5958 virtual bool CheckIsCanonical(Thread* thread) const; |
| 6126 #endif // DEBUG | 5959 #endif // DEBUG |
| 6127 virtual RawString* EnumerateURIs() const; | 5960 virtual RawString* EnumerateURIs() const; |
| 6128 | 5961 |
| 6129 virtual intptr_t Hash() const; | 5962 virtual intptr_t Hash() const; |
| 6130 | 5963 |
| 6131 static intptr_t InstanceSize() { | 5964 static intptr_t InstanceSize() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6185 // Returns true if bounded_type is below upper_bound, otherwise return false | 6018 // Returns true if bounded_type is below upper_bound, otherwise return false |
| 6186 // and set bound_error if both bounded_type and upper_bound are instantiated. | 6019 // and set bound_error if both bounded_type and upper_bound are instantiated. |
| 6187 // If one or both are not instantiated, returning false only means that the | 6020 // If one or both are not instantiated, returning false only means that the |
| 6188 // bound cannot be checked yet and this is not an error. | 6021 // bound cannot be checked yet and this is not an error. |
| 6189 bool CheckBound(const AbstractType& bounded_type, | 6022 bool CheckBound(const AbstractType& bounded_type, |
| 6190 const AbstractType& upper_bound, | 6023 const AbstractType& upper_bound, |
| 6191 Error* bound_error, | 6024 Error* bound_error, |
| 6192 TrailPtr bound_trail, | 6025 TrailPtr bound_trail, |
| 6193 Heap::Space space) const; | 6026 Heap::Space space) const; |
| 6194 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } | 6027 virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; } |
| 6195 virtual bool IsInstantiated(TrailPtr trail = NULL) const { | 6028 virtual bool IsInstantiated(TrailPtr trail = NULL) const { return false; } |
| 6196 return false; | |
| 6197 } | |
| 6198 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 6029 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 6199 virtual bool IsRecursive() const { return false; } | 6030 virtual bool IsRecursive() const { return false; } |
| 6200 virtual RawAbstractType* InstantiateFrom( | 6031 virtual RawAbstractType* InstantiateFrom( |
| 6201 const TypeArguments& instantiator_type_arguments, | 6032 const TypeArguments& instantiator_type_arguments, |
| 6202 Error* bound_error, | 6033 Error* bound_error, |
| 6203 TrailPtr instantiation_trail, | 6034 TrailPtr instantiation_trail, |
| 6204 TrailPtr bound_trail, | 6035 TrailPtr bound_trail, |
| 6205 Heap::Space space) const; | 6036 Heap::Space space) const; |
| 6206 virtual RawAbstractType* CloneUnfinalized() const; | 6037 virtual RawAbstractType* CloneUnfinalized() const; |
| 6207 virtual RawAbstractType* CloneUninstantiated( | 6038 virtual RawAbstractType* CloneUninstantiated(const Class& new_owner, |
| 6208 const Class& new_owner, TrailPtr trail = NULL) const; | 6039 TrailPtr trail = NULL) const; |
| 6209 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 6040 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 6210 return raw(); | 6041 return raw(); |
| 6211 } | 6042 } |
| 6212 #if defined(DEBUG) | 6043 #if defined(DEBUG) |
| 6213 // Check if type parameter is canonical. | 6044 // Check if type parameter is canonical. |
| 6214 virtual bool CheckIsCanonical(Thread* thread) const { | 6045 virtual bool CheckIsCanonical(Thread* thread) const { return true; } |
| 6215 return true; | |
| 6216 } | |
| 6217 #endif // DEBUG | 6046 #endif // DEBUG |
| 6218 virtual RawString* EnumerateURIs() const; | 6047 virtual RawString* EnumerateURIs() const; |
| 6219 | 6048 |
| 6220 virtual intptr_t Hash() const; | 6049 virtual intptr_t Hash() const; |
| 6221 | 6050 |
| 6222 static intptr_t InstanceSize() { | 6051 static intptr_t InstanceSize() { |
| 6223 return RoundedAllocationSize(sizeof(RawTypeParameter)); | 6052 return RoundedAllocationSize(sizeof(RawTypeParameter)); |
| 6224 } | 6053 } |
| 6225 | 6054 |
| 6226 // Only one of parameterized_class and parameterized_function is non-null. | 6055 // Only one of parameterized_class and parameterized_function is non-null. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6297 } | 6126 } |
| 6298 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; | 6127 virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const; |
| 6299 virtual bool IsRecursive() const; | 6128 virtual bool IsRecursive() const; |
| 6300 virtual RawAbstractType* InstantiateFrom( | 6129 virtual RawAbstractType* InstantiateFrom( |
| 6301 const TypeArguments& instantiator_type_arguments, | 6130 const TypeArguments& instantiator_type_arguments, |
| 6302 Error* bound_error, | 6131 Error* bound_error, |
| 6303 TrailPtr instantiation_trail, | 6132 TrailPtr instantiation_trail, |
| 6304 TrailPtr bound_trail, | 6133 TrailPtr bound_trail, |
| 6305 Heap::Space space) const; | 6134 Heap::Space space) const; |
| 6306 virtual RawAbstractType* CloneUnfinalized() const; | 6135 virtual RawAbstractType* CloneUnfinalized() const; |
| 6307 virtual RawAbstractType* CloneUninstantiated( | 6136 virtual RawAbstractType* CloneUninstantiated(const Class& new_owner, |
| 6308 const Class& new_owner, TrailPtr trail = NULL) const; | 6137 TrailPtr trail = NULL) const; |
| 6309 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { | 6138 virtual RawAbstractType* Canonicalize(TrailPtr trail = NULL) const { |
| 6310 return raw(); | 6139 return raw(); |
| 6311 } | 6140 } |
| 6312 #if defined(DEBUG) | 6141 #if defined(DEBUG) |
| 6313 // Check if bounded type is canonical. | 6142 // Check if bounded type is canonical. |
| 6314 virtual bool CheckIsCanonical(Thread* thread) const { | 6143 virtual bool CheckIsCanonical(Thread* thread) const { return true; } |
| 6315 return true; | |
| 6316 } | |
| 6317 #endif // DEBUG | 6144 #endif // DEBUG |
| 6318 virtual RawString* EnumerateURIs() const; | 6145 virtual RawString* EnumerateURIs() const; |
| 6319 | 6146 |
| 6320 virtual intptr_t Hash() const; | 6147 virtual intptr_t Hash() const; |
| 6321 | 6148 |
| 6322 static intptr_t InstanceSize() { | 6149 static intptr_t InstanceSize() { |
| 6323 return RoundedAllocationSize(sizeof(RawBoundedType)); | 6150 return RoundedAllocationSize(sizeof(RawBoundedType)); |
| 6324 } | 6151 } |
| 6325 | 6152 |
| 6326 static RawBoundedType* New(const AbstractType& type, | 6153 static RawBoundedType* New(const AbstractType& type, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6438 } | 6265 } |
| 6439 virtual bool Equals(const Instance& other) const; | 6266 virtual bool Equals(const Instance& other) const; |
| 6440 | 6267 |
| 6441 virtual RawObject* HashCode() const { return raw(); } | 6268 virtual RawObject* HashCode() const { return raw(); } |
| 6442 | 6269 |
| 6443 virtual bool IsZero() const; | 6270 virtual bool IsZero() const; |
| 6444 virtual bool IsNegative() const; | 6271 virtual bool IsNegative() const; |
| 6445 | 6272 |
| 6446 virtual double AsDoubleValue() const; | 6273 virtual double AsDoubleValue() const; |
| 6447 virtual int64_t AsInt64Value() const; | 6274 virtual int64_t AsInt64Value() const; |
| 6448 virtual int64_t AsTruncatedInt64Value() const { | 6275 virtual int64_t AsTruncatedInt64Value() const { return AsInt64Value(); } |
| 6449 return AsInt64Value(); | |
| 6450 } | |
| 6451 virtual uint32_t AsTruncatedUint32Value() const; | 6276 virtual uint32_t AsTruncatedUint32Value() const; |
| 6452 | 6277 |
| 6453 virtual bool FitsIntoSmi() const; | 6278 virtual bool FitsIntoSmi() const; |
| 6454 | 6279 |
| 6455 // Returns 0, -1 or 1. | 6280 // Returns 0, -1 or 1. |
| 6456 virtual int CompareWith(const Integer& other) const; | 6281 virtual int CompareWith(const Integer& other) const; |
| 6457 | 6282 |
| 6458 // Return the most compact presentation of an integer. | 6283 // Return the most compact presentation of an integer. |
| 6459 RawInteger* AsValidInteger() const; | 6284 RawInteger* AsValidInteger() const; |
| 6460 | 6285 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 6471 friend class Class; | 6296 friend class Class; |
| 6472 }; | 6297 }; |
| 6473 | 6298 |
| 6474 | 6299 |
| 6475 class Smi : public Integer { | 6300 class Smi : public Integer { |
| 6476 public: | 6301 public: |
| 6477 static const intptr_t kBits = kSmiBits; | 6302 static const intptr_t kBits = kSmiBits; |
| 6478 static const intptr_t kMaxValue = kSmiMax; | 6303 static const intptr_t kMaxValue = kSmiMax; |
| 6479 static const intptr_t kMinValue = kSmiMin; | 6304 static const intptr_t kMinValue = kSmiMin; |
| 6480 | 6305 |
| 6481 intptr_t Value() const { | 6306 intptr_t Value() const { return ValueFromRaw(raw_value()); } |
| 6482 return ValueFromRaw(raw_value()); | |
| 6483 } | |
| 6484 | 6307 |
| 6485 virtual bool Equals(const Instance& other) const; | 6308 virtual bool Equals(const Instance& other) const; |
| 6486 virtual bool IsZero() const { return Value() == 0; } | 6309 virtual bool IsZero() const { return Value() == 0; } |
| 6487 virtual bool IsNegative() const { return Value() < 0; } | 6310 virtual bool IsNegative() const { return Value() < 0; } |
| 6488 | 6311 |
| 6489 virtual double AsDoubleValue() const; | 6312 virtual double AsDoubleValue() const; |
| 6490 virtual int64_t AsInt64Value() const; | 6313 virtual int64_t AsInt64Value() const; |
| 6491 virtual uint32_t AsTruncatedUint32Value() const; | 6314 virtual uint32_t AsTruncatedUint32Value() const; |
| 6492 | 6315 |
| 6493 virtual bool FitsIntoSmi() const { return true; } | 6316 virtual bool FitsIntoSmi() const { return true; } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6560 | 6383 |
| 6561 | 6384 |
| 6562 class Mint : public Integer { | 6385 class Mint : public Integer { |
| 6563 public: | 6386 public: |
| 6564 static const intptr_t kBits = 63; // 64-th bit is sign. | 6387 static const intptr_t kBits = 63; // 64-th bit is sign. |
| 6565 static const int64_t kMaxValue = | 6388 static const int64_t kMaxValue = |
| 6566 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); | 6389 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); |
| 6567 static const int64_t kMinValue = | 6390 static const int64_t kMinValue = |
| 6568 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); | 6391 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); |
| 6569 | 6392 |
| 6570 int64_t value() const { | 6393 int64_t value() const { return raw_ptr()->value_; } |
| 6571 return raw_ptr()->value_; | |
| 6572 } | |
| 6573 static intptr_t value_offset() { return OFFSET_OF(RawMint, value_); } | 6394 static intptr_t value_offset() { return OFFSET_OF(RawMint, value_); } |
| 6574 | 6395 |
| 6575 virtual bool IsZero() const { | 6396 virtual bool IsZero() const { return value() == 0; } |
| 6576 return value() == 0; | 6397 virtual bool IsNegative() const { return value() < 0; } |
| 6577 } | |
| 6578 virtual bool IsNegative() const { | |
| 6579 return value() < 0; | |
| 6580 } | |
| 6581 | 6398 |
| 6582 virtual bool Equals(const Instance& other) const; | 6399 virtual bool Equals(const Instance& other) const; |
| 6583 | 6400 |
| 6584 virtual double AsDoubleValue() const; | 6401 virtual double AsDoubleValue() const; |
| 6585 virtual int64_t AsInt64Value() const; | 6402 virtual int64_t AsInt64Value() const; |
| 6586 virtual uint32_t AsTruncatedUint32Value() const; | 6403 virtual uint32_t AsTruncatedUint32Value() const; |
| 6587 | 6404 |
| 6588 virtual bool FitsIntoSmi() const; | 6405 virtual bool FitsIntoSmi() const; |
| 6589 | 6406 |
| 6590 virtual int CompareWith(const Integer& other) const; | 6407 virtual int CompareWith(const Integer& other) const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 6605 void set_value(int64_t value) const; | 6422 void set_value(int64_t value) const; |
| 6606 | 6423 |
| 6607 MINT_OBJECT_IMPLEMENTATION(Mint, Integer, Integer); | 6424 MINT_OBJECT_IMPLEMENTATION(Mint, Integer, Integer); |
| 6608 friend class Class; | 6425 friend class Class; |
| 6609 friend class Number; | 6426 friend class Number; |
| 6610 }; | 6427 }; |
| 6611 | 6428 |
| 6612 | 6429 |
| 6613 class Bigint : public Integer { | 6430 class Bigint : public Integer { |
| 6614 public: | 6431 public: |
| 6615 virtual bool IsZero() const { return Used() == 0;} | 6432 virtual bool IsZero() const { return Used() == 0; } |
| 6616 virtual bool IsNegative() const { return Neg(); } | 6433 virtual bool IsNegative() const { return Neg(); } |
| 6617 virtual bool Equals(const Instance& other) const; | 6434 virtual bool Equals(const Instance& other) const; |
| 6618 | 6435 |
| 6619 virtual double AsDoubleValue() const; | 6436 virtual double AsDoubleValue() const; |
| 6620 virtual int64_t AsInt64Value() const; | 6437 virtual int64_t AsInt64Value() const; |
| 6621 virtual int64_t AsTruncatedInt64Value() const; | 6438 virtual int64_t AsTruncatedInt64Value() const; |
| 6622 virtual uint32_t AsTruncatedUint32Value() const; | 6439 virtual uint32_t AsTruncatedUint32Value() const; |
| 6623 | 6440 |
| 6624 virtual int CompareWith(const Integer& other) const; | 6441 virtual int CompareWith(const Integer& other) const; |
| 6625 | 6442 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6653 const char* ToDecCString(Zone* zone) const; | 6470 const char* ToDecCString(Zone* zone) const; |
| 6654 const char* ToHexCString(Zone* zone) const; | 6471 const char* ToHexCString(Zone* zone) const; |
| 6655 | 6472 |
| 6656 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS | 6473 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS |
| 6657 static const intptr_t kBytesPerDigit = 4; | 6474 static const intptr_t kBytesPerDigit = 4; |
| 6658 static const int64_t kDigitBase = 1LL << kBitsPerDigit; | 6475 static const int64_t kDigitBase = 1LL << kBitsPerDigit; |
| 6659 static const int64_t kDigitMask = kDigitBase - 1; | 6476 static const int64_t kDigitMask = kDigitBase - 1; |
| 6660 | 6477 |
| 6661 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots. | 6478 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots. |
| 6662 | 6479 |
| 6663 static RawBigint* New(bool neg, intptr_t used, const TypedData& digits, | 6480 static RawBigint* New(bool neg, |
| 6481 intptr_t used, |
| 6482 const TypedData& digits, |
| 6664 Heap::Space space = Heap::kNew); | 6483 Heap::Space space = Heap::kNew); |
| 6665 | 6484 |
| 6666 static RawBigint* NewFromInt64(int64_t value, | 6485 static RawBigint* NewFromInt64(int64_t value, Heap::Space space = Heap::kNew); |
| 6486 |
| 6487 static RawBigint* NewFromUint64(uint64_t value, |
| 6667 Heap::Space space = Heap::kNew); | 6488 Heap::Space space = Heap::kNew); |
| 6668 | 6489 |
| 6669 static RawBigint* NewFromUint64(uint64_t value, | 6490 static RawBigint* NewFromShiftedInt64(int64_t value, |
| 6670 Heap::Space space = Heap::kNew); | 6491 intptr_t shift, |
| 6671 | 6492 Heap::Space space = Heap::kNew); |
| 6672 static RawBigint* NewFromShiftedInt64(int64_t value, intptr_t shift, | |
| 6673 Heap::Space space = Heap::kNew); | |
| 6674 | 6493 |
| 6675 static RawBigint* NewFromCString(const char* str, | 6494 static RawBigint* NewFromCString(const char* str, |
| 6676 Heap::Space space = Heap::kNew); | 6495 Heap::Space space = Heap::kNew); |
| 6677 | 6496 |
| 6678 // Returns a canonical Bigint object allocated in the old gen space. | 6497 // Returns a canonical Bigint object allocated in the old gen space. |
| 6679 static RawBigint* NewCanonical(const String& str); | 6498 static RawBigint* NewCanonical(const String& str); |
| 6680 | 6499 |
| 6681 private: | 6500 private: |
| 6682 void SetNeg(bool value) const; | 6501 void SetNeg(bool value) const; |
| 6683 void SetUsed(intptr_t value) const; | 6502 void SetUsed(intptr_t value) const; |
| 6684 void set_digits(const TypedData& value) const; | 6503 void set_digits(const TypedData& value) const; |
| 6685 | 6504 |
| 6686 // Convenience helpers. | 6505 // Convenience helpers. |
| 6687 static RawTypedData* NewDigits(intptr_t length, | 6506 static RawTypedData* NewDigits(intptr_t length, |
| 6688 Heap::Space space = Heap::kNew); | 6507 Heap::Space space = Heap::kNew); |
| 6689 static uint32_t DigitAt(const TypedData& digits, intptr_t index); | 6508 static uint32_t DigitAt(const TypedData& digits, intptr_t index); |
| 6690 static void SetDigitAt(const TypedData& digits, | 6509 static void SetDigitAt(const TypedData& digits, |
| 6691 intptr_t index, | 6510 intptr_t index, |
| 6692 uint32_t value); | 6511 uint32_t value); |
| 6693 | 6512 |
| 6694 static RawTypedData* NewDigitsFromHexCString(const char* str, intptr_t* used, | 6513 static RawTypedData* NewDigitsFromHexCString(const char* str, |
| 6514 intptr_t* used, |
| 6695 Heap::Space space = Heap::kNew); | 6515 Heap::Space space = Heap::kNew); |
| 6696 | 6516 |
| 6697 static RawTypedData* NewDigitsFromDecCString(const char* str, intptr_t* used, | 6517 static RawTypedData* NewDigitsFromDecCString(const char* str, |
| 6518 intptr_t* used, |
| 6698 Heap::Space space = Heap::kNew); | 6519 Heap::Space space = Heap::kNew); |
| 6699 | 6520 |
| 6700 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); | 6521 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); |
| 6701 | 6522 |
| 6702 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); | 6523 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); |
| 6703 friend class Class; | 6524 friend class Class; |
| 6704 }; | 6525 }; |
| 6705 | 6526 |
| 6706 | 6527 |
| 6707 // Class Double represents class Double in corelib_impl, which implements | 6528 // Class Double represents class Double in corelib_impl, which implements |
| 6708 // abstract class double in corelib. | 6529 // abstract class double in corelib. |
| 6709 class Double : public Number { | 6530 class Double : public Number { |
| 6710 public: | 6531 public: |
| 6711 double value() const { | 6532 double value() const { return raw_ptr()->value_; } |
| 6712 return raw_ptr()->value_; | |
| 6713 } | |
| 6714 | 6533 |
| 6715 bool BitwiseEqualsToDouble(double value) const; | 6534 bool BitwiseEqualsToDouble(double value) const; |
| 6716 virtual bool OperatorEquals(const Instance& other) const; | 6535 virtual bool OperatorEquals(const Instance& other) const; |
| 6717 virtual bool CanonicalizeEquals(const Instance& other) const; | 6536 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 6718 virtual uword ComputeCanonicalTableHash() const { | 6537 virtual uword ComputeCanonicalTableHash() const { |
| 6719 UNREACHABLE(); | 6538 UNREACHABLE(); |
| 6720 return 0; | 6539 return 0; |
| 6721 } | 6540 } |
| 6722 | 6541 |
| 6723 static RawDouble* New(double d, Heap::Space space = Heap::kNew); | 6542 static RawDouble* New(double d, Heap::Space space = Heap::kNew); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6761 // All strings share the same maximum element count to keep things | 6580 // All strings share the same maximum element count to keep things |
| 6762 // simple. We choose a value that will prevent integer overflow for | 6581 // simple. We choose a value that will prevent integer overflow for |
| 6763 // 2 byte strings, since it is the worst case. | 6582 // 2 byte strings, since it is the worst case. |
| 6764 static const intptr_t kSizeofRawString = | 6583 static const intptr_t kSizeofRawString = |
| 6765 sizeof(RawInstance) + (2 * kWordSize); | 6584 sizeof(RawInstance) + (2 * kWordSize); |
| 6766 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 6585 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; |
| 6767 | 6586 |
| 6768 class CodePointIterator : public ValueObject { | 6587 class CodePointIterator : public ValueObject { |
| 6769 public: | 6588 public: |
| 6770 explicit CodePointIterator(const String& str) | 6589 explicit CodePointIterator(const String& str) |
| 6771 : str_(str), | 6590 : str_(str), ch_(0), index_(-1), end_(str.Length()) { |
| 6772 ch_(0), | |
| 6773 index_(-1), | |
| 6774 end_(str.Length()) { | |
| 6775 ASSERT(!str_.IsNull()); | 6591 ASSERT(!str_.IsNull()); |
| 6776 } | 6592 } |
| 6777 | 6593 |
| 6778 CodePointIterator(const String& str, intptr_t start, intptr_t length) | 6594 CodePointIterator(const String& str, intptr_t start, intptr_t length) |
| 6779 : str_(str), | 6595 : str_(str), ch_(0), index_(start - 1), end_(start + length) { |
| 6780 ch_(0), | |
| 6781 index_(start - 1), | |
| 6782 end_(start + length) { | |
| 6783 ASSERT(start >= 0); | 6596 ASSERT(start >= 0); |
| 6784 ASSERT(end_ <= str.Length()); | 6597 ASSERT(end_ <= str.Length()); |
| 6785 } | 6598 } |
| 6786 | 6599 |
| 6787 int32_t Current() const { | 6600 int32_t Current() const { |
| 6788 ASSERT(index_ >= 0); | 6601 ASSERT(index_ >= 0); |
| 6789 ASSERT(index_ < end_); | 6602 ASSERT(index_ < end_); |
| 6790 return ch_; | 6603 return ch_; |
| 6791 } | 6604 } |
| 6792 | 6605 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6838 uint16_t CharAt(intptr_t index) const; | 6651 uint16_t CharAt(intptr_t index) const; |
| 6839 | 6652 |
| 6840 Scanner::CharAtFunc CharAtFunc() const; | 6653 Scanner::CharAtFunc CharAtFunc() const; |
| 6841 | 6654 |
| 6842 intptr_t CharSize() const; | 6655 intptr_t CharSize() const; |
| 6843 | 6656 |
| 6844 inline bool Equals(const String& str) const; | 6657 inline bool Equals(const String& str) const; |
| 6845 | 6658 |
| 6846 bool Equals(const String& str, | 6659 bool Equals(const String& str, |
| 6847 intptr_t begin_index, // begin index on 'str'. | 6660 intptr_t begin_index, // begin index on 'str'. |
| 6848 intptr_t len) const; // len on 'str'. | 6661 intptr_t len) const; // len on 'str'. |
| 6849 | 6662 |
| 6850 // Compares to a '\0' terminated array of UTF-8 encoded characters. | 6663 // Compares to a '\0' terminated array of UTF-8 encoded characters. |
| 6851 bool Equals(const char* cstr) const; | 6664 bool Equals(const char* cstr) const; |
| 6852 | 6665 |
| 6853 // Compares to an array of Latin-1 encoded characters. | 6666 // Compares to an array of Latin-1 encoded characters. |
| 6854 bool EqualsLatin1(const uint8_t* characters, intptr_t len) const { | 6667 bool EqualsLatin1(const uint8_t* characters, intptr_t len) const { |
| 6855 return Equals(characters, len); | 6668 return Equals(characters, len); |
| 6856 } | 6669 } |
| 6857 | 6670 |
| 6858 // Compares to an array of UTF-16 encoded characters. | 6671 // Compares to an array of UTF-16 encoded characters. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7020 Heap::Space space = Heap::kNew); | 6833 Heap::Space space = Heap::kNew); |
| 7021 | 6834 |
| 7022 static RawString* ToUpperCase(const String& str, | 6835 static RawString* ToUpperCase(const String& str, |
| 7023 Heap::Space space = Heap::kNew); | 6836 Heap::Space space = Heap::kNew); |
| 7024 static RawString* ToLowerCase(const String& str, | 6837 static RawString* ToLowerCase(const String& str, |
| 7025 Heap::Space space = Heap::kNew); | 6838 Heap::Space space = Heap::kNew); |
| 7026 | 6839 |
| 7027 static RawString* ScrubName(const String& name); | 6840 static RawString* ScrubName(const String& name); |
| 7028 static RawString* ScrubNameRetainPrivate(const String& name); | 6841 static RawString* ScrubNameRetainPrivate(const String& name); |
| 7029 | 6842 |
| 7030 static bool EqualsIgnoringPrivateKey(const String& str1, | 6843 static bool EqualsIgnoringPrivateKey(const String& str1, const String& str2); |
| 7031 const String& str2); | |
| 7032 | 6844 |
| 7033 static RawString* NewFormatted(const char* format, ...) | 6845 static RawString* NewFormatted(const char* format, ...) |
| 7034 PRINTF_ATTRIBUTE(1, 2); | 6846 PRINTF_ATTRIBUTE(1, 2); |
| 7035 static RawString* NewFormatted(Heap::Space space, const char* format, ...) | 6847 static RawString* NewFormatted(Heap::Space space, const char* format, ...) |
| 7036 PRINTF_ATTRIBUTE(2, 3); | 6848 PRINTF_ATTRIBUTE(2, 3); |
| 7037 static RawString* NewFormattedV(const char* format, va_list args, | 6849 static RawString* NewFormattedV(const char* format, |
| 6850 va_list args, |
| 7038 Heap::Space space = Heap::kNew); | 6851 Heap::Space space = Heap::kNew); |
| 7039 | 6852 |
| 7040 static bool ParseDouble(const String& str, | 6853 static bool ParseDouble(const String& str, |
| 7041 intptr_t start, | 6854 intptr_t start, |
| 7042 intptr_t end, | 6855 intptr_t end, |
| 7043 double* result); | 6856 double* result); |
| 7044 | 6857 |
| 7045 protected: | 6858 protected: |
| 7046 // These two operate on an array of Latin-1 encoded characters. | 6859 // These two operate on an array of Latin-1 encoded characters. |
| 7047 // They are protected to avoid mistaking Latin-1 for UTF-8, but used | 6860 // They are protected to avoid mistaking Latin-1 for UTF-8, but used |
| 7048 // by friendly templated code (e.g., Symbols). | 6861 // by friendly templated code (e.g., Symbols). |
| 7049 bool Equals(const uint8_t* characters, intptr_t len) const; | 6862 bool Equals(const uint8_t* characters, intptr_t len) const; |
| 7050 static intptr_t Hash(const uint8_t* characters, intptr_t len); | 6863 static intptr_t Hash(const uint8_t* characters, intptr_t len); |
| 7051 | 6864 |
| 7052 void SetLength(intptr_t value) const { | 6865 void SetLength(intptr_t value) const { |
| 7053 // This is only safe because we create a new Smi, which does not cause | 6866 // This is only safe because we create a new Smi, which does not cause |
| 7054 // heap allocation. | 6867 // heap allocation. |
| 7055 StoreSmi(&raw_ptr()->length_, Smi::New(value)); | 6868 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 7056 } | 6869 } |
| 7057 | 6870 |
| 7058 void SetHash(intptr_t value) const { | 6871 void SetHash(intptr_t value) const { |
| 7059 // This is only safe because we create a new Smi, which does not cause | 6872 // This is only safe because we create a new Smi, which does not cause |
| 7060 // heap allocation. | 6873 // heap allocation. |
| 7061 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 6874 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 7062 } | 6875 } |
| 7063 | 6876 |
| 7064 template<typename HandleType, typename ElementType, typename CallbackType> | 6877 template <typename HandleType, typename ElementType, typename CallbackType> |
| 7065 static void ReadFromImpl(SnapshotReader* reader, | 6878 static void ReadFromImpl(SnapshotReader* reader, |
| 7066 String* str_obj, | 6879 String* str_obj, |
| 7067 intptr_t len, | 6880 intptr_t len, |
| 7068 intptr_t tags, | 6881 intptr_t tags, |
| 7069 CallbackType new_symbol, | 6882 CallbackType new_symbol, |
| 7070 Snapshot::Kind kind); | 6883 Snapshot::Kind kind); |
| 7071 | 6884 |
| 7072 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); | 6885 FINAL_HEAP_OBJECT_IMPLEMENTATION(String, Instance); |
| 7073 | 6886 |
| 7074 friend class Class; | 6887 friend class Class; |
| 7075 friend class Symbols; | 6888 friend class Symbols; |
| 7076 friend class StringSlice; // SetHash | 6889 friend class StringSlice; // SetHash |
| 7077 template<typename CharType> friend class CharArray; // SetHash | 6890 template <typename CharType> |
| 6891 friend class CharArray; // SetHash |
| 7078 friend class ConcatString; // SetHash | 6892 friend class ConcatString; // SetHash |
| 7079 friend class OneByteString; | 6893 friend class OneByteString; |
| 7080 friend class TwoByteString; | 6894 friend class TwoByteString; |
| 7081 friend class ExternalOneByteString; | 6895 friend class ExternalOneByteString; |
| 7082 friend class ExternalTwoByteString; | 6896 friend class ExternalTwoByteString; |
| 7083 // So that SkippedCodeFunctions can print a debug string from a NoHandleScope. | 6897 // So that SkippedCodeFunctions can print a debug string from a NoHandleScope. |
| 7084 friend class SkippedCodeFunctions; | 6898 friend class SkippedCodeFunctions; |
| 7085 friend class RawOneByteString; | 6899 friend class RawOneByteString; |
| 7086 friend class RODataSerializationCluster; // SetHash | 6900 friend class RODataSerializationCluster; // SetHash |
| 7087 }; | 6901 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7110 | 6924 |
| 7111 static intptr_t InstanceSize() { | 6925 static intptr_t InstanceSize() { |
| 7112 ASSERT(sizeof(RawOneByteString) == | 6926 ASSERT(sizeof(RawOneByteString) == |
| 7113 OFFSET_OF_RETURNED_VALUE(RawOneByteString, data)); | 6927 OFFSET_OF_RETURNED_VALUE(RawOneByteString, data)); |
| 7114 return 0; | 6928 return 0; |
| 7115 } | 6929 } |
| 7116 | 6930 |
| 7117 static intptr_t InstanceSize(intptr_t len) { | 6931 static intptr_t InstanceSize(intptr_t len) { |
| 7118 ASSERT(sizeof(RawOneByteString) == String::kSizeofRawString); | 6932 ASSERT(sizeof(RawOneByteString) == String::kSizeofRawString); |
| 7119 ASSERT(0 <= len && len <= kMaxElements); | 6933 ASSERT(0 <= len && len <= kMaxElements); |
| 7120 return String::RoundedAllocationSize( | 6934 return String::RoundedAllocationSize(sizeof(RawOneByteString) + |
| 7121 sizeof(RawOneByteString) + (len * kBytesPerElement)); | 6935 (len * kBytesPerElement)); |
| 7122 } | 6936 } |
| 7123 | 6937 |
| 7124 static RawOneByteString* New(intptr_t len, | 6938 static RawOneByteString* New(intptr_t len, Heap::Space space); |
| 7125 Heap::Space space); | |
| 7126 static RawOneByteString* New(const char* c_string, | 6939 static RawOneByteString* New(const char* c_string, |
| 7127 Heap::Space space = Heap::kNew) { | 6940 Heap::Space space = Heap::kNew) { |
| 7128 return New(reinterpret_cast<const uint8_t*>(c_string), | 6941 return New(reinterpret_cast<const uint8_t*>(c_string), strlen(c_string), |
| 7129 strlen(c_string), | |
| 7130 space); | 6942 space); |
| 7131 } | 6943 } |
| 7132 static RawOneByteString* New(const uint8_t* characters, | 6944 static RawOneByteString* New(const uint8_t* characters, |
| 7133 intptr_t len, | 6945 intptr_t len, |
| 7134 Heap::Space space); | 6946 Heap::Space space); |
| 7135 static RawOneByteString* New(const uint16_t* characters, | 6947 static RawOneByteString* New(const uint16_t* characters, |
| 7136 intptr_t len, | 6948 intptr_t len, |
| 7137 Heap::Space space); | 6949 Heap::Space space); |
| 7138 static RawOneByteString* New(const int32_t* characters, | 6950 static RawOneByteString* New(const int32_t* characters, |
| 7139 intptr_t len, | 6951 intptr_t len, |
| 7140 Heap::Space space); | 6952 Heap::Space space); |
| 7141 static RawOneByteString* New(const String& str, | 6953 static RawOneByteString* New(const String& str, Heap::Space space); |
| 7142 Heap::Space space); | |
| 7143 // 'other' must be OneByteString. | 6954 // 'other' must be OneByteString. |
| 7144 static RawOneByteString* New(const String& other_one_byte_string, | 6955 static RawOneByteString* New(const String& other_one_byte_string, |
| 7145 intptr_t other_start_index, | 6956 intptr_t other_start_index, |
| 7146 intptr_t other_len, | 6957 intptr_t other_len, |
| 7147 Heap::Space space); | 6958 Heap::Space space); |
| 7148 | 6959 |
| 7149 static RawOneByteString* New(const TypedData& other_typed_data, | 6960 static RawOneByteString* New(const TypedData& other_typed_data, |
| 7150 intptr_t other_start_index, | 6961 intptr_t other_start_index, |
| 7151 intptr_t other_len, | 6962 intptr_t other_len, |
| 7152 Heap::Space space = Heap::kNew); | 6963 Heap::Space space = Heap::kNew); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7246 | 7057 |
| 7247 static intptr_t InstanceSize() { | 7058 static intptr_t InstanceSize() { |
| 7248 ASSERT(sizeof(RawTwoByteString) == | 7059 ASSERT(sizeof(RawTwoByteString) == |
| 7249 OFFSET_OF_RETURNED_VALUE(RawTwoByteString, data)); | 7060 OFFSET_OF_RETURNED_VALUE(RawTwoByteString, data)); |
| 7250 return 0; | 7061 return 0; |
| 7251 } | 7062 } |
| 7252 | 7063 |
| 7253 static intptr_t InstanceSize(intptr_t len) { | 7064 static intptr_t InstanceSize(intptr_t len) { |
| 7254 ASSERT(sizeof(RawTwoByteString) == String::kSizeofRawString); | 7065 ASSERT(sizeof(RawTwoByteString) == String::kSizeofRawString); |
| 7255 ASSERT(0 <= len && len <= kMaxElements); | 7066 ASSERT(0 <= len && len <= kMaxElements); |
| 7256 return String::RoundedAllocationSize( | 7067 return String::RoundedAllocationSize(sizeof(RawTwoByteString) + |
| 7257 sizeof(RawTwoByteString) + (len * kBytesPerElement)); | 7068 (len * kBytesPerElement)); |
| 7258 } | 7069 } |
| 7259 | 7070 |
| 7260 static RawTwoByteString* New(intptr_t len, | 7071 static RawTwoByteString* New(intptr_t len, Heap::Space space); |
| 7261 Heap::Space space); | |
| 7262 static RawTwoByteString* New(const uint16_t* characters, | 7072 static RawTwoByteString* New(const uint16_t* characters, |
| 7263 intptr_t len, | 7073 intptr_t len, |
| 7264 Heap::Space space); | 7074 Heap::Space space); |
| 7265 static RawTwoByteString* New(intptr_t utf16_len, | 7075 static RawTwoByteString* New(intptr_t utf16_len, |
| 7266 const int32_t* characters, | 7076 const int32_t* characters, |
| 7267 intptr_t len, | 7077 intptr_t len, |
| 7268 Heap::Space space); | 7078 Heap::Space space); |
| 7269 static RawTwoByteString* New(const String& str, | 7079 static RawTwoByteString* New(const String& str, Heap::Space space); |
| 7270 Heap::Space space); | |
| 7271 | 7080 |
| 7272 static RawTwoByteString* New(const TypedData& other_typed_data, | 7081 static RawTwoByteString* New(const TypedData& other_typed_data, |
| 7273 intptr_t other_start_index, | 7082 intptr_t other_start_index, |
| 7274 intptr_t other_len, | 7083 intptr_t other_len, |
| 7275 Heap::Space space = Heap::kNew); | 7084 Heap::Space space = Heap::kNew); |
| 7276 | 7085 |
| 7277 static RawTwoByteString* New(const ExternalTypedData& other_typed_data, | 7086 static RawTwoByteString* New(const ExternalTypedData& other_typed_data, |
| 7278 intptr_t other_start_index, | 7087 intptr_t other_start_index, |
| 7279 intptr_t other_len, | 7088 intptr_t other_len, |
| 7280 Heap::Space space = Heap::kNew); | 7089 Heap::Space space = Heap::kNew); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7496 friend class Class; | 7305 friend class Class; |
| 7497 friend class String; | 7306 friend class String; |
| 7498 friend class SnapshotReader; | 7307 friend class SnapshotReader; |
| 7499 friend class Symbols; | 7308 friend class Symbols; |
| 7500 }; | 7309 }; |
| 7501 | 7310 |
| 7502 | 7311 |
| 7503 // Class Bool implements Dart core class bool. | 7312 // Class Bool implements Dart core class bool. |
| 7504 class Bool : public Instance { | 7313 class Bool : public Instance { |
| 7505 public: | 7314 public: |
| 7506 bool value() const { | 7315 bool value() const { return raw_ptr()->value_; } |
| 7507 return raw_ptr()->value_; | |
| 7508 } | |
| 7509 | 7316 |
| 7510 static intptr_t InstanceSize() { | 7317 static intptr_t InstanceSize() { |
| 7511 return RoundedAllocationSize(sizeof(RawBool)); | 7318 return RoundedAllocationSize(sizeof(RawBool)); |
| 7512 } | 7319 } |
| 7513 | 7320 |
| 7514 static const Bool& True() { | 7321 static const Bool& True() { return Object::bool_true(); } |
| 7515 return Object::bool_true(); | |
| 7516 } | |
| 7517 | 7322 |
| 7518 static const Bool& False() { | 7323 static const Bool& False() { return Object::bool_false(); } |
| 7519 return Object::bool_false(); | |
| 7520 } | |
| 7521 | 7324 |
| 7522 static const Bool& Get(bool value) { | 7325 static const Bool& Get(bool value) { |
| 7523 return value ? Bool::True() : Bool::False(); | 7326 return value ? Bool::True() : Bool::False(); |
| 7524 } | 7327 } |
| 7525 | 7328 |
| 7526 private: | 7329 private: |
| 7527 void set_value(bool value) const { | 7330 void set_value(bool value) const { |
| 7528 StoreNonPointer(&raw_ptr()->value_, value); | 7331 StoreNonPointer(&raw_ptr()->value_, value); |
| 7529 } | 7332 } |
| 7530 | 7333 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 7549 return Smi::Value(raw_ptr()->length_); | 7352 return Smi::Value(raw_ptr()->length_); |
| 7550 } | 7353 } |
| 7551 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } | 7354 static intptr_t length_offset() { return OFFSET_OF(RawArray, length_); } |
| 7552 static intptr_t data_offset() { | 7355 static intptr_t data_offset() { |
| 7553 return OFFSET_OF_RETURNED_VALUE(RawArray, data); | 7356 return OFFSET_OF_RETURNED_VALUE(RawArray, data); |
| 7554 } | 7357 } |
| 7555 static intptr_t element_offset(intptr_t index) { | 7358 static intptr_t element_offset(intptr_t index) { |
| 7556 return OFFSET_OF_RETURNED_VALUE(RawArray, data) + kWordSize * index; | 7359 return OFFSET_OF_RETURNED_VALUE(RawArray, data) + kWordSize * index; |
| 7557 } | 7360 } |
| 7558 | 7361 |
| 7559 RawObject* At(intptr_t index) const { | 7362 RawObject* At(intptr_t index) const { return *ObjectAddr(index); } |
| 7560 return *ObjectAddr(index); | |
| 7561 } | |
| 7562 void SetAt(intptr_t index, const Object& value) const { | 7363 void SetAt(intptr_t index, const Object& value) const { |
| 7563 // TODO(iposva): Add storing NoSafepointScope. | 7364 // TODO(iposva): Add storing NoSafepointScope. |
| 7564 StorePointer(ObjectAddr(index), value.raw()); | 7365 StorePointer(ObjectAddr(index), value.raw()); |
| 7565 } | 7366 } |
| 7566 | 7367 |
| 7567 bool IsImmutable() const { | 7368 bool IsImmutable() const { return raw()->GetClassId() == kImmutableArrayCid; } |
| 7568 return raw()->GetClassId() == kImmutableArrayCid; | |
| 7569 } | |
| 7570 | 7369 |
| 7571 virtual RawTypeArguments* GetTypeArguments() const { | 7370 virtual RawTypeArguments* GetTypeArguments() const { |
| 7572 return raw_ptr()->type_arguments_; | 7371 return raw_ptr()->type_arguments_; |
| 7573 } | 7372 } |
| 7574 virtual void SetTypeArguments(const TypeArguments& value) const { | 7373 virtual void SetTypeArguments(const TypeArguments& value) const { |
| 7575 // An Array is raw or takes one type argument. However, its type argument | 7374 // An Array is raw or takes one type argument. However, its type argument |
| 7576 // vector may be longer than 1 due to a type optimization reusing the type | 7375 // vector may be longer than 1 due to a type optimization reusing the type |
| 7577 // argument vector of the instantiator. | 7376 // argument vector of the instantiator. |
| 7578 ASSERT(value.IsNull() || | 7377 ASSERT(value.IsNull() || |
| 7579 ((value.Length() >= 1) && | 7378 ((value.Length() >= 1) && |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7667 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); | 7466 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); |
| 7668 | 7467 |
| 7669 static RawImmutableArray* ReadFrom(SnapshotReader* reader, | 7468 static RawImmutableArray* ReadFrom(SnapshotReader* reader, |
| 7670 intptr_t object_id, | 7469 intptr_t object_id, |
| 7671 intptr_t tags, | 7470 intptr_t tags, |
| 7672 Snapshot::Kind kind, | 7471 Snapshot::Kind kind, |
| 7673 bool as_reference); | 7472 bool as_reference); |
| 7674 | 7473 |
| 7675 static const ClassId kClassId = kImmutableArrayCid; | 7474 static const ClassId kClassId = kImmutableArrayCid; |
| 7676 | 7475 |
| 7677 static intptr_t InstanceSize() { | 7476 static intptr_t InstanceSize() { return Array::InstanceSize(); } |
| 7678 return Array::InstanceSize(); | |
| 7679 } | |
| 7680 | 7477 |
| 7681 static intptr_t InstanceSize(intptr_t len) { | 7478 static intptr_t InstanceSize(intptr_t len) { |
| 7682 return Array::InstanceSize(len); | 7479 return Array::InstanceSize(len); |
| 7683 } | 7480 } |
| 7684 | 7481 |
| 7685 private: | 7482 private: |
| 7686 static intptr_t NextFieldOffset() { | 7483 static intptr_t NextFieldOffset() { |
| 7687 // Indicates this class cannot be extended by dart code. | 7484 // Indicates this class cannot be extended by dart code. |
| 7688 return -kWordSize; | 7485 return -kWordSize; |
| 7689 } | 7486 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7737 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; | 7534 void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const; |
| 7738 RawObject* RemoveLast() const; | 7535 RawObject* RemoveLast() const; |
| 7739 | 7536 |
| 7740 virtual RawTypeArguments* GetTypeArguments() const { | 7537 virtual RawTypeArguments* GetTypeArguments() const { |
| 7741 return raw_ptr()->type_arguments_; | 7538 return raw_ptr()->type_arguments_; |
| 7742 } | 7539 } |
| 7743 virtual void SetTypeArguments(const TypeArguments& value) const { | 7540 virtual void SetTypeArguments(const TypeArguments& value) const { |
| 7744 // A GrowableObjectArray is raw or takes one type argument. However, its | 7541 // A GrowableObjectArray is raw or takes one type argument. However, its |
| 7745 // type argument vector may be longer than 1 due to a type optimization | 7542 // type argument vector may be longer than 1 due to a type optimization |
| 7746 // reusing the type argument vector of the instantiator. | 7543 // reusing the type argument vector of the instantiator. |
| 7747 ASSERT(value.IsNull() || | 7544 ASSERT(value.IsNull() || ((value.Length() >= 1) && value.IsInstantiated() && |
| 7748 ((value.Length() >= 1) && | 7545 value.IsCanonical())); |
| 7749 value.IsInstantiated() && | |
| 7750 value.IsCanonical())); | |
| 7751 const Array& contents = Array::Handle(data()); | 7546 const Array& contents = Array::Handle(data()); |
| 7752 contents.SetTypeArguments(value); | 7547 contents.SetTypeArguments(value); |
| 7753 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 7548 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 7754 } | 7549 } |
| 7755 | 7550 |
| 7756 // We don't expect a growable object array to be canonicalized. | 7551 // We don't expect a growable object array to be canonicalized. |
| 7757 virtual bool CanonicalizeEquals(const Instance& other) const { | 7552 virtual bool CanonicalizeEquals(const Instance& other) const { |
| 7758 UNREACHABLE(); | 7553 UNREACHABLE(); |
| 7759 return false; | 7554 return false; |
| 7760 } | 7555 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7803 static const int kDefaultInitialCapacity = 4; | 7598 static const int kDefaultInitialCapacity = 4; |
| 7804 | 7599 |
| 7805 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); | 7600 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); |
| 7806 friend class Array; | 7601 friend class Array; |
| 7807 friend class Class; | 7602 friend class Class; |
| 7808 }; | 7603 }; |
| 7809 | 7604 |
| 7810 | 7605 |
| 7811 class Float32x4 : public Instance { | 7606 class Float32x4 : public Instance { |
| 7812 public: | 7607 public: |
| 7813 static RawFloat32x4* New(float value0, float value1, float value2, | 7608 static RawFloat32x4* New(float value0, |
| 7814 float value3, Heap::Space space = Heap::kNew); | 7609 float value1, |
| 7610 float value2, |
| 7611 float value3, |
| 7612 Heap::Space space = Heap::kNew); |
| 7815 static RawFloat32x4* New(simd128_value_t value, | 7613 static RawFloat32x4* New(simd128_value_t value, |
| 7816 Heap::Space space = Heap::kNew); | 7614 Heap::Space space = Heap::kNew); |
| 7817 | 7615 |
| 7818 float x() const; | 7616 float x() const; |
| 7819 float y() const; | 7617 float y() const; |
| 7820 float z() const; | 7618 float z() const; |
| 7821 float w() const; | 7619 float w() const; |
| 7822 | 7620 |
| 7823 void set_x(float x) const; | 7621 void set_x(float x) const; |
| 7824 void set_y(float y) const; | 7622 void set_y(float y) const; |
| 7825 void set_z(float z) const; | 7623 void set_z(float z) const; |
| 7826 void set_w(float w) const; | 7624 void set_w(float w) const; |
| 7827 | 7625 |
| 7828 simd128_value_t value() const; | 7626 simd128_value_t value() const; |
| 7829 void set_value(simd128_value_t value) const; | 7627 void set_value(simd128_value_t value) const; |
| 7830 | 7628 |
| 7831 static intptr_t InstanceSize() { | 7629 static intptr_t InstanceSize() { |
| 7832 return RoundedAllocationSize(sizeof(RawFloat32x4)); | 7630 return RoundedAllocationSize(sizeof(RawFloat32x4)); |
| 7833 } | 7631 } |
| 7834 | 7632 |
| 7835 static intptr_t value_offset() { | 7633 static intptr_t value_offset() { return OFFSET_OF(RawFloat32x4, value_); } |
| 7836 return OFFSET_OF(RawFloat32x4, value_); | |
| 7837 } | |
| 7838 | 7634 |
| 7839 private: | 7635 private: |
| 7840 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance); | 7636 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance); |
| 7841 friend class Class; | 7637 friend class Class; |
| 7842 }; | 7638 }; |
| 7843 | 7639 |
| 7844 | 7640 |
| 7845 class Int32x4 : public Instance { | 7641 class Int32x4 : public Instance { |
| 7846 public: | 7642 public: |
| 7847 static RawInt32x4* New(int32_t value0, int32_t value1, int32_t value2, | 7643 static RawInt32x4* New(int32_t value0, |
| 7848 int32_t value3, Heap::Space space = Heap::kNew); | 7644 int32_t value1, |
| 7849 static RawInt32x4* New(simd128_value_t value, | 7645 int32_t value2, |
| 7850 Heap::Space space = Heap::kNew); | 7646 int32_t value3, |
| 7647 Heap::Space space = Heap::kNew); |
| 7648 static RawInt32x4* New(simd128_value_t value, Heap::Space space = Heap::kNew); |
| 7851 | 7649 |
| 7852 int32_t x() const; | 7650 int32_t x() const; |
| 7853 int32_t y() const; | 7651 int32_t y() const; |
| 7854 int32_t z() const; | 7652 int32_t z() const; |
| 7855 int32_t w() const; | 7653 int32_t w() const; |
| 7856 | 7654 |
| 7857 void set_x(int32_t x) const; | 7655 void set_x(int32_t x) const; |
| 7858 void set_y(int32_t y) const; | 7656 void set_y(int32_t y) const; |
| 7859 void set_z(int32_t z) const; | 7657 void set_z(int32_t z) const; |
| 7860 void set_w(int32_t w) const; | 7658 void set_w(int32_t w) const; |
| 7861 | 7659 |
| 7862 simd128_value_t value() const; | 7660 simd128_value_t value() const; |
| 7863 void set_value(simd128_value_t value) const; | 7661 void set_value(simd128_value_t value) const; |
| 7864 | 7662 |
| 7865 static intptr_t InstanceSize() { | 7663 static intptr_t InstanceSize() { |
| 7866 return RoundedAllocationSize(sizeof(RawInt32x4)); | 7664 return RoundedAllocationSize(sizeof(RawInt32x4)); |
| 7867 } | 7665 } |
| 7868 | 7666 |
| 7869 static intptr_t value_offset() { | 7667 static intptr_t value_offset() { return OFFSET_OF(RawInt32x4, value_); } |
| 7870 return OFFSET_OF(RawInt32x4, value_); | |
| 7871 } | |
| 7872 | 7668 |
| 7873 private: | 7669 private: |
| 7874 FINAL_HEAP_OBJECT_IMPLEMENTATION(Int32x4, Instance); | 7670 FINAL_HEAP_OBJECT_IMPLEMENTATION(Int32x4, Instance); |
| 7875 friend class Class; | 7671 friend class Class; |
| 7876 }; | 7672 }; |
| 7877 | 7673 |
| 7878 | 7674 |
| 7879 class Float64x2 : public Instance { | 7675 class Float64x2 : public Instance { |
| 7880 public: | 7676 public: |
| 7881 static RawFloat64x2* New(double value0, double value1, | 7677 static RawFloat64x2* New(double value0, |
| 7678 double value1, |
| 7882 Heap::Space space = Heap::kNew); | 7679 Heap::Space space = Heap::kNew); |
| 7883 static RawFloat64x2* New(simd128_value_t value, | 7680 static RawFloat64x2* New(simd128_value_t value, |
| 7884 Heap::Space space = Heap::kNew); | 7681 Heap::Space space = Heap::kNew); |
| 7885 | 7682 |
| 7886 double x() const; | 7683 double x() const; |
| 7887 double y() const; | 7684 double y() const; |
| 7888 | 7685 |
| 7889 void set_x(double x) const; | 7686 void set_x(double x) const; |
| 7890 void set_y(double y) const; | 7687 void set_y(double y) const; |
| 7891 | 7688 |
| 7892 simd128_value_t value() const; | 7689 simd128_value_t value() const; |
| 7893 void set_value(simd128_value_t value) const; | 7690 void set_value(simd128_value_t value) const; |
| 7894 | 7691 |
| 7895 static intptr_t InstanceSize() { | 7692 static intptr_t InstanceSize() { |
| 7896 return RoundedAllocationSize(sizeof(RawFloat64x2)); | 7693 return RoundedAllocationSize(sizeof(RawFloat64x2)); |
| 7897 } | 7694 } |
| 7898 | 7695 |
| 7899 static intptr_t value_offset() { | 7696 static intptr_t value_offset() { return OFFSET_OF(RawFloat64x2, value_); } |
| 7900 return OFFSET_OF(RawFloat64x2, value_); | |
| 7901 } | |
| 7902 | 7697 |
| 7903 private: | 7698 private: |
| 7904 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float64x2, Instance); | 7699 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float64x2, Instance); |
| 7905 friend class Class; | 7700 friend class Class; |
| 7906 }; | 7701 }; |
| 7907 | 7702 |
| 7908 | 7703 |
| 7909 class TypedData : public Instance { | 7704 class TypedData : public Instance { |
| 7910 public: | 7705 public: |
| 7911 // We use 30 bits for the hash code so hashes in a snapshot taken on a | 7706 // We use 30 bits for the hash code so hashes in a snapshot taken on a |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7929 } | 7724 } |
| 7930 | 7725 |
| 7931 intptr_t LengthInBytes() const { | 7726 intptr_t LengthInBytes() const { |
| 7932 intptr_t cid = raw()->GetClassId(); | 7727 intptr_t cid = raw()->GetClassId(); |
| 7933 return (ElementSizeInBytes(cid) * Length()); | 7728 return (ElementSizeInBytes(cid) * Length()); |
| 7934 } | 7729 } |
| 7935 | 7730 |
| 7936 void* DataAddr(intptr_t byte_offset) const { | 7731 void* DataAddr(intptr_t byte_offset) const { |
| 7937 ASSERT((byte_offset == 0) || | 7732 ASSERT((byte_offset == 0) || |
| 7938 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); | 7733 ((byte_offset > 0) && (byte_offset < LengthInBytes()))); |
| 7939 return reinterpret_cast<void*>( | 7734 return reinterpret_cast<void*>(UnsafeMutableNonPointer(raw_ptr()->data()) + |
| 7940 UnsafeMutableNonPointer(raw_ptr()->data()) + byte_offset); | 7735 byte_offset); |
| 7941 } | 7736 } |
| 7942 | 7737 |
| 7943 virtual bool CanonicalizeEquals(const Instance& other) const; | 7738 virtual bool CanonicalizeEquals(const Instance& other) const; |
| 7944 virtual uword ComputeCanonicalTableHash() const; | 7739 virtual uword ComputeCanonicalTableHash() const; |
| 7945 | 7740 |
| 7946 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) | 7741 #if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) |
| 7947 #define TYPED_GETTER_SETTER(name, type) \ | 7742 #define TYPED_GETTER_SETTER(name, type) \ |
| 7948 type Get##name(intptr_t byte_offset) const { \ | 7743 type Get##name(intptr_t byte_offset) const { \ |
| 7949 NoSafepointScope no_safepoint; \ | 7744 NoSafepointScope no_safepoint; \ |
| 7950 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ | 7745 return *reinterpret_cast<type*>(DataAddr(byte_offset)); \ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 7976 TYPED_GETTER_SETTER(Int64, int64_t) | 7771 TYPED_GETTER_SETTER(Int64, int64_t) |
| 7977 TYPED_GETTER_SETTER(Uint64, uint64_t) | 7772 TYPED_GETTER_SETTER(Uint64, uint64_t) |
| 7978 TYPED_GETTER_SETTER(Float32, float) | 7773 TYPED_GETTER_SETTER(Float32, float) |
| 7979 TYPED_GETTER_SETTER(Float64, double) | 7774 TYPED_GETTER_SETTER(Float64, double) |
| 7980 TYPED_GETTER_SETTER(Float32x4, simd128_value_t) | 7775 TYPED_GETTER_SETTER(Float32x4, simd128_value_t) |
| 7981 TYPED_GETTER_SETTER(Int32x4, simd128_value_t) | 7776 TYPED_GETTER_SETTER(Int32x4, simd128_value_t) |
| 7982 TYPED_GETTER_SETTER(Float64x2, simd128_value_t) | 7777 TYPED_GETTER_SETTER(Float64x2, simd128_value_t) |
| 7983 | 7778 |
| 7984 #undef TYPED_GETTER_SETTER | 7779 #undef TYPED_GETTER_SETTER |
| 7985 | 7780 |
| 7986 static intptr_t length_offset() { | 7781 static intptr_t length_offset() { return OFFSET_OF(RawTypedData, length_); } |
| 7987 return OFFSET_OF(RawTypedData, length_); | |
| 7988 } | |
| 7989 | 7782 |
| 7990 static intptr_t data_offset() { | 7783 static intptr_t data_offset() { |
| 7991 return OFFSET_OF_RETURNED_VALUE(RawTypedData, data); | 7784 return OFFSET_OF_RETURNED_VALUE(RawTypedData, data); |
| 7992 } | 7785 } |
| 7993 | 7786 |
| 7994 static intptr_t InstanceSize() { | 7787 static intptr_t InstanceSize() { |
| 7995 ASSERT(sizeof(RawTypedData) == | 7788 ASSERT(sizeof(RawTypedData) == |
| 7996 OFFSET_OF_RETURNED_VALUE(RawTypedData, data)); | 7789 OFFSET_OF_RETURNED_VALUE(RawTypedData, data)); |
| 7997 return 0; | 7790 return 0; |
| 7998 } | 7791 } |
| 7999 | 7792 |
| 8000 static intptr_t InstanceSize(intptr_t lengthInBytes) { | 7793 static intptr_t InstanceSize(intptr_t lengthInBytes) { |
| 8001 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); | 7794 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); |
| 8002 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); | 7795 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); |
| 8003 } | 7796 } |
| 8004 | 7797 |
| 8005 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 7798 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 8006 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 7799 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 8007 return element_size(ElementType(class_id)); | 7800 return element_size(ElementType(class_id)); |
| 8008 } | 7801 } |
| 8009 | 7802 |
| 8010 static TypedDataElementType ElementType(intptr_t class_id) { | 7803 static TypedDataElementType ElementType(intptr_t class_id) { |
| 8011 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 7804 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 8012 return static_cast<TypedDataElementType>( | 7805 return static_cast<TypedDataElementType>(class_id - kTypedDataInt8ArrayCid); |
| 8013 class_id - kTypedDataInt8ArrayCid); | |
| 8014 } | 7806 } |
| 8015 | 7807 |
| 8016 static intptr_t MaxElements(intptr_t class_id) { | 7808 static intptr_t MaxElements(intptr_t class_id) { |
| 8017 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 7809 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 8018 return (kSmiMax / ElementSizeInBytes(class_id)); | 7810 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 8019 } | 7811 } |
| 8020 | 7812 |
| 8021 static RawTypedData* New(intptr_t class_id, | 7813 static RawTypedData* New(intptr_t class_id, |
| 8022 intptr_t len, | 7814 intptr_t len, |
| 8023 Heap::Space space = Heap::kNew); | 7815 Heap::Space space = Heap::kNew); |
| 8024 | 7816 |
| 8025 template <typename DstType, typename SrcType> | 7817 template <typename DstType, typename SrcType> |
| 8026 static void Copy(const DstType& dst, intptr_t dst_offset_in_bytes, | 7818 static void Copy(const DstType& dst, |
| 8027 const SrcType& src, intptr_t src_offset_in_bytes, | 7819 intptr_t dst_offset_in_bytes, |
| 7820 const SrcType& src, |
| 7821 intptr_t src_offset_in_bytes, |
| 8028 intptr_t length_in_bytes) { | 7822 intptr_t length_in_bytes) { |
| 8029 ASSERT(Utils::RangeCheck(src_offset_in_bytes, | 7823 ASSERT(Utils::RangeCheck(src_offset_in_bytes, length_in_bytes, |
| 8030 length_in_bytes, | |
| 8031 src.LengthInBytes())); | 7824 src.LengthInBytes())); |
| 8032 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, | 7825 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, length_in_bytes, |
| 8033 length_in_bytes, | |
| 8034 dst.LengthInBytes())); | 7826 dst.LengthInBytes())); |
| 8035 { | 7827 { |
| 8036 NoSafepointScope no_safepoint; | 7828 NoSafepointScope no_safepoint; |
| 8037 if (length_in_bytes > 0) { | 7829 if (length_in_bytes > 0) { |
| 8038 memmove(dst.DataAddr(dst_offset_in_bytes), | 7830 memmove(dst.DataAddr(dst_offset_in_bytes), |
| 8039 src.DataAddr(src_offset_in_bytes), | 7831 src.DataAddr(src_offset_in_bytes), length_in_bytes); |
| 8040 length_in_bytes); | |
| 8041 } | 7832 } |
| 8042 } | 7833 } |
| 8043 } | 7834 } |
| 8044 | 7835 |
| 8045 | 7836 |
| 8046 template <typename DstType, typename SrcType> | 7837 template <typename DstType, typename SrcType> |
| 8047 static void ClampedCopy(const DstType& dst, intptr_t dst_offset_in_bytes, | 7838 static void ClampedCopy(const DstType& dst, |
| 8048 const SrcType& src, intptr_t src_offset_in_bytes, | 7839 intptr_t dst_offset_in_bytes, |
| 7840 const SrcType& src, |
| 7841 intptr_t src_offset_in_bytes, |
| 8049 intptr_t length_in_bytes) { | 7842 intptr_t length_in_bytes) { |
| 8050 ASSERT(Utils::RangeCheck(src_offset_in_bytes, | 7843 ASSERT(Utils::RangeCheck(src_offset_in_bytes, length_in_bytes, |
| 8051 length_in_bytes, | |
| 8052 src.LengthInBytes())); | 7844 src.LengthInBytes())); |
| 8053 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, | 7845 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, length_in_bytes, |
| 8054 length_in_bytes, | |
| 8055 dst.LengthInBytes())); | 7846 dst.LengthInBytes())); |
| 8056 { | 7847 { |
| 8057 NoSafepointScope no_safepoint; | 7848 NoSafepointScope no_safepoint; |
| 8058 if (length_in_bytes > 0) { | 7849 if (length_in_bytes > 0) { |
| 8059 uint8_t* dst_data = | 7850 uint8_t* dst_data = |
| 8060 reinterpret_cast<uint8_t*>(dst.DataAddr(dst_offset_in_bytes)); | 7851 reinterpret_cast<uint8_t*>(dst.DataAddr(dst_offset_in_bytes)); |
| 8061 int8_t* src_data = | 7852 int8_t* src_data = |
| 8062 reinterpret_cast<int8_t*>(src.DataAddr(src_offset_in_bytes)); | 7853 reinterpret_cast<int8_t*>(src.DataAddr(src_offset_in_bytes)); |
| 8063 for (intptr_t ix = 0; ix < length_in_bytes; ix++) { | 7854 for (intptr_t ix = 0; ix < length_in_bytes; ix++) { |
| 8064 int8_t v = *src_data; | 7855 int8_t v = *src_data; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8170 return RoundedAllocationSize(sizeof(RawExternalTypedData)); | 7961 return RoundedAllocationSize(sizeof(RawExternalTypedData)); |
| 8171 } | 7962 } |
| 8172 | 7963 |
| 8173 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 7964 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 8174 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 7965 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 8175 return TypedData::element_size(ElementType(class_id)); | 7966 return TypedData::element_size(ElementType(class_id)); |
| 8176 } | 7967 } |
| 8177 | 7968 |
| 8178 static TypedDataElementType ElementType(intptr_t class_id) { | 7969 static TypedDataElementType ElementType(intptr_t class_id) { |
| 8179 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 7970 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 8180 return static_cast<TypedDataElementType>( | 7971 return static_cast<TypedDataElementType>(class_id - |
| 8181 class_id - kExternalTypedDataInt8ArrayCid); | 7972 kExternalTypedDataInt8ArrayCid); |
| 8182 } | 7973 } |
| 8183 | 7974 |
| 8184 static intptr_t MaxElements(intptr_t class_id) { | 7975 static intptr_t MaxElements(intptr_t class_id) { |
| 8185 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 7976 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 8186 return (kSmiMax / ElementSizeInBytes(class_id)); | 7977 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 8187 } | 7978 } |
| 8188 | 7979 |
| 8189 static RawExternalTypedData* New(intptr_t class_id, | 7980 static RawExternalTypedData* New(intptr_t class_id, |
| 8190 uint8_t* data, | 7981 uint8_t* data, |
| 8191 intptr_t len, | 7982 intptr_t len, |
| 8192 Heap::Space space = Heap::kNew); | 7983 Heap::Space space = Heap::kNew); |
| 8193 | 7984 |
| 8194 static bool IsExternalTypedData(const Instance& obj) { | 7985 static bool IsExternalTypedData(const Instance& obj) { |
| 8195 ASSERT(!obj.IsNull()); | 7986 ASSERT(!obj.IsNull()); |
| 8196 intptr_t cid = obj.raw()->GetClassId(); | 7987 intptr_t cid = obj.raw()->GetClassId(); |
| 8197 return RawObject::IsExternalTypedDataClassId(cid); | 7988 return RawObject::IsExternalTypedDataClassId(cid); |
| 8198 } | 7989 } |
| 8199 | 7990 |
| 8200 protected: | 7991 protected: |
| 8201 void SetLength(intptr_t value) const { | 7992 void SetLength(intptr_t value) const { |
| 8202 StoreSmi(&raw_ptr()->length_, Smi::New(value)); | 7993 StoreSmi(&raw_ptr()->length_, Smi::New(value)); |
| 8203 } | 7994 } |
| 8204 | 7995 |
| 8205 void SetData(uint8_t* data) const { | 7996 void SetData(uint8_t* data) const { |
| 8206 ASSERT(!Isolate::Current()->heap()->Contains( | 7997 ASSERT( |
| 8207 reinterpret_cast<uword>(data))); | 7998 !Isolate::Current()->heap()->Contains(reinterpret_cast<uword>(data))); |
| 8208 StoreNonPointer(&raw_ptr()->data_, data); | 7999 StoreNonPointer(&raw_ptr()->data_, data); |
| 8209 } | 8000 } |
| 8210 | 8001 |
| 8211 private: | 8002 private: |
| 8212 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); | 8003 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); |
| 8213 friend class Class; | 8004 friend class Class; |
| 8214 }; | 8005 }; |
| 8215 | 8006 |
| 8216 | 8007 |
| 8217 class TypedDataView : public AllStatic { | 8008 class TypedDataView : public AllStatic { |
| 8218 public: | 8009 public: |
| 8219 static intptr_t ElementSizeInBytes(const Instance& view_obj) { | 8010 static intptr_t ElementSizeInBytes(const Instance& view_obj) { |
| 8220 ASSERT(!view_obj.IsNull()); | 8011 ASSERT(!view_obj.IsNull()); |
| 8221 intptr_t cid = view_obj.raw()->GetClassId(); | 8012 intptr_t cid = view_obj.raw()->GetClassId(); |
| 8222 return ElementSizeInBytes(cid); | 8013 return ElementSizeInBytes(cid); |
| 8223 } | 8014 } |
| 8224 | 8015 |
| 8225 static RawInstance* Data(const Instance& view_obj) { | 8016 static RawInstance* Data(const Instance& view_obj) { |
| 8226 ASSERT(!view_obj.IsNull()); | 8017 ASSERT(!view_obj.IsNull()); |
| 8227 return *reinterpret_cast<RawInstance* const*>( | 8018 return *reinterpret_cast<RawInstance* const*>(view_obj.raw_ptr() + |
| 8228 view_obj.raw_ptr() + kDataOffset); | 8019 kDataOffset); |
| 8229 } | 8020 } |
| 8230 | 8021 |
| 8231 static RawSmi* OffsetInBytes(const Instance& view_obj) { | 8022 static RawSmi* OffsetInBytes(const Instance& view_obj) { |
| 8232 ASSERT(!view_obj.IsNull()); | 8023 ASSERT(!view_obj.IsNull()); |
| 8233 return *reinterpret_cast<RawSmi* const*>( | 8024 return *reinterpret_cast<RawSmi* const*>(view_obj.raw_ptr() + |
| 8234 view_obj.raw_ptr() + kOffsetInBytesOffset); | 8025 kOffsetInBytesOffset); |
| 8235 } | 8026 } |
| 8236 | 8027 |
| 8237 static RawSmi* Length(const Instance& view_obj) { | 8028 static RawSmi* Length(const Instance& view_obj) { |
| 8238 ASSERT(!view_obj.IsNull()); | 8029 ASSERT(!view_obj.IsNull()); |
| 8239 return *reinterpret_cast<RawSmi* const*>( | 8030 return *reinterpret_cast<RawSmi* const*>(view_obj.raw_ptr() + |
| 8240 view_obj.raw_ptr() + kLengthOffset); | 8031 kLengthOffset); |
| 8241 } | 8032 } |
| 8242 | 8033 |
| 8243 static bool IsExternalTypedDataView(const Instance& view_obj) { | 8034 static bool IsExternalTypedDataView(const Instance& view_obj) { |
| 8244 const Instance& data = Instance::Handle(Data(view_obj)); | 8035 const Instance& data = Instance::Handle(Data(view_obj)); |
| 8245 intptr_t cid = data.raw()->GetClassId(); | 8036 intptr_t cid = data.raw()->GetClassId(); |
| 8246 ASSERT(RawObject::IsTypedDataClassId(cid) || | 8037 ASSERT(RawObject::IsTypedDataClassId(cid) || |
| 8247 RawObject::IsExternalTypedDataClassId(cid)); | 8038 RawObject::IsExternalTypedDataClassId(cid)); |
| 8248 return RawObject::IsExternalTypedDataClassId(cid); | 8039 return RawObject::IsExternalTypedDataClassId(cid); |
| 8249 } | 8040 } |
| 8250 | 8041 |
| 8251 static intptr_t NumberOfFields() { | 8042 static intptr_t NumberOfFields() { return kLengthOffset; } |
| 8252 return kLengthOffset; | |
| 8253 } | |
| 8254 | 8043 |
| 8255 static intptr_t data_offset() { | 8044 static intptr_t data_offset() { return kWordSize * kDataOffset; } |
| 8256 return kWordSize * kDataOffset; | |
| 8257 } | |
| 8258 | 8045 |
| 8259 static intptr_t offset_in_bytes_offset() { | 8046 static intptr_t offset_in_bytes_offset() { |
| 8260 return kWordSize * kOffsetInBytesOffset; | 8047 return kWordSize * kOffsetInBytesOffset; |
| 8261 } | 8048 } |
| 8262 | 8049 |
| 8263 static intptr_t length_offset() { | 8050 static intptr_t length_offset() { return kWordSize * kLengthOffset; } |
| 8264 return kWordSize * kLengthOffset; | |
| 8265 } | |
| 8266 | 8051 |
| 8267 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 8052 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 8268 ASSERT(RawObject::IsTypedDataViewClassId(class_id)); | 8053 ASSERT(RawObject::IsTypedDataViewClassId(class_id)); |
| 8269 return (class_id == kByteDataViewCid) ? | 8054 return (class_id == kByteDataViewCid) |
| 8270 1 : TypedData::element_size(class_id - kTypedDataInt8ArrayViewCid); | 8055 ? 1 |
| 8056 : TypedData::element_size(class_id - kTypedDataInt8ArrayViewCid); |
| 8271 } | 8057 } |
| 8272 | 8058 |
| 8273 private: | 8059 private: |
| 8274 enum { | 8060 enum { |
| 8275 kDataOffset = 1, | 8061 kDataOffset = 1, |
| 8276 kOffsetInBytesOffset = 2, | 8062 kOffsetInBytesOffset = 2, |
| 8277 kLengthOffset = 3, | 8063 kLengthOffset = 3, |
| 8278 }; | 8064 }; |
| 8279 }; | 8065 }; |
| 8280 | 8066 |
| 8281 | 8067 |
| 8282 class ByteBuffer : public AllStatic { | 8068 class ByteBuffer : public AllStatic { |
| 8283 public: | 8069 public: |
| 8284 static RawInstance* Data(const Instance& view_obj) { | 8070 static RawInstance* Data(const Instance& view_obj) { |
| 8285 ASSERT(!view_obj.IsNull()); | 8071 ASSERT(!view_obj.IsNull()); |
| 8286 return *reinterpret_cast<RawInstance* const*>( | 8072 return *reinterpret_cast<RawInstance* const*>(view_obj.raw_ptr() + |
| 8287 view_obj.raw_ptr() + kDataOffset); | 8073 kDataOffset); |
| 8288 } | 8074 } |
| 8289 | 8075 |
| 8290 static intptr_t NumberOfFields() { | 8076 static intptr_t NumberOfFields() { return kDataOffset; } |
| 8291 return kDataOffset; | |
| 8292 } | |
| 8293 | 8077 |
| 8294 static intptr_t data_offset() { | 8078 static intptr_t data_offset() { return kWordSize * kDataOffset; } |
| 8295 return kWordSize * kDataOffset; | |
| 8296 } | |
| 8297 | 8079 |
| 8298 private: | 8080 private: |
| 8299 enum { | 8081 enum { |
| 8300 kDataOffset = 1, | 8082 kDataOffset = 1, |
| 8301 }; | 8083 }; |
| 8302 }; | 8084 }; |
| 8303 | 8085 |
| 8304 | 8086 |
| 8305 // Corresponds to | 8087 // Corresponds to |
| 8306 // - "new Map()", | 8088 // - "new Map()", |
| (...skipping 22 matching lines...) Expand all Loading... |
| 8329 ((value.Length() >= 2) && | 8111 ((value.Length() >= 2) && |
| 8330 value.IsInstantiated() /*&& value.IsCanonical()*/)); | 8112 value.IsInstantiated() /*&& value.IsCanonical()*/)); |
| 8331 // TODO(asiva): Values read from a message snapshot are not properly marked | 8113 // TODO(asiva): Values read from a message snapshot are not properly marked |
| 8332 // as canonical. See for example tests/isolate/message3_test.dart. | 8114 // as canonical. See for example tests/isolate/message3_test.dart. |
| 8333 StorePointer(&raw_ptr()->type_arguments_, value.raw()); | 8115 StorePointer(&raw_ptr()->type_arguments_, value.raw()); |
| 8334 } | 8116 } |
| 8335 static intptr_t type_arguments_offset() { | 8117 static intptr_t type_arguments_offset() { |
| 8336 return OFFSET_OF(RawLinkedHashMap, type_arguments_); | 8118 return OFFSET_OF(RawLinkedHashMap, type_arguments_); |
| 8337 } | 8119 } |
| 8338 | 8120 |
| 8339 RawTypedData* index() const { | 8121 RawTypedData* index() const { return raw_ptr()->index_; } |
| 8340 return raw_ptr()->index_; | |
| 8341 } | |
| 8342 void SetIndex(const TypedData& value) const { | 8122 void SetIndex(const TypedData& value) const { |
| 8343 StorePointer(&raw_ptr()->index_, value.raw()); | 8123 StorePointer(&raw_ptr()->index_, value.raw()); |
| 8344 } | 8124 } |
| 8345 static intptr_t index_offset() { | 8125 static intptr_t index_offset() { return OFFSET_OF(RawLinkedHashMap, index_); } |
| 8346 return OFFSET_OF(RawLinkedHashMap, index_); | |
| 8347 } | |
| 8348 | 8126 |
| 8349 RawArray* data() const { | 8127 RawArray* data() const { return raw_ptr()->data_; } |
| 8350 return raw_ptr()->data_; | |
| 8351 } | |
| 8352 void SetData(const Array& value) const { | 8128 void SetData(const Array& value) const { |
| 8353 StorePointer(&raw_ptr()->data_, value.raw()); | 8129 StorePointer(&raw_ptr()->data_, value.raw()); |
| 8354 } | 8130 } |
| 8355 static intptr_t data_offset() { | 8131 static intptr_t data_offset() { return OFFSET_OF(RawLinkedHashMap, data_); } |
| 8356 return OFFSET_OF(RawLinkedHashMap, data_); | |
| 8357 } | |
| 8358 | 8132 |
| 8359 RawSmi* hash_mask() const { | 8133 RawSmi* hash_mask() const { return raw_ptr()->hash_mask_; } |
| 8360 return raw_ptr()->hash_mask_; | |
| 8361 } | |
| 8362 void SetHashMask(intptr_t value) const { | 8134 void SetHashMask(intptr_t value) const { |
| 8363 StoreSmi(&raw_ptr()->hash_mask_, Smi::New(value)); | 8135 StoreSmi(&raw_ptr()->hash_mask_, Smi::New(value)); |
| 8364 } | 8136 } |
| 8365 static intptr_t hash_mask_offset() { | 8137 static intptr_t hash_mask_offset() { |
| 8366 return OFFSET_OF(RawLinkedHashMap, hash_mask_); | 8138 return OFFSET_OF(RawLinkedHashMap, hash_mask_); |
| 8367 } | 8139 } |
| 8368 | 8140 |
| 8369 RawSmi* used_data() const { | 8141 RawSmi* used_data() const { return raw_ptr()->used_data_; } |
| 8370 return raw_ptr()->used_data_; | |
| 8371 } | |
| 8372 void SetUsedData(intptr_t value) const { | 8142 void SetUsedData(intptr_t value) const { |
| 8373 StoreSmi(&raw_ptr()->used_data_, Smi::New(value)); | 8143 StoreSmi(&raw_ptr()->used_data_, Smi::New(value)); |
| 8374 } | 8144 } |
| 8375 static intptr_t used_data_offset() { | 8145 static intptr_t used_data_offset() { |
| 8376 return OFFSET_OF(RawLinkedHashMap, used_data_); | 8146 return OFFSET_OF(RawLinkedHashMap, used_data_); |
| 8377 } | 8147 } |
| 8378 | 8148 |
| 8379 RawSmi* deleted_keys() const { | 8149 RawSmi* deleted_keys() const { return raw_ptr()->deleted_keys_; } |
| 8380 return raw_ptr()->deleted_keys_; | |
| 8381 } | |
| 8382 void SetDeletedKeys(intptr_t value) const { | 8150 void SetDeletedKeys(intptr_t value) const { |
| 8383 StoreSmi(&raw_ptr()->deleted_keys_, Smi::New(value)); | 8151 StoreSmi(&raw_ptr()->deleted_keys_, Smi::New(value)); |
| 8384 } | 8152 } |
| 8385 static intptr_t deleted_keys_offset() { | 8153 static intptr_t deleted_keys_offset() { |
| 8386 return OFFSET_OF(RawLinkedHashMap, deleted_keys_); | 8154 return OFFSET_OF(RawLinkedHashMap, deleted_keys_); |
| 8387 } | 8155 } |
| 8388 | 8156 |
| 8389 intptr_t Length() const { | 8157 intptr_t Length() const { |
| 8390 intptr_t used = Smi::Value(raw_ptr()->used_data_); | 8158 intptr_t used = Smi::Value(raw_ptr()->used_data_); |
| 8391 intptr_t deleted = Smi::Value(raw_ptr()->deleted_keys_); | 8159 intptr_t deleted = Smi::Value(raw_ptr()->deleted_keys_); |
| 8392 return (used >> 1) - deleted; | 8160 return (used >> 1) - deleted; |
| 8393 } | 8161 } |
| 8394 | 8162 |
| 8395 // This iterator differs somewhat from its Dart counterpart (_CompactIterator | 8163 // This iterator differs somewhat from its Dart counterpart (_CompactIterator |
| 8396 // in runtime/lib/compact_hash.dart): | 8164 // in runtime/lib/compact_hash.dart): |
| 8397 // - There are no checks for concurrent modifications. | 8165 // - There are no checks for concurrent modifications. |
| 8398 // - Accessing a key or value before the first call to MoveNext and after | 8166 // - Accessing a key or value before the first call to MoveNext and after |
| 8399 // MoveNext returns false will result in crashes. | 8167 // MoveNext returns false will result in crashes. |
| 8400 class Iterator : ValueObject { | 8168 class Iterator : ValueObject { |
| 8401 public: | 8169 public: |
| 8402 explicit Iterator(const LinkedHashMap& map) | 8170 explicit Iterator(const LinkedHashMap& map) |
| 8403 : data_(Array::Handle(map.data())), | 8171 : data_(Array::Handle(map.data())), |
| 8404 scratch_(Object::Handle()), | 8172 scratch_(Object::Handle()), |
| 8405 offset_(-2), | 8173 offset_(-2), |
| 8406 length_(Smi::Value(map.used_data())) {} | 8174 length_(Smi::Value(map.used_data())) {} |
| 8407 | 8175 |
| 8408 bool MoveNext() { | 8176 bool MoveNext() { |
| 8409 while (true) { | 8177 while (true) { |
| 8410 offset_ += 2; | 8178 offset_ += 2; |
| 8411 if (offset_ >= length_) { | 8179 if (offset_ >= length_) { |
| 8412 return false; | 8180 return false; |
| 8413 } | 8181 } |
| 8414 scratch_ = data_.At(offset_); | 8182 scratch_ = data_.At(offset_); |
| 8415 if (scratch_.raw() != data_.raw()) { | 8183 if (scratch_.raw() != data_.raw()) { |
| 8416 // Slot is not deleted (self-reference indicates deletion). | 8184 // Slot is not deleted (self-reference indicates deletion). |
| 8417 return true; | 8185 return true; |
| 8418 } | 8186 } |
| 8419 } | 8187 } |
| 8420 } | 8188 } |
| 8421 | 8189 |
| 8422 RawObject* CurrentKey() const { | 8190 RawObject* CurrentKey() const { return data_.At(offset_); } |
| 8423 return data_.At(offset_); | |
| 8424 } | |
| 8425 | 8191 |
| 8426 RawObject* CurrentValue() const { | 8192 RawObject* CurrentValue() const { return data_.At(offset_ + 1); } |
| 8427 return data_.At(offset_ + 1); | |
| 8428 } | |
| 8429 | 8193 |
| 8430 private: | 8194 private: |
| 8431 const Array& data_; | 8195 const Array& data_; |
| 8432 Object& scratch_; | 8196 Object& scratch_; |
| 8433 intptr_t offset_; | 8197 intptr_t offset_; |
| 8434 const intptr_t length_; | 8198 const intptr_t length_; |
| 8435 }; | 8199 }; |
| 8436 | 8200 |
| 8437 private: | 8201 private: |
| 8438 FINAL_HEAP_OBJECT_IMPLEMENTATION(LinkedHashMap, Instance); | 8202 FINAL_HEAP_OBJECT_IMPLEMENTATION(LinkedHashMap, Instance); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8535 | 8299 |
| 8536 Dart_Port origin_id() const { return raw_ptr()->origin_id_; } | 8300 Dart_Port origin_id() const { return raw_ptr()->origin_id_; } |
| 8537 void set_origin_id(Dart_Port id) const { | 8301 void set_origin_id(Dart_Port id) const { |
| 8538 ASSERT(origin_id() == 0); | 8302 ASSERT(origin_id() == 0); |
| 8539 StoreNonPointer(&(raw_ptr()->origin_id_), id); | 8303 StoreNonPointer(&(raw_ptr()->origin_id_), id); |
| 8540 } | 8304 } |
| 8541 | 8305 |
| 8542 static intptr_t InstanceSize() { | 8306 static intptr_t InstanceSize() { |
| 8543 return RoundedAllocationSize(sizeof(RawSendPort)); | 8307 return RoundedAllocationSize(sizeof(RawSendPort)); |
| 8544 } | 8308 } |
| 8545 static RawSendPort* New(Dart_Port id, | 8309 static RawSendPort* New(Dart_Port id, Heap::Space space = Heap::kNew); |
| 8546 Heap::Space space = Heap::kNew); | |
| 8547 static RawSendPort* New(Dart_Port id, | 8310 static RawSendPort* New(Dart_Port id, |
| 8548 Dart_Port origin_id, | 8311 Dart_Port origin_id, |
| 8549 Heap::Space space = Heap::kNew); | 8312 Heap::Space space = Heap::kNew); |
| 8550 | 8313 |
| 8551 private: | 8314 private: |
| 8552 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance); | 8315 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance); |
| 8553 friend class Class; | 8316 friend class Class; |
| 8554 }; | 8317 }; |
| 8555 | 8318 |
| 8556 | 8319 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8644 : raw_ptr()->two_byte_bytecode_; | 8407 : raw_ptr()->two_byte_bytecode_; |
| 8645 } | 8408 } |
| 8646 | 8409 |
| 8647 static intptr_t function_offset(intptr_t cid) { | 8410 static intptr_t function_offset(intptr_t cid) { |
| 8648 switch (cid) { | 8411 switch (cid) { |
| 8649 case kOneByteStringCid: | 8412 case kOneByteStringCid: |
| 8650 return OFFSET_OF(RawRegExp, one_byte_function_); | 8413 return OFFSET_OF(RawRegExp, one_byte_function_); |
| 8651 case kTwoByteStringCid: | 8414 case kTwoByteStringCid: |
| 8652 return OFFSET_OF(RawRegExp, two_byte_function_); | 8415 return OFFSET_OF(RawRegExp, two_byte_function_); |
| 8653 case kExternalOneByteStringCid: | 8416 case kExternalOneByteStringCid: |
| 8654 return OFFSET_OF(RawRegExp, external_one_byte_function_); | 8417 return OFFSET_OF(RawRegExp, external_one_byte_function_); |
| 8655 case kExternalTwoByteStringCid: | 8418 case kExternalTwoByteStringCid: |
| 8656 return OFFSET_OF(RawRegExp, external_two_byte_function_); | 8419 return OFFSET_OF(RawRegExp, external_two_byte_function_); |
| 8657 } | 8420 } |
| 8658 | 8421 |
| 8659 UNREACHABLE(); | 8422 UNREACHABLE(); |
| 8660 return -1; | 8423 return -1; |
| 8661 } | 8424 } |
| 8662 | 8425 |
| 8663 RawFunction** FunctionAddr(intptr_t cid) const { | 8426 RawFunction** FunctionAddr(intptr_t cid) const { |
| 8664 return reinterpret_cast<RawFunction**>( | 8427 return reinterpret_cast<RawFunction**>( |
| 8665 FieldAddrAtOffset(function_offset(cid))); | 8428 FieldAddrAtOffset(function_offset(cid))); |
| 8666 } | 8429 } |
| 8667 | 8430 |
| 8668 RawFunction* function(intptr_t cid) const { | 8431 RawFunction* function(intptr_t cid) const { return *FunctionAddr(cid); } |
| 8669 return *FunctionAddr(cid); | |
| 8670 } | |
| 8671 | 8432 |
| 8672 void set_pattern(const String& pattern) const; | 8433 void set_pattern(const String& pattern) const; |
| 8673 void set_function(intptr_t cid, const Function& value) const; | 8434 void set_function(intptr_t cid, const Function& value) const; |
| 8674 void set_bytecode(bool is_one_byte, const TypedData& bytecode) const; | 8435 void set_bytecode(bool is_one_byte, const TypedData& bytecode) const; |
| 8675 | 8436 |
| 8676 void set_num_bracket_expressions(intptr_t value) const; | 8437 void set_num_bracket_expressions(intptr_t value) const; |
| 8677 void set_is_global() const { set_flags(flags() | kGlobal); } | 8438 void set_is_global() const { set_flags(flags() | kGlobal); } |
| 8678 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } | 8439 void set_is_ignore_case() const { set_flags(flags() | kIgnoreCase); } |
| 8679 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } | 8440 void set_is_multi_line() const { set_flags(flags() | kMultiLine); } |
| 8680 void set_is_simple() const { set_type(kSimple); } | 8441 void set_is_simple() const { set_type(kSimple); } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8698 private: | 8459 private: |
| 8699 void set_type(RegExType type) const { | 8460 void set_type(RegExType type) const { |
| 8700 StoreNonPointer(&raw_ptr()->type_flags_, | 8461 StoreNonPointer(&raw_ptr()->type_flags_, |
| 8701 TypeBits::update(type, raw_ptr()->type_flags_)); | 8462 TypeBits::update(type, raw_ptr()->type_flags_)); |
| 8702 } | 8463 } |
| 8703 void set_flags(intptr_t value) const { | 8464 void set_flags(intptr_t value) const { |
| 8704 StoreNonPointer(&raw_ptr()->type_flags_, | 8465 StoreNonPointer(&raw_ptr()->type_flags_, |
| 8705 FlagsBits::update(value, raw_ptr()->type_flags_)); | 8466 FlagsBits::update(value, raw_ptr()->type_flags_)); |
| 8706 } | 8467 } |
| 8707 | 8468 |
| 8708 RegExType type() const { | 8469 RegExType type() const { return TypeBits::decode(raw_ptr()->type_flags_); } |
| 8709 return TypeBits::decode(raw_ptr()->type_flags_); | 8470 intptr_t flags() const { return FlagsBits::decode(raw_ptr()->type_flags_); } |
| 8710 } | |
| 8711 intptr_t flags() const { | |
| 8712 return FlagsBits::decode(raw_ptr()->type_flags_); | |
| 8713 } | |
| 8714 | 8471 |
| 8715 FINAL_HEAP_OBJECT_IMPLEMENTATION(RegExp, Instance); | 8472 FINAL_HEAP_OBJECT_IMPLEMENTATION(RegExp, Instance); |
| 8716 friend class Class; | 8473 friend class Class; |
| 8717 }; | 8474 }; |
| 8718 | 8475 |
| 8719 | 8476 |
| 8720 class WeakProperty : public Instance { | 8477 class WeakProperty : public Instance { |
| 8721 public: | 8478 public: |
| 8722 RawObject* key() const { | 8479 RawObject* key() const { return raw_ptr()->key_; } |
| 8723 return raw_ptr()->key_; | |
| 8724 } | |
| 8725 | 8480 |
| 8726 void set_key(const Object& key) const { | 8481 void set_key(const Object& key) const { |
| 8727 StorePointer(&raw_ptr()->key_, key.raw()); | 8482 StorePointer(&raw_ptr()->key_, key.raw()); |
| 8728 } | 8483 } |
| 8729 | 8484 |
| 8730 RawObject* value() const { | 8485 RawObject* value() const { return raw_ptr()->value_; } |
| 8731 return raw_ptr()->value_; | |
| 8732 } | |
| 8733 | 8486 |
| 8734 void set_value(const Object& value) const { | 8487 void set_value(const Object& value) const { |
| 8735 StorePointer(&raw_ptr()->value_, value.raw()); | 8488 StorePointer(&raw_ptr()->value_, value.raw()); |
| 8736 } | 8489 } |
| 8737 | 8490 |
| 8738 static RawWeakProperty* New(Heap::Space space = Heap::kNew); | 8491 static RawWeakProperty* New(Heap::Space space = Heap::kNew); |
| 8739 | 8492 |
| 8740 static intptr_t InstanceSize() { | 8493 static intptr_t InstanceSize() { |
| 8741 return RoundedAllocationSize(sizeof(RawWeakProperty)); | 8494 return RoundedAllocationSize(sizeof(RawWeakProperty)); |
| 8742 } | 8495 } |
| 8743 | 8496 |
| 8744 static void Clear(RawWeakProperty* raw_weak) { | 8497 static void Clear(RawWeakProperty* raw_weak) { |
| 8745 ASSERT(raw_weak->ptr()->next_ == 0); | 8498 ASSERT(raw_weak->ptr()->next_ == 0); |
| 8746 raw_weak->StorePointer(&(raw_weak->ptr()->key_), Object::null()); | 8499 raw_weak->StorePointer(&(raw_weak->ptr()->key_), Object::null()); |
| 8747 raw_weak->StorePointer(&(raw_weak->ptr()->value_), Object::null()); | 8500 raw_weak->StorePointer(&(raw_weak->ptr()->value_), Object::null()); |
| 8748 } | 8501 } |
| 8749 | 8502 |
| 8750 private: | 8503 private: |
| 8751 FINAL_HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance); | 8504 FINAL_HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance); |
| 8752 friend class Class; | 8505 friend class Class; |
| 8753 }; | 8506 }; |
| 8754 | 8507 |
| 8755 | 8508 |
| 8756 class MirrorReference : public Instance { | 8509 class MirrorReference : public Instance { |
| 8757 public: | 8510 public: |
| 8758 RawObject* referent() const { | 8511 RawObject* referent() const { return raw_ptr()->referent_; } |
| 8759 return raw_ptr()->referent_; | |
| 8760 } | |
| 8761 | 8512 |
| 8762 void set_referent(const Object& referent) const { | 8513 void set_referent(const Object& referent) const { |
| 8763 StorePointer(&raw_ptr()->referent_, referent.raw()); | 8514 StorePointer(&raw_ptr()->referent_, referent.raw()); |
| 8764 } | 8515 } |
| 8765 | 8516 |
| 8766 RawAbstractType* GetAbstractTypeReferent() const; | 8517 RawAbstractType* GetAbstractTypeReferent() const; |
| 8767 | 8518 |
| 8768 RawClass* GetClassReferent() const; | 8519 RawClass* GetClassReferent() const; |
| 8769 | 8520 |
| 8770 RawField* GetFieldReferent() const; | 8521 RawField* GetFieldReferent() const; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8791 class UserTag : public Instance { | 8542 class UserTag : public Instance { |
| 8792 public: | 8543 public: |
| 8793 uword tag() const { return raw_ptr()->tag(); } | 8544 uword tag() const { return raw_ptr()->tag(); } |
| 8794 void set_tag(uword t) const { | 8545 void set_tag(uword t) const { |
| 8795 ASSERT(t >= UserTags::kUserTagIdOffset); | 8546 ASSERT(t >= UserTags::kUserTagIdOffset); |
| 8796 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); | 8547 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); |
| 8797 StoreNonPointer(&raw_ptr()->tag_, t); | 8548 StoreNonPointer(&raw_ptr()->tag_, t); |
| 8798 } | 8549 } |
| 8799 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); } | 8550 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); } |
| 8800 | 8551 |
| 8801 RawString* label() const { | 8552 RawString* label() const { return raw_ptr()->label_; } |
| 8802 return raw_ptr()->label_; | |
| 8803 } | |
| 8804 | 8553 |
| 8805 void MakeActive() const; | 8554 void MakeActive() const; |
| 8806 | 8555 |
| 8807 static intptr_t InstanceSize() { | 8556 static intptr_t InstanceSize() { |
| 8808 return RoundedAllocationSize(sizeof(RawUserTag)); | 8557 return RoundedAllocationSize(sizeof(RawUserTag)); |
| 8809 } | 8558 } |
| 8810 | 8559 |
| 8811 static RawUserTag* New(const String& label, | 8560 static RawUserTag* New(const String& label, Heap::Space space = Heap::kOld); |
| 8812 Heap::Space space = Heap::kOld); | |
| 8813 static RawUserTag* DefaultTag(); | 8561 static RawUserTag* DefaultTag(); |
| 8814 | 8562 |
| 8815 static bool TagTableIsFull(Thread* thread); | 8563 static bool TagTableIsFull(Thread* thread); |
| 8816 static RawUserTag* FindTagById(uword tag_id); | 8564 static RawUserTag* FindTagById(uword tag_id); |
| 8817 | 8565 |
| 8818 private: | 8566 private: |
| 8819 static RawUserTag* FindTagInIsolate(Thread* thread, const String& label); | 8567 static RawUserTag* FindTagInIsolate(Thread* thread, const String& label); |
| 8820 static void AddTagToIsolate(Thread* thread, const UserTag& tag); | 8568 static void AddTagToIsolate(Thread* thread, const UserTag& tag); |
| 8821 | 8569 |
| 8822 void set_label(const String& tag_label) const { | 8570 void set_label(const String& tag_label) const { |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9039 | 8787 |
| 9040 inline void TypeArguments::SetHash(intptr_t value) const { | 8788 inline void TypeArguments::SetHash(intptr_t value) const { |
| 9041 // This is only safe because we create a new Smi, which does not cause | 8789 // This is only safe because we create a new Smi, which does not cause |
| 9042 // heap allocation. | 8790 // heap allocation. |
| 9043 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8791 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 9044 } | 8792 } |
| 9045 | 8793 |
| 9046 } // namespace dart | 8794 } // namespace dart |
| 9047 | 8795 |
| 9048 #endif // RUNTIME_VM_OBJECT_H_ | 8796 #endif // RUNTIME_VM_OBJECT_H_ |
| OLD | NEW |