| 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 void set_parent(const Context& parent) const { | 4060 void set_parent(const Context& parent) const { |
| 4061 StorePointer(&raw_ptr()->parent_, parent.raw()); | 4061 StorePointer(&raw_ptr()->parent_, parent.raw()); |
| 4062 } | 4062 } |
| 4063 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } | 4063 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } |
| 4064 | 4064 |
| 4065 intptr_t num_variables() const { return raw_ptr()->num_variables_; } | 4065 intptr_t num_variables() const { return raw_ptr()->num_variables_; } |
| 4066 static intptr_t num_variables_offset() { | 4066 static intptr_t num_variables_offset() { |
| 4067 return OFFSET_OF(RawContext, num_variables_); | 4067 return OFFSET_OF(RawContext, num_variables_); |
| 4068 } | 4068 } |
| 4069 | 4069 |
| 4070 RawInstance* At(intptr_t context_index) const { | 4070 RawObject* At(intptr_t context_index) const { |
| 4071 return *InstanceAddr(context_index); | 4071 return *ObjectAddr(context_index); |
| 4072 } | 4072 } |
| 4073 inline void SetAt(intptr_t context_index, const Instance& value) const; | 4073 inline void SetAt(intptr_t context_index, const Object& value) const; |
| 4074 | 4074 |
| 4075 void Dump(int indent = 0) const; | 4075 void Dump(int indent = 0) const; |
| 4076 | 4076 |
| 4077 static const intptr_t kBytesPerElement = kWordSize; | 4077 static const intptr_t kBytesPerElement = kWordSize; |
| 4078 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 4078 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 4079 | 4079 |
| 4080 static intptr_t variable_offset(intptr_t context_index) { | 4080 static intptr_t variable_offset(intptr_t context_index) { |
| 4081 return OFFSET_OF_RETURNED_VALUE(RawContext, data) + | 4081 return OFFSET_OF_RETURNED_VALUE(RawContext, data) + |
| 4082 (kWordSize * context_index); | 4082 (kWordSize * context_index); |
| 4083 } | 4083 } |
| 4084 | 4084 |
| 4085 static intptr_t InstanceSize() { | 4085 static intptr_t InstanceSize() { |
| 4086 ASSERT(sizeof(RawContext) == OFFSET_OF_RETURNED_VALUE(RawContext, data)); | 4086 ASSERT(sizeof(RawContext) == OFFSET_OF_RETURNED_VALUE(RawContext, data)); |
| 4087 return 0; | 4087 return 0; |
| 4088 } | 4088 } |
| 4089 | 4089 |
| 4090 static intptr_t InstanceSize(intptr_t len) { | 4090 static intptr_t InstanceSize(intptr_t len) { |
| 4091 ASSERT(0 <= len && len <= kMaxElements); | 4091 ASSERT(0 <= len && len <= kMaxElements); |
| 4092 return RoundedAllocationSize(sizeof(RawContext) + (len * kBytesPerElement)); | 4092 return RoundedAllocationSize(sizeof(RawContext) + (len * kBytesPerElement)); |
| 4093 } | 4093 } |
| 4094 | 4094 |
| 4095 static RawContext* New(intptr_t num_variables, | 4095 static RawContext* New(intptr_t num_variables, |
| 4096 Heap::Space space = Heap::kNew); | 4096 Heap::Space space = Heap::kNew); |
| 4097 | 4097 |
| 4098 private: | 4098 private: |
| 4099 RawInstance* const* InstanceAddr(intptr_t context_index) const { | 4099 RawObject* const* ObjectAddr(intptr_t context_index) const { |
| 4100 ASSERT((context_index >= 0) && (context_index < num_variables())); | 4100 ASSERT((context_index >= 0) && (context_index < num_variables())); |
| 4101 return &raw_ptr()->data()[context_index]; | 4101 return &raw_ptr()->data()[context_index]; |
| 4102 } | 4102 } |
| 4103 | 4103 |
| 4104 void set_num_variables(intptr_t num_variables) const { | 4104 void set_num_variables(intptr_t num_variables) const { |
| 4105 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); | 4105 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); |
| 4106 } | 4106 } |
| 4107 | 4107 |
| 4108 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); | 4108 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); |
| 4109 friend class Class; | 4109 friend class Class; |
| (...skipping 3329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7439 | 7439 |
| 7440 | 7440 |
| 7441 void Field::SetOffset(intptr_t value_in_bytes) const { | 7441 void Field::SetOffset(intptr_t value_in_bytes) const { |
| 7442 ASSERT(!is_static()); // SetOffset is valid only for instance fields. | 7442 ASSERT(!is_static()); // SetOffset is valid only for instance fields. |
| 7443 ASSERT(kWordSize != 0); | 7443 ASSERT(kWordSize != 0); |
| 7444 StorePointer(&raw_ptr()->value_, | 7444 StorePointer(&raw_ptr()->value_, |
| 7445 static_cast<RawInstance*>(Smi::New(value_in_bytes / kWordSize))); | 7445 static_cast<RawInstance*>(Smi::New(value_in_bytes / kWordSize))); |
| 7446 } | 7446 } |
| 7447 | 7447 |
| 7448 | 7448 |
| 7449 void Context::SetAt(intptr_t index, const Instance& value) const { | 7449 void Context::SetAt(intptr_t index, const Object& value) const { |
| 7450 StorePointer(InstanceAddr(index), value.raw()); | 7450 StorePointer(ObjectAddr(index), value.raw()); |
| 7451 } | 7451 } |
| 7452 | 7452 |
| 7453 | 7453 |
| 7454 intptr_t Instance::GetNativeField(int index) const { | 7454 intptr_t Instance::GetNativeField(int index) const { |
| 7455 ASSERT(IsValidNativeIndex(index)); | 7455 ASSERT(IsValidNativeIndex(index)); |
| 7456 NoGCScope no_gc; | 7456 NoGCScope no_gc; |
| 7457 RawTypedData* native_fields = | 7457 RawTypedData* native_fields = |
| 7458 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); | 7458 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); |
| 7459 if (native_fields == TypedData::null()) { | 7459 if (native_fields == TypedData::null()) { |
| 7460 return 0; | 7460 return 0; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7534 | 7534 |
| 7535 | 7535 |
| 7536 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7536 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7537 intptr_t index) { | 7537 intptr_t index) { |
| 7538 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7538 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7539 } | 7539 } |
| 7540 | 7540 |
| 7541 } // namespace dart | 7541 } // namespace dart |
| 7542 | 7542 |
| 7543 #endif // VM_OBJECT_H_ | 7543 #endif // VM_OBJECT_H_ |
| OLD | NEW |