| 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, | 22 // Index for objects/types stored in the object store, |
| 23 // this index is used in snapshots to refer to classes or objects directly. | 23 // this index is used in snapshots to refer to objects directly. |
| 24 enum { | 24 enum { |
| 25 kTrueValue = Object::kMaxId, | 25 kTrueValue = Object::kMaxId, |
| 26 kFalseValue, | 26 kFalseValue, |
| 27 kObjectType, | 27 kObjectType, |
| 28 kNullType, | 28 kNullType, |
| 29 kDynamicType, | 29 kDynamicType, |
| 30 kVoidType, | 30 kVoidType, |
| 31 kFunctionInterface, | 31 kFunctionInterface, |
| 32 kNumberInterface, | 32 kNumberInterface, |
| 33 kDoubleInterface, | 33 kDoubleInterface, |
| 34 kIntInterface, | 34 kIntInterface, |
| 35 kBoolInterface, | 35 kBoolInterface, |
| 36 kStringInterface, | 36 kStringInterface, |
| 37 kListInterface, | 37 kListInterface, |
| 38 kByteArrayInterface, | 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, | 39 kMaxId, |
| 78 kInvalidIndex = -1, | 40 kInvalidIndex = -1, |
| 79 }; | 41 }; |
| 80 | 42 |
| 81 ~ObjectStore(); | 43 ~ObjectStore(); |
| 82 | 44 |
| 83 RawClass* object_class() const { | 45 RawClass* object_class() const { |
| 84 ASSERT(object_class_ != Object::null()); | 46 ASSERT(object_class_ != Object::null()); |
| 85 return object_class_; | 47 return object_class_; |
| 86 } | 48 } |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 RawArray* keyword_symbols() const { return keyword_symbols_; } | 463 RawArray* keyword_symbols() const { return keyword_symbols_; } |
| 502 void set_keyword_symbols(const Array& value) { | 464 void set_keyword_symbols(const Array& value) { |
| 503 keyword_symbols_ = value.raw(); | 465 keyword_symbols_ = value.raw(); |
| 504 } | 466 } |
| 505 void InitKeywordTable(); | 467 void InitKeywordTable(); |
| 506 | 468 |
| 507 // Visit all object pointers. | 469 // Visit all object pointers. |
| 508 void VisitObjectPointers(ObjectPointerVisitor* visitor); | 470 void VisitObjectPointers(ObjectPointerVisitor* visitor); |
| 509 | 471 |
| 510 RawClass* GetClass(int index); | 472 RawClass* GetClass(int index); |
| 511 int GetClassIndex(const RawClass* raw_class); | |
| 512 RawType* GetType(int index); | 473 RawType* GetType(int index); |
| 513 int GetTypeIndex(const RawType* raw_type); | 474 int GetTypeIndex(const RawType* raw_type); |
| 514 | 475 |
| 515 // Called to initialize objects required by the vm but which invoke | 476 // Called to initialize objects required by the vm but which invoke |
| 516 // dart code. If an error occurs then false is returned and error | 477 // dart code. If an error occurs then false is returned and error |
| 517 // information is stored in sticky_error(). | 478 // information is stored in sticky_error(). |
| 518 bool PreallocateObjects(); | 479 bool PreallocateObjects(); |
| 519 | 480 |
| 520 static void Init(Isolate* isolate); | 481 static void Init(Isolate* isolate); |
| 521 | 482 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 RawObject** to() { return reinterpret_cast<RawObject**>(&keyword_symbols_); } | 558 RawObject** to() { return reinterpret_cast<RawObject**>(&keyword_symbols_); } |
| 598 | 559 |
| 599 friend class SnapshotReader; | 560 friend class SnapshotReader; |
| 600 | 561 |
| 601 DISALLOW_COPY_AND_ASSIGN(ObjectStore); | 562 DISALLOW_COPY_AND_ASSIGN(ObjectStore); |
| 602 }; | 563 }; |
| 603 | 564 |
| 604 } // namespace dart | 565 } // namespace dart |
| 605 | 566 |
| 606 #endif // VM_OBJECT_STORE_H_ | 567 #endif // VM_OBJECT_STORE_H_ |
| OLD | NEW |