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

Unified Diff: runtime/vm/scavenger.cc

Issue 18259014: Object ID Ring with tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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/scavenger.cc
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc
index 8d6e4bf5be189dedb5a462cb1a672fb9afa992e9..a4c9dd46d281e692bc7bfadf32611b4a7d468fd9 100644
--- a/runtime/vm/scavenger.cc
+++ b/runtime/vm/scavenger.cc
@@ -17,6 +17,7 @@
#include "vm/verifier.h"
#include "vm/visitor.h"
#include "vm/weak_table.h"
+#include "vm/object_id_ring.h"
namespace dart {
@@ -404,6 +405,14 @@ void Scavenger::IterateStoreBuffers(Isolate* isolate,
}
+void Scavenger::IterateObjectIdTable(Isolate* isolate,
+ ScavengerVisitor* visitor) {
+ ObjectIdRing* ring = isolate->object_id_ring();
+ ASSERT(ring != NULL);
+ ring->VisitPointers(visitor);
+}
+
+
void Scavenger::IterateRoots(Isolate* isolate,
ScavengerVisitor* visitor,
bool visit_prologue_weak_persistent_handles) {
@@ -413,6 +422,7 @@ void Scavenger::IterateRoots(Isolate* isolate,
StackFrameIterator::kDontValidateFrames);
int64_t middle = OS::GetCurrentTimeMicros();
IterateStoreBuffers(isolate, visitor);
+ IterateObjectIdTable(isolate, visitor);
int64_t end = OS::GetCurrentTimeMicros();
heap_->RecordTime(kVisitIsolateRoots, middle - start);
heap_->RecordTime(kIterateStoreBuffers, end - middle);
@@ -590,6 +600,44 @@ void Scavenger::ProcessWeakTables() {
}
+class ObjectIdRingMovePointerVisitor : public ObjectPointerVisitor {
+ public:
+ explicit ObjectIdRingMovePointerVisitor(Isolate* isolate) :
+ ObjectPointerVisitor(isolate) {}
+
+ void Move(RawObject** current) {
+ RawObject* raw_obj = *current;
+ ASSERT(raw_obj->IsHeapObject());
+ if (raw_obj->IsOldObject()) {
+ // Skip old objects.
+ return;
+ }
+ uword raw_addr = RawObject::ToAddr(raw_obj);
+ uword header = *reinterpret_cast<uword*>(raw_addr);
+ if (IsForwarding(header)) {
+ // The object has survived. Update its address in the table.
+ uword new_addr = ForwardedAddr(header);
+ raw_obj = RawObject::FromAddr(new_addr);
+ *current = raw_obj;
+ }
+ }
+
+ void VisitPointers(RawObject** first, RawObject** last) {
+ for (RawObject** current = first; current <= last; current++) {
+ Move(current);
+ }
+ }
+};
+
+
+void Scavenger::ProcessObjectIdTable(Isolate* isolate) {
+ ObjectIdRingMovePointerVisitor visitor(isolate);
+ ObjectIdRing* ring = isolate->object_id_ring();
+ ASSERT(ring != NULL);
+ ring->VisitPointers(&visitor);
+}
+
+
void Scavenger::VisitObjectPointers(ObjectPointerVisitor* visitor) const {
uword cur = FirstObjectStart();
while (cur < top_) {
@@ -642,6 +690,7 @@ void Scavenger::Scavenge(bool invoke_api_callbacks) {
IterateWeakRoots(isolate, &weak_visitor, invoke_api_callbacks);
visitor.Finalize();
ProcessWeakTables();
+ ProcessObjectIdTable(isolate);
Ivan Posva 2013/07/11 17:01:42 It is unclear to me why you need this here and all
Cutch 2013/07/11 21:31:47 You are correct.
int64_t end = OS::GetCurrentTimeMicros();
heap_->RecordTime(kProcessToSpace, middle - start);
heap_->RecordTime(kIterateWeaks, end - middle);

Powered by Google App Engine
This is Rietveld 408576698