mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
more weak reference work, plus debug logging
This commit is contained in:
parent
b70e4b368f
commit
4decde57e6
@ -177,16 +177,22 @@ postVisit(Thread* t, Heap::Visitor* v)
|
|||||||
if (m->heap->status(*p) == Heap::Unreachable) {
|
if (m->heap->status(*p) == Heap::Unreachable) {
|
||||||
// reference is unreachable - remove it from the list
|
// reference is unreachable - remove it from the list
|
||||||
|
|
||||||
|
fprintf(stderr, "unreachable wr: %p\n", *p);
|
||||||
|
|
||||||
*p = jreferenceNext(t, *p);
|
*p = jreferenceNext(t, *p);
|
||||||
} else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) {
|
} else if (m->heap->status(jreferenceTarget(t, *p)) == Heap::Unreachable) {
|
||||||
// target is unreachable - clear the reference and remove it
|
// target is unreachable - clear the reference and remove it
|
||||||
// from the list
|
// from the list
|
||||||
|
|
||||||
|
fprintf(stderr, "target unreachable for wr: %p\n", *p);
|
||||||
|
|
||||||
jreferenceTarget(t, *p) = 0;
|
jreferenceTarget(t, *p) = 0;
|
||||||
*p = jreferenceNext(t, *p);
|
*p = jreferenceNext(t, *p);
|
||||||
} else {
|
} else {
|
||||||
// both reference and target are reachable
|
// both reference and target are reachable
|
||||||
|
|
||||||
|
fprintf(stderr, "viable wr: %p\n", *p);
|
||||||
|
|
||||||
v->visit(&jreferenceTarget(t, *p));
|
v->visit(&jreferenceTarget(t, *p));
|
||||||
v->visit(p);
|
v->visit(p);
|
||||||
|
|
||||||
@ -341,14 +347,6 @@ collect(Thread* t, Heap::CollectionType type)
|
|||||||
cast<uintptr_t>(dst, 0) |= ExtendedMark;
|
cast<uintptr_t>(dst, 0) |= ExtendedMark;
|
||||||
extendedWord(t, dst, base) = takeHash(t, o);
|
extendedWord(t, dst, base) = takeHash(t, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classVmFlags(t, class_) & WeakReferenceFlag) {
|
|
||||||
fprintf(stderr, "weak reference to %p at %p\n",
|
|
||||||
jreferenceTarget(t, dst),
|
|
||||||
&jreferenceTarget(t, dst));
|
|
||||||
jreferenceNext(t, dst) = m->weakReferences;
|
|
||||||
m->weakReferences = dst;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void walk(void* p, Heap::Walker* w) {
|
virtual void walk(void* p, Heap::Walker* w) {
|
||||||
@ -482,6 +480,7 @@ Machine::Machine(System* system, Heap* heap, ClassFinder* classFinder):
|
|||||||
finalizers(0),
|
finalizers(0),
|
||||||
tenuredFinalizers(0),
|
tenuredFinalizers(0),
|
||||||
finalizeQueue(0),
|
finalizeQueue(0),
|
||||||
|
weakReferences(0),
|
||||||
tenuredWeakReferences(0),
|
tenuredWeakReferences(0),
|
||||||
unsafe(false)
|
unsafe(false)
|
||||||
{
|
{
|
||||||
@ -998,6 +997,10 @@ objectMonitor(Thread* t, object o)
|
|||||||
object p = hashMapFind(t, t->vm->monitorMap, o, objectHash, referenceEqual);
|
object p = hashMapFind(t, t->vm->monitorMap, o, objectHash, referenceEqual);
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
|
fprintf(stderr, "found monitor %p for object 0x%x\n",
|
||||||
|
static_cast<System::Monitor*>(pointerValue(t, p)),
|
||||||
|
objectHash(t, o));
|
||||||
|
|
||||||
return static_cast<System::Monitor*>(pointerValue(t, p));
|
return static_cast<System::Monitor*>(pointerValue(t, p));
|
||||||
} else {
|
} else {
|
||||||
PROTECT(t, o);
|
PROTECT(t, o);
|
||||||
@ -1011,7 +1014,13 @@ objectMonitor(Thread* t, object o)
|
|||||||
p = makePointer(t, m);
|
p = makePointer(t, m);
|
||||||
PROTECT(t, p);
|
PROTECT(t, p);
|
||||||
|
|
||||||
object wr = makeWeakReference(t, o, 0);
|
object wr = makeWeakReference(t, o, t->vm->weakReferences);
|
||||||
|
t->vm->weakReferences = wr;
|
||||||
|
|
||||||
|
fprintf(stderr, "made monitor %p for object 0x%x\n",
|
||||||
|
m,
|
||||||
|
objectHash(t, o));
|
||||||
|
fprintf(stderr, "new wr: %p\n", wr);
|
||||||
|
|
||||||
hashMapInsert(t, t->vm->monitorMap, wr, p, referenceHash);
|
hashMapInsert(t, t->vm->monitorMap, wr, p, referenceHash);
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ namespace vm {
|
|||||||
|
|
||||||
const bool Verbose = false;
|
const bool Verbose = false;
|
||||||
const bool Debug = false;
|
const bool Debug = false;
|
||||||
const bool DebugRun = true;
|
const bool DebugRun = false;
|
||||||
const bool DebugStack = true;
|
const bool DebugStack = false;
|
||||||
|
|
||||||
const uintptr_t HashTakenMark = 1;
|
const uintptr_t HashTakenMark = 1;
|
||||||
const uintptr_t ExtendedMark = 2;
|
const uintptr_t ExtendedMark = 2;
|
||||||
@ -1644,13 +1644,6 @@ hash(const int8_t* s, unsigned length)
|
|||||||
inline unsigned
|
inline unsigned
|
||||||
baseSize(Thread* t, object o, object class_)
|
baseSize(Thread* t, object o, object class_)
|
||||||
{
|
{
|
||||||
if (classArrayElementSize(t, class_)) {
|
|
||||||
noop();
|
|
||||||
if (cast<uintptr_t>(o, classFixedSize(t, class_) - BytesPerWord)) {
|
|
||||||
noop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return divide(classFixedSize(t, class_), BytesPerWord)
|
return divide(classFixedSize(t, class_), BytesPerWord)
|
||||||
+ divide(classArrayElementSize(t, class_)
|
+ divide(classArrayElementSize(t, class_)
|
||||||
* cast<uintptr_t>(o, classFixedSize(t, class_) - BytesPerWord),
|
* cast<uintptr_t>(o, classFixedSize(t, class_) - BytesPerWord),
|
||||||
|
Loading…
Reference in New Issue
Block a user