| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_STORE_H_ | 5 #ifndef VM_OBJECT_STORE_H_ |
| 6 #define VM_OBJECT_STORE_H_ | 6 #define VM_OBJECT_STORE_H_ |
| 7 | 7 |
| 8 #include "vm/object.h" | 8 #include "vm/object.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 // Forward declarations. | 12 // Forward declarations. |
| 13 class Isolate; | 13 class Isolate; |
| 14 class ObjectPointerVisitor; | 14 class ObjectPointerVisitor; |
| 15 | 15 |
| 16 // The object store is a per isolate instance which stores references to | 16 // The object store is a per isolate instance which stores references to |
| 17 // objects used by the VM. | 17 // objects used by the VM. |
| 18 // TODO(iposva): Move the actual store into the object heap for quick handling | 18 // TODO(iposva): Move the actual store into the object heap for quick handling |
| 19 // by snapshots eventually. | 19 // by snapshots eventually. |
| 20 class ObjectStore { | 20 class ObjectStore { |
| 21 public: | 21 public: |
| 22 // Index for objects/types/classes stored in the object store, | |
| 23 // this index is used in snapshots to refer to classes or objects directly. | |
| 24 enum { | |
| 25 kTrueValue = Object::kMaxId, | |
| 26 kFalseValue, | |
| 27 kObjectType, | |
| 28 kNullType, | |
| 29 kDynamicType, | |
| 30 kVoidType, | |
| 31 kFunctionInterface, | |
| 32 kNumberInterface, | |
| 33 kDoubleInterface, | |
| 34 kIntInterface, | |
| 35 kBoolInterface, | |
| 36 kStringInterface, | |
| 37 kListInterface, | |
| 38 kByteArrayInterface, | |
| 39 kObjectClass, | |
| 40 kIntegerImplementationClass, | |
| 41 kSmiClass, | |
| 42 kMintClass, | |
| 43 kBigintClass, | |
| 44 kDoubleClass, | |
| 45 kOneByteStringClass, | |
| 46 kTwoByteStringClass, | |
| 47 kFourByteStringClass, | |
| 48 kExternalOneByteStringClass, | |
| 49 kExternalTwoByteStringClass, | |
| 50 kExternalFourByteStringClass, | |
| 51 kBoolClass, | |
| 52 kArrayClass, | |
| 53 kImmutableArrayClass, | |
| 54 kGrowableObjectArrayClass, | |
| 55 kInt8ArrayClass, | |
| 56 kUint8ArrayClass, | |
| 57 kInt16ArrayClass, | |
| 58 kUint16ArrayClass, | |
| 59 kInt32ArrayClass, | |
| 60 kUint32ArrayClass, | |
| 61 kInt64ArrayClass, | |
| 62 kUint64ArrayClass, | |
| 63 kFloat32ArrayClass, | |
| 64 kFloat64ArrayClass, | |
| 65 kExternalInt8ArrayClass, | |
| 66 kExternalUint8ArrayClass, | |
| 67 kExternalInt16ArrayClass, | |
| 68 kExternalUint16ArrayClass, | |
| 69 kExternalInt32ArrayClass, | |
| 70 kExternalUint32ArrayClass, | |
| 71 kExternalInt64ArrayClass, | |
| 72 kExternalUint64ArrayClass, | |
| 73 kExternalFloat32ArrayClass, | |
| 74 kExternalFloat64ArrayClass, | |
| 75 kStacktraceClass, | |
| 76 kJSRegExpClass, | |
| 77 kMaxId, | |
| 78 kInvalidIndex = -1, | |
| 79 }; | |
| 80 | |
| 81 ~ObjectStore(); | 22 ~ObjectStore(); |
| 82 | 23 |
| 83 RawClass* object_class() const { | 24 RawClass* object_class() const { |
| 84 ASSERT(object_class_ != Object::null()); | 25 ASSERT(object_class_ != Object::null()); |
| 85 return object_class_; | 26 return object_class_; |
| 86 } | 27 } |
| 87 void set_object_class(const Class& value) { object_class_ = value.raw(); } | 28 void set_object_class(const Class& value) { object_class_ = value.raw(); } |
| 88 static intptr_t object_class_offset() { | 29 static intptr_t object_class_offset() { |
| 89 return OFFSET_OF(ObjectStore, object_class_); | 30 return OFFSET_OF(ObjectStore, object_class_); |
| 90 } | 31 } |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 441 |
| 501 RawArray* keyword_symbols() const { return keyword_symbols_; } | 442 RawArray* keyword_symbols() const { return keyword_symbols_; } |
| 502 void set_keyword_symbols(const Array& value) { | 443 void set_keyword_symbols(const Array& value) { |
| 503 keyword_symbols_ = value.raw(); | 444 keyword_symbols_ = value.raw(); |
| 504 } | 445 } |
| 505 void InitKeywordTable(); | 446 void InitKeywordTable(); |
| 506 | 447 |
| 507 // Visit all object pointers. | 448 // Visit all object pointers. |
| 508 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 449 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 509 | 450 |
| 510 RawClass* GetClass(int index); | |
| 511 int GetClassIndex(const RawClass* raw_class); | |
| 512 RawType* GetType(int index); | 451 RawType* GetType(int index); |
| 513 int GetTypeIndex(const RawType* raw_type); | 452 int GetTypeIndex(const RawType* raw_type); |
| 514 | 453 |
| 515 // Called to initialize objects required by the vm but which invoke | 454 // Called to initialize objects required by the vm but which invoke |
| 516 // dart code. If an error occurs then false is returned and error | 455 // dart code. If an error occurs then false is returned and error |
| 517 // information is stored in sticky_error(). | 456 // information is stored in sticky_error(). |
| 518 bool PreallocateObjects(); | 457 bool PreallocateObjects(); |
| 519 | 458 |
| 520 static void Init(Isolate* isolate); | 459 static void Init(Isolate* isolate); |
| 521 | 460 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 RawObject** to() { return reinterpret_cast<RawObject**>(&keyword_symbols_); } | 536 RawObject** to() { return reinterpret_cast<RawObject**>(&keyword_symbols_); } |
| 598 | 537 |
| 599 friend class SnapshotReader; | 538 friend class SnapshotReader; |
| 600 | 539 |
| 601 DISALLOW_COPY_AND_ASSIGN(ObjectStore); | 540 DISALLOW_COPY_AND_ASSIGN(ObjectStore); |
| 602 }; | 541 }; |
| 603 | 542 |
| 604 } // namespace dart | 543 } // namespace dart |
| 605 | 544 |
| 606 #endif // VM_OBJECT_STORE_H_ | 545 #endif // VM_OBJECT_STORE_H_ |
| OLD | NEW |