Skip to content

Commit

Permalink
[GR-36701] Add PolyglotIsolate code to espresso library.
Browse files Browse the repository at this point in the history
PullRequest: graal/11163
  • Loading branch information
matneu committed Feb 24, 2022
2 parents 9ac77ad + 832c4da commit 19dbed0
Show file tree
Hide file tree
Showing 41 changed files with 219 additions and 219 deletions.
45 changes: 21 additions & 24 deletions espresso/mx.espresso/mx_espresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _espresso_launcher_command(args):


def _java_truffle_command(args):
"""Java launcher using libespresso in GraalVM + arguments"""
"""Java launcher using libjavavm in GraalVM + arguments"""
return _espresso_command('java', ['-truffle'] + args)


Expand Down Expand Up @@ -106,24 +106,24 @@ def _espresso_gate_runner(args, tasks):
with Task(mokapot_header_gate_name, tasks, tags=[EspressoTags.verify]) as t:
if t:
import mx_sdk_vm_impl
run_instructions = "$ mx --dynamicimports=/substratevm --native-images=lib:espresso gate --all-suites --task '{}'".format(mokapot_header_gate_name)
run_instructions = "$ mx --dynamicimports=/substratevm --native-images=lib:javavm gate --all-suites --task '{}'".format(mokapot_header_gate_name)
if mx_sdk_vm_impl._skip_libraries(espresso_library_config):
mx.abort("""\
The registration of the Espresso library ('lib:espresso') is skipped. Please run this gate as follows:
The registration of the Espresso library ('lib:javavm') is skipped. Please run this gate as follows:
{}""".format(run_instructions))

errors = False
mokapot_dir = join(mx.project('com.oracle.truffle.espresso.mokapot').dir, 'include')
libespresso_dir = mx.project(mx_sdk_vm_impl.GraalVmNativeImage.project_name(espresso_library_config)).get_output_root()
libjavavm_dir = mx.project(mx_sdk_vm_impl.GraalVmNativeImage.project_name(espresso_library_config)).get_output_root()

for header in ['libespresso_dynamic.h', 'graal_isolate_dynamic.h']:
for header in ['libjavavm_dynamic.h', 'graal_isolate_dynamic.h']:
committed_header = join(mokapot_dir, header)
if not mx.exists(committed_header):
mx.abort("Cannot locate '{}'. Was the file moved or renamed?".format(committed_header))

generated_header = join(libespresso_dir, header)
generated_header = join(libjavavm_dir, header)
if not mx.exists(generated_header):
mx.abort("Cannot locate '{}'. Did you forget to build? Example:\n'mx --dynamicimports=/substratevm --native-images=lib:espresso build'".format(generated_header))
mx.abort("Cannot locate '{}'. Did you forget to build? Example:\n'mx --dynamicimports=/substratevm --native-images=lib:javavm build'".format(generated_header))

committed_header_copyright = []
with open(committed_header, 'r') as committed_header_file:
Expand Down Expand Up @@ -151,7 +151,7 @@ def _espresso_gate_runner(args, tasks):
To fix the issue, run this gate locally:
{instructions}
And adapt the code to the modified headers in '{committed}'.
""".format(committed=os.path.relpath(mokapot_dir, _suite.vc_dir), generated=os.path.relpath(libespresso_dir, _suite.vc_dir), instructions=run_instructions))
""".format(committed=os.path.relpath(mokapot_dir, _suite.vc_dir), generated=os.path.relpath(libjavavm_dir, _suite.vc_dir), instructions=run_instructions))


# REGISTER MX GATE RUNNER
Expand All @@ -160,23 +160,20 @@ def _espresso_gate_runner(args, tasks):


if mx.is_windows():
lib_espresso_cp = '%GRAALVM_HOME%\\lib\\graalvm\\lib-espresso.jar'
lib_javavm_cp = '%GRAALVM_HOME%\\lib\\graalvm\\lib-javavm.jar'
else:
lib_espresso_cp = '${GRAALVM_HOME}/lib/graalvm/lib-espresso.jar'
lib_javavm_cp = '${GRAALVM_HOME}/lib/graalvm/lib-javavm.jar'


espresso_library_config = mx_sdk_vm.LibraryConfig(
destination='lib/<lib:espresso>',
jar_distributions=['espresso:LIB_ESPRESSO'],
espresso_library_config = mx_sdk_vm.LanguageLibraryConfig(
language='java',
jar_distributions=['espresso:LIB_JAVAVM'],
build_args=[
'--language:java',
'--tool:all',
'-H:+EnableSignalAPI',
'-H:-JNIExportSymbols',
'-R:+EnableSignalHandling',
'-R:+InstallSegfaultHandler',
'--features=com.oracle.truffle.espresso.ref.FinalizationFeature',
],
home_finder=True,
)

mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage(
Expand All @@ -191,7 +188,7 @@ def _espresso_gate_runner(args, tasks):
truffle_jars=['espresso:ESPRESSO'],
support_distributions=['espresso:ESPRESSO_SUPPORT'],
library_configs=[espresso_library_config],
polyglot_lib_jar_dependencies=['espresso:LIB_ESPRESSO'],
polyglot_lib_jar_dependencies=['espresso:LIB_JAVAVM'],
has_polyglot_lib_entrypoints=True,
priority=1,
post_install_msg="""
Expand All @@ -203,7 +200,7 @@ def _espresso_gate_runner(args, tasks):
(to execute a jar file)
To rebuild the polyglot library:
gu rebuild-images libpolyglot -cp """ + lib_espresso_cp,
gu rebuild-images libpolyglot -cp """ + lib_javavm_cp,
stability="supported",
))

Expand Down Expand Up @@ -302,8 +299,8 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
# Build configs
# pylint: disable=bad-whitespace
tools = ['cov', 'dap', 'ins', 'insight', 'insightheap', 'lsp', 'pro', 'vvm']
mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'elau' ] + tools, _suite, env_file='jvm')
mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'svm', 'svmnfi' , 'tflm', 'elau', 'lg', 'bespresso', 'sespresso', 'spolyglot'] + tools, _suite, env_file='jvm-ce')
mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp', 'cmpee', 'svm', 'svmnfi', 'svmee', 'tflm', 'elau', 'lg', 'bespresso', 'sespresso', 'spolyglot'] + tools, _suite, env_file='jvm-ee')
mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'svm', 'svmnfi' , 'tflm' , 'spolyglot'] + tools, _suite, env_file='native-ce')
mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp', 'cmpee', 'svm', 'svmnfi', 'svmee', 'tflm' , 'spolyglot'] + tools, _suite, env_file='native-ee')
mx_sdk_vm.register_vm_config('espresso-jvm', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'elau' ] + tools, _suite, env_file='jvm')
mx_sdk_vm.register_vm_config('espresso-jvm-ce', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'svm', 'svmnfi' , 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + tools, _suite, env_file='jvm-ce')
mx_sdk_vm.register_vm_config('espresso-jvm-ee', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp', 'cmpee', 'svm', 'svmnfi', 'svmee', 'tflm', 'elau', 'lg', 'bespresso', 'sjavavm', 'spolyglot'] + tools, _suite, env_file='jvm-ee')
mx_sdk_vm.register_vm_config('espresso-native-ce', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp' , 'svm', 'svmnfi' , 'tflm' , 'spolyglot'] + tools, _suite, env_file='native-ce')
mx_sdk_vm.register_vm_config('espresso-native-ee', ['java', 'ejvm', 'libpoly', 'nfi-libffi', 'nfi', 'sdk', 'tfl', 'cmp', 'cmpee', 'svm', 'svmnfi', 'svmee', 'tflm' , 'spolyglot'] + tools, _suite, env_file='native-ee')
4 changes: 2 additions & 2 deletions espresso/mx.espresso/native-ce
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# mx --dynamicimports=/vm,/substratevm --components="Java on Truffle,SubstrateVM,suite:tools" --native-images=lib:espresso --disable-installables=true graalvm-show
# mx --dynamicimports=/vm,/substratevm --components="Java on Truffle,SubstrateVM,suite:tools" --native-images=lib:javavm --disable-installables=true graalvm-show

DYNAMIC_IMPORTS=/vm,/substratevm
COMPONENTS=Java on Truffle,SubstrateVM,suite:tools
NATIVE_IMAGES=lib:espresso
NATIVE_IMAGES=lib:javavm
DISABLE_INSTALLABLES=true
4 changes: 2 additions & 2 deletions espresso/mx.espresso/native-ee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# mx --dynamicimports=/vm-enterprise,/substratevm-enterprise,/tools-enterprise --components="Java on Truffle,SubstrateVM Enterprise,suite:tools,suite:tools-enterprise" --native-images=lib:espresso --disable-installables=true graalvm-show
# mx --dynamicimports=/vm-enterprise,/substratevm-enterprise,/tools-enterprise --components="Java on Truffle,SubstrateVM Enterprise,suite:tools,suite:tools-enterprise" --native-images=lib:javavm --disable-installables=true graalvm-show

DYNAMIC_IMPORTS=/vm-enterprise,/substratevm-enterprise,/tools-enterprise
COMPONENTS=Java on Truffle,SubstrateVM Enterprise,suite:tools,suite:tools-enterprise
NATIVE_IMAGES=lib:espresso
NATIVE_IMAGES=lib:javavm
DISABLE_INSTALLABLES=true
EXCLUDE_COMPONENTS=hprf
6 changes: 3 additions & 3 deletions espresso/mx.espresso/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"checkstyle": "com.oracle.truffle.espresso",
},

"com.oracle.truffle.espresso.libespresso": {
"com.oracle.truffle.espresso.libjavavm": {
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
Expand Down Expand Up @@ -348,10 +348,10 @@
"maven": False,
},

"LIB_ESPRESSO": {
"LIB_JAVAVM": {
"subDir": "src",
"dependencies": [
"com.oracle.truffle.espresso.libespresso",
"com.oracle.truffle.espresso.libjavavm",
],
"distDependencies": [
"sdk:GRAAL_SDK",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso;
package com.oracle.truffle.espresso.libjavavm;

import static com.oracle.truffle.espresso.libespresso.jniapi.JNIErrors.JNI_ERR;
import static com.oracle.truffle.espresso.libjavavm.jniapi.JNIErrors.JNI_ERR;

import java.io.File;
import java.io.PrintStream;
Expand All @@ -37,10 +37,10 @@
import org.graalvm.polyglot.Context;
import org.graalvm.word.Pointer;

import com.oracle.truffle.espresso.libespresso.arghelper.ArgumentsHandler;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIErrors;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMOption;
import com.oracle.truffle.espresso.libjavavm.arghelper.ArgumentsHandler;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIErrors;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMOption;

public final class Arguments {
private static final PrintStream STDERR = System.err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso;
package com.oracle.truffle.espresso.libjavavm;

import java.io.PrintStream;

Expand All @@ -33,13 +33,13 @@
import org.graalvm.polyglot.Value;
import org.graalvm.word.WordFactory;

import com.oracle.truffle.espresso.libespresso.jniapi.JNIEnvironmentPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIErrors;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIFunctionPointerTypes.GetEnvFunctionPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVM;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIVersion;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIEnvironmentPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIErrors;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIFunctionPointerTypes.GetEnvFunctionPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVM;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIVersion;

public class LibEspresso {
private static final PrintStream STDERR = System.err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso;
package com.oracle.truffle.espresso.libjavavm;

public enum OS {
Darwin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
* questions.
*/

package com.oracle.truffle.espresso.libespresso.arghelper;
package com.oracle.truffle.espresso.libjavavm.arghelper;

import static com.oracle.truffle.espresso.libespresso.Arguments.abort;
import static com.oracle.truffle.espresso.libjavavm.Arguments.abort;

import java.io.PrintStream;
import java.util.function.Consumer;
Expand All @@ -37,9 +37,9 @@
import org.graalvm.polyglot.Context;
import org.graalvm.word.Pointer;

import com.oracle.truffle.espresso.libespresso.Arguments;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIJavaVMOption;
import com.oracle.truffle.espresso.libjavavm.Arguments;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMInitArgs;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIJavaVMOption;

/**
* A helper class that centralizes different ways of handling option parsing for the java -truffle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* questions.
*/

package com.oracle.truffle.espresso.libespresso.arghelper;
package com.oracle.truffle.espresso.libjavavm.arghelper;

import org.graalvm.polyglot.Context;

import com.oracle.truffle.espresso.libespresso.Arguments;
import com.oracle.truffle.espresso.libjavavm.Arguments;

/**
* Handles numbered System properties, which may require keeping track of some counters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* questions.
*/

package com.oracle.truffle.espresso.libespresso.arghelper;
package com.oracle.truffle.espresso.libjavavm.arghelper;

import static com.oracle.truffle.espresso.libespresso.Arguments.abort;
import static com.oracle.truffle.espresso.libespresso.arghelper.ArgumentsHandler.isBooleanOption;
import static com.oracle.truffle.espresso.libjavavm.Arguments.abort;
import static com.oracle.truffle.espresso.libjavavm.arghelper.ArgumentsHandler.isBooleanOption;

import java.util.EnumSet;
import java.util.Map;
Expand All @@ -35,7 +35,7 @@
import org.graalvm.options.OptionDescriptor;
import org.graalvm.options.OptionDescriptors;

import com.oracle.truffle.espresso.libespresso.Arguments;
import com.oracle.truffle.espresso.libjavavm.Arguments;

/**
* Handles communication with the host VM for passing arguments from the command line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
* questions.
*/

package com.oracle.truffle.espresso.libespresso.arghelper;
package com.oracle.truffle.espresso.libjavavm.arghelper;

import static com.oracle.truffle.espresso.libespresso.Arguments.abort;
import static com.oracle.truffle.espresso.libespresso.Arguments.abortExperimental;
import static com.oracle.truffle.espresso.libespresso.arghelper.ArgumentsHandler.isBooleanOption;
import static com.oracle.truffle.espresso.libjavavm.Arguments.abort;
import static com.oracle.truffle.espresso.libjavavm.Arguments.abortExperimental;
import static com.oracle.truffle.espresso.libjavavm.arghelper.ArgumentsHandler.isBooleanOption;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.CREATE_NEW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.constant.CConstant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.struct.CField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.struct.CPointerTo;
import org.graalvm.word.PointerBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.constant.CConstant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.struct.CStruct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.c.function.CFunctionPointer;
import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -31,7 +31,7 @@

import org.graalvm.nativeimage.c.CContext;

import com.oracle.truffle.espresso.libespresso.OS;
import com.oracle.truffle.espresso.libjavavm.OS;

public class JNIHeaderDirectives implements CContext.Directives {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.oracle.truffle.espresso.libespresso.jniapi;
package com.oracle.truffle.espresso.libjavavm.jniapi;

import org.graalvm.nativeimage.ObjectHandle;
import org.graalvm.nativeimage.c.CContext;
import org.graalvm.nativeimage.c.struct.CField;
import org.graalvm.nativeimage.c.struct.CStruct;
import org.graalvm.word.PointerBase;

import com.oracle.truffle.espresso.libespresso.jniapi.JNIFunctionPointerTypes.AttachCurrentThreadFunctionPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIFunctionPointerTypes.DestroyJavaVMFunctionPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIFunctionPointerTypes.DetachCurrentThreadFunctionPointer;
import com.oracle.truffle.espresso.libespresso.jniapi.JNIFunctionPointerTypes.GetEnvFunctionPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIFunctionPointerTypes.AttachCurrentThreadFunctionPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIFunctionPointerTypes.DestroyJavaVMFunctionPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIFunctionPointerTypes.DetachCurrentThreadFunctionPointer;
import com.oracle.truffle.espresso.libjavavm.jniapi.JNIFunctionPointerTypes.GetEnvFunctionPointer;

@CContext(JNIHeaderDirectives.class)
@CStruct(value = "JNIInvokeInterface_", addStructKeyword = true)
Expand Down
Loading

0 comments on commit 19dbed0

Please sign in to comment.