Add epoch-style interrupt support for compiled Wasm code#27
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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