diff --git a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java index c3ae733c7287..c6e9e5d765e7 100644 --- a/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java +++ b/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java @@ -1857,9 +1857,16 @@ public StaticObject doEspressoException(EspressoException value) { "interop.isException(value)", "!isEspressoException(value)" }) - StaticObject doforeign(Object value, + StaticObject doForeign(Object value, @CachedLibrary(limit = "LIMIT") InteropLibrary interop, - @Bind("getContext()") EspressoContext context) { + @Cached LookupTypeConverterNode lookupTypeConverterNode, + @Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode, + @Cached ToReference.DynamicToReference converterToEspresso, + @Bind("getContext()") EspressoContext context) throws UnsupportedTypeException { + StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta()); + if (result != null) { + return result; + } return StaticObject.createForeignException(context, value, interop); } @@ -1908,9 +1915,16 @@ public StaticObject doEspressoException(EspressoException value, @Bind("getMeta( "interop.isException(value)", "!isEspressoException(value)" }) - StaticObject doforeign(Object value, + StaticObject doForeign(Object value, @CachedLibrary(limit = "LIMIT") InteropLibrary interop, - @Bind("getContext()") EspressoContext context) { + @Cached LookupTypeConverterNode lookupTypeConverterNode, + @Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode, + @Cached ToReference.DynamicToReference converterToEspresso, + @Bind("getContext()") EspressoContext context) throws UnsupportedTypeException { + StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta()); + if (result != null) { + return result; + } return StaticObject.createForeignException(context, value, interop); } @@ -1959,9 +1973,16 @@ public StaticObject doEspressoException(EspressoException value, @Bind("getMeta( "interop.isException(value)", "!isEspressoException(value)" }) - StaticObject doforeign(Object value, + StaticObject doForeign(Object value, @CachedLibrary(limit = "LIMIT") InteropLibrary interop, - @Bind("getContext()") EspressoContext context) { + @Bind("getContext()") EspressoContext context, + @Cached LookupTypeConverterNode lookupTypeConverterNode, + @Cached LookupInternalTypeConverterNode lookupInternalTypeConverterNode, + @Cached ToReference.DynamicToReference converterToEspresso) throws UnsupportedTypeException { + StaticObject result = ToReference.tryConverterForUnknownTarget(value, interop, lookupTypeConverterNode, lookupInternalTypeConverterNode, converterToEspresso, context.getMeta()); + if (result != null) { + return result; + } return StaticObject.createForeignException(context, value, interop); }