Skip to content

Commit 480305e

Browse files
committed
[GR-35549] ContextSharingTest#testThreadCheck fails in polyglot isolate.
1 parent 4a13bc3 commit 480305e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/Accessor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ public abstract <T, G> Iterator<T> mergeHostGuestFrames(Object instrumentEnv, St
630630

631631
public abstract boolean isResourceLimitCancelExecution(Throwable cancelExecution);
632632

633+
public abstract boolean isPolyglotEngineException(Throwable throwable);
634+
635+
public abstract Throwable getPolyglotEngineExceptionCause(Throwable engineException);
636+
637+
public abstract RuntimeException createPolyglotEngineException(RuntimeException cause);
638+
633639
public abstract int getExitExceptionExitCode(Throwable cancelExecution);
634640

635641
public abstract SourceSection getCancelExecutionSourceLocation(Throwable cancelExecution);

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/EngineAccessor.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,21 @@ public boolean isResourceLimitCancelExecution(Throwable cancelExecution) {
14791479
return ((PolyglotEngineImpl.CancelExecution) cancelExecution).isResourceLimit();
14801480
}
14811481

1482+
@Override
1483+
public boolean isPolyglotEngineException(Throwable throwable) {
1484+
return throwable instanceof PolyglotEngineException;
1485+
}
1486+
1487+
@Override
1488+
public RuntimeException getPolyglotEngineExceptionCause(Throwable polyglotEngineException) {
1489+
return ((PolyglotEngineException) polyglotEngineException).e;
1490+
}
1491+
1492+
@Override
1493+
public RuntimeException createPolyglotEngineException(RuntimeException cause) {
1494+
return new PolyglotEngineException(cause);
1495+
}
1496+
14821497
@Override
14831498
public int getExitExceptionExitCode(Throwable exitException) {
14841499
return ((PolyglotContextImpl.ExitException) exitException).getExitCode();

truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/OtherContextGuestObject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ static <T extends Exception> RuntimeException migrateException(PolyglotContextIm
189189
} else {
190190
throw new OtherContextException(receiverContext, e, valueContext);
191191
}
192+
} else if (e instanceof PolyglotEngineException) {
193+
// [GR-35549] Truffle isolate enters the guest context as result of
194+
// delegateLibrary#send(). Exceptions thrown by enter are wrapped as
195+
// PolyglotEngineException. We need to unwrap them and throw as host exception.
196+
throw toHostException(receiverContext, e);
192197
} else {
193198
throw e;
194199
}

0 commit comments

Comments
 (0)