RFR: 8350983: JShell LocalExecutionControl only needs stopCheck() on backward branches [v3]

Archie Cobbs acobbs at openjdk.org
Tue Apr 22 18:19:08 UTC 2025


On Tue, 22 Apr 2025 14:17:57 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> JShell's `LocalExecutionControl` ensures a running eval thread can be stopped by `JShell.stop()` by inserting an invocation of `stopCheck()` at every branch point in the bytecode of loaded classfiles.
>> 
>> However, this same guarantee can be provided by invoking `stopCheck()` only at backward branches and not at forward branches. By doing this, the performance and size impact on the executing code can be reduced.
>> 
>> Fortunately the new ClassFile API makes this kind of modification easy 👍
>
> Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Style improvements based on review comments.

Thinking about this more, there really should also be a `stopCheck()` added at the start of each method. This would then make it impossible to delay when a snippet notices a stop request for an arbitrarily long amount of time.

We are not trying to turn JShell into true container here, but this basic guard against foot-shooting is an easy one to implement and closes the last remaining loophole in this basic "infinite loop" prevention.

I've created [JDK-8355323](https://bugs.openjdk.org/browse/JDK-8355323) to track it.

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

PR Comment: https://git.openjdk.org/jdk/pull/23850#issuecomment-2822115204


More information about the kulla-dev mailing list