| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 kScriptClass, | 149 kScriptClass, |
| 150 kLibraryClass, | 150 kLibraryClass, |
| 151 kLibraryPrefixClass, | 151 kLibraryPrefixClass, |
| 152 kCodeClass, | 152 kCodeClass, |
| 153 kInstructionsClass, | 153 kInstructionsClass, |
| 154 kPcDescriptorsClass, | 154 kPcDescriptorsClass, |
| 155 kLocalVarDescriptorsClass, | 155 kLocalVarDescriptorsClass, |
| 156 kExceptionHandlersClass, | 156 kExceptionHandlersClass, |
| 157 kContextClass, | 157 kContextClass, |
| 158 kContextScopeClass, | 158 kContextScopeClass, |
| 159 kICDataClass, |
| 159 kApiErrorClass, | 160 kApiErrorClass, |
| 160 kLanguageErrorClass, | 161 kLanguageErrorClass, |
| 161 kUnhandledExceptionClass, | 162 kUnhandledExceptionClass, |
| 162 kUnwindErrorClass, | 163 kUnwindErrorClass, |
| 163 kICDataClass, | |
| 164 kMaxId, | 164 kMaxId, |
| 165 kInvalidIndex = -1, | 165 kInvalidIndex = -1, |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 virtual ~Object() { } | 168 virtual ~Object() { } |
| 169 | 169 |
| 170 RawObject* raw() const { return raw_; } | 170 RawObject* raw() const { return raw_; } |
| 171 void operator=(RawObject* value) { SetRaw(value); } | 171 void operator=(RawObject* value) { SetRaw(value); } |
| 172 | 172 |
| 173 void set_tags(intptr_t value) const { | 173 void set_tags(intptr_t value) const { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 static RawClass* script_class_; // Class of the Script vm object. | 397 static RawClass* script_class_; // Class of the Script vm object. |
| 398 static RawClass* library_class_; // Class of the Library vm object. | 398 static RawClass* library_class_; // Class of the Library vm object. |
| 399 static RawClass* library_prefix_class_; // Class of Library prefix vm object. | 399 static RawClass* library_prefix_class_; // Class of Library prefix vm object. |
| 400 static RawClass* code_class_; // Class of the Code vm object. | 400 static RawClass* code_class_; // Class of the Code vm object. |
| 401 static RawClass* instructions_class_; // Class of the Instructions vm object. | 401 static RawClass* instructions_class_; // Class of the Instructions vm object. |
| 402 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. | 402 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. |
| 403 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. | 403 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. |
| 404 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. | 404 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. |
| 405 static RawClass* context_class_; // Class of the Context vm object. | 405 static RawClass* context_class_; // Class of the Context vm object. |
| 406 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 406 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
| 407 static RawClass* icdata_class_; // Class of ICData. |
| 407 static RawClass* api_error_class_; // Class of ApiError. | 408 static RawClass* api_error_class_; // Class of ApiError. |
| 408 static RawClass* language_error_class_; // Class of LanguageError. | 409 static RawClass* language_error_class_; // Class of LanguageError. |
| 409 static RawClass* unhandled_exception_class_; // Class of UnhandledException. | 410 static RawClass* unhandled_exception_class_; // Class of UnhandledException. |
| 410 static RawClass* unwind_error_class_; // Class of UnwindError. | 411 static RawClass* unwind_error_class_; // Class of UnwindError. |
| 411 static RawClass* icdata_class_; // Class of ICData. | |
| 412 | 412 |
| 413 friend void RawObject::Validate() const; | 413 friend void RawObject::Validate() const; |
| 414 friend class SnapshotReader; | 414 friend class SnapshotReader; |
| 415 | 415 |
| 416 // Disallow allocation. | 416 // Disallow allocation. |
| 417 void* operator new(size_t size); | 417 void* operator new(size_t size); |
| 418 // Disallow copy constructor. | 418 // Disallow copy constructor. |
| 419 DISALLOW_COPY_AND_ASSIGN(Object); | 419 DISALLOW_COPY_AND_ASSIGN(Object); |
| 420 }; | 420 }; |
| 421 | 421 |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 raw_addr += sizeof(RawContextScope) + | 2346 raw_addr += sizeof(RawContextScope) + |
| 2347 (index * sizeof(RawContextScope::VariableDesc)); | 2347 (index * sizeof(RawContextScope::VariableDesc)); |
| 2348 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); | 2348 return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr); |
| 2349 } | 2349 } |
| 2350 | 2350 |
| 2351 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); | 2351 HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); |
| 2352 friend class Class; | 2352 friend class Class; |
| 2353 }; | 2353 }; |
| 2354 | 2354 |
| 2355 | 2355 |
| 2356 // Object holding information about an IC: test classes and their |
| 2357 // corresponding classes. |
| 2358 class ICData : public Object { |
| 2359 public: |
| 2360 RawFunction* function() const { |
| 2361 return raw_ptr()->function_; |
| 2362 } |
| 2363 |
| 2364 RawString* target_name() const { |
| 2365 return raw_ptr()->target_name_; |
| 2366 } |
| 2367 |
| 2368 intptr_t num_args_tested() const { |
| 2369 return raw_ptr()->num_args_tested_; |
| 2370 } |
| 2371 |
| 2372 intptr_t id() const { |
| 2373 return raw_ptr()->id_; |
| 2374 } |
| 2375 |
| 2376 intptr_t NumberOfChecks() const; |
| 2377 |
| 2378 static intptr_t InstanceSize() { |
| 2379 return RoundedAllocationSize(sizeof(RawICData)); |
| 2380 } |
| 2381 |
| 2382 static intptr_t target_name_offset() { |
| 2383 return OFFSET_OF(RawICData, target_name_); |
| 2384 } |
| 2385 |
| 2386 static intptr_t num_args_tested_offset() { |
| 2387 return OFFSET_OF(RawICData, num_args_tested_); |
| 2388 } |
| 2389 |
| 2390 static intptr_t ic_data_offset() { |
| 2391 return OFFSET_OF(RawICData, ic_data_); |
| 2392 } |
| 2393 |
| 2394 static intptr_t function_offset() { |
| 2395 return OFFSET_OF(RawICData, function_); |
| 2396 } |
| 2397 |
| 2398 void AddCheck(const GrowableArray<const Class*>& classes, |
| 2399 const Function& target) const; |
| 2400 void GetCheckAt(intptr_t index, |
| 2401 GrowableArray<const Class*>* classes, |
| 2402 Function* target) const; |
| 2403 void GetOneClassCheckAt(int index, Class* cls, Function* target) const; |
| 2404 |
| 2405 static RawICData* New(const Function& caller_function, |
| 2406 const String& target_name, |
| 2407 intptr_t id, |
| 2408 intptr_t num_args_tested); |
| 2409 |
| 2410 private: |
| 2411 RawArray* ic_data() const { |
| 2412 return raw_ptr()->ic_data_; |
| 2413 } |
| 2414 |
| 2415 void set_function(const Function& value) const; |
| 2416 void set_target_name(const String& value) const; |
| 2417 void set_id(intptr_t value) const; |
| 2418 void set_num_args_tested(intptr_t value) const; |
| 2419 void set_ic_data(const Array& value) const; |
| 2420 |
| 2421 intptr_t TestEntryLength() const; |
| 2422 |
| 2423 HEAP_OBJECT_IMPLEMENTATION(ICData, Object); |
| 2424 friend class Class; |
| 2425 }; |
| 2426 |
| 2427 |
| 2356 class Error : public Object { | 2428 class Error : public Object { |
| 2357 public: | 2429 public: |
| 2358 virtual const char* ToErrorCString() const; | 2430 virtual const char* ToErrorCString() const; |
| 2359 | 2431 |
| 2360 private: | 2432 private: |
| 2361 HEAP_OBJECT_IMPLEMENTATION(Error, Object); | 2433 HEAP_OBJECT_IMPLEMENTATION(Error, Object); |
| 2362 }; | 2434 }; |
| 2363 | 2435 |
| 2364 | 2436 |
| 2365 class ApiError : public Error { | 2437 class ApiError : public Error { |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3780 // This is only safe because we create a new Smi, which does not cause | 3852 // This is only safe because we create a new Smi, which does not cause |
| 3781 // heap allocation. | 3853 // heap allocation. |
| 3782 raw_ptr()->data_length_ = Smi::New(value); | 3854 raw_ptr()->data_length_ = Smi::New(value); |
| 3783 } | 3855 } |
| 3784 | 3856 |
| 3785 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); | 3857 HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance); |
| 3786 friend class Class; | 3858 friend class Class; |
| 3787 }; | 3859 }; |
| 3788 | 3860 |
| 3789 | 3861 |
| 3790 // Object holding information about an IC: test classes and their | |
| 3791 // corresponding classes. | |
| 3792 class ICData : public Instance { | |
| 3793 public: | |
| 3794 RawFunction* function() const { | |
| 3795 return raw_ptr()->function_; | |
| 3796 } | |
| 3797 | |
| 3798 RawString* target_name() const { | |
| 3799 return raw_ptr()->target_name_; | |
| 3800 } | |
| 3801 | |
| 3802 intptr_t num_args_tested() const { | |
| 3803 return raw_ptr()->num_args_tested_; | |
| 3804 } | |
| 3805 | |
| 3806 intptr_t id() const { | |
| 3807 return raw_ptr()->id_; | |
| 3808 } | |
| 3809 | |
| 3810 intptr_t NumberOfChecks() const; | |
| 3811 | |
| 3812 static intptr_t InstanceSize() { | |
| 3813 return RoundedAllocationSize(sizeof(RawICData)); | |
| 3814 } | |
| 3815 | |
| 3816 static intptr_t target_name_offset() { | |
| 3817 return OFFSET_OF(RawICData, target_name_); | |
| 3818 } | |
| 3819 | |
| 3820 static intptr_t num_args_tested_offset() { | |
| 3821 return OFFSET_OF(RawICData, num_args_tested_); | |
| 3822 } | |
| 3823 | |
| 3824 static intptr_t ic_data_offset() { | |
| 3825 return OFFSET_OF(RawICData, ic_data_); | |
| 3826 } | |
| 3827 | |
| 3828 static intptr_t function_offset() { | |
| 3829 return OFFSET_OF(RawICData, function_); | |
| 3830 } | |
| 3831 | |
| 3832 void AddCheck(const GrowableArray<const Class*>& classes, | |
| 3833 const Function& target) const; | |
| 3834 void GetCheckAt(intptr_t index, | |
| 3835 GrowableArray<const Class*>* classes, | |
| 3836 Function* target) const; | |
| 3837 void GetOneClassCheckAt(int index, Class* cls, Function* target) const; | |
| 3838 | |
| 3839 static RawICData* New(const Function& caller_function, | |
| 3840 const String& target_name, | |
| 3841 intptr_t id, | |
| 3842 intptr_t num_args_tested); | |
| 3843 | |
| 3844 private: | |
| 3845 RawArray* ic_data() const { | |
| 3846 return raw_ptr()->ic_data_; | |
| 3847 } | |
| 3848 | |
| 3849 void set_function(const Function& value) const; | |
| 3850 void set_target_name(const String& value) const; | |
| 3851 void set_id(intptr_t value) const; | |
| 3852 void set_num_args_tested(intptr_t value) const; | |
| 3853 void set_ic_data(const Array& value) const; | |
| 3854 | |
| 3855 intptr_t TestEntryLength() const; | |
| 3856 | |
| 3857 HEAP_OBJECT_IMPLEMENTATION(ICData, Instance); | |
| 3858 friend class Class; | |
| 3859 }; | |
| 3860 | |
| 3861 | |
| 3862 // Breaking cycles and loops. | 3862 // Breaking cycles and loops. |
| 3863 RawClass* Object::clazz() const { | 3863 RawClass* Object::clazz() const { |
| 3864 uword raw_value = reinterpret_cast<uword>(raw_); | 3864 uword raw_value = reinterpret_cast<uword>(raw_); |
| 3865 if ((raw_value & kSmiTagMask) == kSmiTag) { | 3865 if ((raw_value & kSmiTagMask) == kSmiTag) { |
| 3866 return Smi::Class(); | 3866 return Smi::Class(); |
| 3867 } | 3867 } |
| 3868 return raw_->ptr()->class_; | 3868 return raw_->ptr()->class_; |
| 3869 } | 3869 } |
| 3870 | 3870 |
| 3871 | 3871 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3926 } | 3926 } |
| 3927 | 3927 |
| 3928 | 3928 |
| 3929 void Context::SetAt(intptr_t index, const Instance& value) const { | 3929 void Context::SetAt(intptr_t index, const Instance& value) const { |
| 3930 StorePointer(InstanceAddr(index), value.raw()); | 3930 StorePointer(InstanceAddr(index), value.raw()); |
| 3931 } | 3931 } |
| 3932 | 3932 |
| 3933 } // namespace dart | 3933 } // namespace dart |
| 3934 | 3934 |
| 3935 #endif // VM_OBJECT_H_ | 3935 #endif // VM_OBJECT_H_ |
| OLD | NEW |