| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 // Verification and resolving of interfaces occurs in finalizer. | 1847 // Verification and resolving of interfaces occurs in finalizer. |
| 1848 ASSERT(!value.IsNull()); | 1848 ASSERT(!value.IsNull()); |
| 1849 StorePointer(&raw_ptr()->interfaces_, value.raw()); | 1849 StorePointer(&raw_ptr()->interfaces_, value.raw()); |
| 1850 } | 1850 } |
| 1851 | 1851 |
| 1852 | 1852 |
| 1853 void Class::AddDirectSubclass(const Class& subclass) const { | 1853 void Class::AddDirectSubclass(const Class& subclass) const { |
| 1854 ASSERT(!subclass.IsNull()); | 1854 ASSERT(!subclass.IsNull()); |
| 1855 ASSERT(subclass.SuperClass() == raw()); | 1855 ASSERT(subclass.SuperClass() == raw()); |
| 1856 // Do not keep track of the direct subclasses of class Object. | 1856 // Do not keep track of the direct subclasses of class Object. |
| 1857 // TODO(regis): Replace assert below with ASSERT(id() != kDartObjectCid). | |
| 1858 ASSERT(!IsObjectClass()); | 1857 ASSERT(!IsObjectClass()); |
| 1859 GrowableObjectArray& direct_subclasses = | 1858 GrowableObjectArray& direct_subclasses = |
| 1860 GrowableObjectArray::Handle(raw_ptr()->direct_subclasses_); | 1859 GrowableObjectArray::Handle(raw_ptr()->direct_subclasses_); |
| 1861 if (direct_subclasses.IsNull()) { | 1860 if (direct_subclasses.IsNull()) { |
| 1862 direct_subclasses = GrowableObjectArray::New(4, Heap::kOld); | 1861 direct_subclasses = GrowableObjectArray::New(4, Heap::kOld); |
| 1863 StorePointer(&raw_ptr()->direct_subclasses_, direct_subclasses.raw()); | 1862 StorePointer(&raw_ptr()->direct_subclasses_, direct_subclasses.raw()); |
| 1864 } | 1863 } |
| 1865 #if defined(DEBUG) | 1864 #if defined(DEBUG) |
| 1866 // Verify that the same class is not added twice. | 1865 // Verify that the same class is not added twice. |
| 1867 for (intptr_t i = 0; i < direct_subclasses.Length(); i++) { | 1866 for (intptr_t i = 0; i < direct_subclasses.Length(); i++) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1893 | 1892 |
| 1894 | 1893 |
| 1895 void Class::set_allocation_stub(const Code& value) const { | 1894 void Class::set_allocation_stub(const Code& value) const { |
| 1896 ASSERT(!value.IsNull()); | 1895 ASSERT(!value.IsNull()); |
| 1897 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); | 1896 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); |
| 1898 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); | 1897 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); |
| 1899 } | 1898 } |
| 1900 | 1899 |
| 1901 | 1900 |
| 1902 bool Class::IsObjectClass() const { | 1901 bool Class::IsObjectClass() const { |
| 1903 return raw() == Type::Handle(Type::ObjectType()).type_class(); | 1902 return id() == kInstanceCid; |
| 1904 } | 1903 } |
| 1905 | 1904 |
| 1906 | 1905 |
| 1907 bool Class::IsCanonicalSignatureClass() const { | 1906 bool Class::IsCanonicalSignatureClass() const { |
| 1908 const Function& function = Function::Handle(signature_function()); | 1907 const Function& function = Function::Handle(signature_function()); |
| 1909 return (!function.IsNull() && (function.signature_class() == raw())); | 1908 return (!function.IsNull() && (function.signature_class() == raw())); |
| 1910 } | 1909 } |
| 1911 | 1910 |
| 1912 | 1911 |
| 1913 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T. | 1912 // If test_kind == kIsSubtypeOf, checks if type S is a subtype of type T. |
| (...skipping 8173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10087 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 10086 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 10088 raw->ptr()->tags_ = tags; | 10087 raw->ptr()->tags_ = tags; |
| 10089 intptr_t leftover_len = | 10088 intptr_t leftover_len = |
| 10090 ((leftover_size - Array::InstanceSize(0)) / kWordSize); | 10089 ((leftover_size - Array::InstanceSize(0)) / kWordSize); |
| 10091 raw->ptr()->tags_ = tags; | 10090 raw->ptr()->tags_ = tags; |
| 10092 raw->ptr()->length_ = Smi::New(leftover_len); | 10091 raw->ptr()->length_ = Smi::New(leftover_len); |
| 10093 } else { | 10092 } else { |
| 10094 // Update the leftover space as a basic object. | 10093 // Update the leftover space as a basic object. |
| 10095 ASSERT(leftover_size == Object::InstanceSize()); | 10094 ASSERT(leftover_size == Object::InstanceSize()); |
| 10096 RawObject* raw = reinterpret_cast<RawObject*>(RawObject::FromAddr(addr)); | 10095 RawObject* raw = reinterpret_cast<RawObject*>(RawObject::FromAddr(addr)); |
| 10097 const Class& cls = Class::Handle(isolate->object_store()->object_class()); | |
| 10098 tags = 0; | 10096 tags = 0; |
| 10099 tags = RawObject::SizeTag::update(leftover_size, tags); | 10097 tags = RawObject::SizeTag::update(leftover_size, tags); |
| 10100 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 10098 tags = RawObject::ClassIdTag::update(kInstanceCid, tags); |
| 10101 raw->ptr()->tags_ = tags; | 10099 raw->ptr()->tags_ = tags; |
| 10102 } | 10100 } |
| 10103 } | 10101 } |
| 10104 return array.raw(); | 10102 return array.raw(); |
| 10105 } | 10103 } |
| 10106 | 10104 |
| 10107 | 10105 |
| 10108 RawImmutableArray* ImmutableArray::New(intptr_t len, | 10106 RawImmutableArray* ImmutableArray::New(intptr_t len, |
| 10109 Heap::Space space) { | 10107 Heap::Space space) { |
| 10110 ObjectStore* object_store = Isolate::Current()->object_store(); | 10108 ObjectStore* object_store = Isolate::Current()->object_store(); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11134 } | 11132 } |
| 11135 return result.raw(); | 11133 return result.raw(); |
| 11136 } | 11134 } |
| 11137 | 11135 |
| 11138 | 11136 |
| 11139 const char* WeakProperty::ToCString() const { | 11137 const char* WeakProperty::ToCString() const { |
| 11140 return "WeakProperty"; | 11138 return "WeakProperty"; |
| 11141 } | 11139 } |
| 11142 | 11140 |
| 11143 } // namespace dart | 11141 } // namespace dart |
| OLD | NEW |