Skip to content

Commit 1319571

Browse files
Automatic merge of master into galahad
2 parents 6fa75a2 + 0840d5d commit 1319571

File tree

42 files changed

+752
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+752
-243
lines changed

docs/reference-manual/native-image/ReachabilityMetadata.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,8 @@ To request a bundle from a specific module:
612612
{
613613
"resources": [
614614
{
615-
"bundle": "app.module:module.pkg.Bundle"
615+
"module": "app.module"
616+
"bundle": "your.pkg.Bundle"
616617
}
617618
]
618619
}

espresso-compiler-stub/src/com.oracle.truffle.espresso.graal/src/com/oracle/truffle/espresso/graal/DummyReplacements.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package com.oracle.truffle.espresso.graal;
2424

2525
import java.util.BitSet;
26+
import java.util.Map;
2627

2728
import jdk.graal.compiler.api.replacements.SnippetTemplateCache;
2829
import jdk.graal.compiler.bytecode.BytecodeProvider;
@@ -40,6 +41,7 @@
4041
import jdk.graal.compiler.nodes.spi.SnippetParameterInfo;
4142
import jdk.graal.compiler.options.OptionValues;
4243
import jdk.graal.compiler.phases.util.Providers;
44+
import jdk.graal.compiler.replacements.SnippetTemplate;
4345
import jdk.vm.ci.meta.JavaKind;
4446
import jdk.vm.ci.meta.ResolvedJavaMethod;
4547

@@ -70,6 +72,11 @@ public GraphBuilderConfiguration.Plugins getGraphBuilderPlugins() {
7072
throw GraalError.unimplementedOverride();
7173
}
7274

75+
@Override
76+
public Map<SnippetTemplate.CacheKey, SnippetTemplate> getTemplatesCache() {
77+
throw GraalError.unimplementedOverride();
78+
}
79+
7380
@Override
7481
public Class<? extends GraphBuilderPlugin> getIntrinsifyingPlugin(ResolvedJavaMethod method) {
7582
throw GraalError.unimplementedOverride();

espresso-shared/src/com.oracle.truffle.espresso.shared/src/com/oracle/truffle/espresso/shared/meta/TypeAccess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ default boolean isJavaLangObject() {
202202

203203
/**
204204
* Resolves a class in the runtime constant pool of this type, then returns it. Further calls to
205-
* this method with the same cpi should not trigger class loading.
205+
* this method with the same cpi should not trigger class loading. Resolution errors should not
206+
* be saved in the constant pool.
206207
*
207208
* @param cpi The constant pool index in which to find the class constant
208209
* @throws IllegalArgumentException If there is no

espresso/ci/ci.jsonnet

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
vm_guard_includes: [],
1010

1111
local espresso_compiler_stub_gate = common.eclipse + common.jdt + common.predicates(true, true, false) +
12-
# [GR-64739] move espresso JDK 21 gates to on demand
13-
# common.espresso_gate(allow_warnings=false, tags='style,fullbuild', timelimit='35:00', name='gate-espresso-compiler-stub-style-jdk21-linux-amd64', imports='/substratevm') + {
14-
common.espresso_gate(allow_warnings=false, tags='style,fullbuild', timelimit='35:00', name='ondemand-espresso-compiler-stub-style-jdk21-linux-amd64', imports='/substratevm') + {
12+
common.espresso_gate(allow_warnings=false, tags='style,fullbuild', timelimit='35:00', name='gate-espresso-compiler-stub-style-jdkLatest-linux-amd64', imports='/substratevm') + {
1513
setup+: [
1614
['cd', "../espresso-compiler-stub"],
17-
# Ensure we can build an espresso-ni standalone with native-image from the substratevm suite
18-
['set-export', 'JAVA_HOME', '$ESPRESSO_JAVA_HOME']
1915
],
2016
guard+: {
2117
includes+: [
@@ -32,9 +28,7 @@
3228
},
3329

3430
local _builds = common.builds + [
35-
# [GR-64739] move espresso JDK 21 gates to on demand
36-
# common.jdk21_gate_linux_amd64 + espresso_compiler_stub_gate,
37-
common.jdk21_on_demand_linux + espresso_compiler_stub_gate,
31+
common.jdkLatest_gate_linux_amd64 + espresso_compiler_stub_gate,
3832
common.jdkLatest_gate_linux_amd64 + espresso_shared_gate,
3933
// Benchmarks
4034
// AWFY peak perf. benchmarks

espresso/ci/ci_common/common.jsonnet

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
6565
"ESPRESSO_LLVM_JAVA_HOME": graal_common.labsjdk21LLVM.downloads["LLVM_JAVA_HOME"],
6666
},
6767
},
68+
espresso_jdkLatest_llvm: {
69+
downloads+: {
70+
"ESPRESSO_LLVM_JAVA_HOME": graal_common.labsjdkLatestLLVM.downloads["LLVM_JAVA_HOME"],
71+
},
72+
},
6873

6974
predicates(with_compiler, with_native_image, with_vm, with_espresso=true): {
7075
assert !with_native_image || with_compiler,
@@ -117,9 +122,10 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
117122
darwin_aarch64_21: self.espresso_jdk_21 + graal_common.labsjdkLatest + self.darwin_aarch64,
118123
windows_21: self.espresso_jdk_21 + graal_common.labsjdkLatest + self.windows + devkits["windows-jdk-latest"],
119124

120-
linux_amd64_latest: graal_common.labsjdkLatest + self.linux_amd64,
125+
linux_amd64_latest: graal_common.labsjdkLatest + self.espresso_jdkLatest_llvm + self.linux_amd64,
126+
linux_aarch64_latest: graal_common.labsjdkLatest + self.linux_aarch64,
121127

122-
linux_amd64_graalvm21: self.espresso_jdk_21 + graal_common.graalvmee21 + self.espresso_jdk_21_llvm + self.linux_amd64,
128+
linux_amd64_graalvm21: self.espresso_jdk_21 + graal_common.graalvmee21 + self.espresso_jdk_21_llvm + self.linux_amd64,
123129

124130

125131

@@ -163,9 +169,11 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
163169
jdk21_on_demand_bench_linux : self.onDemandBench + self.linux_amd64_21 + self.x52,
164170
jdk21_on_demand_bench_darwin : self.onDemandBench + self.darwin_amd64_21,
165171
jdk21_on_demand_bench_windows : self.onDemandBench + self.windows_21,
172+
166173
jdkLatest_gate_linux_amd64 : self.gate + self.linux_amd64_latest,
167174
jdkLatest_daily_linux_amd64 : self.daily + self.linux_amd64_latest,
168175
jdkLatest_weekly_linux_amd64 : self.weekly + self.linux_amd64_latest,
176+
jdkLatest_weekly_linux_aarch64: self.weekly + self.linux_aarch64_latest,
169177

170178
// shared snippets
171179
eclipse: graal_common.deps.eclipse,
@@ -193,8 +201,9 @@ local benchmark_suites = ['dacapo', 'renaissance', 'scala-dacapo'];
193201
run+: [
194202
['mx'] + extra_dynamic_imports_args + ['sversions'],
195203
that._mx(env, (if debug then ['--debug-images'] else []) + extra_mx_args + extra_dynamic_imports_args + ['build'] + targets_args),
196-
['set-export', 'ESPRESSO_HOME', that._mx(env, ['--quiet', '--no-warning'] + extra_mx_args + extra_dynamic_imports_args + ['path', '--output', standalone])],
197-
],
204+
] + if default_env_traget then [
205+
['set-export', 'ESPRESSO_HOME', that._mx(env, ['--quiet', '--no-warning'] + extra_mx_args + extra_dynamic_imports_args + ['path', '--output', standalone])]
206+
] else [],
198207
},
199208

200209
// LD_DEBUG=unused is a workaround for: symbol lookup error: jre/lib/amd64/libnio.so: undefined symbol: fstatat64

espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/meta/EspressoBootstrapMethodInvocation.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.List;
2828
import java.util.StringJoiner;
2929

30-
import jdk.vm.ci.common.JVMCIError;
3130
import jdk.vm.ci.meta.ConstantPool;
3231
import jdk.vm.ci.meta.JavaConstant;
3332

@@ -41,13 +40,17 @@ public final class EspressoBootstrapMethodInvocation implements ConstantPool.Boo
4140
private final String name;
4241
private final JavaConstant type;
4342
private final List<JavaConstant> staticArguments;
43+
private final int cpi;
44+
private final EspressoConstantPool constantPool;
4445

45-
EspressoBootstrapMethodInvocation(boolean indy, EspressoResolvedJavaMethod method, String name, JavaConstant type, JavaConstant[] staticArguments) {
46+
EspressoBootstrapMethodInvocation(boolean indy, EspressoResolvedJavaMethod method, String name, JavaConstant type, JavaConstant[] staticArguments, int cpi, EspressoConstantPool constantPool) {
4647
this.indy = indy;
4748
this.method = method;
4849
this.name = name;
4950
this.type = type;
5051
this.staticArguments = Collections.unmodifiableList(Arrays.asList(staticArguments));
52+
this.cpi = cpi;
53+
this.constantPool = constantPool;
5154
}
5255

5356
@Override
@@ -77,12 +80,20 @@ public List<JavaConstant> getStaticArguments() {
7780

7881
@Override
7982
public void resolve() {
80-
throw JVMCIError.unimplemented();
83+
if (isInvokeDynamic()) {
84+
constantPool.loadReferencedType(cpi, EspressoConstantPool.INVOKEDYNAMIC);
85+
} else {
86+
constantPool.lookupConstant(cpi, true);
87+
}
8188
}
8289

8390
@Override
8491
public JavaConstant lookup() {
85-
throw JVMCIError.unimplemented();
92+
if (isInvokeDynamic()) {
93+
return constantPool.lookupAppendix(cpi, EspressoConstantPool.INVOKEDYNAMIC);
94+
} else {
95+
return (JavaConstant) constantPool.lookupConstant(cpi, false);
96+
}
8697
}
8798

8899
@Override

espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/meta/EspressoConstantPool.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
import static com.oracle.truffle.espresso.jvmci.EspressoJVMCIRuntime.runtime;
2626

2727
import java.lang.invoke.MethodHandle;
28+
import java.util.ArrayList;
29+
import java.util.Collections;
2830
import java.util.List;
2931

30-
import jdk.vm.ci.common.JVMCIError;
3132
import jdk.vm.ci.meta.ConstantPool;
3233
import jdk.vm.ci.meta.JavaConstant;
3334
import jdk.vm.ci.meta.JavaField;
@@ -75,7 +76,13 @@ public void loadReferencedType(int cpi, int opcode, boolean initialize) {
7576

7677
@Override
7778
public JavaField lookupField(int cpi, ResolvedJavaMethod method, int opcode) {
78-
EspressoResolvedJavaField field = lookupResolvedField(cpi, (EspressoResolvedJavaMethod) method, opcode);
79+
EspressoResolvedJavaField field;
80+
try {
81+
field = lookupResolvedField(cpi, (EspressoResolvedJavaMethod) method, opcode);
82+
} catch (Throwable t) {
83+
// ignore errors that can happen during type resolution
84+
field = null;
85+
}
7986
if (field != null) {
8087
return field;
8188
}
@@ -90,7 +97,13 @@ public JavaField lookupField(int cpi, ResolvedJavaMethod method, int opcode) {
9097

9198
@Override
9299
public JavaMethod lookupMethod(int cpi, int opcode, ResolvedJavaMethod caller) {
93-
EspressoResolvedJavaMethod method = lookupResolvedMethod(cpi, opcode, (EspressoResolvedJavaMethod) caller);
100+
EspressoResolvedJavaMethod method;
101+
try {
102+
method = lookupResolvedMethod(cpi, opcode, (EspressoResolvedJavaMethod) caller);
103+
} catch (Throwable t) {
104+
// ignore errors that can happen during type resolution
105+
method = null;
106+
}
94107
if (method != null) {
95108
return method;
96109
}
@@ -114,11 +127,36 @@ public JavaMethod lookupMethod(int cpi, int opcode, ResolvedJavaMethod caller) {
114127
@Override
115128
public native EspressoBootstrapMethodInvocation lookupBootstrapMethodInvocation(int cpi, int opcode);
116129

130+
private native EspressoBootstrapMethodInvocation lookupIndyBootstrapMethodInvocation(int siteIndex);
131+
117132
@Override
118133
public List<BootstrapMethodInvocation> lookupBootstrapMethodInvocations(boolean invokeDynamic) {
119-
throw JVMCIError.unimplemented();
134+
List<BootstrapMethodInvocation> result;
135+
if (invokeDynamic) {
136+
int indyEntries = getNumIndyEntries();
137+
if (indyEntries == 0) {
138+
return Collections.emptyList();
139+
}
140+
result = new ArrayList<>(indyEntries);
141+
for (int i = 0; i < indyEntries; i++) {
142+
result.add(lookupIndyBootstrapMethodInvocation(i));
143+
}
144+
} else {
145+
result = new ArrayList<>();
146+
int length = length();
147+
for (int i = 0; i < length; i++) {
148+
byte tagByte = getTagByteAt(i);
149+
if (tagByte == 17) {
150+
// Dynamic
151+
result.add(lookupBootstrapMethodInvocation(i, -1));
152+
}
153+
}
154+
}
155+
return result;
120156
}
121157

158+
private native int getNumIndyEntries();
159+
122160
@Override
123161
public native JavaType lookupType(int cpi, int opcode);
124162

espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/meta/EspressoResolvedInstanceType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,11 @@ public List<ResolvedJavaMethod> getAllMethods(boolean forceLink) {
488488
if (forceLink) {
489489
link();
490490
}
491-
throw JVMCIError.unimplemented();
491+
return Arrays.asList(getAllMethods0());
492492
}
493493

494+
private native EspressoResolvedJavaMethod[] getAllMethods0();
495+
494496
@Override
495497
public native EspressoResolvedJavaMethod getClassInitializer();
496498

espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/meta/EspressoResolvedJavaMethod.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static com.oracle.truffle.espresso.jvmci.EspressoJVMCIRuntime.runtime;
2626
import static com.oracle.truffle.espresso.jvmci.meta.EspressoResolvedJavaType.NO_ANNOTATIONS;
2727
import static com.oracle.truffle.espresso.jvmci.meta.ExtendedModifiers.BRIDGE;
28+
import static com.oracle.truffle.espresso.jvmci.meta.ExtendedModifiers.SCOPED_METHOD;
2829
import static com.oracle.truffle.espresso.jvmci.meta.ExtendedModifiers.SYNTHETIC;
2930
import static com.oracle.truffle.espresso.jvmci.meta.ExtendedModifiers.VARARGS;
3031
import static java.lang.reflect.Modifier.ABSTRACT;
@@ -59,13 +60,15 @@ public final class EspressoResolvedJavaMethod implements ResolvedJavaMethod {
5960
public static final Parameter[] NO_PARAMETERS = new Parameter[0];
6061

6162
private final EspressoResolvedInstanceType holder;
63+
private final boolean poisonPill;
6264
private Executable mirrorCache;
6365
private String nameCache;
6466
private byte[] code;
6567
private EspressoSignature signature;
6668

67-
private EspressoResolvedJavaMethod(EspressoResolvedInstanceType holder) {
69+
private EspressoResolvedJavaMethod(EspressoResolvedInstanceType holder, boolean poisonPill) {
6870
this.holder = holder;
71+
this.poisonPill = poisonPill;
6972
}
7073

7174
@Override
@@ -148,7 +151,10 @@ public boolean isDefault() {
148151

149152
@Override
150153
public boolean isDeclared() {
151-
throw JVMCIError.unimplemented();
154+
if (isConstructor() || isClassInitializer()) {
155+
return false;
156+
}
157+
return !poisonPill;
152158
}
153159

154160
@Override
@@ -328,6 +334,11 @@ public Executable getMirror() {
328334

329335
public native boolean isLeafMethod();
330336

337+
@Override
338+
public boolean isScoped() {
339+
return (getFlags() & SCOPED_METHOD) != 0;
340+
}
341+
331342
@Override
332343
public boolean equals(Object o) {
333344
if (this == o) {
@@ -337,13 +348,17 @@ public boolean equals(Object o) {
337348
return false;
338349
}
339350
EspressoResolvedJavaMethod that = (EspressoResolvedJavaMethod) o;
340-
return equals0(that);
351+
return this.poisonPill == that.poisonPill && equals0(that);
341352
}
342353

343354
private native boolean equals0(EspressoResolvedJavaMethod that);
344355

345356
@Override
346-
public native int hashCode();
357+
public int hashCode() {
358+
return 13 * Boolean.hashCode(poisonPill) + hashCode0();
359+
}
360+
361+
private native int hashCode0();
347362

348363
@Override
349364
public String toString() {

espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/meta/EspressoResolvedJavaType.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,21 @@ public EspressoResolvedArrayType getArrayClass() {
5252
public abstract boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass);
5353

5454
@Override
55-
public ResolvedJavaMethod[] getDeclaredMethods() {
55+
public final ResolvedJavaMethod[] getDeclaredMethods() {
5656
return getDeclaredMethods(true);
5757
}
5858

5959
@Override
60-
public ResolvedJavaMethod[] getDeclaredConstructors() {
60+
public abstract ResolvedJavaMethod[] getDeclaredMethods(boolean forceLink);
61+
62+
@Override
63+
public final ResolvedJavaMethod[] getDeclaredConstructors() {
6164
return getDeclaredConstructors(true);
6265
}
6366

67+
@Override
68+
public abstract ResolvedJavaMethod[] getDeclaredConstructors(boolean forceLink);
69+
6470
@Override
6571
public String toString() {
6672
return getClass().getSimpleName() + "<" + getName() + ">";

0 commit comments

Comments
 (0)