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

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

Issue 10996002: Fix snapshot reading of canonicalized types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months 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/class_finalizer.cc ('k') | runtime/vm/raw_object_snapshot.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) 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 2957 matching lines...) Expand 10 before | Expand all | Expand 10 after
2968 return AbstractTypeArguments::AreIdentical( 2968 return AbstractTypeArguments::AreIdentical(
2969 AbstractTypeArguments::Handle(arguments()), 2969 AbstractTypeArguments::Handle(arguments()),
2970 AbstractTypeArguments::Handle(other.arguments()), 2970 AbstractTypeArguments::Handle(other.arguments()),
2971 false); // Bounds are only checked at the top level. 2971 false); // Bounds are only checked at the top level.
2972 } 2972 }
2973 2973
2974 2974
2975 RawAbstractType* Type::Canonicalize() const { 2975 RawAbstractType* Type::Canonicalize() const {
2976 ASSERT(IsFinalized()); 2976 ASSERT(IsFinalized());
2977 if (IsCanonical() || IsMalformed()) { 2977 if (IsCanonical() || IsMalformed()) {
2978 ASSERT(IsMalformed() || AbstractTypeArguments::Handle(arguments()).IsOld());
2978 return this->raw(); 2979 return this->raw();
2979 } 2980 }
2980 const Class& cls = Class::Handle(type_class()); 2981 const Class& cls = Class::Handle(type_class());
2981 Array& canonical_types = Array::Handle(cls.canonical_types()); 2982 Array& canonical_types = Array::Handle(cls.canonical_types());
2982 if (canonical_types.IsNull()) { 2983 if (canonical_types.IsNull()) {
2983 // Types defined in the VM isolate are canonicalized via the object store. 2984 // Types defined in the VM isolate are canonicalized via the object store.
2984 return this->raw(); 2985 return this->raw();
2985 } 2986 }
2986 const intptr_t canonical_types_len = canonical_types.Length(); 2987 const intptr_t canonical_types_len = canonical_types.Length();
2987 // Linear search to see whether this type is already present in the 2988 // Linear search to see whether this type is already present in the
(...skipping 10 matching lines...) Expand all
2998 if (!type.IsFinalized()) { 2999 if (!type.IsFinalized()) {
2999 ASSERT((index == 0) && cls.IsSignatureClass()); 3000 ASSERT((index == 0) && cls.IsSignatureClass());
3000 index++; 3001 index++;
3001 continue; 3002 continue;
3002 } 3003 }
3003 if (this->Equals(type)) { 3004 if (this->Equals(type)) {
3004 return type.raw(); 3005 return type.raw();
3005 } 3006 }
3006 index++; 3007 index++;
3007 } 3008 }
3009 // Canonicalize the type arguments.
3010 AbstractTypeArguments& type_args = AbstractTypeArguments::Handle(arguments());
3011 type_args = type_args.Canonicalize();
3012 set_arguments(type_args);
3008 // The type needs to be added to the list. Grow the list if it is full. 3013 // The type needs to be added to the list. Grow the list if it is full.
3009 if (index == canonical_types_len) { 3014 if (index == canonical_types_len) {
3010 const intptr_t kLengthIncrement = 2; // Raw and parameterized. 3015 const intptr_t kLengthIncrement = 2; // Raw and parameterized.
3011 const intptr_t new_length = canonical_types.Length() + kLengthIncrement; 3016 const intptr_t new_length = canonical_types.Length() + kLengthIncrement;
3012 const Array& new_canonical_types = 3017 const Array& new_canonical_types =
3013 Array::Handle(Array::Grow(canonical_types, new_length, Heap::kOld)); 3018 Array::Handle(Array::Grow(canonical_types, new_length, Heap::kOld));
3014 cls.set_canonical_types(new_canonical_types); 3019 cls.set_canonical_types(new_canonical_types);
3015 new_canonical_types.SetAt(index, *this); 3020 new_canonical_types.SetAt(index, *this);
3016 } else { 3021 } else {
3017 canonical_types.SetAt(index, *this); 3022 canonical_types.SetAt(index, *this);
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
3638 3643
3639 void TypeArguments::SetLength(intptr_t value) const { 3644 void TypeArguments::SetLength(intptr_t value) const {
3640 ASSERT(!IsCanonical()); 3645 ASSERT(!IsCanonical());
3641 // This is only safe because we create a new Smi, which does not cause 3646 // This is only safe because we create a new Smi, which does not cause
3642 // heap allocation. 3647 // heap allocation.
3643 raw_ptr()->length_ = Smi::New(value); 3648 raw_ptr()->length_ = Smi::New(value);
3644 } 3649 }
3645 3650
3646 3651
3647 RawAbstractTypeArguments* TypeArguments::Canonicalize() const { 3652 RawAbstractTypeArguments* TypeArguments::Canonicalize() const {
3648 if (IsNull() || IsCanonical() || !IsInstantiated()) { 3653 if (IsNull() || IsCanonical()) {
3654 ASSERT(IsOld());
3649 return this->raw(); 3655 return this->raw();
3650 } 3656 }
3651 ObjectStore* object_store = Isolate::Current()->object_store(); 3657 ObjectStore* object_store = Isolate::Current()->object_store();
3652 // 'table' must be null terminated. 3658 // 'table' must be null terminated.
3653 Array& table = Array::Handle(object_store->canonical_type_arguments()); 3659 Array& table = Array::Handle(object_store->canonical_type_arguments());
3654 ASSERT(table.Length() > 0); 3660 ASSERT(table.Length() > 0);
3655 intptr_t index = 0; 3661 intptr_t index = 0;
3656 TypeArguments& result = TypeArguments::Handle(); 3662 TypeArguments& result = TypeArguments::Handle();
3657 result ^= table.At(index); 3663 result ^= table.At(index);
3658 while (!result.IsNull()) { 3664 while (!result.IsNull()) {
(...skipping 8473 matching lines...) Expand 10 before | Expand all | Expand 10 after
12132 } 12138 }
12133 return result.raw(); 12139 return result.raw();
12134 } 12140 }
12135 12141
12136 12142
12137 const char* WeakProperty::ToCString() const { 12143 const char* WeakProperty::ToCString() const {
12138 return "_WeakProperty"; 12144 return "_WeakProperty";
12139 } 12145 }
12140 12146
12141 } // namespace dart 12147 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698