Skip to content

Commit 97876cd

Browse files
committed
[GR-21700] [GR-21972] Add metaobject to TCK; Improve value asserts in TCK and some fixes.
PullRequest: graal/5642
2 parents 6ff944a + d09ed1b commit 97876cd

File tree

40 files changed

+787
-590
lines changed

40 files changed

+787
-590
lines changed

compiler/mx.compiler/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@
18491849
"org.graalvm.compiler.truffle.runtime",
18501850
"org.graalvm.compiler.core.test",
18511851
"truffle:TRUFFLE_SL_TEST",
1852-
"truffle:TRUFFLE_INSTRUMENT_TEST",
1852+
"truffle:TRUFFLE_TEST",
18531853
],
18541854
"annotationProcessors" : [
18551855
"GRAAL_PROCESSOR",
@@ -2118,7 +2118,7 @@
21182118
"JVMCI_HOTSPOT",
21192119
"GRAAL",
21202120
"truffle:TRUFFLE_SL_TEST",
2121-
"truffle:TRUFFLE_INSTRUMENT_TEST",
2121+
"truffle:TRUFFLE_TEST",
21222122
],
21232123
"exclude" : [
21242124
"mx:JUNIT",

sdk/src/org.graalvm.polyglot.tck/snapshot.sigtest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ fld public final static org.graalvm.polyglot.tck.TypeDescriptor EXECUTABLE_ANY
131131
fld public final static org.graalvm.polyglot.tck.TypeDescriptor HOST_OBJECT
132132
fld public final static org.graalvm.polyglot.tck.TypeDescriptor INSTANTIABLE
133133
fld public final static org.graalvm.polyglot.tck.TypeDescriptor INSTANTIABLE_ANY
134+
fld public final static org.graalvm.polyglot.tck.TypeDescriptor META_OBJECT
134135
fld public final static org.graalvm.polyglot.tck.TypeDescriptor NATIVE_POINTER
135136
fld public final static org.graalvm.polyglot.tck.TypeDescriptor NULL
136137
fld public final static org.graalvm.polyglot.tck.TypeDescriptor NUMBER

sdk/src/org.graalvm.polyglot.tck/src/org/graalvm/polyglot/tck/TypeDescriptor.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,38 @@ public final class TypeDescriptor {
125125
/**
126126
* Type descriptor for date.
127127
*
128-
* @since 20.0.0 beta 2
128+
* @since 20.0
129129
*/
130130
public static final TypeDescriptor DATE = new TypeDescriptor(new PrimitiveImpl(PrimitiveKind.DATE));
131131

132132
/**
133133
* Type descriptor for time.
134134
*
135-
* @since 20.0.0 beta 2
135+
* @since 20.0
136136
*/
137137
public static final TypeDescriptor TIME = new TypeDescriptor(new PrimitiveImpl(PrimitiveKind.TIME));
138138

139139
/**
140140
* Type descriptor for time zone.
141141
*
142-
* @since 20.0.0 beta 2
142+
* @since 20.0
143143
*/
144144
public static final TypeDescriptor TIME_ZONE = new TypeDescriptor(new PrimitiveImpl(PrimitiveKind.TIME_ZONE));
145145

146146
/**
147147
* Type descriptor for duration.
148148
*
149-
* @since 20.0.0 beta 2
149+
* @since 20.0
150150
*/
151151
public static final TypeDescriptor DURATION = new TypeDescriptor(new PrimitiveImpl(PrimitiveKind.DURATION));
152152

153+
/**
154+
* Type descriptor for metaobjects.
155+
*
156+
* @since 20.0
157+
*/
158+
public static final TypeDescriptor META_OBJECT = new TypeDescriptor(new PrimitiveImpl(PrimitiveKind.META_OBJECT));
159+
153160
/**
154161
* Type descriptor for duration.
155162
*
@@ -226,10 +233,11 @@ public final class TypeDescriptor {
226233
*/
227234
public static final TypeDescriptor ANY = new TypeDescriptor(new UnionImpl(new HashSet<>(Arrays.asList(
228235
NOTYPE.impl, NULL.impl, BOOLEAN.impl, NUMBER.impl, STRING.impl, HOST_OBJECT.impl, NATIVE_POINTER.impl, OBJECT.impl, ARRAY.impl, EXECUTABLE_ANY.impl, INSTANTIABLE_ANY.impl,
229-
DATE.impl, TIME.impl, TIME_ZONE.impl, DURATION.impl, EXCEPTION.impl))));
236+
DATE.impl, TIME.impl, TIME_ZONE.impl, DURATION.impl, META_OBJECT.impl, EXCEPTION.impl))));
230237

231238
private static final TypeDescriptor[] PREDEFINED_TYPES = new TypeDescriptor[]{
232-
NOTYPE, NULL, BOOLEAN, NUMBER, STRING, HOST_OBJECT, DATE, TIME, TIME_ZONE, DURATION, EXCEPTION, NATIVE_POINTER, OBJECT, ARRAY, EXECUTABLE, EXECUTABLE_ANY, INSTANTIABLE,
239+
NOTYPE, NULL, BOOLEAN, NUMBER, STRING, HOST_OBJECT, DATE, TIME, TIME_ZONE, DURATION, META_OBJECT, EXCEPTION, NATIVE_POINTER, OBJECT, ARRAY, EXECUTABLE, EXECUTABLE_ANY,
240+
INSTANTIABLE,
233241
INSTANTIABLE_ANY, ANY
234242
};
235243

@@ -633,6 +641,9 @@ public static TypeDescriptor forValue(final Value value) {
633641
if (value.isDuration()) {
634642
descs.add(DURATION);
635643
}
644+
if (value.isMetaObject()) {
645+
descs.add(META_OBJECT);
646+
}
636647
if (value.isException()) {
637648
descs.add(EXCEPTION);
638649
}
@@ -697,6 +708,7 @@ private enum PrimitiveKind {
697708
TIME("time"),
698709
TIME_ZONE("timeZone"),
699710
DURATION("duration"),
711+
META_OBJECT("metaObject"),
700712
OBJECT("object"),
701713
EXCEPTION("exception");
702714

sdk/src/org.graalvm.polyglot/snapshot.sigtest

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ meth public boolean asBoolean()
438438
meth public boolean canExecute()
439439
meth public boolean canInstantiate()
440440
meth public boolean canInvokeMember(java.lang.String)
441+
meth public boolean equals(java.lang.Object)
441442
meth public boolean fitsInByte()
442443
meth public boolean fitsInDouble()
443444
meth public boolean fitsInFloat()
@@ -468,6 +469,7 @@ meth public byte asByte()
468469
meth public double asDouble()
469470
meth public float asFloat()
470471
meth public int asInt()
472+
meth public int hashCode()
471473
meth public java.lang.RuntimeException throwException()
472474
meth public java.lang.String asString()
473475
meth public java.lang.String getMetaQualifiedName()

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,29 @@ public Context getContext() {
13261326
return impl.getContext();
13271327
}
13281328

1329+
/**
1330+
* {@inheritDoc}
1331+
*
1332+
* @since 20.1
1333+
*/
1334+
@Override
1335+
public boolean equals(Object obj) {
1336+
if (!(obj instanceof Value)) {
1337+
return false;
1338+
}
1339+
return impl.equalsImpl(receiver, ((Value) obj).receiver);
1340+
}
1341+
1342+
/**
1343+
* {@inheritDoc}
1344+
*
1345+
* @since 20.1
1346+
*/
1347+
@Override
1348+
public int hashCode() {
1349+
return impl.hashCodeImpl(receiver);
1350+
}
1351+
13291352
/**
13301353
* Converts a Java host value to a polyglot value. Returns a value for any host or guest value.
13311354
* If there is a context available use {@link Context#asValue(Object)} for efficiency instead.

sdk/src/org.graalvm.polyglot/src/org/graalvm/polyglot/impl/AbstractPolyglotImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ public boolean isMetaObject(Object receiver) {
744744
public abstract String getMetaSimpleName(Object receiver);
745745

746746
public abstract boolean isMetaInstance(Object receiver, Object instance);
747+
748+
public abstract boolean equalsImpl(Object receiver, Object obj);
749+
750+
public abstract int hashCodeImpl(Object receiver);
747751
}
748752

749753
public abstract Class<?> loadLanguageClass(String className);

tools/mx.tools/suite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"sourceDirs" : ["src"],
8787
"dependencies" : [
8888
"com.oracle.truffle.tools.agentscript",
89-
"truffle:TRUFFLE_INSTRUMENT_TEST",
89+
"truffle:TRUFFLE_TEST",
9090
"mx:JUNIT"
9191
],
9292
"annotationProcessors" : ["truffle:TRUFFLE_DSL_PROCESSOR"],
@@ -115,7 +115,7 @@
115115
"sourceDirs" : ["src"],
116116
"dependencies" : [
117117
"com.oracle.truffle.tools.profiler",
118-
"truffle:TRUFFLE_INSTRUMENT_TEST",
118+
"truffle:TRUFFLE_TEST",
119119
"mx:JUNIT"
120120
],
121121
"annotationProcessors" : ["truffle:TRUFFLE_DSL_PROCESSOR"],
@@ -144,7 +144,7 @@
144144
"sourceDirs" : ["src"],
145145
"dependencies" : [
146146
"com.oracle.truffle.tools.coverage",
147-
"truffle:TRUFFLE_INSTRUMENT_TEST",
147+
"truffle:TRUFFLE_TEST",
148148
"mx:JUNIT"
149149
],
150150
"annotationProcessors" : ["truffle:TRUFFLE_DSL_PROCESSOR"],
@@ -300,7 +300,7 @@
300300
"com.oracle.truffle.tools.agentscript.test",
301301
],
302302
"distDependencies" : [
303-
"truffle:TRUFFLE_INSTRUMENT_TEST",
303+
"truffle:TRUFFLE_TEST",
304304
"AGENTSCRIPT",
305305
],
306306
"description" : "Tests for the script driven tracing and instrumentation Agent.",
@@ -335,7 +335,7 @@
335335
"com.oracle.truffle.tools.profiler.test",
336336
],
337337
"distDependencies" : [
338-
"truffle:TRUFFLE_INSTRUMENT_TEST",
338+
"truffle:TRUFFLE_TEST",
339339
"TRUFFLE_PROFILER",
340340
],
341341
"description" : "Tests for the truffle profiler.",
@@ -370,7 +370,7 @@
370370
"com.oracle.truffle.tools.coverage.test",
371371
],
372372
"distDependencies" : [
373-
"truffle:TRUFFLE_INSTRUMENT_TEST",
373+
"truffle:TRUFFLE_TEST",
374374
"TRUFFLE_COVERAGE",
375375
],
376376
"description" : "Tests for the truffle coverage tool.",

truffle/mx.truffle/suite.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
"subDir" : "src",
175175
"sourceDirs" : ["src"],
176176
"dependencies" : [
177+
"TRUFFLE_TCK_TESTS",
177178
"TRUFFLE_API",
178179
"TRUFFLE_SL",
179180
"mx:JUNIT",
@@ -194,8 +195,8 @@
194195
"subDir" : "src",
195196
"sourceDirs" : ["src"],
196197
"dependencies" : [
198+
"com.oracle.truffle.api.instrumentation.test",
197199
"TRUFFLE_API",
198-
"TRUFFLE_INSTRUMENT_TEST",
199200
"mx:JMH_1_21",
200201
],
201202
"requiresConcealed" : {
@@ -1025,25 +1026,6 @@
10251026
"maven" : False
10261027
},
10271028

1028-
"TRUFFLE_INSTRUMENT_TEST" : {
1029-
"subDir" : "src",
1030-
"javaCompliance" : "8+",
1031-
"dependencies" : [
1032-
"com.oracle.truffle.api.instrumentation.test",
1033-
],
1034-
"exclude" : ["mx:HAMCREST", "mx:JUNIT", "mx:JMH_1_21"],
1035-
"distDependencies" : [
1036-
"TRUFFLE_API",
1037-
"TRUFFLE_SL",
1038-
"TRUFFLE_TCK",
1039-
"sdk:POLYGLOT_TCK",
1040-
"TRUFFLE_DSL_PROCESSOR",
1041-
],
1042-
"description" : "Instrumentation tests including InstrumentationTestLanguage.",
1043-
"allowsJavadocWarnings": True,
1044-
"maven" : False,
1045-
},
1046-
10471029
"TRUFFLE_TEST" : {
10481030
"subDir" : "src",
10491031
"javaCompliance" : "8+",
@@ -1061,9 +1043,11 @@
10611043
"exclude" : ["mx:HAMCREST", "mx:JUNIT", "mx:JMH_1_21"],
10621044
"distDependencies" : [
10631045
"TRUFFLE_API",
1046+
"TRUFFLE_SL",
1047+
"TRUFFLE_TCK_COMMON",
1048+
"TRUFFLE_TCK_TESTS",
10641049
"TRUFFLE_NFI",
10651050
"TRUFFLE_DSL_PROCESSOR",
1066-
"TRUFFLE_INSTRUMENT_TEST",
10671051
"TRUFFLE_TEST_NATIVE",
10681052
"TRUFFLE_TCK",
10691053
],

truffle/src/com.oracle.truffle.api.library/src/com/oracle/truffle/api/library/ReflectionLibrary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ final class ReflectionLibraryDefault {
152152
static class Send {
153153

154154
@Specialization(guards = {"message == cachedMessage", "cachedLibrary.accepts(receiver)"}, limit = "LIMIT")
155-
static Object doSendCached(Object receiver, Message message, Object[] args,
155+
static Object doSendCached(Object receiver, @SuppressWarnings("unused") Message message, Object[] args,
156156
@Cached("message") Message cachedMessage,
157157
@Cached("createLibrary(message, receiver)") Library cachedLibrary) throws Exception {
158-
return message.getFactory().genericDispatch(cachedLibrary, receiver, cachedMessage, args, 0);
158+
return cachedMessage.getFactory().genericDispatch(cachedLibrary, receiver, cachedMessage, args, 0);
159159
}
160160

161161
static Library createLibrary(Message message, Object receiver) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Args = -H:Features=com.oracle.truffle.api.test.polyglot.RegisterTestClassesForReflectionFeature \
2+
-H:ReflectionConfigurationResources=com/oracle/truffle/api/test/polyglot/reflection.json \
3+
-H:DynamicProxyConfigurationResources=com/oracle/truffle/api/test/polyglot/proxys.json

0 commit comments

Comments
 (0)