Skip to content

Commit 9cb8c91

Browse files
Add JVMCI partial implementation
Also: * Track hasDefaultMethods for classes as well. It is true if any of the interfaces (directly or indirectly) implemented by the class have default methods. * Git: ignore compilation databases. * Minor simplification of `ArrayKlass.arrayTypeChecks`. * Simplify `InterfaceTables.getITable`. * Ignore `UseJVMCICompiler` in espresso launchers. * `RuntimeConstantPool`: replace `context` & `classLoader` with `holder`. * `Methodversion.refKind` can be a byte. * Add `Meta.isSignaturePolymorphicHolderType`. * Allow hidden fields to be predicated on the language. * Remove `ContextDescription`: the version is part of the language * ModuleExtension: * Add Builder to help build ModuleExtensions * Add `autoAdd` property to automatically add the module (`--add-modules`) if it is enabled. * Add `optional` property to ignore a module if its jar is not available * Add `requiresConcealed` property to automatically add exports if the extension is enabled. * Don't add platform extensions to the boot class path * Print warning on missing required ModuleExtension jar
1 parent e754473 commit 9cb8c91

File tree

92 files changed

+8500
-216
lines changed

Some content is hidden

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

92 files changed

+8500
-216
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Use $GRAALVM/bin/native-image in the resulting GraalVM
2+
DYNAMIC_IMPORTS=/vm,/substratevm
3+
COMPONENTS=Java on Truffle,Espresso Standalone jvm.cfg,SubstrateVM,tflm,ni,sdkni,svmt,svmsl,tflc,tflsm,ecs
4+
NATIVE_IMAGES=lib:javavm
5+
DISABLE_INSTALLABLES=true
6+
DISABLE_LIBPOLYGLOT=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Use $GRAALVM/bin/native-image --vm.Dcom.oracle.svm.driver.java.executable.override=$GRAALVM/bin/espresso in the resulting GraalVM
2+
DYNAMIC_IMPORTS=/vm,/substratevm
3+
COMPONENTS=Espresso Launcher,LibGraal,Java on Truffle,SubstrateVM,Java on Truffle LLVM Java libraries,tflm,ni,sdkni,svmt,svmsl,tflc,tflsm,ecs
4+
NATIVE_IMAGES=lib:jvmcicompiler
5+
DISABLE_INSTALLABLES=true
6+
DISABLE_LIBPOLYGLOT=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#
2+
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# This code is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License version 2 only, as
7+
# published by the Free Software Foundation.
8+
#
9+
# This code is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
# version 2 for more details (a copy is included in the LICENSE file that
13+
# accompanied this code).
14+
#
15+
# You should have received a copy of the GNU General Public License version
16+
# 2 along with this work; if not, write to the Free Software Foundation,
17+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
# or visit www.oracle.com if you need additional information or have any
21+
# questions.
22+
#
23+
from os.path import exists
24+
25+
import mx
26+
import mx_sdk_vm
27+
import mx_sdk_vm_impl
28+
import mx_gate
29+
30+
from mx_espresso import _espresso_stability, espresso_library_config, _espresso_command, _send_sigquit, _llvm_toolchain_wrappers
31+
32+
_suite = mx.suite('espresso-compiler-stub')
33+
34+
mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage(
35+
suite=_suite,
36+
name='Espresso Compiler Stub',
37+
short_name='ecs',
38+
license_files=[],
39+
third_party_license_files=[],
40+
truffle_jars=[],
41+
dir_name='java',
42+
installable_id='espresso-compiler-stub',
43+
installable=True,
44+
dependencies=['Java on Truffle'],
45+
support_distributions=['espresso-compiler-stub:ESPRESSO_COMPILER_SUPPORT'],
46+
priority=2,
47+
stability=_espresso_stability,
48+
standalone=False,
49+
))
50+
51+
52+
def _run_espresso_native_image_launcher(args, cwd=None, nonZeroIsFatal=True, out=None, err=None, timeout=None):
53+
extra_args = ['-J--vm.' + arg for arg in mx_gate.get_jacoco_agent_args() or []]
54+
if mx_sdk_vm_impl._skip_libraries(espresso_library_config):
55+
# JVM mode
56+
espresso_launcher = _espresso_command('espresso', [])[0]
57+
if not exists(espresso_launcher):
58+
raise mx.abort("It looks like JVM mode but the espresso launcher does not exist")
59+
extra_args += [
60+
'--vm.Dcom.oracle.svm.driver.java.executable.override=' + espresso_launcher,
61+
'-J--java.GuestFieldOffsetStrategy=graal',
62+
'-J--java.NativeBackend=nfi-llvm',
63+
]
64+
native_image_command = _espresso_command('native-image', extra_args + args)
65+
if not exists(native_image_command[0]):
66+
raise mx.abort("The native-image launcher does not exist")
67+
return mx.run(native_image_command, cwd=cwd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, timeout=timeout, on_timeout=_send_sigquit)
68+
69+
70+
mx.update_commands(_suite, {
71+
'espresso-native-image': [_run_espresso_native_image_launcher, '[args]'],
72+
})
73+
74+
mx_sdk_vm.register_vm_config('espresso-ni-ce', ['java', 'ejvm', 'ejc', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'cmp', 'svm', 'svmt', 'svmsl', 'tflm', 'bnative-image', 'ni', 'nil', 'tflsm', 'snative-image-agent', 'snative-image-diagnostics-agent', 'ecs'], _suite, env_file='espresso-ni') # pylint: disable=line-too-long
75+
mx_sdk_vm.register_vm_config('espresso-ni-jvm-ce', ['java', 'ejvm', 'elau', 'ellvm', 'nfi-libffi', 'nfi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'tfl', 'tfla', 'tflc', 'cmp', 'antlr4', 'llrc', 'llrlf', 'llrn', 'svm', 'svmt', 'svmsl', 'tflm', 'bnative-image', 'ni', 'nil', 'tflsm', 'snative-image-agent', 'snative-image-diagnostics-agent', 'lg', 'sjavavm', 'bespresso', 'ecs'] + _llvm_toolchain_wrappers, _suite, env_file='espresso-ni-jvm') # pylint: disable=line-too-long
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#
2+
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# This code is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License version 2 only, as
7+
# published by the Free Software Foundation.
8+
#
9+
# This code is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
# version 2 for more details (a copy is included in the LICENSE file that
13+
# accompanied this code).
14+
#
15+
# You should have received a copy of the GNU General Public License version
16+
# 2 along with this work; if not, write to the Free Software Foundation,
17+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
#
19+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
# or visit www.oracle.com if you need additional information or have any
21+
# questions.
22+
#
23+
24+
suite = {
25+
"mxversion": "7.33.0",
26+
"name": "espresso-compiler-stub",
27+
"version": "24.2.0",
28+
"release": False,
29+
"groupId": "org.graalvm.espresso",
30+
"url": "https://www.graalvm.org/reference-manual/java-on-truffle/",
31+
"developer": {
32+
"name": "GraalVM Development",
33+
"email": "[email protected]",
34+
"organization": "Oracle Corporation",
35+
"organizationUrl": "http://www.graalvm.org/",
36+
},
37+
"scm": {
38+
"url": "https://github.com/oracle/graal/tree/master/truffle",
39+
"read": "https://github.com/oracle/graal.git",
40+
"write": "[email protected]:oracle/graal.git",
41+
},
42+
43+
# ------------- licenses
44+
45+
"defaultLicense": "GPLv2",
46+
47+
# ------------- imports
48+
49+
"imports": {
50+
"suites": [
51+
{
52+
"name": "espresso",
53+
"subdir": True,
54+
},
55+
{
56+
"name": "compiler",
57+
"subdir": True,
58+
},
59+
],
60+
},
61+
62+
# ------------- projects
63+
64+
"projects": {
65+
"com.oracle.truffle.espresso.graal": {
66+
"subDir": "src",
67+
"sourceDirs": ["src"],
68+
"dependencies": [
69+
"espresso:ESPRESSO_JVMCI",
70+
"compiler:GRAAL"
71+
],
72+
"requires": [
73+
"jdk.internal.vm.ci",
74+
],
75+
"requiresConcealed": {
76+
"jdk.internal.vm.ci": [
77+
"jdk.vm.ci.code",
78+
"jdk.vm.ci.meta",
79+
"jdk.vm.ci.runtime",
80+
],
81+
},
82+
"javaCompliance": "8+",
83+
"checkstyle": "com.oracle.truffle.espresso",
84+
},
85+
},
86+
87+
# ------------- distributions
88+
89+
"distributions": {
90+
"ESPRESSO_COMPILER_SUPPORT": {
91+
"native": True,
92+
"description": "Espresso GraalVM support distribution for the espresso compiler stub",
93+
"platformDependent": True,
94+
"layout": {
95+
"lib/": [
96+
"dependency:espresso-compiler-stub:ESPRESSO_GRAAL/*",
97+
],
98+
},
99+
"maven": False,
100+
},
101+
102+
"ESPRESSO_GRAAL": {
103+
"subDir": "src",
104+
"moduleInfo": {
105+
"name": "jdk.graal.compiler.espresso"
106+
},
107+
"dependencies": [
108+
"com.oracle.truffle.espresso.graal",
109+
],
110+
"distDependencies": [
111+
"compiler:GRAAL",
112+
"espresso:ESPRESSO_JVMCI",
113+
],
114+
"description": "A dummy GraalJVMCICompiler implementation for Espresso",
115+
"maven": False,
116+
},
117+
}
118+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package com.oracle.truffle.espresso.graal;
24+
25+
import jdk.graal.compiler.code.CompilationResult;
26+
import jdk.graal.compiler.core.common.alloc.RegisterAllocationConfig;
27+
import jdk.graal.compiler.core.target.Backend;
28+
import jdk.graal.compiler.debug.GraalError;
29+
import jdk.graal.compiler.options.OptionValues;
30+
import jdk.graal.compiler.phases.tiers.SuitesProvider;
31+
import jdk.graal.compiler.phases.util.Providers;
32+
import jdk.vm.ci.code.CompilationRequest;
33+
import jdk.vm.ci.code.CompiledCode;
34+
import jdk.vm.ci.code.RegisterConfig;
35+
import jdk.vm.ci.meta.ResolvedJavaMethod;
36+
37+
public final class DummyEspressoBackend extends Backend {
38+
DummyEspressoBackend(Providers providers) {
39+
super(providers);
40+
}
41+
42+
@Override
43+
public SuitesProvider getSuites() {
44+
throw GraalError.unimplementedOverride();
45+
}
46+
47+
@Override
48+
public RegisterAllocationConfig newRegisterAllocationConfig(RegisterConfig registerConfig, String[] allocationRestrictedTo, Object stub) {
49+
throw GraalError.unimplementedOverride();
50+
}
51+
52+
@Override
53+
protected CompiledCode createCompiledCode(ResolvedJavaMethod method, CompilationRequest compilationRequest, CompilationResult compilationResult, boolean isDefault, OptionValues options) {
54+
throw GraalError.unimplementedOverride();
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package com.oracle.truffle.espresso.graal;
24+
25+
import jdk.graal.compiler.api.runtime.GraalJVMCICompiler;
26+
import jdk.graal.compiler.api.runtime.GraalRuntime;
27+
import jdk.graal.compiler.debug.GraalError;
28+
import jdk.vm.ci.code.CompilationRequest;
29+
import jdk.vm.ci.code.CompilationRequestResult;
30+
import jdk.vm.ci.runtime.JVMCIRuntime;
31+
32+
public final class DummyEspressoGraalJVMCICompiler implements GraalJVMCICompiler {
33+
34+
private final EspressoGraalRuntime runtime;
35+
36+
private DummyEspressoGraalJVMCICompiler(JVMCIRuntime jvmciRuntime) {
37+
runtime = new EspressoGraalRuntime(jvmciRuntime);
38+
}
39+
40+
// used by the VM
41+
public static DummyEspressoGraalJVMCICompiler create(JVMCIRuntime jvmciRuntime) {
42+
return new DummyEspressoGraalJVMCICompiler(jvmciRuntime);
43+
}
44+
45+
@Override
46+
public GraalRuntime getGraalRuntime() {
47+
return runtime;
48+
}
49+
50+
@Override
51+
public CompilationRequestResult compileMethod(CompilationRequest request) {
52+
throw GraalError.unimplementedOverride();
53+
}
54+
55+
@Override
56+
public boolean isGCSupported(int gcIdentifier) {
57+
throw GraalError.unimplementedOverride();
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package com.oracle.truffle.espresso.graal;
24+
25+
import jdk.graal.compiler.core.common.LIRKind;
26+
import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor;
27+
import jdk.graal.compiler.core.common.spi.ForeignCallLinkage;
28+
import jdk.graal.compiler.core.common.spi.ForeignCallSignature;
29+
import jdk.graal.compiler.core.common.spi.ForeignCallsProvider;
30+
import jdk.graal.compiler.debug.GraalError;
31+
import jdk.vm.ci.meta.JavaKind;
32+
33+
public final class DummyForeignCallsProvider implements ForeignCallsProvider {
34+
@Override
35+
public ForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
36+
throw GraalError.unimplementedOverride();
37+
}
38+
39+
@Override
40+
public ForeignCallDescriptor getDescriptor(ForeignCallSignature signature) {
41+
throw GraalError.unimplementedOverride();
42+
}
43+
44+
@Override
45+
public LIRKind getValueKind(JavaKind javaKind) {
46+
throw GraalError.unimplementedOverride();
47+
}
48+
}

0 commit comments

Comments
 (0)