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 4049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4060 // So that the RawFunction pointer visitor can determine whether code the | 4060 // So that the RawFunction pointer visitor can determine whether code the |
4061 // function points to is optimized. | 4061 // function points to is optimized. |
4062 friend class RawFunction; | 4062 friend class RawFunction; |
4063 }; | 4063 }; |
4064 | 4064 |
4065 | 4065 |
4066 class Context : public Object { | 4066 class Context : public Object { |
4067 public: | 4067 public: |
4068 RawContext* parent() const { return raw_ptr()->parent_; } | 4068 RawContext* parent() const { return raw_ptr()->parent_; } |
4069 void set_parent(const Context& parent) const { | 4069 void set_parent(const Context& parent) const { |
4070 ASSERT(parent.IsNull() || parent.isolate() == Isolate::Current()); | |
4071 StorePointer(&raw_ptr()->parent_, parent.raw()); | 4070 StorePointer(&raw_ptr()->parent_, parent.raw()); |
4072 } | 4071 } |
4073 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } | 4072 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } |
4074 | 4073 |
4075 Isolate* isolate() const { return raw_ptr()->isolate_; } | |
4076 static intptr_t isolate_offset() { return OFFSET_OF(RawContext, isolate_); } | |
4077 | |
4078 intptr_t num_variables() const { return raw_ptr()->num_variables_; } | 4074 intptr_t num_variables() const { return raw_ptr()->num_variables_; } |
4079 static intptr_t num_variables_offset() { | 4075 static intptr_t num_variables_offset() { |
4080 return OFFSET_OF(RawContext, num_variables_); | 4076 return OFFSET_OF(RawContext, num_variables_); |
4081 } | 4077 } |
4082 | 4078 |
4083 RawInstance* At(intptr_t context_index) const { | 4079 RawInstance* At(intptr_t context_index) const { |
4084 return *InstanceAddr(context_index); | 4080 return *InstanceAddr(context_index); |
4085 } | 4081 } |
4086 inline void SetAt(intptr_t context_index, const Instance& value) const; | 4082 inline void SetAt(intptr_t context_index, const Instance& value) const; |
4087 | 4083 |
(...skipping 19 matching lines...) Expand all Loading... |
4107 | 4103 |
4108 static RawContext* New(intptr_t num_variables, | 4104 static RawContext* New(intptr_t num_variables, |
4109 Heap::Space space = Heap::kNew); | 4105 Heap::Space space = Heap::kNew); |
4110 | 4106 |
4111 private: | 4107 private: |
4112 RawInstance* const* InstanceAddr(intptr_t context_index) const { | 4108 RawInstance* const* InstanceAddr(intptr_t context_index) const { |
4113 ASSERT((context_index >= 0) && (context_index < num_variables())); | 4109 ASSERT((context_index >= 0) && (context_index < num_variables())); |
4114 return &raw_ptr()->data()[context_index]; | 4110 return &raw_ptr()->data()[context_index]; |
4115 } | 4111 } |
4116 | 4112 |
4117 void set_isolate(Isolate* isolate) const { | |
4118 StoreNonPointer(&raw_ptr()->isolate_, isolate); | |
4119 } | |
4120 | |
4121 void set_num_variables(intptr_t num_variables) const { | 4113 void set_num_variables(intptr_t num_variables) const { |
4122 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); | 4114 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); |
4123 } | 4115 } |
4124 | 4116 |
4125 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); | 4117 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); |
4126 friend class Class; | 4118 friend class Class; |
4127 }; | 4119 }; |
4128 | 4120 |
4129 | 4121 |
4130 // The ContextScope class makes it possible to delay the compilation of a local | 4122 // The ContextScope class makes it possible to delay the compilation of a local |
(...skipping 3428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7559 | 7551 |
7560 | 7552 |
7561 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7553 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7562 intptr_t index) { | 7554 intptr_t index) { |
7563 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7555 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7564 } | 7556 } |
7565 | 7557 |
7566 } // namespace dart | 7558 } // namespace dart |
7567 | 7559 |
7568 #endif // VM_OBJECT_H_ | 7560 #endif // VM_OBJECT_H_ |
OLD | NEW |