| 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_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/dart.h" | 9 #include "vm/dart.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 kTokenStreamClass, | 132 kTokenStreamClass, |
| 133 kScriptClass, | 133 kScriptClass, |
| 134 kLibraryClass, | 134 kLibraryClass, |
| 135 kLibraryPrefixClass, | 135 kLibraryPrefixClass, |
| 136 kCodeClass, | 136 kCodeClass, |
| 137 kInstructionsClass, | 137 kInstructionsClass, |
| 138 kPcDescriptorsClass, | 138 kPcDescriptorsClass, |
| 139 kExceptionHandlersClass, | 139 kExceptionHandlersClass, |
| 140 kContextClass, | 140 kContextClass, |
| 141 kContextScopeClass, | 141 kContextScopeClass, |
| 142 kApiFailureClass, | 142 kApiErrorClass, |
| 143 kMaxId, | 143 kMaxId, |
| 144 kInvalidIndex = -1, | 144 kInvalidIndex = -1, |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 virtual ~Object() { } | 147 virtual ~Object() { } |
| 148 | 148 |
| 149 RawObject* raw() const { return raw_; } | 149 RawObject* raw() const { return raw_; } |
| 150 void operator=(RawObject* value) { SetRaw(value); } | 150 void operator=(RawObject* value) { SetRaw(value); } |
| 151 | 151 |
| 152 inline RawClass* clazz() const; | 152 inline RawClass* clazz() const; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 static RawClass* library_class() { return library_class_; } | 232 static RawClass* library_class() { return library_class_; } |
| 233 static RawClass* library_prefix_class() { return library_prefix_class_; } | 233 static RawClass* library_prefix_class() { return library_prefix_class_; } |
| 234 static RawClass* code_class() { return code_class_; } | 234 static RawClass* code_class() { return code_class_; } |
| 235 static RawClass* instructions_class() { return instructions_class_; } | 235 static RawClass* instructions_class() { return instructions_class_; } |
| 236 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } | 236 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } |
| 237 static RawClass* exception_handlers_class() { | 237 static RawClass* exception_handlers_class() { |
| 238 return exception_handlers_class_; | 238 return exception_handlers_class_; |
| 239 } | 239 } |
| 240 static RawClass* context_class() { return context_class_; } | 240 static RawClass* context_class() { return context_class_; } |
| 241 static RawClass* context_scope_class() { return context_scope_class_; } | 241 static RawClass* context_scope_class() { return context_scope_class_; } |
| 242 static RawClass* api_failure_class() { return api_failure_class_; } | 242 static RawClass* api_error_class() { return api_error_class_; } |
| 243 | 243 |
| 244 static int GetSingletonClassIndex(const RawClass* raw_class); | 244 static int GetSingletonClassIndex(const RawClass* raw_class); |
| 245 static RawClass* GetSingletonClass(int index); | 245 static RawClass* GetSingletonClass(int index); |
| 246 static const char* GetSingletonClassName(int index); | 246 static const char* GetSingletonClassName(int index); |
| 247 | 247 |
| 248 static void Init(Isolate* isolate); | 248 static void Init(Isolate* isolate); |
| 249 static void InitFromSnapshot(Isolate* isolate); | 249 static void InitFromSnapshot(Isolate* isolate); |
| 250 static void InitOnce(); | 250 static void InitOnce(); |
| 251 | 251 |
| 252 static intptr_t InstanceSize() { | 252 static intptr_t InstanceSize() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 static RawClass* token_stream_class_; // Class of the TokenStream vm object. | 325 static RawClass* token_stream_class_; // Class of the TokenStream vm object. |
| 326 static RawClass* script_class_; // Class of the Script vm object. | 326 static RawClass* script_class_; // Class of the Script vm object. |
| 327 static RawClass* library_class_; // Class of the Library vm object. | 327 static RawClass* library_class_; // Class of the Library vm object. |
| 328 static RawClass* library_prefix_class_; // Class of Library prefix vm object. | 328 static RawClass* library_prefix_class_; // Class of Library prefix vm object. |
| 329 static RawClass* code_class_; // Class of the Code vm object. | 329 static RawClass* code_class_; // Class of the Code vm object. |
| 330 static RawClass* instructions_class_; // Class of the Instructions vm object. | 330 static RawClass* instructions_class_; // Class of the Instructions vm object. |
| 331 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. | 331 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. |
| 332 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. | 332 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. |
| 333 static RawClass* context_class_; // Class of the Context vm object. | 333 static RawClass* context_class_; // Class of the Context vm object. |
| 334 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 334 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
| 335 static RawClass* api_failure_class_; // Class of ApiFailure. | 335 static RawClass* api_error_class_; // Class of ApiError. |
| 336 | 336 |
| 337 friend class Class; | 337 friend class Class; |
| 338 friend class SnapshotReader; | 338 friend class SnapshotReader; |
| 339 | 339 |
| 340 // Disallow allocation. | 340 // Disallow allocation. |
| 341 void* operator new(size_t size); | 341 void* operator new(size_t size); |
| 342 // Disallow copy constructor. | 342 // Disallow copy constructor. |
| 343 DISALLOW_COPY_AND_ASSIGN(Object); | 343 DISALLOW_COPY_AND_ASSIGN(Object); |
| 344 }; | 344 }; |
| 345 | 345 |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 | 2044 |
| 2045 private: | 2045 private: |
| 2046 void set_exception(const Instance& exception) const; | 2046 void set_exception(const Instance& exception) const; |
| 2047 void set_stacktrace(const Instance& stacktrace) const; | 2047 void set_stacktrace(const Instance& stacktrace) const; |
| 2048 | 2048 |
| 2049 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Object); | 2049 HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Object); |
| 2050 friend class Class; | 2050 friend class Class; |
| 2051 }; | 2051 }; |
| 2052 | 2052 |
| 2053 | 2053 |
| 2054 class ApiFailure : public Object { | 2054 class ApiError : public Object { |
| 2055 public: | 2055 public: |
| 2056 RawString* message() const { return raw_ptr()->message_; } | 2056 RawObject* data() const { return raw_ptr()->data_; } |
| 2057 static intptr_t message_offset() { | 2057 static intptr_t data_offset() { |
| 2058 return OFFSET_OF(RawApiFailure, message_); | 2058 return OFFSET_OF(RawApiError, data_); |
| 2059 } | 2059 } |
| 2060 | 2060 |
| 2061 static intptr_t InstanceSize() { | 2061 static intptr_t InstanceSize() { |
| 2062 return RoundedAllocationSize(sizeof(RawApiFailure)); | 2062 return RoundedAllocationSize(sizeof(RawApiError)); |
| 2063 } | 2063 } |
| 2064 | 2064 |
| 2065 static RawApiFailure* New(const String& message, | 2065 static RawApiError* New(const String& message, |
| 2066 Heap::Space space = Heap::kNew); | 2066 Heap::Space space = Heap::kNew); |
| 2067 |
| 2068 static RawApiError* New(const UnhandledException& exception, |
| 2069 Heap::Space space = Heap::kNew); |
| 2067 | 2070 |
| 2068 private: | 2071 private: |
| 2069 void set_message(const String& message) const; | 2072 void set_data(const Object& data) const; |
| 2070 | 2073 |
| 2071 HEAP_OBJECT_IMPLEMENTATION(ApiFailure, Object); | 2074 HEAP_OBJECT_IMPLEMENTATION(ApiError, Object); |
| 2072 friend class Class; | 2075 friend class Class; |
| 2073 }; | 2076 }; |
| 2074 | 2077 |
| 2075 | 2078 |
| 2076 // Instance is the base class for all instance objects (aka the Object class | 2079 // Instance is the base class for all instance objects (aka the Object class |
| 2077 // in Dart source code. | 2080 // in Dart source code. |
| 2078 class Instance : public Object { | 2081 class Instance : public Object { |
| 2079 public: | 2082 public: |
| 2080 virtual bool Equals(const Instance& other) const; | 2083 virtual bool Equals(const Instance& other) const; |
| 2081 virtual RawInstance* Canonicalize() const; | 2084 virtual RawInstance* Canonicalize() const; |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2989 } | 2992 } |
| 2990 | 2993 |
| 2991 | 2994 |
| 2992 void Context::SetAt(intptr_t index, const Instance& value) const { | 2995 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 2993 StorePointer(InstanceAddr(index), value.raw()); | 2996 StorePointer(InstanceAddr(index), value.raw()); |
| 2994 } | 2997 } |
| 2995 | 2998 |
| 2996 } // namespace dart | 2999 } // namespace dart |
| 2997 | 3000 |
| 2998 #endif // VM_OBJECT_H_ | 3001 #endif // VM_OBJECT_H_ |
| OLD | NEW |