mirror of
https://github.com/corda/corda.git
synced 2025-03-03 12:57:29 +00:00
various bugfixes to get Continuations test working
This commit is contained in:
parent
6dc6f01359
commit
8cb59c9d4c
@ -860,9 +860,8 @@ Avian_avian_Continuations_callWithCurrentContinuation(Thread* t,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_avian_Continuation_handleResult(Thread* t,
|
||||
object,
|
||||
uintptr_t* arguments)
|
||||
Avian_avian_Continuations_00024Continuation_handleResult
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
t->m->processor->feedResultToContinuation
|
||||
(t, reinterpret_cast<object>(arguments[0]),
|
||||
@ -872,9 +871,8 @@ Avian_avian_Continuation_handleResult(Thread* t,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_avian_Continuation_handleException(Thread* t,
|
||||
object,
|
||||
uintptr_t* arguments)
|
||||
Avian_avian_Continuations_00024Continuation_handleException
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
t->m->processor->feedExceptionToContinuation
|
||||
(t, reinterpret_cast<object>(arguments[0]),
|
||||
|
@ -74,7 +74,8 @@ LOCAL(vmInvoke_argumentTest):
|
||||
// call function
|
||||
call *%rsi
|
||||
|
||||
LOCAL(vmInvoke_returnAddress):
|
||||
.globl vmInvoke_returnAddress
|
||||
vmInvoke_returnAddress:
|
||||
// restore stack pointer
|
||||
movq %rbp,%rsp
|
||||
|
||||
@ -84,10 +85,10 @@ LOCAL(vmInvoke_returnAddress):
|
||||
je LOCAL(vmInvoke_exit)
|
||||
|
||||
movq CONTINUATION_LENGTH(%rcx),%rsi
|
||||
shrq $3,%rsi
|
||||
subq %rsi,%rsp
|
||||
shlq $3,%rsi
|
||||
subq %rsi,%rsp
|
||||
|
||||
movq CONTINUATION_BODY(%rcx),%rdi
|
||||
leaq CONTINUATION_BODY(%rcx),%rdi
|
||||
|
||||
movq $0,%r9
|
||||
jmp LOCAL(vmInvoke_continuationTest)
|
||||
@ -102,12 +103,13 @@ LOCAL(vmInvoke_continuationTest):
|
||||
jb LOCAL(vmInvoke_continuationLoop)
|
||||
|
||||
movq CONTINUATION_RETURN_ADDRESS_OFFSET(%rcx),%rdi
|
||||
movq LOCAL(vmInvoke_returnAddress)@GOTPCREL(%rip),%r10
|
||||
movq vmInvoke_returnAddress@GOTPCREL(%rip),%r10
|
||||
movq %r10,(%rsp,%rdi,1)
|
||||
|
||||
movq CONTINUATION_FRAME_POINTER_OFFSET(%rcx),%rdi
|
||||
movq %rbp,(%rsp,%rdi,1)
|
||||
subq %rdi,%rbp
|
||||
addq %rsp,%rdi
|
||||
movq %rdi,%rbp
|
||||
|
||||
movq CONTINUATION_NEXT(%rcx),%rdi
|
||||
movq %rdi,THREAD_CONTINUATION(%rbx)
|
||||
@ -151,13 +153,13 @@ vmCallWithContinuation:
|
||||
// %r8 : base
|
||||
// %r9 : stack
|
||||
|
||||
movq %rdi,%rdx
|
||||
movq %rdi,%rbx
|
||||
movq %r8,%rbp
|
||||
movq %r9,%rsp
|
||||
movq LOCAL(vmInvoke_returnAddress)@GOTPCREL(%rip),%r10
|
||||
movq vmInvoke_returnAddress@GOTPCREL(%rip),%r10
|
||||
movq %r10,(%rsp)
|
||||
movq %rcx,8(%rsp)
|
||||
movq %rdx,16(%rsp)
|
||||
movq %rdx,8(%rsp)
|
||||
movq %rcx,16(%rsp)
|
||||
jmp *%rsi
|
||||
|
||||
#elif defined __i386__
|
||||
|
@ -1432,7 +1432,7 @@ findUnwindTarget(MyThread* t, void** targetIp, void** targetBase,
|
||||
reinterpret_cast<uint8_t*>(t->continuation)
|
||||
+ ContinuationBody
|
||||
+ continuationReturnAddressOffset(t, t->continuation)
|
||||
-t->arch->returnAddressOffset());
|
||||
- t->arch->returnAddressOffset());
|
||||
}
|
||||
|
||||
t->continuation = continuationNext(t, t->continuation);
|
||||
@ -1467,7 +1467,8 @@ makeCurrentContinuation(MyThread* t, void** targetIp, void** targetBase,
|
||||
if (method) {
|
||||
PROTECT(t, method);
|
||||
|
||||
void** top = static_cast<void**>(stack) - t->arch->frameHeaderSize();
|
||||
void** top = static_cast<void**>(stack)
|
||||
+ t->arch->frameReturnAddressSize();
|
||||
unsigned argumentFootprint
|
||||
= t->arch->argumentFootprint(methodParameterFootprint(t, target));
|
||||
unsigned alignment = t->arch->stackAlignmentInWords();
|
||||
@ -1477,17 +1478,21 @@ makeCurrentContinuation(MyThread* t, void** targetIp, void** targetBase,
|
||||
|
||||
t->arch->nextFrame(&stack, &base);
|
||||
|
||||
void** bottom = static_cast<void**>(stack);
|
||||
void** bottom = static_cast<void**>(stack)
|
||||
+ t->arch->frameReturnAddressSize();
|
||||
unsigned frameSize = bottom - top;
|
||||
unsigned totalSize = frameSize
|
||||
+ t->arch->frameHeaderSize()
|
||||
+ t->arch->frameFooterSize()
|
||||
+ t->arch->argumentFootprint(methodParameterFootprint(t, method));
|
||||
|
||||
object c = makeContinuation
|
||||
(t, 0, method, ip,
|
||||
((frameSize + t->arch->returnAddressOffset()) * BytesPerWord),
|
||||
((frameSize + t->arch->framePointerOffset()) * BytesPerWord),
|
||||
((frameSize
|
||||
+ t->arch->returnAddressOffset()
|
||||
- t->arch->frameReturnAddressSize()) * BytesPerWord),
|
||||
((frameSize
|
||||
+ t->arch->framePointerOffset()
|
||||
- t->arch->frameReturnAddressSize()) * BytesPerWord),
|
||||
totalSize);
|
||||
|
||||
memcpy(&continuationBody(t, c, 0), top, totalSize * BytesPerWord);
|
||||
@ -1580,6 +1585,9 @@ findInterfaceMethodFromInstance(MyThread* t, object method, object instance)
|
||||
if (UNLIKELY(t->exception)) {
|
||||
unwind(t);
|
||||
} else {
|
||||
if (methodFlags(t, target) & ACC_NATIVE) {
|
||||
t->trace->nativeMethod = target;
|
||||
}
|
||||
return methodAddress(t, target);
|
||||
}
|
||||
} else {
|
||||
@ -5965,6 +5973,15 @@ class MyProcessor: public Processor {
|
||||
(t, "%s %s not found in %s", methodName, methodSpec, className);
|
||||
t->exception = makeNoSuchMethodError(t, message);
|
||||
}
|
||||
|
||||
if (LIKELY(t->exception == 0)) {
|
||||
object continuationClass = arrayBody
|
||||
(t, t->m->types, Machine::ContinuationType);
|
||||
|
||||
if (classVmFlags(t, continuationClass) & BootstrapFlag) {
|
||||
resolveClass(t, vm::className(t, continuationClass));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (LIKELY(t->exception == 0)) {
|
||||
|
@ -1313,14 +1313,7 @@ updateBootstrapClass(Thread* t, object bootstrapClass, object class_)
|
||||
expect(t, classSuper(t, bootstrapClass) == classSuper(t, class_));
|
||||
|
||||
expect(t, bootstrapClass == arrayBody(t, t->m->types, Machine::ClassType)
|
||||
or classFixedSize(t, bootstrapClass) == classFixedSize(t, class_));
|
||||
|
||||
expect(t,
|
||||
(classVmFlags(t, bootstrapClass) & ReferenceFlag)
|
||||
or (classObjectMask(t, bootstrapClass) == 0
|
||||
and classObjectMask(t, class_) == 0)
|
||||
or intArrayEqual(t, classObjectMask(t, bootstrapClass),
|
||||
classObjectMask(t, class_)));
|
||||
or classFixedSize(t, bootstrapClass) >= classFixedSize(t, class_));
|
||||
|
||||
PROTECT(t, bootstrapClass);
|
||||
PROTECT(t, class_);
|
||||
@ -1329,7 +1322,7 @@ updateBootstrapClass(Thread* t, object bootstrapClass, object class_)
|
||||
|
||||
classVmFlags(t, bootstrapClass) &= ~BootstrapFlag;
|
||||
classVmFlags(t, bootstrapClass) |= classVmFlags(t, class_);
|
||||
classFlags(t, bootstrapClass) = classFlags(t, class_);
|
||||
classFlags(t, bootstrapClass) |= classFlags(t, class_);
|
||||
|
||||
set(t, bootstrapClass, ClassSuper, classSuper(t, class_));
|
||||
set(t, bootstrapClass, ClassInterfaceTable, classInterfaceTable(t, class_));
|
||||
|
@ -1943,15 +1943,6 @@ stringEqual(Thread* t, object a, object b)
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
intArrayEqual(Thread* t, object a, object b)
|
||||
{
|
||||
return a == b or
|
||||
((intArrayLength(t, a) == intArrayLength(t, b)) and
|
||||
memcmp(&intArrayBody(t, a, 0), &intArrayBody(t, b, 0),
|
||||
intArrayLength(t, a) * 4) == 0);
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
methodHash(Thread* t, object method)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user