Skip to content

Commit

Permalink
Add JVMCI partial implementation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gilles-duboscq committed Jan 10, 2025
1 parent fe3b740 commit 12dfd28
Show file tree
Hide file tree
Showing 92 changed files with 8,500 additions and 216 deletions.
6 changes: 6 additions & 0 deletions espresso-compiler-stub/mx.espresso-compiler-stub/espresso-ni
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Use $GRAALVM/bin/native-image in the resulting GraalVM
DYNAMIC_IMPORTS=/vm,/substratevm
COMPONENTS=Java on Truffle,Espresso Standalone jvm.cfg,SubstrateVM,tflm,ni,sdkni,svmt,svmsl,tflc,tflsm,ecs
NATIVE_IMAGES=lib:javavm
DISABLE_INSTALLABLES=true
DISABLE_LIBPOLYGLOT=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Use $GRAALVM/bin/native-image --vm.Dcom.oracle.svm.driver.java.executable.override=$GRAALVM/bin/espresso in the resulting GraalVM
DYNAMIC_IMPORTS=/vm,/substratevm
COMPONENTS=Espresso Launcher,LibGraal,Java on Truffle,SubstrateVM,Java on Truffle LLVM Java libraries,tflm,ni,sdkni,svmt,svmsl,tflc,tflsm,ecs
NATIVE_IMAGES=lib:jvmcicompiler
DISABLE_INSTALLABLES=true
DISABLE_LIBPOLYGLOT=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
from os.path import exists

import mx
import mx_sdk_vm
import mx_sdk_vm_impl
import mx_gate

from mx_espresso import _espresso_stability, espresso_library_config, _espresso_command, _send_sigquit, _llvm_toolchain_wrappers

_suite = mx.suite('espresso-compiler-stub')

mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage(
suite=_suite,
name='Espresso Compiler Stub',
short_name='ecs',
license_files=[],
third_party_license_files=[],
truffle_jars=[],
dir_name='java',
installable_id='espresso-compiler-stub',
installable=True,
dependencies=['Java on Truffle'],
support_distributions=['espresso-compiler-stub:ESPRESSO_COMPILER_SUPPORT'],
priority=2,
stability=_espresso_stability,
standalone=False,
))


def _run_espresso_native_image_launcher(args, cwd=None, nonZeroIsFatal=True, out=None, err=None, timeout=None):
extra_args = ['-J--vm.' + arg for arg in mx_gate.get_jacoco_agent_args() or []]
if mx_sdk_vm_impl._skip_libraries(espresso_library_config):
# JVM mode
espresso_launcher = _espresso_command('espresso', [])[0]
if not exists(espresso_launcher):
raise mx.abort("It looks like JVM mode but the espresso launcher does not exist")
extra_args += [
'--vm.Dcom.oracle.svm.driver.java.executable.override=' + espresso_launcher,
'-J--java.GuestFieldOffsetStrategy=graal',
'-J--java.NativeBackend=nfi-llvm',
]
native_image_command = _espresso_command('native-image', extra_args + args)
if not exists(native_image_command[0]):
raise mx.abort("The native-image launcher does not exist")
return mx.run(native_image_command, cwd=cwd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, timeout=timeout, on_timeout=_send_sigquit)


mx.update_commands(_suite, {
'espresso-native-image': [_run_espresso_native_image_launcher, '[args]'],
})

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
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
118 changes: 118 additions & 0 deletions espresso-compiler-stub/mx.espresso-compiler-stub/suite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

suite = {
"mxversion": "7.33.0",
"name": "espresso-compiler-stub",
"version": "24.2.0",
"release": False,
"groupId": "org.graalvm.espresso",
"url": "https://www.graalvm.org/reference-manual/java-on-truffle/",
"developer": {
"name": "GraalVM Development",
"email": "[email protected]",
"organization": "Oracle Corporation",
"organizationUrl": "http://www.graalvm.org/",
},
"scm": {
"url": "https://github.com/oracle/graal/tree/master/truffle",
"read": "https://github.com/oracle/graal.git",
"write": "[email protected]:oracle/graal.git",
},

# ------------- licenses

"defaultLicense": "GPLv2",

# ------------- imports

"imports": {
"suites": [
{
"name": "espresso",
"subdir": True,
},
{
"name": "compiler",
"subdir": True,
},
],
},

# ------------- projects

"projects": {
"com.oracle.truffle.espresso.graal": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"espresso:ESPRESSO_JVMCI",
"compiler:GRAAL"
],
"requires": [
"jdk.internal.vm.ci",
],
"requiresConcealed": {
"jdk.internal.vm.ci": [
"jdk.vm.ci.code",
"jdk.vm.ci.meta",
"jdk.vm.ci.runtime",
],
},
"javaCompliance": "8+",
"checkstyle": "com.oracle.truffle.espresso",
},
},

# ------------- distributions

"distributions": {
"ESPRESSO_COMPILER_SUPPORT": {
"native": True,
"description": "Espresso GraalVM support distribution for the espresso compiler stub",
"platformDependent": True,
"layout": {
"lib/": [
"dependency:espresso-compiler-stub:ESPRESSO_GRAAL/*",
],
},
"maven": False,
},

"ESPRESSO_GRAAL": {
"subDir": "src",
"moduleInfo": {
"name": "jdk.graal.compiler.espresso"
},
"dependencies": [
"com.oracle.truffle.espresso.graal",
],
"distDependencies": [
"compiler:GRAAL",
"espresso:ESPRESSO_JVMCI",
],
"description": "A dummy GraalJVMCICompiler implementation for Espresso",
"maven": False,
},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.graal;

import jdk.graal.compiler.code.CompilationResult;
import jdk.graal.compiler.core.common.alloc.RegisterAllocationConfig;
import jdk.graal.compiler.core.target.Backend;
import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.tiers.SuitesProvider;
import jdk.graal.compiler.phases.util.Providers;
import jdk.vm.ci.code.CompilationRequest;
import jdk.vm.ci.code.CompiledCode;
import jdk.vm.ci.code.RegisterConfig;
import jdk.vm.ci.meta.ResolvedJavaMethod;

public final class DummyEspressoBackend extends Backend {
DummyEspressoBackend(Providers providers) {
super(providers);
}

@Override
public SuitesProvider getSuites() {
throw GraalError.unimplementedOverride();
}

@Override
public RegisterAllocationConfig newRegisterAllocationConfig(RegisterConfig registerConfig, String[] allocationRestrictedTo, Object stub) {
throw GraalError.unimplementedOverride();
}

@Override
protected CompiledCode createCompiledCode(ResolvedJavaMethod method, CompilationRequest compilationRequest, CompilationResult compilationResult, boolean isDefault, OptionValues options) {
throw GraalError.unimplementedOverride();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.graal;

import jdk.graal.compiler.api.runtime.GraalJVMCICompiler;
import jdk.graal.compiler.api.runtime.GraalRuntime;
import jdk.graal.compiler.debug.GraalError;
import jdk.vm.ci.code.CompilationRequest;
import jdk.vm.ci.code.CompilationRequestResult;
import jdk.vm.ci.runtime.JVMCIRuntime;

public final class DummyEspressoGraalJVMCICompiler implements GraalJVMCICompiler {

private final EspressoGraalRuntime runtime;

private DummyEspressoGraalJVMCICompiler(JVMCIRuntime jvmciRuntime) {
runtime = new EspressoGraalRuntime(jvmciRuntime);
}

// used by the VM
public static DummyEspressoGraalJVMCICompiler create(JVMCIRuntime jvmciRuntime) {
return new DummyEspressoGraalJVMCICompiler(jvmciRuntime);
}

@Override
public GraalRuntime getGraalRuntime() {
return runtime;
}

@Override
public CompilationRequestResult compileMethod(CompilationRequest request) {
throw GraalError.unimplementedOverride();
}

@Override
public boolean isGCSupported(int gcIdentifier) {
throw GraalError.unimplementedOverride();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.graal;

import jdk.graal.compiler.core.common.LIRKind;
import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor;
import jdk.graal.compiler.core.common.spi.ForeignCallLinkage;
import jdk.graal.compiler.core.common.spi.ForeignCallSignature;
import jdk.graal.compiler.core.common.spi.ForeignCallsProvider;
import jdk.graal.compiler.debug.GraalError;
import jdk.vm.ci.meta.JavaKind;

public final class DummyForeignCallsProvider implements ForeignCallsProvider {
@Override
public ForeignCallLinkage lookupForeignCall(ForeignCallDescriptor descriptor) {
throw GraalError.unimplementedOverride();
}

@Override
public ForeignCallDescriptor getDescriptor(ForeignCallSignature signature) {
throw GraalError.unimplementedOverride();
}

@Override
public LIRKind getValueKind(JavaKind javaKind) {
throw GraalError.unimplementedOverride();
}
}
Loading

0 comments on commit 12dfd28

Please sign in to comment.