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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 bool IsNew() const { return raw()->IsNewObject(); } | 203 bool IsNew() const { return raw()->IsNewObject(); } |
204 bool IsOld() const { return raw()->IsOldObject(); } | 204 bool IsOld() const { return raw()->IsOldObject(); } |
205 | 205 |
206 // Print the object on stdout for debugging. | 206 // Print the object on stdout for debugging. |
207 void Print() const; | 207 void Print() const; |
208 | 208 |
209 bool IsZoneHandle() const { | 209 bool IsZoneHandle() const { |
210 return VMHandles::IsZoneHandle(reinterpret_cast<uword>(this)); | 210 return VMHandles::IsZoneHandle(reinterpret_cast<uword>(this)); |
211 } | 211 } |
212 | 212 |
| 213 bool IsReadOnlyHandle() const; |
| 214 |
213 bool IsNotTemporaryScopedHandle() const; | 215 bool IsNotTemporaryScopedHandle() const; |
214 | 216 |
215 static RawObject* Clone(const Object& src, Heap::Space space = Heap::kNew); | 217 static RawObject* Clone(const Object& src, Heap::Space space = Heap::kNew); |
216 | 218 |
217 static Object& Handle(Isolate* isolate, RawObject* raw_ptr) { | 219 static Object& Handle(Isolate* isolate, RawObject* raw_ptr) { |
218 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(isolate)); | 220 Object* obj = reinterpret_cast<Object*>(VMHandles::AllocateHandle(isolate)); |
219 initializeHandle(obj, raw_ptr); | 221 initializeHandle(obj, raw_ptr); |
220 return *obj; | 222 return *obj; |
221 } | 223 } |
222 | 224 |
(...skipping 18 matching lines...) Expand all Loading... |
241 | 243 |
242 static Object& ZoneHandle() { | 244 static Object& ZoneHandle() { |
243 return ZoneHandle(Isolate::Current(), null_); | 245 return ZoneHandle(Isolate::Current(), null_); |
244 } | 246 } |
245 | 247 |
246 static Object& ZoneHandle(RawObject* raw_ptr) { | 248 static Object& ZoneHandle(RawObject* raw_ptr) { |
247 return ZoneHandle(Isolate::Current(), raw_ptr); | 249 return ZoneHandle(Isolate::Current(), raw_ptr); |
248 } | 250 } |
249 | 251 |
250 static RawObject* null() { return null_; } | 252 static RawObject* null() { return null_; } |
251 static RawArray* empty_array() { return empty_array_; } | 253 static const Array& empty_array() { |
| 254 ASSERT(empty_array_ != NULL); |
| 255 return *empty_array_; |
| 256 } |
252 | 257 |
253 // The sentinel is a value that cannot be produced by Dart code. | 258 // The sentinel is a value that cannot be produced by Dart code. |
254 // It can be used to mark special values, for example to distinguish | 259 // It can be used to mark special values, for example to distinguish |
255 // "uninitialized" fields. | 260 // "uninitialized" fields. |
256 static RawInstance* sentinel() { return sentinel_; } | 261 static const Instance& sentinel() { |
| 262 ASSERT(sentinel_ != NULL); |
| 263 return *sentinel_; |
| 264 } |
257 // Value marking that we are transitioning from sentinel, e.g., computing | 265 // Value marking that we are transitioning from sentinel, e.g., computing |
258 // a field value. Used to detect circular initialization. | 266 // a field value. Used to detect circular initialization. |
259 static RawInstance* transition_sentinel() { return transition_sentinel_; } | 267 static const Instance& transition_sentinel() { |
| 268 ASSERT(transition_sentinel_ != NULL); |
| 269 return *transition_sentinel_; |
| 270 } |
260 | 271 |
261 static RawClass* class_class() { return class_class_; } | 272 static RawClass* class_class() { return class_class_; } |
262 static RawClass* null_class() { return null_class_; } | 273 static RawClass* null_class() { return null_class_; } |
263 static RawClass* dynamic_class() { return dynamic_class_; } | 274 static RawClass* dynamic_class() { return dynamic_class_; } |
264 static RawClass* void_class() { return void_class_; } | 275 static RawClass* void_class() { return void_class_; } |
265 static RawClass* unresolved_class_class() { return unresolved_class_class_; } | 276 static RawClass* unresolved_class_class() { return unresolved_class_class_; } |
266 static RawClass* type_arguments_class() { return type_arguments_class_; } | 277 static RawClass* type_arguments_class() { return type_arguments_class_; } |
267 static RawClass* instantiated_type_arguments_class() { | 278 static RawClass* instantiated_type_arguments_class() { |
268 return instantiated_type_arguments_class_; | 279 return instantiated_type_arguments_class_; |
269 } | 280 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 uword vtable_addr = reinterpret_cast<uword>(this); | 404 uword vtable_addr = reinterpret_cast<uword>(this); |
394 return reinterpret_cast<cpp_vtable*>(vtable_addr); | 405 return reinterpret_cast<cpp_vtable*>(vtable_addr); |
395 } | 406 } |
396 | 407 |
397 static cpp_vtable handle_vtable_; | 408 static cpp_vtable handle_vtable_; |
398 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; | 409 static cpp_vtable builtin_vtables_[kNumPredefinedCids]; |
399 | 410 |
400 // The static values below are singletons shared between the different | 411 // The static values below are singletons shared between the different |
401 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. | 412 // isolates. They are all allocated in the non-GC'd Dart::vm_isolate_. |
402 static RawObject* null_; | 413 static RawObject* null_; |
403 static RawArray* empty_array_; | |
404 static RawInstance* sentinel_; | |
405 static RawInstance* transition_sentinel_; | |
406 | 414 |
407 static RawClass* class_class_; // Class of the Class vm object. | 415 static RawClass* class_class_; // Class of the Class vm object. |
408 static RawClass* null_class_; // Class of the null object. | 416 static RawClass* null_class_; // Class of the null object. |
409 static RawClass* dynamic_class_; // Class of the 'dynamic' type. | 417 static RawClass* dynamic_class_; // Class of the 'dynamic' type. |
410 static RawClass* void_class_; // Class of the 'void' type. | 418 static RawClass* void_class_; // Class of the 'void' type. |
411 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. | 419 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. |
412 // Class of the TypeArguments vm object. | 420 // Class of the TypeArguments vm object. |
413 static RawClass* type_arguments_class_; | 421 static RawClass* type_arguments_class_; |
414 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. | 422 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. |
415 static RawClass* patch_class_class_; // Class of the PatchClass vm object. | 423 static RawClass* patch_class_class_; // Class of the PatchClass vm object. |
(...skipping 17 matching lines...) Expand all Loading... |
433 static RawClass* context_class_; // Class of the Context vm object. | 441 static RawClass* context_class_; // Class of the Context vm object. |
434 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 442 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
435 static RawClass* icdata_class_; // Class of ICData. | 443 static RawClass* icdata_class_; // Class of ICData. |
436 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. | 444 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. |
437 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. | 445 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. |
438 static RawClass* api_error_class_; // Class of ApiError. | 446 static RawClass* api_error_class_; // Class of ApiError. |
439 static RawClass* language_error_class_; // Class of LanguageError. | 447 static RawClass* language_error_class_; // Class of LanguageError. |
440 static RawClass* unhandled_exception_class_; // Class of UnhandledException. | 448 static RawClass* unhandled_exception_class_; // Class of UnhandledException. |
441 static RawClass* unwind_error_class_; // Class of UnwindError. | 449 static RawClass* unwind_error_class_; // Class of UnwindError. |
442 | 450 |
| 451 // The static values below are read-only handle pointers for singleton |
| 452 // objects that are shared between the different isolates. |
| 453 static Array* empty_array_; |
| 454 static Instance* sentinel_; |
| 455 static Instance* transition_sentinel_; |
| 456 |
443 friend void ClassTable::Register(const Class& cls); | 457 friend void ClassTable::Register(const Class& cls); |
444 friend void RawObject::Validate(Isolate* isolate) const; | 458 friend void RawObject::Validate(Isolate* isolate) const; |
445 friend class Closure; | 459 friend class Closure; |
446 friend class SnapshotReader; | 460 friend class SnapshotReader; |
447 friend class OneByteString; | 461 friend class OneByteString; |
448 friend class TwoByteString; | 462 friend class TwoByteString; |
449 friend class ExternalOneByteString; | 463 friend class ExternalOneByteString; |
450 friend class ExternalTwoByteString; | 464 friend class ExternalTwoByteString; |
451 | 465 |
452 // Disallow allocation. | 466 // Disallow allocation. |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2545 | 2559 |
2546 intptr_t Length() const; | 2560 intptr_t Length() const; |
2547 | 2561 |
2548 void SetPCOffsetAt(intptr_t idx, intptr_t pc_offset); | 2562 void SetPCOffsetAt(intptr_t idx, intptr_t pc_offset); |
2549 void SetCommentAt(intptr_t idx, const String& comment); | 2563 void SetCommentAt(intptr_t idx, const String& comment); |
2550 | 2564 |
2551 intptr_t PCOffsetAt(intptr_t idx) const; | 2565 intptr_t PCOffsetAt(intptr_t idx) const; |
2552 const String& CommentAt(intptr_t idx) const; | 2566 const String& CommentAt(intptr_t idx) const; |
2553 | 2567 |
2554 private: | 2568 private: |
2555 explicit Comments(RawArray* comments); | 2569 explicit Comments(const Array& comments); |
2556 | 2570 |
2557 // Layout of entries describing comments. | 2571 // Layout of entries describing comments. |
2558 enum { | 2572 enum { |
2559 kPCOffsetEntry = 0, // PC offset to a comment as a Smi. | 2573 kPCOffsetEntry = 0, // PC offset to a comment as a Smi. |
2560 kCommentEntry, // Comment text as a String. | 2574 kCommentEntry, // Comment text as a String. |
2561 kNumberOfEntries | 2575 kNumberOfEntries |
2562 }; | 2576 }; |
2563 | 2577 |
2564 const Array& comments_; | 2578 const Array& comments_; |
2565 | 2579 |
(...skipping 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6198 | 6212 |
6199 | 6213 |
6200 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6214 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6201 intptr_t index) { | 6215 intptr_t index) { |
6202 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6216 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6203 } | 6217 } |
6204 | 6218 |
6205 } // namespace dart | 6219 } // namespace dart |
6206 | 6220 |
6207 #endif // VM_OBJECT_H_ | 6221 #endif // VM_OBJECT_H_ |
OLD | NEW |