Chromium Code Reviews| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 bool IsCanonical() const { | 193 bool IsCanonical() const { |
| 194 ASSERT(!IsNull()); | 194 ASSERT(!IsNull()); |
| 195 return raw()->IsCanonical(); | 195 return raw()->IsCanonical(); |
| 196 } | 196 } |
| 197 void SetCanonical() const { | 197 void SetCanonical() const { |
| 198 ASSERT(!IsNull()); | 198 ASSERT(!IsNull()); |
| 199 raw()->SetCanonical(); | 199 raw()->SetCanonical(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 inline RawClass* clazz() const; | 202 inline RawClass* clazz() const; |
| 203 static intptr_t class_offset() { return OFFSET_OF(RawObject, class_); } | |
| 204 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); } | 203 static intptr_t tags_offset() { return OFFSET_OF(RawObject, tags_); } |
| 205 | 204 |
| 206 // Class testers. | 205 // Class testers. |
| 207 #define DEFINE_CLASS_TESTER(clazz) \ | 206 #define DEFINE_CLASS_TESTER(clazz) \ |
| 208 virtual bool Is##clazz() const { return false; } | 207 virtual bool Is##clazz() const { return false; } |
| 209 CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER); | 208 CLASS_LIST_NO_OBJECT(DEFINE_CLASS_TESTER); |
| 210 #undef DEFINE_CLASS_TESTER | 209 #undef DEFINE_CLASS_TESTER |
| 211 | 210 |
| 212 bool IsNull() const { return raw_ == null_; } | 211 bool IsNull() const { return raw_ == null_; } |
| 213 | 212 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 // class of signature_function. | 702 // class of signature_function. |
| 704 static RawClass* NewSignatureClass(const String& name, | 703 static RawClass* NewSignatureClass(const String& name, |
| 705 const Function& signature_function, | 704 const Function& signature_function, |
| 706 const Script& script); | 705 const Script& script); |
| 707 | 706 |
| 708 // Return a class object corresponding to the specified kind. If | 707 // Return a class object corresponding to the specified kind. If |
| 709 // a canonicalized version of it exists then that object is returned | 708 // a canonicalized version of it exists then that object is returned |
| 710 // otherwise a new object is allocated and returned. | 709 // otherwise a new object is allocated and returned. |
| 711 static RawClass* GetClass(ObjectKind kind); | 710 static RawClass* GetClass(ObjectKind kind); |
| 712 | 711 |
| 712 void ForceSetRaw(RawClass* raw) { | |
| 713 raw_ = raw; | |
| 714 } | |
| 715 | |
| 713 private: | 716 private: |
| 714 void set_name(const String& value) const; | 717 void set_name(const String& value) const; |
| 715 void set_script(const Script& value) const; | 718 void set_script(const Script& value) const; |
| 716 void set_token_index(intptr_t value) const; | 719 void set_token_index(intptr_t value) const; |
| 717 void set_signature_function(const Function& value) const; | 720 void set_signature_function(const Function& value) const; |
| 718 void set_signature_type(const AbstractType& value) const; | 721 void set_signature_type(const AbstractType& value) const; |
| 719 void set_class_state(int8_t state) const; | 722 void set_class_state(int8_t state) const; |
| 720 | 723 |
| 721 void set_constants(const Array& value) const; | 724 void set_constants(const Array& value) const; |
| 722 | 725 |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2244 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); | 2247 ASSERT(sizeof(RawCode) == OFFSET_OF(RawCode, data_)); |
| 2245 return 0; | 2248 return 0; |
| 2246 } | 2249 } |
| 2247 static intptr_t InstanceSize(intptr_t pointer_offsets_length) { | 2250 static intptr_t InstanceSize(intptr_t pointer_offsets_length) { |
| 2248 return RoundedAllocationSize( | 2251 return RoundedAllocationSize( |
| 2249 sizeof(RawCode) + (pointer_offsets_length * kEntrySize)); | 2252 sizeof(RawCode) + (pointer_offsets_length * kEntrySize)); |
| 2250 } | 2253 } |
| 2251 static RawCode* FinalizeCode(const Function& function, Assembler* assembler); | 2254 static RawCode* FinalizeCode(const Function& function, Assembler* assembler); |
| 2252 static RawCode* FinalizeCode(const char* name, Assembler* assembler); | 2255 static RawCode* FinalizeCode(const char* name, Assembler* assembler); |
| 2253 static RawCode* LookupCode(uword pc); | 2256 static RawCode* LookupCode(uword pc); |
| 2257 #ifdef DEBUG | |
| 2258 static void FindAndPrint(uword pc); | |
| 2259 #endif | |
| 2254 | 2260 |
| 2255 int32_t GetPointerOffsetAt(int index) const { | 2261 int32_t GetPointerOffsetAt(int index) const { |
| 2256 return *PointerOffsetAddrAt(index); | 2262 return *PointerOffsetAddrAt(index); |
| 2257 } | 2263 } |
| 2258 intptr_t GetTokenIndexOfPC(uword pc) const; | 2264 intptr_t GetTokenIndexOfPC(uword pc) const; |
| 2259 | 2265 |
| 2260 // Find pc of patch code buffer. Return 0 if not found. | 2266 // Find pc of patch code buffer. Return 0 if not found. |
| 2261 uword GetPatchCodePc() const; | 2267 uword GetPatchCodePc() const; |
| 2262 | 2268 |
| 2263 uword GetDeoptPcAtNodeId(intptr_t node_id) const; | 2269 uword GetDeoptPcAtNodeId(intptr_t node_id) const; |
| (...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4870 friend class Class; | 4876 friend class Class; |
| 4871 }; | 4877 }; |
| 4872 | 4878 |
| 4873 | 4879 |
| 4874 // Breaking cycles and loops. | 4880 // Breaking cycles and loops. |
| 4875 RawClass* Object::clazz() const { | 4881 RawClass* Object::clazz() const { |
| 4876 uword raw_value = reinterpret_cast<uword>(raw_); | 4882 uword raw_value = reinterpret_cast<uword>(raw_); |
| 4877 if ((raw_value & kSmiTagMask) == kSmiTag) { | 4883 if ((raw_value & kSmiTagMask) == kSmiTag) { |
| 4878 return Smi::Class(); | 4884 return Smi::Class(); |
| 4879 } | 4885 } |
| 4880 RawClass* result = raw_->ptr()->class_; | 4886 |
| 4881 ASSERT(result->ptr()->index_ == | 4887 return raw_->GetClass(); |
|
Ivan Posva
2012/05/26 04:34:46
Please no functionality on RawObjects.
Vyacheslav Egorov (Google)
2012/05/26 16:48:22
ok. There is RawObject::Size so I assumed that Raw
| |
| 4882 RawObject::ClassTag::decode(raw_->ptr()->tags_)); | |
| 4883 ASSERT(Isolate::Current()->class_table()->At( | |
| 4884 RawObject::ClassTag::decode(raw_->ptr()->tags_)) == result); | |
| 4885 return result; | |
| 4886 } | 4888 } |
| 4887 | 4889 |
| 4888 | 4890 |
| 4889 void Object::SetRaw(RawObject* value) { | 4891 void Object::SetRaw(RawObject* value) { |
| 4890 // NOTE: The assignment "raw_ = value" should be the first statement in | 4892 // NOTE: The assignment "raw_ = value" should be the first statement in |
| 4891 // this function. Also do not use 'value' in this function after the | 4893 // this function. Also do not use 'value' in this function after the |
| 4892 // assignment (use 'raw_' instead). | 4894 // assignment (use 'raw_' instead). |
| 4893 raw_ = value; | 4895 raw_ = value; |
| 4894 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { | 4896 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { |
| 4895 set_vtable(Smi::handle_vtable_); | 4897 set_vtable(Smi::handle_vtable_); |
| 4896 return; | 4898 return; |
| 4897 } | 4899 } |
| 4898 #ifdef DEBUG | 4900 #ifdef DEBUG |
| 4899 Heap* isolate_heap = Isolate::Current()->heap(); | 4901 Heap* isolate_heap = Isolate::Current()->heap(); |
| 4900 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); | 4902 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); |
| 4901 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) || | 4903 ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) || |
| 4902 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr()))); | 4904 vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr()))); |
| 4903 #endif | 4905 #endif |
| 4904 set_vtable((raw_ == null_) ? | 4906 set_vtable((raw_ == null_) ? |
| 4905 handle_vtable_ : raw_->ptr()->class_->ptr()->handle_vtable_); | 4907 handle_vtable_ : raw_->GetClass()->ptr()->handle_vtable_); |
| 4906 } | 4908 } |
| 4907 | 4909 |
| 4908 | 4910 |
| 4909 bool Function::HasCode() const { | 4911 bool Function::HasCode() const { |
| 4910 return raw_ptr()->code_ != Code::null(); | 4912 return raw_ptr()->code_ != Code::null(); |
| 4911 } | 4913 } |
| 4912 | 4914 |
| 4913 | 4915 |
| 4914 intptr_t Field::Offset() const { | 4916 intptr_t Field::Offset() const { |
| 4915 ASSERT(!is_static()); // Offset is valid only for instance fields. | 4917 ASSERT(!is_static()); // Offset is valid only for instance fields. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4948 } | 4950 } |
| 4949 | 4951 |
| 4950 | 4952 |
| 4951 intptr_t Stackmap::SizeInBits() const { | 4953 intptr_t Stackmap::SizeInBits() const { |
| 4952 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); | 4954 return (Smi::Value(raw_ptr()->bitmap_size_in_bytes_) * kBitsPerByte); |
| 4953 } | 4955 } |
| 4954 | 4956 |
| 4955 } // namespace dart | 4957 } // namespace dart |
| 4956 | 4958 |
| 4957 #endif // VM_OBJECT_H_ | 4959 #endif // VM_OBJECT_H_ |
| OLD | NEW |