| 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 4868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4879 friend class Class; | 4879 friend class Class; |
| 4880 }; | 4880 }; |
| 4881 | 4881 |
| 4882 | 4882 |
| 4883 // Breaking cycles and loops. | 4883 // Breaking cycles and loops. |
| 4884 RawClass* Object::clazz() const { | 4884 RawClass* Object::clazz() const { |
| 4885 uword raw_value = reinterpret_cast<uword>(raw_); | 4885 uword raw_value = reinterpret_cast<uword>(raw_); |
| 4886 if ((raw_value & kSmiTagMask) == kSmiTag) { | 4886 if ((raw_value & kSmiTagMask) == kSmiTag) { |
| 4887 return Smi::Class(); | 4887 return Smi::Class(); |
| 4888 } | 4888 } |
| 4889 RawClass* result = raw_->ptr()->class_; | 4889 return Isolate::Current()->class_table()->At(raw()->GetClassIndex()); |
| 4890 ASSERT(result->ptr()->index_ == | |
| 4891 RawObject::ClassTag::decode(raw_->ptr()->tags_)); | |
| 4892 ASSERT(Isolate::Current()->class_table()->At( | |
| 4893 RawObject::ClassTag::decode(raw_->ptr()->tags_)) == result); | |
| 4894 return result; | |
| 4895 } | 4890 } |
| 4896 | 4891 |
| 4897 | 4892 |
| 4898 void Object::SetRaw(RawObject* value) { | 4893 void Object::SetRaw(RawObject* value) { |
| 4899 // NOTE: The assignment "raw_ = value" should be the first statement in | 4894 // NOTE: The assignment "raw_ = value" should be the first statement in |
| 4900 // this function. Also do not use 'value' in this function after the | 4895 // this function. Also do not use 'value' in this function after the |
| 4901 // assignment (use 'raw_' instead). | 4896 // assignment (use 'raw_' instead). |
| 4902 raw_ = value; | 4897 raw_ = value; |
| 4903 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { | 4898 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { |
| 4904 set_vtable(Smi::handle_vtable_); | 4899 set_vtable(Smi::handle_vtable_); |
| 4905 return; | 4900 return; |
| 4906 } | 4901 } |
| 4907 #ifdef DEBUG | 4902 #ifdef DEBUG |
| 4908 Heap* isolate_heap = Isolate::Current()->heap(); | 4903 Heap* isolate_heap = Isolate::Current()->heap(); |
| 4909 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); | 4904 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); |
| 4910 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) || | 4905 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) || |
| 4911 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr()))); | 4906 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr()))); |
| 4912 #endif | 4907 #endif |
| 4913 set_vtable((raw_ == null_) ? | 4908 if (raw_ == null_) { |
| 4914 handle_vtable_ : raw_->ptr()->class_->ptr()->handle_vtable_); | 4909 set_vtable(handle_vtable_); |
| 4910 } else { |
| 4911 RawClass* raw_class = |
| 4912 Isolate::Current()->class_table()->At(raw_->GetClassIndex()); |
| 4913 set_vtable(raw_class->ptr()->handle_vtable_); |
| 4914 } |
| 4915 } | 4915 } |
| 4916 | 4916 |
| 4917 | 4917 |
| 4918 bool Function::HasCode() const { | 4918 bool Function::HasCode() const { |
| 4919 return raw_ptr()->code_ != Code::null(); | 4919 return raw_ptr()->code_ != Code::null(); |
| 4920 } | 4920 } |
| 4921 | 4921 |
| 4922 | 4922 |
| 4923 intptr_t Field::Offset() const { | 4923 intptr_t Field::Offset() const { |
| 4924 ASSERT(!is_static()); // Offset is valid only for instance fields. | 4924 ASSERT(!is_static()); // Offset is valid only for instance fields. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4957 } | 4957 } |
| 4958 | 4958 |
| 4959 | 4959 |
| 4960 intptr_t Stackmap::SizeInBits() const { | 4960 intptr_t Stackmap::SizeInBits() const { |
| 4961 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 4961 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 4962 } | 4962 } |
| 4963 | 4963 |
| 4964 } // namespace dart | 4964 } // namespace dart |
| 4965 | 4965 |
| 4966 #endif // VM_OBJECT_H_ | 4966 #endif // VM_OBJECT_H_ |
| OLD | NEW |