Skip to content

Add epoch-style interrupt support for compiled Wasm code#27

Merged
andreaTP merged 4 commits into
roastedroot:mainfrom
andreaTP:interrupt-support
May 5, 2026
Merged

Add epoch-style interrupt support for compiled Wasm code#27
andreaTP merged 4 commits into
roastedroot:mainfrom
andreaTP:interrupt-support

Conversation

@andreaTP
Copy link
Copy Markdown
Contributor

Needs review.

Follow up from discussion on dylibso/chicory#1284

Compiled native code now checks an interrupt flag in ctxBuffer at function prologues and loop headers, allowing long-running Wasm execution to be interrupted from another thread via requestInterrupt(). The pre-call path also checks Thread.interrupted() for compatibility.

cc. @wendigo

andreaTP and others added 2 commits April 29, 2026 15:40
Compiled native code now checks an interrupt flag in ctxBuffer at
function prologues and loop headers, allowing long-running Wasm
execution to be interrupted from another thread via requestInterrupt().
The pre-call path also checks Thread.interrupted() for compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Runnable constructor params in RedlineInstance with an
Interruptable interface that factories implement. RedlineInstance
delegates via instanceof — no constructor pollution.

Add a watchdog thread in call() that polls Thread.isInterrupted()
and bridges it to the ctxBuffer flag, so standard Thread.interrupt()
works during native execution. Tests now use only Thread.interrupt()
matching Chicory's InterruptionTest pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
andreaTP and others added 2 commits April 30, 2026 17:27
Use JNI-backed MemoryIO (getCheckedInstance) for interrupt flag writes
in JffiNativeMachine. On Java 11, JFFI defaults to Unsafe.putLong which
doesn't reliably propagate cross-thread to compiled native code. The
checked instance uses Foreign.putLong (JNI native call) which matches
the code path that works on Java 25.

Also add Thread.interrupted() checks in all upcall paths (trampoline,
import dispatch, memory grow) in both backends, bridging Thread.interrupt()
to the ctxBuffer flag whenever native code upcalls to Java.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The setup-java cache: maven on the Java 11 step was restoring old
999-SNAPSHOT artifacts over the freshly built ones from the Java 25
compile step, causing NoClassDefFoundError and JVM crashes from stale
class files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@andreaTP andreaTP marked this pull request as ready for review May 5, 2026 10:51
@andreaTP andreaTP merged commit bf9784d into roastedroot:main May 5, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant