mirror of
https://github.com/corda/corda.git
synced 2025-06-14 05:08:18 +00:00
various bugfixes
This commit is contained in:
@ -99,6 +99,21 @@ visitRoots(Thread* t, BootImage* image, HeapWalker* w, object constants)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
visitReference(Thread* t, HeapWalker* w, uintptr_t* heap, uintptr_t* map,
|
||||||
|
object r)
|
||||||
|
{
|
||||||
|
int target = w->map()->find(jreferenceTarget(t, r));
|
||||||
|
assert(t, target > 0);
|
||||||
|
|
||||||
|
int reference = w->map()->find(r);
|
||||||
|
assert(t, reference > 0);
|
||||||
|
|
||||||
|
unsigned index = reference - 1 + (JreferenceTarget / BytesPerWord);
|
||||||
|
markBit(map, index);
|
||||||
|
heap[index] = target;
|
||||||
|
}
|
||||||
|
|
||||||
HeapWalker*
|
HeapWalker*
|
||||||
makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
||||||
unsigned capacity, object constants)
|
unsigned capacity, object constants)
|
||||||
@ -161,6 +176,14 @@ makeHeapImage(Thread* t, BootImage* image, uintptr_t* heap, uintptr_t* map,
|
|||||||
HeapWalker* w = makeHeapWalker(t, &visitor);
|
HeapWalker* w = makeHeapWalker(t, &visitor);
|
||||||
visitRoots(t, image, w, constants);
|
visitRoots(t, image, w, constants);
|
||||||
|
|
||||||
|
for (object r = t->m->weakReferences; r; r = jreferenceVmNext(t, r)) {
|
||||||
|
visitReference(t, w, heap, map, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (object r = t->m->tenuredWeakReferences; r; r = jreferenceVmNext(t, r)) {
|
||||||
|
visitReference(t, w, heap, map, r);
|
||||||
|
}
|
||||||
|
|
||||||
image->heapSize = visitor.position * BytesPerWord;
|
image->heapSize = visitor.position * BytesPerWord;
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
@ -212,6 +235,9 @@ writeBootImage(Thread* t, FILE* out)
|
|||||||
(t->m->heap->allocate(heapMapSize(HeapCapacity)));
|
(t->m->heap->allocate(heapMapSize(HeapCapacity)));
|
||||||
memset(heapMap, 0, heapMapSize(HeapCapacity));
|
memset(heapMap, 0, heapMapSize(HeapCapacity));
|
||||||
|
|
||||||
|
PROTECT(t, constants);
|
||||||
|
collect(t, Heap::MajorCollection);
|
||||||
|
|
||||||
HeapWalker* heapWalker = makeHeapImage
|
HeapWalker* heapWalker = makeHeapImage
|
||||||
(t, &image, heap, heapMap, HeapCapacity, constants);
|
(t, &image, heap, heapMap, HeapCapacity, constants);
|
||||||
|
|
||||||
@ -220,11 +246,12 @@ writeBootImage(Thread* t, FILE* out)
|
|||||||
heapWalker->dispose();
|
heapWalker->dispose();
|
||||||
|
|
||||||
image.magic = BootImage::Magic;
|
image.magic = BootImage::Magic;
|
||||||
|
image.codeBase = reinterpret_cast<uintptr_t>(code);
|
||||||
|
|
||||||
if (false) {
|
fprintf(stderr, "heap size %d code size %d\n",
|
||||||
fprintf(stderr, "heap size %d code size %d\n",
|
image.heapSize, image.codeSize);
|
||||||
image.heapSize, image.codeSize);
|
|
||||||
} else {
|
if (true) {
|
||||||
fwrite(&image, sizeof(BootImage), 1, out);
|
fwrite(&image, sizeof(BootImage), 1, out);
|
||||||
|
|
||||||
fwrite(heapMap, pad(heapMapSize(image.heapSize)), 1, out);
|
fwrite(heapMap, pad(heapMapSize(image.heapSize)), 1, out);
|
||||||
|
@ -1482,10 +1482,46 @@ makeBlankObjectArray(MyThread* t, object class_, int32_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
object FORCE_ALIGN
|
object FORCE_ALIGN
|
||||||
makeBlankArray(MyThread* t, object (*constructor)(Thread*, uintptr_t, bool),
|
makeBlankArray(MyThread* t, unsigned type, int32_t length)
|
||||||
int32_t length)
|
|
||||||
{
|
{
|
||||||
if (length >= 0) {
|
if (length >= 0) {
|
||||||
|
object (*constructor)(Thread*, uintptr_t, bool);
|
||||||
|
switch (type) {
|
||||||
|
case T_BOOLEAN:
|
||||||
|
constructor = makeBooleanArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_CHAR:
|
||||||
|
constructor = makeCharArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_FLOAT:
|
||||||
|
constructor = makeFloatArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_DOUBLE:
|
||||||
|
constructor = makeDoubleArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_BYTE:
|
||||||
|
constructor = makeByteArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_SHORT:
|
||||||
|
constructor = makeShortArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_INT:
|
||||||
|
constructor = makeIntArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_LONG:
|
||||||
|
constructor = makeLongArray;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: abort(t);
|
||||||
|
}
|
||||||
|
|
||||||
return constructor(t, length, true);
|
return constructor(t, length, true);
|
||||||
} else {
|
} else {
|
||||||
object message = makeString(t, "%d", length);
|
object message = makeString(t, "%d", length);
|
||||||
@ -3272,51 +3308,13 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
|
|||||||
|
|
||||||
Compiler::Operand* length = frame->popInt();
|
Compiler::Operand* length = frame->popInt();
|
||||||
|
|
||||||
object (*constructor)(Thread*, uintptr_t, bool);
|
|
||||||
switch (type) {
|
|
||||||
case T_BOOLEAN:
|
|
||||||
constructor = makeBooleanArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_CHAR:
|
|
||||||
constructor = makeCharArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_FLOAT:
|
|
||||||
constructor = makeFloatArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_DOUBLE:
|
|
||||||
constructor = makeDoubleArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_BYTE:
|
|
||||||
constructor = makeByteArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_SHORT:
|
|
||||||
constructor = makeShortArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_INT:
|
|
||||||
constructor = makeIntArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_LONG:
|
|
||||||
constructor = makeLongArray;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: abort(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->pushObject
|
frame->pushObject
|
||||||
(c->call
|
(c->call
|
||||||
(c->constant(getThunk(t, makeBlankArrayThunk)),
|
(c->constant(getThunk(t, makeBlankArrayThunk)),
|
||||||
0,
|
0,
|
||||||
frame->trace(0, false),
|
frame->trace(0, false),
|
||||||
BytesPerWord,
|
BytesPerWord,
|
||||||
3, c->thread(), c->constant(reinterpret_cast<intptr_t>(constructor)),
|
3, c->thread(), c->constant(type), length));
|
||||||
length));
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case nop: break;
|
case nop: break;
|
||||||
@ -4693,6 +4691,7 @@ fixupCallTable(MyThread* t, object oldTable, uintptr_t oldBase,
|
|||||||
next = callNodeNext(t, p);
|
next = callNodeNext(t, p);
|
||||||
|
|
||||||
intptr_t k = (callNodeAddress(t, p) - oldBase) + newBase;
|
intptr_t k = (callNodeAddress(t, p) - oldBase) + newBase;
|
||||||
|
callNodeAddress(t, p) = k;
|
||||||
|
|
||||||
unsigned index = k & (arrayLength(t, newTable) - 1);
|
unsigned index = k & (arrayLength(t, newTable) - 1);
|
||||||
|
|
||||||
|
@ -1560,14 +1560,29 @@ boot(Thread* t, BootImage* image)
|
|||||||
if (classMethodTable(t, c)) {
|
if (classMethodTable(t, c)) {
|
||||||
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, c)); ++i) {
|
for (unsigned i = 0; i < arrayLength(t, classMethodTable(t, c)); ++i) {
|
||||||
object method = arrayBody(t, classMethodTable(t, c), i);
|
object method = arrayBody(t, classMethodTable(t, c), i);
|
||||||
methodCompiled(t, method)
|
if (methodCode(t, method)) {
|
||||||
= (methodCompiled(t, method) - image->codeBase)
|
assert(t, (methodCompiled(t, method) - image->codeBase)
|
||||||
+ reinterpret_cast<uintptr_t>(code);
|
<= image->codeSize);
|
||||||
|
|
||||||
|
methodCompiled(t, method)
|
||||||
|
= (methodCompiled(t, method) - image->codeBase)
|
||||||
|
+ reinterpret_cast<uintptr_t>(code);
|
||||||
|
|
||||||
|
// fprintf(stderr, "%p %p %s.%s%s\n",
|
||||||
|
// reinterpret_cast<uint8_t*>(methodCompiled(t, method)),
|
||||||
|
// reinterpret_cast<uint8_t*>(methodCompiled(t, method)) +
|
||||||
|
// reinterpret_cast<uintptr_t*>(methodCompiled(t, method))[-1],
|
||||||
|
// &byteArrayBody(t, className(t, methodClass(t, method)), 0),
|
||||||
|
// &byteArrayBody(t, methodName(t, method), 0),
|
||||||
|
// &byteArrayBody(t, methodSpec(t, method), 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t->m->processor->initVtable(t, c);
|
t->m->processor->initVtable(t, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t->m->bootstrapClassMap = makeHashMap(t, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user