Chromium Code Reviews| 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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
| 11 | 11 |
| 12 #include "include/dart_api.h" | 12 #include "include/dart_api.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 // Macrobatics to define the Object hierarchy of VM implementation classes. | 16 // Macrobatics to define the Object hierarchy of VM implementation classes. |
| 17 #define CLASS_LIST_NO_OBJECT(V) \ | 17 #define CLASS_LIST_NO_OBJECT(V) \ |
| 18 V(Class) \ | 18 V(Class) \ |
| 19 V(UnresolvedClass) \ | 19 V(UnresolvedClass) \ |
| 20 V(AbstractType) \ | 20 V(AbstractType) \ |
| 21 V(Type) \ | 21 V(Type) \ |
| 22 V(TypeParameter) \ | 22 V(TypeParameter) \ |
| 23 V(InstantiatedType) \ | 23 V(InstantiatedType) \ |
| 24 V(TypeArguments) \ | 24 V(AbstractTypeArguments) \ |
| 25 V(TypeArray) \ | 25 V(TypeArguments) \ |
| 26 V(InstantiatedTypeArguments) \ | 26 V(InstantiatedTypeArguments) \ |
| 27 V(Function) \ | 27 V(Function) \ |
| 28 V(Field) \ | 28 V(Field) \ |
| 29 V(TokenStream) \ | 29 V(TokenStream) \ |
| 30 V(Script) \ | 30 V(Script) \ |
| 31 V(Library) \ | 31 V(Library) \ |
| 32 V(LibraryPrefix) \ | 32 V(LibraryPrefix) \ |
| 33 V(Code) \ | 33 V(Code) \ |
| 34 V(Instructions) \ | 34 V(Instructions) \ |
| 35 V(PcDescriptors) \ | 35 V(PcDescriptors) \ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 kFinalized, // All checks completed, class ready for use. | 215 kFinalized, // All checks completed, class ready for use. |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 private: | 218 private: |
| 219 RAW_HEAP_OBJECT_IMPLEMENTATION(Class); | 219 RAW_HEAP_OBJECT_IMPLEMENTATION(Class); |
| 220 | 220 |
| 221 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 221 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 222 RawString* name_; | 222 RawString* name_; |
| 223 RawArray* functions_; | 223 RawArray* functions_; |
| 224 RawArray* fields_; | 224 RawArray* fields_; |
| 225 // TODO(srdjan): RawTypeArguments* interfaces_; // Array of Type. | 225 // TODO(srdjan): RawTypeArguments* interfaces_; // Array of Type. |
|
regis
2011/12/01 22:20:16
You want to change this later, I guess?
srdjan
2011/12/01 22:44:08
Yes.
| |
| 226 RawArray* interfaces_; // Array of AbstractType. | 226 RawArray* interfaces_; // Array of AbstractType. |
| 227 RawScript* script_; | 227 RawScript* script_; |
| 228 RawLibrary* library_; | 228 RawLibrary* library_; |
| 229 RawArray* type_parameters_; // Array of String. | 229 RawArray* type_parameters_; // Array of String. |
| 230 RawTypeArray* type_parameter_extends_; // DynamicType if no extends clause. | 230 RawTypeArguments* type_parameter_extends_; // DynamicType if no extends. |
| 231 RawType* super_type_; | 231 RawType* super_type_; |
| 232 RawObject* factory_class_; // UnresolvedClass (until finalization) or Class. | 232 RawObject* factory_class_; // UnresolvedClass (until finalization) or Class. |
| 233 RawFunction* signature_function_; // Associated function for signature class. | 233 RawFunction* signature_function_; // Associated function for signature class. |
| 234 RawArray* functions_cache_; // See class FunctionsCache. | 234 RawArray* functions_cache_; // See class FunctionsCache. |
| 235 RawArray* constants_; // Canonicalized values of this class. | 235 RawArray* constants_; // Canonicalized values of this class. |
| 236 // TODO(srdjan): RawTypeArguments* canonical_types_; | 236 // TODO(srdjan): RawTypeArguments* canonical_types_; |
| 237 RawArray* canonical_types_; // Canonicalized types of this class. | 237 RawArray* canonical_types_; // Canonicalized types of this class. |
| 238 RawCode* allocation_stub_; // Stub code for allocation of instances. | 238 RawCode* allocation_stub_; // Stub code for allocation of instances. |
| 239 RawObject** to() { | 239 RawObject** to() { |
| 240 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); | 240 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 kBeingFinalized, // In the process of being finalized. | 285 kBeingFinalized, // In the process of being finalized. |
| 286 kFinalized, // Type ready for use. | 286 kFinalized, // Type ready for use. |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); | 289 RAW_HEAP_OBJECT_IMPLEMENTATION(Type); |
| 290 | 290 |
| 291 RawObject** from() { | 291 RawObject** from() { |
| 292 return reinterpret_cast<RawObject**>(&ptr()->type_class_); | 292 return reinterpret_cast<RawObject**>(&ptr()->type_class_); |
| 293 } | 293 } |
| 294 RawObject* type_class_; // Either resolved class or unresolved class. | 294 RawObject* type_class_; // Either resolved class or unresolved class. |
| 295 RawTypeArguments* arguments_; | 295 RawAbstractTypeArguments* arguments_; |
| 296 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->arguments_); } | 296 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->arguments_); } |
| 297 int8_t type_state_; | 297 int8_t type_state_; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 | 300 |
| 301 class RawTypeParameter : public RawAbstractType { | 301 class RawTypeParameter : public RawAbstractType { |
| 302 private: | 302 private: |
| 303 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); | 303 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); |
| 304 | 304 |
| 305 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 305 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 306 RawString* name_; | 306 RawString* name_; |
| 307 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 307 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
| 308 intptr_t index_; | 308 intptr_t index_; |
| 309 }; | 309 }; |
| 310 | 310 |
| 311 | 311 |
| 312 class RawInstantiatedType : public RawAbstractType { | 312 class RawInstantiatedType : public RawAbstractType { |
| 313 private: | 313 private: |
| 314 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedType); | 314 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedType); |
| 315 | 315 |
| 316 RawObject** from() { | 316 RawObject** from() { |
| 317 return reinterpret_cast<RawObject**>(&ptr()->uninstantiated_type_); | 317 return reinterpret_cast<RawObject**>(&ptr()->uninstantiated_type_); |
| 318 } | 318 } |
| 319 RawAbstractType* uninstantiated_type_; | 319 RawAbstractType* uninstantiated_type_; |
| 320 RawTypeArguments* instantiator_type_arguments_; | 320 RawAbstractTypeArguments* instantiator_type_arguments_; |
| 321 RawObject** to() { | 321 RawObject** to() { |
| 322 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); | 322 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); |
| 323 } | 323 } |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 | 326 |
| 327 class RawTypeArguments : public RawObject { | 327 class RawAbstractTypeArguments : public RawObject { |
| 328 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); | 328 RAW_HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments); |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 | 331 |
| 332 class RawTypeArray : public RawTypeArguments { | 332 class RawTypeArguments : public RawAbstractTypeArguments { |
| 333 private: | 333 private: |
| 334 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArray); | 334 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); |
| 335 | 335 |
| 336 RawObject** from() { | 336 RawObject** from() { |
| 337 return reinterpret_cast<RawObject**>(&ptr()->length_); | 337 return reinterpret_cast<RawObject**>(&ptr()->length_); |
| 338 } | 338 } |
| 339 RawSmi* length_; | 339 RawSmi* length_; |
| 340 | 340 |
| 341 // Variable length data follows here. | 341 // Variable length data follows here. |
| 342 RawAbstractType* types_[0]; | 342 RawAbstractType* types_[0]; |
| 343 RawObject** to(intptr_t length) { | 343 RawObject** to(intptr_t length) { |
| 344 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); | 344 return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]); |
| 345 } | 345 } |
| 346 }; | 346 }; |
| 347 | 347 |
| 348 | 348 |
| 349 class RawInstantiatedTypeArguments : public RawTypeArguments { | 349 class RawInstantiatedTypeArguments : public RawAbstractTypeArguments { |
| 350 private: | 350 private: |
| 351 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments); | 351 RAW_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments); |
| 352 | 352 |
| 353 RawObject** from() { | 353 RawObject** from() { |
| 354 return reinterpret_cast<RawObject**>( | 354 return reinterpret_cast<RawObject**>( |
| 355 &ptr()->uninstantiated_type_arguments_); | 355 &ptr()->uninstantiated_type_arguments_); |
| 356 } | 356 } |
| 357 RawTypeArguments* uninstantiated_type_arguments_; | 357 RawAbstractTypeArguments* uninstantiated_type_arguments_; |
| 358 RawTypeArguments* instantiator_type_arguments_; | 358 RawAbstractTypeArguments* instantiator_type_arguments_; |
| 359 RawObject** to() { | 359 RawObject** to() { |
| 360 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); | 360 return reinterpret_cast<RawObject**>(&ptr()->instantiator_type_arguments_); |
| 361 } | 361 } |
| 362 }; | 362 }; |
| 363 | 363 |
| 364 | 364 |
| 365 class RawFunction : public RawObject { | 365 class RawFunction : public RawObject { |
| 366 public: | 366 public: |
| 367 enum Kind { | 367 enum Kind { |
| 368 kFunction, | 368 kFunction, |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 bool value_; | 766 bool value_; |
| 767 }; | 767 }; |
| 768 | 768 |
| 769 | 769 |
| 770 class RawArray : public RawInstance { | 770 class RawArray : public RawInstance { |
| 771 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); | 771 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); |
| 772 | 772 |
| 773 RawObject** from() { | 773 RawObject** from() { |
| 774 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 774 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 775 } | 775 } |
| 776 RawTypeArguments* type_arguments_; | 776 RawAbstractTypeArguments* type_arguments_; |
| 777 RawSmi* length_; | 777 RawSmi* length_; |
| 778 // Variable length data follows here. | 778 // Variable length data follows here. |
| 779 RawObject** data() { | 779 RawObject** data() { |
| 780 uword address_of_length = reinterpret_cast<uword>(&length_); | 780 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 781 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); | 781 return reinterpret_cast<RawObject**>(address_of_length + kWordSize); |
| 782 } | 782 } |
| 783 RawObject** to(intptr_t length) { | 783 RawObject** to(intptr_t length) { |
| 784 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); | 784 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); |
| 785 } | 785 } |
| 786 | 786 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 802 uint8_t* data_; | 802 uint8_t* data_; |
| 803 }; | 803 }; |
| 804 | 804 |
| 805 | 805 |
| 806 class RawClosure : public RawInstance { | 806 class RawClosure : public RawInstance { |
| 807 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); | 807 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
| 808 | 808 |
| 809 RawObject** from() { | 809 RawObject** from() { |
| 810 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 810 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 811 } | 811 } |
| 812 RawTypeArguments* type_arguments_; | 812 RawAbstractTypeArguments* type_arguments_; |
| 813 RawFunction* function_; | 813 RawFunction* function_; |
| 814 RawContext* context_; | 814 RawContext* context_; |
| 815 // TODO(iposva): Remove this temporary hack. | 815 // TODO(iposva): Remove this temporary hack. |
| 816 RawInteger* smrck_; | 816 RawInteger* smrck_; |
| 817 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->smrck_); } | 817 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->smrck_); } |
| 818 }; | 818 }; |
| 819 | 819 |
| 820 | 820 |
| 821 // VM type for capturing stacktraces when exceptions are thrown, | 821 // VM type for capturing stacktraces when exceptions are thrown, |
| 822 // Currently we don't have any interface that this object is supposed | 822 // Currently we don't have any interface that this object is supposed |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 intptr_t type_; // Uninitialized, simple or complex. | 854 intptr_t type_; // Uninitialized, simple or complex. |
| 855 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 855 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 856 | 856 |
| 857 // Variable length data follows here. | 857 // Variable length data follows here. |
| 858 uint8_t data_[0]; | 858 uint8_t data_[0]; |
| 859 }; | 859 }; |
| 860 | 860 |
| 861 } // namespace dart | 861 } // namespace dart |
| 862 | 862 |
| 863 #endif // VM_RAW_OBJECT_H_ | 863 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |