From 742810f7be5458272c323ba7f3bf1b53452db58c Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Mon, 7 Dec 2020 13:54:02 +0100 Subject: [PATCH 1/2] Enable MultiTier option. --- .../compiler/truffle/options/PolyglotCompilerOptions.java | 2 +- .../oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.truffle.options/src/org/graalvm/compiler/truffle/options/PolyglotCompilerOptions.java b/compiler/src/org.graalvm.compiler.truffle.options/src/org/graalvm/compiler/truffle/options/PolyglotCompilerOptions.java index ee558d689773..c12176721992 100644 --- a/compiler/src/org.graalvm.compiler.truffle.options/src/org/graalvm/compiler/truffle/options/PolyglotCompilerOptions.java +++ b/compiler/src/org.graalvm.compiler.truffle.options/src/org/graalvm/compiler/truffle/options/PolyglotCompilerOptions.java @@ -278,7 +278,7 @@ private String indent(int nameLength) { // MultiTier @Option(help = "Whether to use multiple Truffle compilation tiers by default.", category = OptionCategory.EXPERT) - public static final OptionKey MultiTier = new OptionKey<>(false); + public static final OptionKey MultiTier = new OptionKey<>(true); @Option(help = "Explicitly pick a first tier inlining policy by name (None, TrivialOnly). If empty (default) the lowest priority policy (TrivialOnly) is chosen.", category = OptionCategory.INTERNAL) public static final OptionKey FirstTierInliningPolicy = new OptionKey<>(""); diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java index 3308af580019..b57083f9eda3 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java @@ -119,7 +119,7 @@ public SubstrateOptimizedCallTargetInstalledCode createSubstrateInstalledCode() return createInstalledCode(); } - void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) { + protected void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) { VMOperation.guaranteeInProgressAtSafepoint("Must be at a safepoint"); assert code != null : "Must never become null"; if (code == installedCode) { From 247f2f15f025877bb304791001ab78292893cd11 Mon Sep 17 00:00:00 2001 From: Peter Hofer Date: Tue, 22 Dec 2020 19:50:00 +0100 Subject: [PATCH 2/2] Minor SubstrateOptimizedCallTarget refactoring. --- .../api/SubstrateOptimizedCallTarget.java | 23 ++++++++++++++++++- ...trateOptimizedCallTargetInstalledCode.java | 13 +++-------- .../SubstrateTruffleGraphBuilderPlugins.java | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java index b57083f9eda3..003be96e628e 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTarget.java @@ -91,6 +91,14 @@ public long getCodeAddress() { return installedCode.getAddress(); } + /** + * Prevents reads from floating across a safepoint when the caller is inlined in another method. + * Intrinsified in {@link SubstrateTruffleGraphBuilderPlugins}. + */ + public static void safepointBarrier() { + // Intrinsified, but empty so it can be called during hosted Truffle calls + } + @Override public Object doInvoke(Object[] args) { return SubstrateOptimizedCallTargetInstalledCode.doInvoke(this, args); @@ -119,7 +127,11 @@ public SubstrateOptimizedCallTargetInstalledCode createSubstrateInstalledCode() return createInstalledCode(); } - protected void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) { + /** + * Called from {@link SubstrateOptimizedCallTargetInstalledCode#setAddress} for code + * representing this call target. + */ + protected void onCodeInstalled(SubstrateOptimizedCallTargetInstalledCode code) { VMOperation.guaranteeInProgressAtSafepoint("Must be at a safepoint"); assert code != null : "Must never become null"; if (code == installedCode) { @@ -129,6 +141,15 @@ protected void setInstalledCode(SubstrateOptimizedCallTargetInstalledCode code) installedCode = code; } + /** + * Called from {@link SubstrateOptimizedCallTargetInstalledCode#clearAddress} for code + * representing this call target. The caller can, however, be older code and not the current + * entry point, so that {@code code != installedCode}. + */ + protected void onCodeCleared(@SuppressWarnings("unused") SubstrateOptimizedCallTargetInstalledCode code) { + VMOperation.guaranteeInProgressAtSafepoint("Must be at a safepoint"); + } + /** Creates the instance for initializing {@link #installedCode} so it is never {@code null}. */ protected SubstrateOptimizedCallTargetInstalledCode createInitializationInstalledCode() { return createInstalledCode(); diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java index 423884fd99be..020335ce2eba 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateOptimizedCallTargetInstalledCode.java @@ -113,7 +113,7 @@ public void setAddress(long address, ResolvedJavaMethod method) { assert VMOperation.isInProgressAtSafepoint(); this.entryPoint = address; this.address = address; - callTarget.setInstalledCode(this); + callTarget.onCodeInstalled(this); } @Override @@ -121,6 +121,7 @@ public void clearAddress() { assert VMOperation.isInProgressAtSafepoint(); this.entryPoint = 0; this.address = 0; + callTarget.onCodeCleared(this); } @Override @@ -147,16 +148,8 @@ private void invalidateWithoutDeoptimization0() { } } - /** - * Prevents reads from floating across a safepoint when the caller is inlined in another method. - * Intrinsified in {@link SubstrateTruffleGraphBuilderPlugins}. - */ - protected static void safepointBarrier() { - // Intrinsified, but empty so it can be called during hosted Truffle calls - } - static Object doInvoke(SubstrateOptimizedCallTarget callTarget, Object[] args) { - safepointBarrier(); + SubstrateOptimizedCallTarget.safepointBarrier(); /* * We have to be very careful that the calling code is uninterruptible, i.e., has no * safepoint between the read of the entry point address and the indirect call to this diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleGraphBuilderPlugins.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleGraphBuilderPlugins.java index e8060c8f687f..cc0640ce2fb8 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleGraphBuilderPlugins.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/api/SubstrateTruffleGraphBuilderPlugins.java @@ -62,7 +62,7 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec } private static void registerOptimizedCallTargetPlugins(InvocationPlugins plugins) { - InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, SubstrateOptimizedCallTargetInstalledCode.class); + InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, SubstrateOptimizedCallTarget.class); r0.register0("safepointBarrier", new InvocationPlugin() { @Override public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {