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

Unified Diff: runtime/vm/object.cc

Issue 10450014: Request for comments on overall approach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix scavenger and freelist handling Created 8 years, 7 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
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index b227e909c1face0575f73b1249bb677108c05bac..4d92512cc5e84fbb52b6f69adb59e1fcce0522b3 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -17,6 +17,7 @@
#include "vm/dart_api_state.h"
#include "vm/dart_entry.h"
#include "vm/debuginfo.h"
+#include "vm/disassembler.h"
#include "vm/double_conversion.h"
#include "vm/exceptions.h"
#include "vm/growable_array.h"
@@ -273,12 +274,10 @@ void Object::InitOnce() {
uword address = heap->Allocate(size, Heap::kOld);
class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag);
InitializeObject(address, Class::kInstanceKind, size);
- // Make the class_ field point to itself.
- class_class_->ptr()->class_ = class_class_;
Class fake;
// Initialization from Class::New<Class>.
- cls = class_class_;
+ cls.ForceSetRaw(class_class_);
cls.set_handle_vtable(fake.vtable());
cls.set_instance_size(Class::InstanceSize());
cls.set_next_field_offset(Class::InstanceSize());
@@ -299,10 +298,6 @@ void Object::InitOnce() {
cls.set_is_finalized();
null_class_ = cls.raw();
- // Complete initialization of null_ instance, i.e. initialize its class_
- // field.
- null_->ptr()->class_ = null_class_;
-
// Allocate and initialize the sentinel values of Null class.
{
cls = null_class_;
@@ -988,10 +983,7 @@ RawObject* Object::Allocate(const Class& cls,
}
NoGCScope no_gc;
InitializeObject(address, cls.index(), size);
- RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
- raw_obj->ptr()->class_ = cls.raw();
- ASSERT(cls.index() == RawObject::ClassTag::decode(raw_obj->ptr()->tags_));
- return raw_obj;
+ return reinterpret_cast<RawObject*>(address + kHeapObjectTag);
}
@@ -6302,6 +6294,17 @@ RawCode* Code::LookupCode(uword pc) {
}
+#ifdef DEBUG
+void Code::FindAndPrint(uword pc) {
Ivan Posva 2012/05/26 04:34:46 ?
Vyacheslav Egorov (Google) 2012/05/26 16:48:22 This is a very useful helper method for debugging.
+ const Code& code = Code::Handle(Code::LookupCode(pc));
+ const Instructions& instructions =
+ Instructions::Handle(code.instructions());
+ uword start = instructions.EntryPoint();
+ Disassembler::Disassemble(start, start + instructions.size());
+}
+#endif
+
+
intptr_t Code::GetTokenIndexOfPC(uword pc) const {
intptr_t token_index = -1;
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
@@ -8965,7 +8968,6 @@ void Array::MakeImmutable() const {
isolate, isolate->object_store()->immutable_array_class());
{
NoGCScope no_gc;
- raw_ptr()->class_ = cls.raw();
uword tags = raw_ptr()->tags_;
tags = RawObject::ClassTag::update(cls.index(), tags);
raw_ptr()->tags_ = tags;
@@ -9036,21 +9038,18 @@ RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) {
// space as an Array object.
RawArray* raw = reinterpret_cast<RawArray*>(RawObject::FromAddr(addr));
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);
- raw->ptr()->tags_ = tags;
raw->ptr()->length_ = Smi::New(leftover_len);
} else {
// Update the leftover space as a basic object.
ASSERT(leftover_size == Object::InstanceSize());
RawObject* raw = reinterpret_cast<RawObject*>(RawObject::FromAddr(addr));
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);

Powered by Google App Engine
This is Rietveld 408576698