mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
fix tails=true bootimage=true build
compileDirectInvoke does some magic to optimize tail calls to native methods which involves storing the return address (which we'll never actually return to, since it's a tail call) in a thread-local field so the thunk function can figure out which native method to look up at runtime. Since this address will change when the boot image is loaded, the boot image creation code needs to know about it.
This commit is contained in:
parent
98b82a9bc1
commit
d308ba93c7
@ -2770,12 +2770,13 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target, bool tailCall,
|
||||
traceFlags |= TraceElement::TailCall;
|
||||
|
||||
TraceElement* trace = frame->trace(target, traceFlags);
|
||||
Compiler::Operand* returnAddress = c->promiseConstant
|
||||
(new (frame->context->zone.allocate(sizeof(TraceElementPromise)))
|
||||
TraceElementPromise(t->m->system, trace), Compiler::AddressType);
|
||||
|
||||
Promise* returnAddressPromise = new
|
||||
(frame->context->zone.allocate(sizeof(TraceElementPromise)))
|
||||
TraceElementPromise(t->m->system, trace);
|
||||
|
||||
Compiler::Operand* result = c->stackCall
|
||||
(returnAddress,
|
||||
(c->promiseConstant(returnAddressPromise, Compiler::AddressType),
|
||||
flags,
|
||||
trace,
|
||||
rSize,
|
||||
@ -2783,7 +2784,8 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target, bool tailCall,
|
||||
methodParameterFootprint(t, target));
|
||||
|
||||
c->store
|
||||
(BytesPerWord, returnAddress, BytesPerWord, c->memory
|
||||
(BytesPerWord, frame->addressOperand(returnAddressPromise),
|
||||
BytesPerWord, c->memory
|
||||
(c->register_(t->arch->thread()), Compiler::AddressType,
|
||||
difference(&(t->tailAddress), t)));
|
||||
|
||||
@ -2832,8 +2834,10 @@ compileDirectInvoke(MyThread* t, Frame* frame, object target, bool tailCall)
|
||||
} else {
|
||||
BootContext* bc = frame->context->bootContext;
|
||||
if (bc) {
|
||||
if (methodClass(t, target) == methodClass(t, frame->context->method)
|
||||
or (not classNeedsInit(t, methodClass(t, target))))
|
||||
if ((methodClass(t, target) == methodClass(t, frame->context->method)
|
||||
or (not classNeedsInit(t, methodClass(t, target))))
|
||||
and (not (TailCalls and tailCall
|
||||
and (methodFlags(t, target) & ACC_NATIVE))))
|
||||
{
|
||||
Promise* p = new (bc->zone->allocate(sizeof(ListenPromise)))
|
||||
ListenPromise(t->m->system, bc->zone);
|
||||
|
Loading…
Reference in New Issue
Block a user