RFR: 8072070: Improve interpreter stack banging

Aleksey Shipilev shade at openjdk.java.net
Fri Feb 4 16:02:13 UTC 2022


On Fri, 4 Feb 2022 13:54:02 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:

> A quick question. Why can't we just use something like the following on linux?
> 
> ```
>   __ cmpptr(rsp, Address(r15_thread, JavaThread::stack_overflow_limit_offset()));
>   __ jump_cc(Assembler::belowEqual, ExternalAddress(Interpreter::_throw_StackOverflowError_entry));
> ```
> 
> Is banging the shadow area strictly required on linux? Could be that it is needed on some OSes.

(There is a large comment in `stackOverflow.hpp` -- do you see blind spots there?)

My early patches were something like that. But the deeper I got into this, the more I realized it is safer to keep banging in order to cooperate with the rest of stack overflow machinery. For example, I am not at all sure that throwing the SOE when below `stack_overflow_limit` works well with reserved zone handling. It was probably okay when we only had the yellow+red zones.

AFAIU, the only OS that needs to bang page by page to commit stacks is Windows; got some funky GHA failures without it. But, given how the watermark code effectively bangs each part of the stack once, I don't see a reason to bother with OS-specific code here. We can keep "overbanging" on Linux, and pay little cost for it. Same with `native_call`-s.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7247


More information about the hotspot-dev mailing list