Skip to content

Commit 6a208f7

Browse files
committed
Resolved review comments.
1 parent 4ce9c20 commit 6a208f7

File tree

36 files changed

+218
-221
lines changed

36 files changed

+218
-221
lines changed

espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/nodes/interop/ToReference.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ public StaticObject doForeignNull(Object value,
656656
@Specialization(guards = {
657657
"interop.hasIterator(value)",
658658
"interop.hasMetaObject(value)",
659-
"interop.hasHostObject(value)",
659+
"interop.isHostObject(value)",
660660
"!isStaticObject(value)"
661661
})
662662
@SuppressWarnings("truffle-static-method")
@@ -734,7 +734,7 @@ public StaticObject doForeignNull(Object value,
734734
@Specialization(guards = {
735735
"interop.hasIterator(value)",
736736
"interop.hasMetaObject(value)",
737-
"interop.hasHostObject(value)",
737+
"interop.isHostObject(value)",
738738
"!isStaticObject(value)"
739739
})
740740
@SuppressWarnings("truffle-static-method")
@@ -812,7 +812,7 @@ public StaticObject doForeignNull(Object value,
812812
@Specialization(guards = {
813813
"interop.isIterator(value)",
814814
"interop.hasMetaObject(value)",
815-
"interop.hasHostObject(value)",
815+
"interop.isHostObject(value)",
816816
"!isStaticObject(value)"
817817
})
818818
@SuppressWarnings("truffle-static-method")
@@ -890,7 +890,7 @@ public StaticObject doForeignNull(Object value,
890890
@Specialization(guards = {
891891
"interop.hasHashEntries(value)",
892892
"interop.hasMetaObject(value)",
893-
"interop.hasHostObject(value)",
893+
"interop.isHostObject(value)",
894894
"!isStaticObject(value)"
895895
})
896896
@SuppressWarnings("truffle-static-method")
@@ -966,7 +966,7 @@ public StaticObject doForeignNull(Object value,
966966

967967
@Specialization(guards = {
968968
"interop.hasMetaObject(value)",
969-
"interop.hasHostObject(value)",
969+
"interop.isHostObject(value)",
970970
"!isStaticObject(value)"
971971
})
972972
@SuppressWarnings("truffle-static-method")
@@ -1715,7 +1715,7 @@ public StaticObject doEspresso(StaticObject value,
17151715
@Specialization(guards = {
17161716
"!isStaticObject(value)",
17171717
"!interop.isNull(value)",
1718-
"interop.hasHostObject(value)"
1718+
"interop.isHostObject(value)"
17191719
})
17201720
StaticObject doForeignInterface(Object value,
17211721
@Bind Node node,
@@ -1780,7 +1780,7 @@ public StaticObject doEspresso(StaticObject value,
17801780
@Specialization(guards = {
17811781
"!isStaticObject(value)",
17821782
"!interop.isNull(value)",
1783-
"interop.hasHostObject(value)"
1783+
"interop.isHostObject(value)"
17841784
})
17851785
StaticObject doForeignConverter(Object value,
17861786
@Bind Node node,
@@ -1855,7 +1855,7 @@ public StaticObject doEspresso(StaticObject value,
18551855
@Specialization(guards = {
18561856
"!isStaticObject(value)",
18571857
"!interop.isNull(value)",
1858-
"interop.hasHostObject(value)"
1858+
"interop.isHostObject(value)"
18591859
})
18601860
StaticObject doForeignInternalConverter(Object value,
18611861
@Bind Node node,

sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/Value.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,6 @@ public boolean removeMember(String identifier) {
10121012
* Returns {@code true} if this value provides a {@linkplain #getStaticReceiver() static
10131013
* receiver}. A static receiver represents the static or class-level members associated with
10141014
* this value's type, such as static fields or methods.
1015-
* <p>
1016-
* This method may only return {@code true} if {@link #hasMembers()} also returns {@code true}.
10171015
*
10181016
* @throws IllegalStateException if the context is already {@linkplain Context#close() closed}
10191017
* @throws PolyglotException if a guest language error occurs during execution
@@ -1033,14 +1031,15 @@ public boolean hasStaticReceiver() {
10331031
* {@link #getMember(String)}, {@link #getMemberKeys()}, or
10341032
* {@link #invokeMember(String, Object...)}.
10351033
* <p>
1036-
* When this value {@linkplain #hasMembers() has members}, its static receiver is also expected
1037-
* to provide (static) members and/or declared members representing the value's static context.
1034+
* The returned static receiver is always expected to provide {@link #hasMembers() members},
1035+
* representing the receiver's static context.
10381036
* <p>
10391037
* <b>Examples:</b>
10401038
* <ul>
10411039
* <li>For a Java class instance, the static receiver exposes the class's static fields and
10421040
* methods.</li>
1043-
* <li>For a Python object, the static receiver exposes class-level attributes and methods.</li>
1041+
* <li>For a Python object, the static receiver exposes class-level attributes and methods,
1042+
* effectively corresponding to the members provided by the Python metaobject.</li>
10441043
* </ul>
10451044
*
10461045
* @throws UnsupportedOperationException if and only if this value does not

sulong/tests/com.oracle.truffle.llvm.tests.interop/src/com/oracle/truffle/llvm/tests/interop/PolyglotBuiltinTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ public void testHostInterop(@Inject(TestHostInteropNode.class) CallTarget testHo
168168
Object ret = testHostInterop.call();
169169

170170
InteropLibrary interop = InteropLibrary.getUncached(ret);
171-
Assert.assertTrue("hasHostObject", interop.hasHostObject(ret));
172-
Assert.assertSame("ret", BigInteger.class, interop.getHostObject(ret));
171+
Assert.assertTrue("isHostObject", interop.isHostObject(ret));
172+
Assert.assertSame("ret", BigInteger.class, interop.asHostObject(ret));
173173
}
174174

175175
public static class TestEvalNoLang extends SulongTestNode {

truffle/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ This changelog summarizes major changes between Truffle versions relevant to lan
3939
* GR-70086 Deprecated `Message.resolve(Class<?>, String)`. Use `Message.resolveExact(Class<?>, String, Class<?>...)` with argument types instead. This deprecation was necessary as library messages are no longer unique by message name, if the previous message was deprecated.
4040
* GR-71299 Improved the responsiveness of the Truffle compilation queue by refining the computation of the execution rate of compilation units in the queue.
4141
* Added `engine.TraversingQueueRateHalfLife` to allow fine-tuning of the compilation queue responsiveness.
42-
* GR-71402: Added `InteropLibrary#hasStaticReceiver` and `InteropLibrary#getStaticReceiver` returning the static receiver for given object.
4342

4443
* GR-36894: Added `DynamicObject` nodes for dealing with `DynamicObject` properties and shapes, as a more lightweight replacement for `DynamicObjectLibrary`, including:
4544
* `DynamicObject.GetNode`: gets the value of a property or a default value if absent
@@ -63,6 +62,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan
6362
* GR-71870 Truffle DSL no longer supports mixed exclusive and shared inlined caches. Sharing will now be disabled if mixing was used. To resolve the new warnings it is typically necessary to use either `@Exclusive` or `@Shared` for all caches.
6463
* GR-71887: Bytecode DSL: Added a `ClearLocal` operation for fast clearing of local values.
6564
* GR-71402: Added `InteropLibrary#hasHostObject` and `InteropLibrary#getHostObject` for accessing the Java host-object representation of a Truffle guest object. Deprecated `Env#isHostObject`, `Env#isHostException`, `Env#isHostFunction`, `Env#isHostSymbol`, `Env#asHostObject`, and `Env#asHostException` in favor of the new InteropLibrary messages.
65+
* GR-71402: Added `InteropLibrary#isHostObject` and `InteropLibrary#asHostObject` for accessing the Java host-object representation of a Truffle guest object. Deprecated `Env#isHostObject`, `Env#isHostException`, `Env#isHostFunction`, `Env#isHostSymbol`, `Env#asHostObject`, and `Env#asHostException` in favor of the new InteropLibrary messages.
6666
* GR-71402: Added `InteropLibrary#hasStaticReceiver` and `InteropLibrary#getStaticReceiver` returning the static receiver for given object.
6767

6868

truffle/src/com.oracle.truffle.api.exception/src/com/oracle/truffle/api/exception/ExceptionAccessor.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
import java.util.ListIterator;
4848
import java.util.function.Function;
4949

50-
import com.oracle.truffle.api.CompilerDirectives;
51-
5250
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
5351
import com.oracle.truffle.api.TruffleStackTrace;
5452
import com.oracle.truffle.api.TruffleStackTraceElement;
@@ -183,9 +181,9 @@ public Object getExceptionStackTrace(Object receiver, Object polyglotContext) {
183181

184182
private static Object[] mergeHostGuestFrames(Throwable throwable, List<TruffleStackTraceElement> guestStack, boolean inHost, Object polyglotEngine) {
185183
StackTraceElement[] hostStack = null;
186-
if (ACCESSOR.engineSupport().isHostException(throwable)) {
187-
Throwable original = unboxHostException(throwable);
188-
hostStack = original.getStackTrace();
184+
Throwable originalHostException;
185+
if (ACCESSOR.engineSupport().isHostException(throwable) && (originalHostException = ACCESSOR.engineSupport().asHostException(throwable)) != null) {
186+
hostStack = originalHostException.getStackTrace();
189187
} else if (throwable instanceof AbstractTruffleException) {
190188
Throwable lazyStackTrace = ((AbstractTruffleException) throwable).getLazyStackTrace();
191189
if (lazyStackTrace != null) {
@@ -245,14 +243,6 @@ public Object apply(TruffleStackTraceElement element) {
245243
return elementsList.toArray();
246244
}
247245

248-
private static Throwable unboxHostException(Throwable throwable) {
249-
try {
250-
return ACCESSOR.engineSupport().asHostException(throwable);
251-
} catch (Exception e) {
252-
throw CompilerDirectives.shouldNotReachHere(e);
253-
}
254-
}
255-
256246
private static int indexOfLastGuestToHostFrame(List<TruffleStackTraceElement> guestStack) {
257247
for (var iterator = guestStack.listIterator(guestStack.size()); iterator.hasPrevious();) {
258248
int index = iterator.previousIndex();

truffle/src/com.oracle.truffle.api.interop/snapshot.sigtest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ meth public boolean hasExceptionMessage(java.lang.Object)
5959
meth public boolean hasExceptionStackTrace(java.lang.Object)
6060
meth public boolean hasExecutableName(java.lang.Object)
6161
meth public boolean hasHashEntries(java.lang.Object)
62-
meth public boolean hasHostObject(java.lang.Object)
6362
meth public boolean hasIterator(java.lang.Object)
6463
meth public boolean hasIteratorNextElement(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
6564
meth public boolean hasLanguage(java.lang.Object)
@@ -90,6 +89,7 @@ meth public boolean isHashEntryModifiable(java.lang.Object,java.lang.Object)
9089
meth public boolean isHashEntryReadable(java.lang.Object,java.lang.Object)
9190
meth public boolean isHashEntryRemovable(java.lang.Object,java.lang.Object)
9291
meth public boolean isHashEntryWritable(java.lang.Object,java.lang.Object)
92+
meth public boolean isHostObject(java.lang.Object)
9393
meth public boolean isIdentical(java.lang.Object,java.lang.Object,com.oracle.truffle.api.interop.InteropLibrary)
9494
meth public boolean isInstantiable(java.lang.Object)
9595
meth public boolean isIterator(java.lang.Object)
@@ -131,6 +131,7 @@ meth public int identityHashCode(java.lang.Object) throws com.oracle.truffle.api
131131
meth public int readBufferInt(java.lang.Object,java.nio.ByteOrder,long) throws com.oracle.truffle.api.interop.InvalidBufferOffsetException,com.oracle.truffle.api.interop.UnsupportedMessageException
132132
meth public java.lang.Class<? extends com.oracle.truffle.api.TruffleLanguage<?>> getLanguage(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
133133
anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="25.1")
134+
meth public java.lang.Object asHostObject(java.lang.Object) throws com.oracle.truffle.api.interop.HeapIsolationException,com.oracle.truffle.api.interop.UnsupportedMessageException
134135
meth public java.lang.Object getDeclaringMetaObject(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
135136
meth public java.lang.Object getExceptionCause(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
136137
meth public java.lang.Object getExceptionMessage(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
@@ -139,7 +140,6 @@ meth public java.lang.Object getExecutableName(java.lang.Object) throws com.orac
139140
meth public java.lang.Object getHashEntriesIterator(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
140141
meth public java.lang.Object getHashKeysIterator(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
141142
meth public java.lang.Object getHashValuesIterator(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
142-
meth public java.lang.Object getHostObject(java.lang.Object) throws com.oracle.truffle.api.interop.HeapIsolationException,com.oracle.truffle.api.interop.UnsupportedMessageException
143143
meth public java.lang.Object getIterator(java.lang.Object) throws com.oracle.truffle.api.interop.UnsupportedMessageException
144144
meth public java.lang.Object getIteratorNextElement(java.lang.Object) throws com.oracle.truffle.api.interop.StopIterationException,com.oracle.truffle.api.interop.UnsupportedMessageException
145145
meth public java.lang.Object getMembers(java.lang.Object,boolean) throws com.oracle.truffle.api.interop.UnsupportedMessageException

truffle/src/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/HeapIsolationException.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* Exception thrown when a {@link TruffleObject} cannot unbox a host object because the object
4747
* resides in a foreign heap.
4848
*
49-
* @since 26.0
49+
* @since 25.1
5050
*/
5151
@SuppressWarnings("serial")
5252
public final class HeapIsolationException extends InteropException {
@@ -62,7 +62,7 @@ private HeapIsolationException(Throwable cause) {
6262
/**
6363
* {@inheritDoc}
6464
*
65-
* @since 26.0
65+
* @since 25.1
6666
*/
6767
@Override
6868
public String getMessage() {
@@ -72,12 +72,12 @@ public String getMessage() {
7272
/**
7373
* Creates a new {@link HeapIsolationException} indicating that a host object cannot be unboxed
7474
* because it was allocated in a foreign heap. For example, when
75-
* {@link InteropLibrary#getHostObject(Object)} is invoked from within a polyglot isolate.
75+
* {@link InteropLibrary#asHostObject(Object)} is invoked from within a polyglot isolate.
7676
* <p>
7777
* This factory method is intended for use in {@link CompilerDirectives#inCompiledCode()
7878
* compiled code paths}.
7979
*
80-
* @since 26.0
80+
* @since 25.1
8181
*/
8282
public static HeapIsolationException create() {
8383
return new HeapIsolationException();
@@ -86,7 +86,7 @@ public static HeapIsolationException create() {
8686
/**
8787
* Creates a new {@link HeapIsolationException} indicating that a host object cannot be unboxed
8888
* because it was allocated in a foreign heap. For example, when
89-
* {@link InteropLibrary#getHostObject(Object)} is invoked from within a polyglot isolate.
89+
* {@link InteropLibrary#asHostObject(Object)} is invoked from within a polyglot isolate.
9090
* <p>
9191
* In addition, a cause may be provided. The cause should only be set if the guest language code
9292
* caused this problem. An example for this is a language specific proxy mechanism that invokes
@@ -102,7 +102,7 @@ public static HeapIsolationException create() {
102102
* This factory method is intended for use in {@link CompilerDirectives#inCompiledCode()
103103
* compiled code paths}.
104104
*
105-
* @since 26.0
105+
* @since 25.1
106106
*/
107107
public static HeapIsolationException create(Throwable cause) {
108108
return new HeapIsolationException(cause);

0 commit comments

Comments
 (0)