Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: runtime/vm/object.cc

Issue 8372041: Canonicalize types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 608
609 void Object::InitFromSnapshot(Isolate* isolate) { 609 void Object::InitFromSnapshot(Isolate* isolate) {
610 TIMERSCOPE(time_bootstrap); 610 TIMERSCOPE(time_bootstrap);
611 ObjectStore* object_store = isolate->object_store(); 611 ObjectStore* object_store = isolate->object_store();
612 612
613 Class& cls = Class::Handle(); 613 Class& cls = Class::Handle();
614 614
615 // Set up empty classes in the object store, these will get 615 // Set up empty classes in the object store, these will get
616 // initialized correctly when we read from the snapshot. 616 // initialized correctly when we read from the snapshot.
617 // This is done do allow bootstrapping of reading classes from 617 // This is done to allow bootstrapping of reading classes from the snapshot.
618 // the snapshot.
619 cls = Class::New<Array>(); 618 cls = Class::New<Array>();
620 object_store->set_array_class(cls); 619 object_store->set_array_class(cls);
621 620
622 Array& empty_array = Array::Handle(); 621 Array& empty_array = Array::Handle();
623 empty_array = Array::New(0); 622 empty_array = Array::New(0);
624 object_store->set_empty_array(empty_array); 623 object_store->set_empty_array(empty_array);
625 624
626 cls = Class::New<ImmutableArray>(); 625 cls = Class::New<ImmutableArray>();
627 object_store->set_immutable_array_class(cls); 626 object_store->set_immutable_array_class(cls);
628 627
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 result.set_instance_size(FakeObject::InstanceSize()); 766 result.set_instance_size(FakeObject::InstanceSize());
768 result.set_next_field_offset(FakeObject::InstanceSize()); 767 result.set_next_field_offset(FakeObject::InstanceSize());
769 result.set_instance_kind(FakeObject::kInstanceKind); 768 result.set_instance_kind(FakeObject::kInstanceKind);
770 result.raw_ptr()->is_const_ = false; 769 result.raw_ptr()->is_const_ = false;
771 result.raw_ptr()->is_interface_ = false; 770 result.raw_ptr()->is_interface_ = false;
772 // VM backed classes are almost ready: run checks and resolve class 771 // VM backed classes are almost ready: run checks and resolve class
773 // references, but do not recompute size. 772 // references, but do not recompute size.
774 result.raw_ptr()->class_state_ = RawClass::kPreFinalized; 773 result.raw_ptr()->class_state_ = RawClass::kPreFinalized;
775 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 774 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
776 result.raw_ptr()->num_constants_ = 0; 775 result.raw_ptr()->num_constants_ = 0;
776 result.raw_ptr()->num_canonical_types_ = 0;
777 result.raw_ptr()->num_native_fields_ = 0; 777 result.raw_ptr()->num_native_fields_ = 0;
778 result.InitEmptyFields(); 778 result.InitEmptyFields();
779 return result.raw(); 779 return result.raw();
780 } 780 }
781 781
782 782
783 // Initialize class fields of type Array with empty array. 783 // Initialize class fields of type Array with empty array.
784 void Class::InitEmptyFields() { 784 void Class::InitEmptyFields() {
785 const Array& empty_array = Array::Handle(Array::Empty()); 785 const Array& empty_array = Array::Handle(Array::Empty());
786 if (empty_array.IsNull()) { 786 if (empty_array.IsNull()) {
787 // The empty array has not been initialized yet. 787 // The empty array has not been initialized yet.
788 return; 788 return;
789 } 789 }
790 StorePointer(&raw_ptr()->interfaces_, empty_array.raw()); 790 StorePointer(&raw_ptr()->interfaces_, empty_array.raw());
791 // TODO(srdjan): Make functions_cache growable and start with a smaller size. 791 // TODO(srdjan): Make functions_cache growable and start with a smaller size.
792 Array& fcache = 792 Array& fcache =
793 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld)); 793 Array::Handle(Array::New(FunctionsCache::kNumEntries * 32, Heap::kOld));
794 StorePointer(&raw_ptr()->functions_cache_, fcache.raw()); 794 StorePointer(&raw_ptr()->functions_cache_, fcache.raw());
795 StorePointer(&raw_ptr()->constants_, empty_array.raw()); 795 StorePointer(&raw_ptr()->constants_, empty_array.raw());
796 StorePointer(&raw_ptr()->canonical_types_, empty_array.raw());
796 StorePointer(&raw_ptr()->functions_, empty_array.raw()); 797 StorePointer(&raw_ptr()->functions_, empty_array.raw());
797 StorePointer(&raw_ptr()->fields_, empty_array.raw()); 798 StorePointer(&raw_ptr()->fields_, empty_array.raw());
798 } 799 }
799 800
800 void Class::SetFunctions(const Array& value) const { 801 void Class::SetFunctions(const Array& value) const {
801 ASSERT(!value.IsNull()); 802 ASSERT(!value.IsNull());
802 // Bind all the functions in the array to this class. 803 // Bind all the functions in the array to this class.
803 Function& func = Function::Handle(); 804 Function& func = Function::Handle();
804 intptr_t len = value.Length(); 805 intptr_t len = value.Length();
805 for (intptr_t i = 0; i < len; i++) { 806 for (intptr_t i = 0; i < len; i++) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 result.set_instance_size(FakeInstance::InstanceSize()); 1004 result.set_instance_size(FakeInstance::InstanceSize());
1004 result.set_next_field_offset(FakeInstance::InstanceSize()); 1005 result.set_next_field_offset(FakeInstance::InstanceSize());
1005 result.set_instance_kind(FakeInstance::kInstanceKind); 1006 result.set_instance_kind(FakeInstance::kInstanceKind);
1006 result.set_name(name); 1007 result.set_name(name);
1007 result.set_script(script); 1008 result.set_script(script);
1008 result.raw_ptr()->is_const_ = false; 1009 result.raw_ptr()->is_const_ = false;
1009 result.raw_ptr()->is_interface_ = false; 1010 result.raw_ptr()->is_interface_ = false;
1010 result.raw_ptr()->class_state_ = RawClass::kAllocated; 1011 result.raw_ptr()->class_state_ = RawClass::kAllocated;
1011 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments; 1012 result.raw_ptr()->type_arguments_instance_field_offset_ = kNoTypeArguments;
1012 result.raw_ptr()->num_constants_ = 0; 1013 result.raw_ptr()->num_constants_ = 0;
1014 result.raw_ptr()->num_canonical_types_ = 0;
1013 result.raw_ptr()->num_native_fields_ = 0; 1015 result.raw_ptr()->num_native_fields_ = 0;
1014 result.InitEmptyFields(); 1016 result.InitEmptyFields();
1015 return result.raw(); 1017 return result.raw();
1016 } 1018 }
1017 1019
1018 1020
1019 RawClass* Class::New(const String& name, const Script& script) { 1021 RawClass* Class::New(const String& name, const Script& script) {
1020 Class& result = Class::Handle(New<Instance>(name, script)); 1022 Class& result = Class::Handle(New<Instance>(name, script));
1021 return result.raw(); 1023 return result.raw();
1022 } 1024 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 intptr_t Class::num_constants() const { 1205 intptr_t Class::num_constants() const {
1204 return raw_ptr()->num_constants_; 1206 return raw_ptr()->num_constants_;
1205 } 1207 }
1206 1208
1207 1209
1208 void Class::set_num_constants(intptr_t value) const { 1210 void Class::set_num_constants(intptr_t value) const {
1209 raw_ptr()->num_constants_ = value; 1211 raw_ptr()->num_constants_ = value;
1210 } 1212 }
1211 1213
1212 1214
1215 RawArray* Class::canonical_types() const {
1216 return raw_ptr()->canonical_types_;
1217 }
1218
1219 void Class::set_canonical_types(const Array& value) const {
1220 ASSERT(!value.IsNull());
1221 StorePointer(&raw_ptr()->canonical_types_, value.raw());
1222 }
1223
1224
1225 intptr_t Class::num_canonical_types() const {
1226 return raw_ptr()->num_canonical_types_;
1227 }
1228
1229
1230 void Class::set_num_canonical_types(intptr_t value) const {
1231 raw_ptr()->num_canonical_types_ = value;
1232 }
1233
1234
1213 void Class::set_allocation_stub(const Code& value) const { 1235 void Class::set_allocation_stub(const Code& value) const {
1214 ASSERT(!value.IsNull()); 1236 ASSERT(!value.IsNull());
1215 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); 1237 ASSERT(raw_ptr()->allocation_stub_ == Code::null());
1216 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); 1238 StorePointer(&raw_ptr()->allocation_stub_, value.raw());
1217 } 1239 }
1218 1240
1219 1241
1220 bool Class::IsObjectClass() const { 1242 bool Class::IsObjectClass() const {
1221 return raw() == Type::Handle(Type::ObjectType()).type_class(); 1243 return raw() == Type::Handle(Type::ObjectType()).type_class();
1222 } 1244 }
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 } 1669 }
1648 1670
1649 1671
1650 bool Type::IsBeingFinalized() const { 1672 bool Type::IsBeingFinalized() const {
1651 // Type is an abstract class. 1673 // Type is an abstract class.
1652 UNREACHABLE(); 1674 UNREACHABLE();
1653 return false; 1675 return false;
1654 } 1676 }
1655 1677
1656 1678
1679 bool Type::Equals(const Type& other) const {
1680 // Type is an abstract class.
1681 UNREACHABLE();
1682 return false;
1683 }
1684
1685
1657 RawType* Type::InstantiateFrom( 1686 RawType* Type::InstantiateFrom(
1658 const TypeArguments& instantiator_type_arguments, 1687 const TypeArguments& instantiator_type_arguments,
1659 intptr_t offset) const { 1688 intptr_t offset) const {
1660 // Type is an abstract class. 1689 // Type is an abstract class.
1661 UNREACHABLE(); 1690 UNREACHABLE();
1662 return Type::null(); 1691 return Type::null();
1663 } 1692 }
1664 1693
1665 1694
1695 RawType* Type::Canonicalize() const {
1696 // Type is an abstract class.
1697 UNREACHABLE();
1698 return Type::null();
1699 }
1700
1701
1666 RawString* Type::Name() const { 1702 RawString* Type::Name() const {
1667 // If the type is still being finalized, we may be reporting an error about 1703 // If the type is still being finalized, we may be reporting an error about
1668 // an illformed type, so proceed with caution. 1704 // an illformed type, so proceed with caution.
1669 const TypeArguments& args = TypeArguments::Handle(arguments()); 1705 const TypeArguments& args = TypeArguments::Handle(arguments());
1670 const intptr_t num_args = args.IsNull() ? 0 : args.Length(); 1706 const intptr_t num_args = args.IsNull() ? 0 : args.Length();
1671 String& class_name = String::Handle(); 1707 String& class_name = String::Handle();
1672 intptr_t first_type_param_index; 1708 intptr_t first_type_param_index;
1673 intptr_t num_type_params; // Number of type parameters to print. 1709 intptr_t num_type_params; // Number of type parameters to print.
1674 if (HasResolvedTypeClass()) { 1710 if (HasResolvedTypeClass()) {
1675 const Class& cls = Class::Handle(type_class()); 1711 const Class& cls = Class::Handle(type_class());
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 } 1920 }
1885 1921
1886 1922
1887 RawType* Type::NewNonParameterizedType(const Class& type_class) { 1923 RawType* Type::NewNonParameterizedType(const Class& type_class) {
1888 ASSERT(!type_class.HasTypeArguments()); 1924 ASSERT(!type_class.HasTypeArguments());
1889 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 1925 const TypeArguments& no_type_arguments = TypeArguments::Handle();
1890 ParameterizedType& type = ParameterizedType::Handle(); 1926 ParameterizedType& type = ParameterizedType::Handle();
1891 type ^= ParameterizedType::New( 1927 type ^= ParameterizedType::New(
1892 Object::Handle(type_class.raw()), no_type_arguments); 1928 Object::Handle(type_class.raw()), no_type_arguments);
1893 type.set_is_finalized(); 1929 type.set_is_finalized();
1930 type ^= type.Canonicalize();
1894 return type.raw(); 1931 return type.raw();
1895 } 1932 }
1896 1933
1897 1934
1898 RawType* Type::NewParameterizedType(const Object& clazz, 1935 RawType* Type::NewParameterizedType(const Object& clazz,
1899 const TypeArguments& arguments) { 1936 const TypeArguments& arguments) {
1900 return ParameterizedType::New(clazz, arguments); 1937 return ParameterizedType::New(clazz, arguments);
1901 } 1938 }
1902 1939
1903 1940
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 const Class& cls = Class::Handle(type_class()); 2027 const Class& cls = Class::Handle(type_class());
1991 ParameterizedType& instantiated_type = ParameterizedType::Handle( 2028 ParameterizedType& instantiated_type = ParameterizedType::Handle(
1992 ParameterizedType::New(cls, type_arguments)); 2029 ParameterizedType::New(cls, type_arguments));
1993 ASSERT(type_arguments.IsNull() || 2030 ASSERT(type_arguments.IsNull() ||
1994 (type_arguments.Length() == cls.NumTypeArguments())); 2031 (type_arguments.Length() == cls.NumTypeArguments()));
1995 instantiated_type.set_is_finalized(); 2032 instantiated_type.set_is_finalized();
1996 return instantiated_type.raw(); 2033 return instantiated_type.raw();
1997 } 2034 }
1998 2035
1999 2036
2037 bool ParameterizedType::Equals(const Type& other) const {
2038 ASSERT(IsFinalized() && other.IsFinalized());
2039 if (raw() == other.raw()) {
2040 return true;
2041 }
2042 if (!other.IsParameterizedType()) {
2043 return false;
2044 }
2045 ParameterizedType& other_parameterized_type = ParameterizedType::Handle();
2046 other_parameterized_type ^= other.raw();
2047 if (type_class() != other_parameterized_type.type_class()) {
2048 return false;
2049 }
2050 return TypeArguments::AreEqual(TypeArguments::Handle(arguments()),
2051 TypeArguments::Handle(other.arguments()));
2052 }
2053
2054
2055 RawType* ParameterizedType::Canonicalize() const {
2056 const Class& cls = Class::Handle(type_class());
2057 Array& canonical_types = Array::Handle(cls.canonical_types());
2058 if (canonical_types.IsNull()) {
2059 // Types defined in the VM isolate are canonicalized via the object store.
2060 // TODO(regis): Should we add null_class_, void_class_, dynamic_class_ to
2061 // the object store, remove all types from the object store, and replace
2062 // the test above by an assert?
2063 return this->raw();
2064 }
2065 const intptr_t num_canonical_types = cls.num_canonical_types();
2066 ASSERT(canonical_types.Length() >= num_canonical_types);
2067 // Linear search to see whether this type is already present in the
2068 // list of canonicalized types.
2069 Type& type = Type::Handle();
2070 for (int i = 0; i < num_canonical_types; i++) {
2071 type ^= canonical_types.At(i);
2072 ASSERT(!type.IsNull());
2073 if (this->Equals(type)) {
2074 return type.raw();
2075 }
2076 }
2077 // The type needs to be added to the list. Grow the list if it is full.
2078 if (canonical_types.Length() == num_canonical_types) {
2079 const intptr_t kLengthIncrement = 2; // Raw and parameterized.
2080 const intptr_t new_length = canonical_types.Length() + kLengthIncrement;
2081 const Array& new_canonical_types =
2082 Array::Handle(Array::Grow(canonical_types, new_length, Heap::kOld));
2083 cls.set_canonical_types(new_canonical_types);
2084 new_canonical_types.SetAt(num_canonical_types, *this);
2085 } else {
2086 canonical_types.SetAt(num_canonical_types, *this);
2087 }
2088 cls.set_num_canonical_types(num_canonical_types + 1);
2089 return this->raw();
2090 }
2091
2092
2000 void ParameterizedType::set_type_class(const Object& value) const { 2093 void ParameterizedType::set_type_class(const Object& value) const {
2001 ASSERT(!value.IsNull() && (value.IsClass() || value.IsUnresolvedClass())); 2094 ASSERT(!value.IsNull() && (value.IsClass() || value.IsUnresolvedClass()));
2002 StorePointer(&raw_ptr()->type_class_, value.raw()); 2095 StorePointer(&raw_ptr()->type_class_, value.raw());
2003 } 2096 }
2004 2097
2005 2098
2006 void ParameterizedType::set_arguments(const TypeArguments& value) const { 2099 void ParameterizedType::set_arguments(const TypeArguments& value) const {
2007 StorePointer(&raw_ptr()->arguments_, value.raw()); 2100 StorePointer(&raw_ptr()->arguments_, value.raw());
2008 } 2101 }
2009 2102
(...skipping 25 matching lines...) Expand all
2035 state == RawParameterizedType::kFinalized); 2128 state == RawParameterizedType::kFinalized);
2036 raw_ptr()->type_state_ = state; 2129 raw_ptr()->type_state_ = state;
2037 } 2130 }
2038 2131
2039 2132
2040 const char* ParameterizedType::ToCString() const { 2133 const char* ParameterizedType::ToCString() const {
2041 return "ParameterizedType"; 2134 return "ParameterizedType";
2042 } 2135 }
2043 2136
2044 2137
2138 bool TypeParameter::Equals(const Type& other) const {
2139 if (raw() == other.raw()) {
2140 return true;
2141 }
2142 if (!other.IsTypeParameter()) {
2143 return false;
2144 }
2145 TypeParameter& other_type_parameter = TypeParameter::Handle();
2146 other_type_parameter ^= other.raw();
2147 return Index() == other_type_parameter.Index();
2148 }
2149
2150
2045 void TypeParameter::set_index(intptr_t value) const { 2151 void TypeParameter::set_index(intptr_t value) const {
2046 ASSERT(value >= 0); 2152 ASSERT(value >= 0);
2047 raw_ptr()->index_ = value; 2153 raw_ptr()->index_ = value;
2048 } 2154 }
2049 2155
2050 2156
2051 void TypeParameter::set_name(const String& value) const { 2157 void TypeParameter::set_name(const String& value) const {
2052 ASSERT(value.IsSymbol()); 2158 ASSERT(value.IsSymbol());
2053 StorePointer(&raw_ptr()->name_, value.raw()); 2159 StorePointer(&raw_ptr()->name_, value.raw());
2054 } 2160 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 } 2276 }
2171 2277
2172 2278
2173 bool TypeArguments::IsUninstantiatedIdentity() const { 2279 bool TypeArguments::IsUninstantiatedIdentity() const {
2174 // TypeArguments is an abstract class. 2280 // TypeArguments is an abstract class.
2175 UNREACHABLE(); 2281 UNREACHABLE();
2176 return false; 2282 return false;
2177 } 2283 }
2178 2284
2179 2285
2286 bool TypeArguments::Equals(const TypeArguments& other) const {
2287 // TypeArguments is an abstract class.
2288 UNREACHABLE();
2289 return false;
2290 }
2291
2292
2293 bool TypeArguments::AreEqual(const TypeArguments& arguments,
2294 const TypeArguments& other_arguments) {
2295 if (arguments.raw() == other_arguments.raw()) {
2296 return true;
2297 }
2298 if (arguments.IsNull()) {
2299 return other_arguments.IsDynamicTypes(other_arguments.Length());
2300 }
2301 if (other_arguments.IsNull()) {
2302 return arguments.IsDynamicTypes(arguments.Length());
2303 }
2304 return arguments.Equals(other_arguments);
2305 }
2306
2307
2180 RawTypeArguments* TypeArguments::InstantiateFrom( 2308 RawTypeArguments* TypeArguments::InstantiateFrom(
2181 const TypeArguments& instantiator_type_arguments, 2309 const TypeArguments& instantiator_type_arguments,
2182 intptr_t offset) const { 2310 intptr_t offset) const {
2183 // TypeArguments is an abstract class. 2311 // TypeArguments is an abstract class.
2184 UNREACHABLE(); 2312 UNREACHABLE();
2185 return TypeArguments::null(); 2313 return TypeArguments::null();
2186 } 2314 }
2187 2315
2188 2316
2189 bool TypeArguments::IsDynamicTypes(intptr_t len) const { 2317 bool TypeArguments::IsDynamicTypes(intptr_t len) const {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 for (intptr_t i = 0; i < num_types; i++) { 2424 for (intptr_t i = 0; i < num_types; i++) {
2297 type = TypeAt(i); 2425 type = TypeAt(i);
2298 if (!type.IsTypeParameter() || (type.Index() != i)) { 2426 if (!type.IsTypeParameter() || (type.Index() != i)) {
2299 return false; 2427 return false;
2300 } 2428 }
2301 } 2429 }
2302 return true; 2430 return true;
2303 } 2431 }
2304 2432
2305 2433
2434 bool TypeArray::Equals(const TypeArguments& other) const {
2435 intptr_t num_types = Length();
2436 if (num_types != other.Length()) {
2437 return false;
2438 }
2439 Type& type = Type::Handle();
2440 Type& other_type = Type::Handle();
2441 for (intptr_t i = 0; i < num_types; i++) {
2442 type = TypeAt(i);
2443 other_type = other.TypeAt(i);
2444 if (!type.Equals(other_type)) {
2445 return false;
2446 }
2447 }
2448 return true;
2449 }
2450
2451
2306 RawTypeArguments* TypeArray::InstantiateFrom( 2452 RawTypeArguments* TypeArray::InstantiateFrom(
2307 const TypeArguments& instantiator_type_arguments, 2453 const TypeArguments& instantiator_type_arguments,
2308 intptr_t offset) const { 2454 intptr_t offset) const {
2309 ASSERT(!IsInstantiated()); 2455 ASSERT(!IsInstantiated());
2310 if (instantiator_type_arguments.IsNull()) { 2456 if (instantiator_type_arguments.IsNull()) {
2311 return TypeArguments::null(); 2457 return TypeArguments::null();
2312 } 2458 }
2313 if ((offset == 0) && 2459 if ((offset == 0) &&
2314 !instantiator_type_arguments.IsNull() && 2460 !instantiator_type_arguments.IsNull() &&
2315 IsUninstantiatedIdentity() && 2461 IsUninstantiatedIdentity() &&
(...skipping 4098 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 bool Array::Equals(const Instance& other) const { 6560 bool Array::Equals(const Instance& other) const {
6415 if (this->raw() == other.raw()) { 6561 if (this->raw() == other.raw()) {
6416 // Both handles point to the same raw instance. 6562 // Both handles point to the same raw instance.
6417 return true; 6563 return true;
6418 } 6564 }
6419 6565
6420 if (!other.IsArray() || other.IsNull()) { 6566 if (!other.IsArray() || other.IsNull()) {
6421 return false; 6567 return false;
6422 } 6568 }
6423 6569
6424 // Must have the same type. 6570 // Must have the same type arguments.
6425 if (GetTypeArguments() != other.GetTypeArguments()) { 6571 if (!TypeArguments::AreEqual(
6572 TypeArguments::Handle(GetTypeArguments()),
6573 TypeArguments::Handle(other.GetTypeArguments()))) {
6426 return false; 6574 return false;
6427 } 6575 }
6428 6576
6429 Array& other_arr = Array::Handle(); 6577 Array& other_arr = Array::Handle();
6430 other_arr ^= other.raw(); 6578 other_arr ^= other.raw();
6431 6579
6432 intptr_t len = this->Length(); 6580 intptr_t len = this->Length();
6433 if (len != other_arr.Length()) { 6581 if (len != other_arr.Length()) {
6434 return false; 6582 return false;
6435 } 6583 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
6810 const String& str = String::Handle(pattern()); 6958 const String& str = String::Handle(pattern());
6811 const char* format = "JSRegExp: pattern=%s flags=%s"; 6959 const char* format = "JSRegExp: pattern=%s flags=%s";
6812 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6960 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6813 char* chars = reinterpret_cast<char*>( 6961 char* chars = reinterpret_cast<char*>(
6814 Isolate::Current()->current_zone()->Allocate(len + 1)); 6962 Isolate::Current()->current_zone()->Allocate(len + 1));
6815 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6963 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6816 return chars; 6964 return chars;
6817 } 6965 }
6818 6966
6819 } // namespace dart 6967 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698