On Mon, 28 Oct 2024 18:56:58 GMT, Patricio Chilano Mateo <pchilanom...@openjdk.org> wrote:
>> The issue with the c2 runtime stub on aarch64 (and riscv) is that >> cb->frame_size() doesn't match the size of the physical frame, it's short by >> 2 words. I explained the reason for that in the comment above. So for a >> regular return we don't care about last_Java_sp, rsp will point to the same >> place as before the call when we return. But when resuming for the >> preemption case, the rsp will be two words short, since when we freezed the >> runtime stub we freeze 2 words less (and we have to do that to be able to >> correctly get the sender when we walk it). >> One way to get rid of this would be to have c2 just set last_Java_pc too >> along with last_Java_sp, so we don't need to push lr to be able to do >> last_Java_sp[-1] to make the frame walkable. I guess this was a micro >> optimization. > >> Could the problem be solved with a resume adapter instead, like the >> interpreter uses? >> > It will just move the task of adjusting the size of the frame somewhere else. > One way to get rid of this would be to have c2 just set last_Java_pc too > along with last_Java_sp, so we don't need to push lr to be able to do > last_Java_sp[-1] to make the frame walkable. If that would solve the problem, then that must mean we save/freeze last_Java_pc as part of the virtual thread's state. So why can't we just call make_walkable() before we freeze, to fix things up as if C2 had stored last_Java_pc to the anchor? Then freeze could assert that the thread is already walkable. I'm surprised it doesn't already. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21565#discussion_r1819896849