Files
sdk/runtime/vm/verifier.cc
T
cshapiro@google.com f4c5dd4db3 Implement prologue weak persistent handles.
Prologue weak persistent handles are similar to weak persistent
handles but exhibit different behavior during garbage collections that
invoke the prologue and epilogue callbacks.  While weak persistent
handles always weakly reference their referents, prologue weak
persistent handles weakly reference their referents only during a
garbage collection occurs that invokes the prologue and epilogue
callbacks.  During all other garbage collections, prologue weak
persistent handles strongly reference their referents.

Review URL: https://chromiumcodereview.appspot.com//9655011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5445 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 23:41:59 +00:00

66 lines
2.1 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/verifier.h"
#include "platform/assert.h"
#include "vm/dart.h"
#include "vm/dart_api_state.h"
#include "vm/freelist.h"
#include "vm/heap.h"
#include "vm/isolate.h"
#include "vm/object.h"
#include "vm/raw_object.h"
#include "vm/stack_frame.h"
namespace dart {
DEFINE_FLAG(bool, verify_on_transition, false, "Verify on dart <==> VM.");
void VerifyPointersVisitor::VisitPointers(RawObject** first, RawObject** last) {
for (RawObject** current = first; current <= last; current++) {
RawObject* raw_obj = *current;
if (raw_obj->IsHeapObject()) {
// Skip visits of FreeListElements.
if (FreeListElement::IsSpecialClass(raw_obj)) {
// Only the class of the free list element should ever be visited.
ASSERT(first == last);
return;
}
uword obj_addr = RawObject::ToAddr(raw_obj);
if (!Isolate::Current()->heap()->Contains(obj_addr) &&
!Dart::vm_isolate()->heap()->Contains(obj_addr)) {
FATAL1("Invalid object pointer encountered 0x%lx\n", obj_addr);
}
raw_obj->Validate();
}
}
}
void VerifyWeakPointersVisitor::VisitHandle(uword addr) {
FinalizablePersistentHandle* handle =
reinterpret_cast<FinalizablePersistentHandle*>(addr);
RawObject* raw_obj = handle->raw();
visitor_->VisitPointer(&raw_obj);
}
void VerifyPointersVisitor::VerifyPointers() {
NoGCScope no_gc;
Isolate* isolate = Isolate::Current();
VerifyPointersVisitor visitor;
// Visit all strongly reachable objects.
isolate->VisitObjectPointers(&visitor,
false, // skip prologue weak handles
StackFrameIterator::kValidateFrames);
VerifyWeakPointersVisitor weak_visitor(&visitor);
// Visit weak handles and prologue weak handles.
isolate->VisitWeakPersistentHandles(&weak_visitor,
true); // visit prologue weak handles
}
} // namespace dart