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