mirror of
https://github.com/corda/corda.git
synced 2025-01-31 16:35:43 +00:00
initial sketch of singleton support
This commit is contained in:
parent
d3592f2dbd
commit
80775f6cf8
@ -2886,13 +2886,13 @@ class MyProcessor: public Processor {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void*
|
virtual object
|
||||||
methodStub(vm::Thread*)
|
methodStub(vm::Thread*)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void*
|
virtual object
|
||||||
nativeInvoker(vm::Thread*)
|
nativeInvoker(vm::Thread*)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -142,37 +142,15 @@ visitRoots(Thread* t, Heap::Visitor* v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
walk(Thread* t, object o, Heap::Walker* w)
|
walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize,
|
||||||
|
unsigned arrayElementSize, unsigned arrayLength)
|
||||||
{
|
{
|
||||||
object class_ = static_cast<object>(t->m->heap->follow(objectClass(t, o)));
|
|
||||||
object objectMask = static_cast<object>
|
|
||||||
(t->m->heap->follow(classObjectMask(t, class_)));
|
|
||||||
|
|
||||||
if (objectMask) {
|
|
||||||
// fprintf(stderr, "p: %p; class: %p; mask: %p; mask length: %d\n",
|
|
||||||
// p, class_, objectMask, intArrayLength(t, objectMask));
|
|
||||||
|
|
||||||
unsigned fixedSize = classFixedSize(t, class_);
|
|
||||||
unsigned arrayElementSize = classArrayElementSize(t, class_);
|
|
||||||
unsigned arrayLength
|
|
||||||
= (arrayElementSize ?
|
|
||||||
cast<uintptr_t>(o, fixedSize - BytesPerWord) : 0);
|
|
||||||
|
|
||||||
int mask[intArrayLength(t, objectMask)];
|
|
||||||
memcpy(mask, &intArrayBody(t, objectMask, 0),
|
|
||||||
intArrayLength(t, objectMask) * 4);
|
|
||||||
|
|
||||||
// fprintf
|
|
||||||
// (stderr,
|
|
||||||
// "fixed size: %d; array length: %d; element size: %d; mask: %x\n",
|
|
||||||
// fixedSize, arrayLength, arrayElementSize, mask[0]);
|
|
||||||
|
|
||||||
unsigned fixedSizeInWords = ceiling(fixedSize, BytesPerWord);
|
unsigned fixedSizeInWords = ceiling(fixedSize, BytesPerWord);
|
||||||
unsigned arrayElementSizeInWords
|
unsigned arrayElementSizeInWords
|
||||||
= ceiling(arrayElementSize, BytesPerWord);
|
= ceiling(arrayElementSize, BytesPerWord);
|
||||||
|
|
||||||
for (unsigned i = 0; i < fixedSizeInWords; ++i) {
|
for (unsigned i = 0; i < fixedSizeInWords; ++i) {
|
||||||
if (mask[i / 32] & (static_cast<uintptr_t>(1) << (i % 32))) {
|
if (mask[i / 32] & (static_cast<uint32_t>(1) << (i % 32))) {
|
||||||
if (not w->visit(i)) {
|
if (not w->visit(i)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -182,7 +160,7 @@ walk(Thread* t, object o, Heap::Walker* w)
|
|||||||
bool arrayObjectElements = false;
|
bool arrayObjectElements = false;
|
||||||
for (unsigned j = 0; j < arrayElementSizeInWords; ++j) {
|
for (unsigned j = 0; j < arrayElementSizeInWords; ++j) {
|
||||||
unsigned k = fixedSizeInWords + j;
|
unsigned k = fixedSizeInWords + j;
|
||||||
if (mask[k / 32] & (static_cast<uintptr_t>(1) << (k % 32))) {
|
if (mask[k / 32] & (static_cast<uint32_t>(1) << (k % 32))) {
|
||||||
arrayObjectElements = true;
|
arrayObjectElements = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -192,7 +170,7 @@ walk(Thread* t, object o, Heap::Walker* w)
|
|||||||
for (unsigned i = 0; i < arrayLength; ++i) {
|
for (unsigned i = 0; i < arrayLength; ++i) {
|
||||||
for (unsigned j = 0; j < arrayElementSizeInWords; ++j) {
|
for (unsigned j = 0; j < arrayElementSizeInWords; ++j) {
|
||||||
unsigned k = fixedSizeInWords + j;
|
unsigned k = fixedSizeInWords + j;
|
||||||
if (mask[k / 32] & (static_cast<uintptr_t>(1) << (k % 32))) {
|
if (mask[k / 32] & (static_cast<uint32_t>(1) << (k % 32))) {
|
||||||
if (not w->visit
|
if (not w->visit
|
||||||
(fixedSizeInWords + (i * arrayElementSizeInWords) + j))
|
(fixedSizeInWords + (i * arrayElementSizeInWords) + j))
|
||||||
{
|
{
|
||||||
@ -202,6 +180,30 @@ walk(Thread* t, object o, Heap::Walker* w)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
walk(Thread* t, Heap::Walker* w, object o)
|
||||||
|
{
|
||||||
|
object class_ = static_cast<object>(t->m->heap->follow(objectClass(t, o)));
|
||||||
|
object objectMask = static_cast<object>
|
||||||
|
(t->m->heap->follow(classObjectMask(t, class_)));
|
||||||
|
|
||||||
|
if (objectMask) {
|
||||||
|
unsigned fixedSize = classFixedSize(t, class_);
|
||||||
|
unsigned arrayElementSize = classArrayElementSize(t, class_);
|
||||||
|
unsigned arrayLength
|
||||||
|
= (arrayElementSize ?
|
||||||
|
cast<uintptr_t>(o, fixedSize - BytesPerWord) : 0);
|
||||||
|
|
||||||
|
uint32_t mask[intArrayLength(t, objectMask)];
|
||||||
|
memcpy(mask, &intArrayBody(t, objectMask, 0),
|
||||||
|
intArrayLength(t, objectMask) * 4);
|
||||||
|
|
||||||
|
walk(t, w, mask, fixedSize, arrayElementSize, arrayLength);
|
||||||
|
// } else if (classVmFlags(t, class_) & SingletonFlag) {
|
||||||
|
// unsigned length = singletonLength(t, o);
|
||||||
|
// walk(t, w, mask, fixedSize, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
w->visit(0);
|
w->visit(0);
|
||||||
}
|
}
|
||||||
@ -1116,11 +1118,11 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
unsigned parameterFootprint = t->m->processor->parameterFootprint
|
unsigned parameterFootprint = t->m->processor->parameterFootprint
|
||||||
(t, specString, flags & ACC_STATIC);
|
(t, specString, flags & ACC_STATIC);
|
||||||
|
|
||||||
Compiled* compiled;
|
object compiled;
|
||||||
if (flags & ACC_NATIVE) {
|
if (flags & ACC_NATIVE) {
|
||||||
compiled = static_cast<Compiled*>(t->m->processor->nativeInvoker(t));
|
compiled = t->m->processor->nativeInvoker(t);
|
||||||
} else {
|
} else {
|
||||||
compiled = static_cast<Compiled*>(t->m->processor->methodStub(t));
|
compiled = t->m->processor->methodStub(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
object method = makeMethod(t,
|
object method = makeMethod(t,
|
||||||
@ -1134,7 +1136,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
arrayBody(t, pool, spec - 1),
|
arrayBody(t, pool, spec - 1),
|
||||||
class_,
|
class_,
|
||||||
code,
|
code,
|
||||||
reinterpret_cast<uint64_t>(compiled));
|
compiled);
|
||||||
PROTECT(t, method);
|
PROTECT(t, method);
|
||||||
|
|
||||||
if (flags & ACC_STATIC) {
|
if (flags & ACC_STATIC) {
|
||||||
@ -1511,7 +1513,7 @@ class HeapClient: public Heap::Client {
|
|||||||
|
|
||||||
virtual void walk(void* p, Heap::Walker* w) {
|
virtual void walk(void* p, Heap::Walker* w) {
|
||||||
object o = static_cast<object>(m->heap->follow(mask(p)));
|
object o = static_cast<object>(m->heap->follow(mask(p)));
|
||||||
::walk(m->rootThread, o, w);
|
::walk(m->rootThread, w, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void dispose() {
|
virtual void dispose() {
|
||||||
|
@ -14,10 +14,10 @@ class Processor {
|
|||||||
virtual Thread*
|
virtual Thread*
|
||||||
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
|
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
|
||||||
|
|
||||||
virtual void*
|
virtual object
|
||||||
methodStub(Thread* t) = 0;
|
methodStub(Thread* t) = 0;
|
||||||
|
|
||||||
virtual void*
|
virtual object
|
||||||
nativeInvoker(Thread* t) = 0;
|
nativeInvoker(Thread* t) = 0;
|
||||||
|
|
||||||
virtual unsigned
|
virtual unsigned
|
||||||
|
Loading…
x
Reference in New Issue
Block a user