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

Unified Diff: vm/object.cc

Issue 10271032: - Add extra checking when validating objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/object.cc
===================================================================
--- vm/object.cc (revision 7183)
+++ vm/object.cc (working copy)
@@ -1401,6 +1401,7 @@
case kInstance:
return Class::New<Instance>();
default:
+ OS::Print("Class::GetClass kind unknown: %d\n", kind);
UNREACHABLE();
}
return Class::null();
@@ -3159,7 +3160,7 @@
}
-void TypeArguments::SetLength(intptr_t value) {
+void TypeArguments::SetLength(intptr_t value) const {
ASSERT(!IsCanonical());
// This is only safe because we create a new Smi, which does not cause
// heap allocation.
@@ -8653,14 +8654,15 @@
intptr_t used_len = growable_array.Length();
intptr_t capacity_len = growable_array.Capacity();
Isolate* isolate = Isolate::Current();
- Array& array = Array::Handle(isolate, growable_array.data());
- Array& new_array = Array::Handle(isolate, Array::Empty());
+ const Array& array = Array::Handle(isolate, growable_array.data());
+ const Array& new_array = Array::Handle(isolate, Array::Empty());
intptr_t capacity_size = Array::InstanceSize(capacity_len);
intptr_t used_size = Array::InstanceSize(used_len);
NoGCScope no_gc;
// Update the size in the header field and length of the array object.
- uword tags = 0;
+ uword tags = array.raw_ptr()->tags_;
+ ASSERT(kArray == RawObject::ClassTag::decode(tags));
tags = RawObject::SizeTag::update(used_size, tags);
array.raw_ptr()->tags_ = tags;
array.SetLength(used_len);
@@ -8681,9 +8683,11 @@
// As we have enough space to use an array object, update the leftover
// space as an Array object.
RawArray* raw = reinterpret_cast<RawArray*>(RawObject::FromAddr(addr));
- raw->ptr()->class_ = isolate->object_store()->array_class();
+ const Class& cls = Class::Handle(isolate->object_store()->array_class());
+ raw->ptr()->class_ = cls.raw();
tags = 0;
tags = RawObject::SizeTag::update(leftover_size, tags);
+ tags = RawObject::ClassTag::update(cls.index(), tags);
raw->ptr()->tags_ = tags;
intptr_t leftover_len =
((leftover_size - Array::InstanceSize(0)) / kWordSize);
@@ -8693,9 +8697,11 @@
// Update the leftover space as a basic object.
ASSERT(leftover_size == Object::InstanceSize());
RawObject* raw = reinterpret_cast<RawObject*>(RawObject::FromAddr(addr));
- raw->ptr()->class_ = isolate->object_store()->object_class();
+ const Class& cls = Class::Handle(isolate->object_store()->object_class());
+ raw->ptr()->class_ = cls.raw();
tags = 0;
tags = RawObject::SizeTag::update(leftover_size, tags);
+ tags = RawObject::ClassTag::update(cls.index(), tags);
raw->ptr()->tags_ = tags;
}
}
« no previous file with comments | « vm/object.h ('k') | vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698