summaryrefslogtreecommitdiff
path: root/runtime/gc/reference_queue.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2014-01-28 14:50:23 -0800
committer Mathieu Chartier <mathieuc@google.com> 2014-02-11 10:40:10 -0800
commit83c8ee000d525017ead8753fce6bc1020249b96a (patch)
treed5167ed15dee2629905ac3640b6ea0578d4ae312 /runtime/gc/reference_queue.cc
parent7cba217ab0661d74deccbb97160cdf60b74d4ea3 (diff)
Add root types and thread id to root visiting.
Enables us to pass the root type and thread id to hprof. Bug: 12680863 Change-Id: I6a0f1f9e3aa8f9b4033d695818ae7ca3460d67cb
Diffstat (limited to 'runtime/gc/reference_queue.cc')
-rw-r--r--runtime/gc/reference_queue.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc
index 2d73a71421..fae4caccad 100644
--- a/runtime/gc/reference_queue.cc
+++ b/runtime/gc/reference_queue.cc
@@ -94,13 +94,14 @@ void ReferenceQueue::Dump(std::ostream& os) const {
}
}
-void ReferenceQueue::ClearWhiteReferences(ReferenceQueue& cleared_references, RootVisitor visitor,
+void ReferenceQueue::ClearWhiteReferences(ReferenceQueue& cleared_references,
+ IsMarkedCallback* preserve_callback,
void* arg) {
while (!IsEmpty()) {
mirror::Object* ref = DequeuePendingReference();
mirror::Object* referent = heap_->GetReferenceReferent(ref);
if (referent != nullptr) {
- mirror::Object* forward_address = visitor(referent, arg);
+ mirror::Object* forward_address = preserve_callback(referent, arg);
if (forward_address == nullptr) {
// Referent is white, clear it.
heap_->ClearReferenceReferent(ref);
@@ -108,7 +109,7 @@ void ReferenceQueue::ClearWhiteReferences(ReferenceQueue& cleared_references, Ro
cleared_references.EnqueuePendingReference(ref);
}
} else if (referent != forward_address) {
- // Object moved, need to updated the referrent.
+ // Object moved, need to updated the referent.
heap_->SetReferenceReferent(ref, forward_address);
}
}
@@ -116,8 +117,9 @@ void ReferenceQueue::ClearWhiteReferences(ReferenceQueue& cleared_references, Ro
}
void ReferenceQueue::EnqueueFinalizerReferences(ReferenceQueue& cleared_references,
- RootVisitor is_marked_callback,
- RootVisitor recursive_mark_callback, void* arg) {
+ IsMarkedCallback is_marked_callback,
+ MarkObjectCallback recursive_mark_callback,
+ void* arg) {
while (!IsEmpty()) {
mirror::Object* ref = DequeuePendingReference();
mirror::Object* referent = heap_->GetReferenceReferent(ref);
@@ -139,7 +141,7 @@ void ReferenceQueue::EnqueueFinalizerReferences(ReferenceQueue& cleared_referenc
}
}
-void ReferenceQueue::PreserveSomeSoftReferences(RootVisitor preserve_callback, void* arg) {
+void ReferenceQueue::PreserveSomeSoftReferences(IsMarkedCallback preserve_callback, void* arg) {
ReferenceQueue cleared(heap_);
while (!IsEmpty()) {
mirror::Object* ref = DequeuePendingReference();
@@ -149,7 +151,7 @@ void ReferenceQueue::PreserveSomeSoftReferences(RootVisitor preserve_callback, v
if (forward_address == nullptr) {
// Either the reference isn't marked or we don't wish to preserve it.
cleared.EnqueuePendingReference(ref);
- } else {
+ } else if (forward_address != referent) {
heap_->SetReferenceReferent(ref, forward_address);
}
}