OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 RawObject* raw() const { return raw_; } | 243 RawObject* raw() const { return raw_; } |
244 void operator=(RawObject* value) { | 244 void operator=(RawObject* value) { |
245 initializeHandle(this, value); | 245 initializeHandle(this, value); |
246 } | 246 } |
247 | 247 |
248 uword CompareAndSwapTags(uword old_tags, uword new_tags) const { | 248 uword CompareAndSwapTags(uword old_tags, uword new_tags) const { |
249 return AtomicOperations::CompareAndSwapWord( | 249 return AtomicOperations::CompareAndSwapWord( |
250 &raw()->ptr()->tags_, old_tags, new_tags); | 250 &raw()->ptr()->tags_, old_tags, new_tags); |
251 } | 251 } |
252 void set_tags(intptr_t value) const { | |
253 ASSERT(!IsNull()); | |
254 // TODO(asiva): Remove the capability of setting tags in general. The mask | |
255 // here only allows for canonical and from_snapshot flags to be set. | |
256 value = value & 0x0000000c; | |
257 uword tags = raw()->ptr()->tags_; | |
258 uword old_tags; | |
259 do { | |
260 old_tags = tags; | |
261 uword new_tags = (old_tags & ~0x0000000c) | value; | |
262 tags = CompareAndSwapTags(old_tags, new_tags); | |
263 } while (tags != old_tags); | |
264 } | |
265 void SetCreatedFromSnapshot() const { | |
266 ASSERT(!IsNull()); | |
267 raw()->SetCreatedFromSnapshot(); | |
268 } | |
269 bool IsCanonical() const { | 252 bool IsCanonical() const { |
270 ASSERT(!IsNull()); | 253 ASSERT(!IsNull()); |
271 return raw()->IsCanonical(); | 254 return raw()->IsCanonical(); |
272 } | 255 } |
273 void SetCanonical() const { | 256 void SetCanonical() const { |
274 ASSERT(!IsNull()); | 257 ASSERT(!IsNull()); |
275 raw()->SetCanonical(); | 258 raw()->SetCanonical(); |
276 } | 259 } |
277 void ClearCanonical() const { | 260 void ClearCanonical() const { |
278 ASSERT(!IsNull()); | 261 ASSERT(!IsNull()); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 bool ref) const; | 704 bool ref) const; |
722 | 705 |
723 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; | 706 virtual void PrintJSONImpl(JSONStream* stream, bool ref) const; |
724 | 707 |
725 private: | 708 private: |
726 static intptr_t NextFieldOffset() { | 709 static intptr_t NextFieldOffset() { |
727 // Indicates this class cannot be extended by dart code. | 710 // Indicates this class cannot be extended by dart code. |
728 return -kWordSize; | 711 return -kWordSize; |
729 } | 712 } |
730 | 713 |
731 static void InitializeObject(uword address, intptr_t id, intptr_t size); | 714 static void InitializeObject(uword address, |
| 715 intptr_t id, |
| 716 intptr_t size, |
| 717 bool is_vm_object); |
732 | 718 |
733 static void RegisterClass(const Class& cls, | 719 static void RegisterClass(const Class& cls, |
734 const String& name, | 720 const String& name, |
735 const Library& lib); | 721 const Library& lib); |
736 static void RegisterPrivateClass(const Class& cls, | 722 static void RegisterPrivateClass(const Class& cls, |
737 const String& name, | 723 const String& name, |
738 const Library& lib); | 724 const Library& lib); |
739 | 725 |
740 /* Initialize the handle based on the raw_ptr in the presence of null. */ | 726 /* Initialize the handle based on the raw_ptr in the presence of null. */ |
741 static void initializeHandle(Object* obj, RawObject* raw_ptr) { | 727 static void initializeHandle(Object* obj, RawObject* raw_ptr) { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 } | 924 } |
939 intptr_t id() const { return raw_ptr()->id_; } | 925 intptr_t id() const { return raw_ptr()->id_; } |
940 void set_id(intptr_t value) const { | 926 void set_id(intptr_t value) const { |
941 ASSERT(is_valid_id(value)); | 927 ASSERT(is_valid_id(value)); |
942 StoreNonPointer(&raw_ptr()->id_, value); | 928 StoreNonPointer(&raw_ptr()->id_, value); |
943 } | 929 } |
944 | 930 |
945 RawString* Name() const; | 931 RawString* Name() const; |
946 RawString* PrettyName() const; | 932 RawString* PrettyName() const; |
947 RawString* UserVisibleName() const; | 933 RawString* UserVisibleName() const; |
| 934 bool IsInFullSnapshot() const; |
948 | 935 |
949 virtual RawString* DictionaryName() const { return Name(); } | 936 virtual RawString* DictionaryName() const { return Name(); } |
950 | 937 |
951 RawScript* script() const { return raw_ptr()->script_; } | 938 RawScript* script() const { return raw_ptr()->script_; } |
952 void set_script(const Script& value) const; | 939 void set_script(const Script& value) const; |
953 | 940 |
954 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 941 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
955 void set_token_pos(intptr_t value) const; | 942 void set_token_pos(intptr_t value) const; |
956 | 943 |
957 intptr_t ComputeEndTokenPos() const; | 944 intptr_t ComputeEndTokenPos() const; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 // Check if this class represents the 'Function' class. | 1095 // Check if this class represents the 'Function' class. |
1109 bool IsFunctionClass() const; | 1096 bool IsFunctionClass() const; |
1110 | 1097 |
1111 // Check if this class represents a signature class. | 1098 // Check if this class represents a signature class. |
1112 bool IsSignatureClass() const { | 1099 bool IsSignatureClass() const { |
1113 return signature_function() != Object::null(); | 1100 return signature_function() != Object::null(); |
1114 } | 1101 } |
1115 static bool IsSignatureClass(RawClass* cls) { | 1102 static bool IsSignatureClass(RawClass* cls) { |
1116 return cls->ptr()->signature_function_ != Object::null(); | 1103 return cls->ptr()->signature_function_ != Object::null(); |
1117 } | 1104 } |
| 1105 static bool IsInFullSnapshot(RawClass* cls) { |
| 1106 NoSafepointScope no_safepoint; |
| 1107 return cls->ptr()->library_->ptr()->is_in_fullsnapshot_; |
| 1108 } |
1118 | 1109 |
1119 // Check if this class represents a canonical signature class, i.e. not an | 1110 // Check if this class represents a canonical signature class, i.e. not an |
1120 // alias as defined in a typedef. | 1111 // alias as defined in a typedef. |
1121 bool IsCanonicalSignatureClass() const; | 1112 bool IsCanonicalSignatureClass() const; |
1122 | 1113 |
1123 // Check the subtype relationship. | 1114 // Check the subtype relationship. |
1124 bool IsSubtypeOf(const TypeArguments& type_arguments, | 1115 bool IsSubtypeOf(const TypeArguments& type_arguments, |
1125 const Class& other, | 1116 const Class& other, |
1126 const TypeArguments& other_type_arguments, | 1117 const TypeArguments& other_type_arguments, |
1127 Error* bound_error) const { | 1118 Error* bound_error) const { |
(...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3385 } | 3376 } |
3386 Dart_NativeEntrySymbol native_entry_symbol_resolver() const { | 3377 Dart_NativeEntrySymbol native_entry_symbol_resolver() const { |
3387 return raw_ptr()->native_entry_symbol_resolver_; | 3378 return raw_ptr()->native_entry_symbol_resolver_; |
3388 } | 3379 } |
3389 void set_native_entry_symbol_resolver( | 3380 void set_native_entry_symbol_resolver( |
3390 Dart_NativeEntrySymbol native_symbol_resolver) const { | 3381 Dart_NativeEntrySymbol native_symbol_resolver) const { |
3391 StoreNonPointer(&raw_ptr()->native_entry_symbol_resolver_, | 3382 StoreNonPointer(&raw_ptr()->native_entry_symbol_resolver_, |
3392 native_symbol_resolver); | 3383 native_symbol_resolver); |
3393 } | 3384 } |
3394 | 3385 |
| 3386 bool is_in_fullsnapshot() const { return raw_ptr()->is_in_fullsnapshot_; } |
| 3387 void set_is_in_fullsnapshot(bool value) const { |
| 3388 StoreNonPointer(&raw_ptr()->is_in_fullsnapshot_, value); |
| 3389 } |
| 3390 |
3395 RawError* Patch(const Script& script) const; | 3391 RawError* Patch(const Script& script) const; |
3396 | 3392 |
3397 RawString* PrivateName(const String& name) const; | 3393 RawString* PrivateName(const String& name) const; |
3398 | 3394 |
3399 intptr_t index() const { return raw_ptr()->index_; } | 3395 intptr_t index() const { return raw_ptr()->index_; } |
3400 void set_index(intptr_t value) const { | 3396 void set_index(intptr_t value) const { |
3401 StoreNonPointer(&raw_ptr()->index_, value); | 3397 StoreNonPointer(&raw_ptr()->index_, value); |
3402 } | 3398 } |
3403 | 3399 |
3404 void Register() const; | 3400 void Register() const; |
(...skipping 4634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8039 | 8035 |
8040 | 8036 |
8041 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8037 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8042 intptr_t index) { | 8038 intptr_t index) { |
8043 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8039 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8044 } | 8040 } |
8045 | 8041 |
8046 } // namespace dart | 8042 } // namespace dart |
8047 | 8043 |
8048 #endif // VM_OBJECT_H_ | 8044 #endif // VM_OBJECT_H_ |
OLD | NEW |