mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
various bugfixes
This commit is contained in:
parent
cd2c1a2836
commit
f0bc4dbe76
54
src/vm.cpp
54
src/vm.cpp
@ -747,7 +747,7 @@ inline object
|
|||||||
make(Thread* t, object class_)
|
make(Thread* t, object class_)
|
||||||
{
|
{
|
||||||
PROTECT(t, class_);
|
PROTECT(t, class_);
|
||||||
unsigned sizeInBytes = classFixedSize(t, class_);
|
unsigned sizeInBytes = pad(classFixedSize(t, class_));
|
||||||
object instance = allocate(t, sizeInBytes);
|
object instance = allocate(t, sizeInBytes);
|
||||||
*static_cast<object*>(instance) = class_;
|
*static_cast<object*>(instance) = class_;
|
||||||
memset(static_cast<object*>(instance) + sizeof(object), 0,
|
memset(static_cast<object*>(instance) + sizeof(object), 0,
|
||||||
@ -923,6 +923,8 @@ fieldCode(Thread* t, unsigned javaCode)
|
|||||||
return LongField;
|
return LongField;
|
||||||
case 'S':
|
case 'S':
|
||||||
return ShortField;
|
return ShortField;
|
||||||
|
case 'V':
|
||||||
|
return VoidField;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
return BooleanField;
|
return BooleanField;
|
||||||
case 'L':
|
case 'L':
|
||||||
@ -987,18 +989,20 @@ unsigned
|
|||||||
primitiveSize(Thread* t, unsigned code)
|
primitiveSize(Thread* t, unsigned code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case VoidField:
|
||||||
|
return 0;
|
||||||
case ByteField:
|
case ByteField:
|
||||||
case BooleanField:
|
case BooleanField:
|
||||||
return 1;
|
return 1;
|
||||||
case CharField:
|
case CharField:
|
||||||
case ShortField:
|
case ShortField:
|
||||||
return 2;
|
return 2;
|
||||||
case DoubleField:
|
|
||||||
case LongField:
|
|
||||||
return 8;
|
|
||||||
case FloatField:
|
case FloatField:
|
||||||
case IntField:
|
case IntField:
|
||||||
return 4;
|
return 4;
|
||||||
|
case DoubleField:
|
||||||
|
case LongField:
|
||||||
|
return 8;
|
||||||
|
|
||||||
default: abort(t);
|
default: abort(t);
|
||||||
}
|
}
|
||||||
@ -1994,9 +1998,14 @@ resolveNativeMethodData(Thread* t, object method)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (LIKELY(data)) {
|
||||||
set(t, methodCode(t, method), data);
|
set(t, methodCode(t, method), data);
|
||||||
|
} else {
|
||||||
|
object message = makeString
|
||||||
|
(t, "%s", &byteArrayBody(t, methodCode(t, method), 0));
|
||||||
|
t->exception = makeUnsatisfiedLinkError(t, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} else {
|
} else {
|
||||||
return methodCode(t, method);
|
return methodCode(t, method);
|
||||||
@ -2007,13 +2016,7 @@ inline object
|
|||||||
invokeNative(Thread* t, object method)
|
invokeNative(Thread* t, object method)
|
||||||
{
|
{
|
||||||
object data = resolveNativeMethodData(t, method);
|
object data = resolveNativeMethodData(t, method);
|
||||||
if (UNLIKELY(data == 0)) {
|
if (UNLIKELY(t->exception)) {
|
||||||
object message = makeString
|
|
||||||
(t, "%s.%s:%s",
|
|
||||||
&byteArrayBody(t, className(t, methodClass(t, method)), 0),
|
|
||||||
&byteArrayBody(t, methodName(t, method), 0),
|
|
||||||
&byteArrayBody(t, methodSpec(t, method), 0));
|
|
||||||
t->exception = makeUnsatisfiedLinkError(t, message);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2212,7 +2215,9 @@ Machine::dispose()
|
|||||||
stateLock->dispose();
|
stateLock->dispose();
|
||||||
heapLock->dispose();
|
heapLock->dispose();
|
||||||
classLock->dispose();
|
classLock->dispose();
|
||||||
|
if (libraries) {
|
||||||
libraries->dispose();
|
libraries->dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (rootThread) {
|
if (rootThread) {
|
||||||
rootThread->dispose();
|
rootThread->dispose();
|
||||||
@ -2267,7 +2272,7 @@ Thread::Thread(Machine* m):
|
|||||||
} builtins[] = {
|
} builtins[] = {
|
||||||
{ "Java_java_lang_Object_toString",
|
{ "Java_java_lang_Object_toString",
|
||||||
reinterpret_cast<void*>(builtinToString) },
|
reinterpret_cast<void*>(builtinToString) },
|
||||||
{ "Java_java_lang_System_load",
|
{ "Java_java_lang_System_loadLibrary",
|
||||||
reinterpret_cast<void*>(builtinLoadLibrary) },
|
reinterpret_cast<void*>(builtinLoadLibrary) },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
@ -3640,13 +3645,6 @@ run(Thread* t)
|
|||||||
unsigned parameterCount = methodParameterCount(t, code);
|
unsigned parameterCount = methodParameterCount(t, code);
|
||||||
unsigned base = sp - parameterCount;
|
unsigned base = sp - parameterCount;
|
||||||
|
|
||||||
if (UNLIKELY(codeMaxStack(t, methodCode(t, code)) + base
|
|
||||||
> Thread::StackSizeInWords))
|
|
||||||
{
|
|
||||||
exception = makeStackOverflowError(t);
|
|
||||||
goto throw_;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (methodFlags(t, code) & ACC_NATIVE) {
|
if (methodFlags(t, code) & ACC_NATIVE) {
|
||||||
object r = invokeNative(t, code);
|
object r = invokeNative(t, code);
|
||||||
|
|
||||||
@ -3659,6 +3657,13 @@ run(Thread* t)
|
|||||||
push(t, r);
|
push(t, r);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (UNLIKELY(codeMaxStack(t, methodCode(t, code)) + base
|
||||||
|
> Thread::StackSizeInWords))
|
||||||
|
{
|
||||||
|
exception = makeStackOverflowError(t);
|
||||||
|
goto throw_;
|
||||||
|
}
|
||||||
|
|
||||||
frameIp(t, frame) = ip;
|
frameIp(t, frame) = ip;
|
||||||
ip = 0;
|
ip = 0;
|
||||||
|
|
||||||
@ -3666,11 +3671,15 @@ run(Thread* t)
|
|||||||
codeMaxLocals(t, methodCode(t, code)), false);
|
codeMaxLocals(t, methodCode(t, code)), false);
|
||||||
code = methodCode(t, code);
|
code = methodCode(t, code);
|
||||||
|
|
||||||
|
if (parameterCount) {
|
||||||
memcpy(&frameLocals(t, frame, 0), stack + base,
|
memcpy(&frameLocals(t, frame, 0), stack + base,
|
||||||
parameterCount * BytesPerWord);
|
parameterCount * BytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameLength(t, frame) - parameterCount) {
|
||||||
memset(&frameLocals(t, frame, 0) + parameterCount, 0,
|
memset(&frameLocals(t, frame, 0) + parameterCount, 0,
|
||||||
(frameLength(t, frame) - parameterCount) * BytesPerWord);
|
(frameLength(t, frame) - parameterCount) * BytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
sp = base;
|
sp = base;
|
||||||
}
|
}
|
||||||
@ -3725,7 +3734,10 @@ run(Thread* t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; p; p = traceNext(t, p)) {
|
for (; p; p = traceNext(t, p)) {
|
||||||
fprintf(stderr, " at %s\n", &byteArrayBody
|
fprintf(stderr, " at %s:%s\n",
|
||||||
|
&byteArrayBody
|
||||||
|
(t, className(t, methodClass(t, traceMethod(t, p))), 0),
|
||||||
|
&byteArrayBody
|
||||||
(t, methodName(t, traceMethod(t, p)), 0));
|
(t, methodName(t, traceMethod(t, p)), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user