[aarch64-port-dev ] RFR: 8079564: aarch64: Use FP register as proper frame pointer

Edward Nevill edward.nevill at linaro.org
Tue May 12 15:41:28 UTC 2015


On Thu, 2015-05-07 at 15:39 +0100, Andrew Haley wrote:
> Please explain the changes to method handle calls.
> 

Hi,

The changes are based on the premise that SP is preserved across methodhandle calls.

This is certainly the case for any compiled code and also for any native code.

The only case in question is the c2i_adapter.

In this case SP is saved in the 'senderSP' (R13).

Here is the code that drops the stack in the c2i_adapter

  // Since all args are passed on the stack, total_args_passed *
  // Interpreter::stackElementSize is the space we need.

  int extraspace = total_args_passed * Interpreter::stackElementSize;

  __ mov(r13, sp);

  // stack is aligned, keep it that way
  extraspace = round_to(extraspace, 2*wordSize);

  if (extraspace)
    __ sub(sp, sp, extraspace);

....

It then jumps to the the interpreter with a dropped stack.

...
  __ mov(esp, sp); // Interp expects args on caller's expression stack

  __ ldr(rscratch1, Address(rmethod, in_bytes(Method::interpreter_entry_offset())));
  __ br(rscratch1);

This would create an unbalanced stack if the interpreter returned directly. But the interpreter restores SP from senderSP.

I have tested this by changing the above to

  __ mov(r13, -1024)

and running it in gdb, and I do indeed get a SEGV with SP having the value -1024.

So, all the changes to the method handle calls are to remove the special case code where it had to save/restore from rfp if it was a method handle call.

Does this answer your question?

All the best,
Ed.




More information about the aarch64-port-dev mailing list