Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Jun 4, 2024
2 parents 414d874 + 187834a commit 78ec64e
Show file tree
Hide file tree
Showing 99 changed files with 1,894 additions and 724 deletions.
14 changes: 7 additions & 7 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+24", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+24-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+24-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+25", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-23+25-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-23+25-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* Copyright (c) 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 jdk.graal.compiler.truffle.test;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameSlotKind;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.runtime.OptimizedCallTarget;

public class CallPartialEvaluationTest extends TestWithSynchronousCompiling {

static class ConstantTargetRootNode extends RootNode {

// deliberately
final CallTarget target;

protected ConstantTargetRootNode(RootNode target) {
super(null);
this.target = target.getCallTarget();
}

@Override
public Object execute(VirtualFrame frame) {
Object result = target.call(this);
if (CompilerDirectives.inCompiledCode() && !CompilerDirectives.isCompilationConstant(result)) {
throw CompilerDirectives.shouldNotReachHere();
}
return result;
}

}

static class NonConstantTargetRootNode extends RootNode {

// deliberately not a constant
CallTarget target;

protected NonConstantTargetRootNode(RootNode target) {
super(null);
this.target = target.getCallTarget();
}

@Override
public Object execute(VirtualFrame frame) {
Object result = target.call(this);
if (CompilerDirectives.inCompiledCode() && CompilerDirectives.isCompilationConstant(result)) {
throw CompilerDirectives.shouldNotReachHere();
}
return result;
}

}

@Test
public void testInliningConstant() {
var root0 = new ConstantTargetRootNode(RootNode.createConstantNode(42));
var root1 = new ConstantTargetRootNode(root0);
var root2 = new ConstantTargetRootNode(root1);

OptimizedCallTarget target = (OptimizedCallTarget) root2.getCallTarget();
target.call();
target.compile(true);
target.call();
assertTrue(target.isValid());
}

static class ExpectedNonConstantRootNode extends RootNode {

protected ExpectedNonConstantRootNode() {
super(null);
}

@Override
public Object execute(VirtualFrame frame) {
return 42;
}

}

@Test
public void testInliningNonConstant() {
var root = new NonConstantTargetRootNode(RootNode.createConstantNode(42));
OptimizedCallTarget target = (OptimizedCallTarget) root.getCallTarget();
target.call();
target.compile(true);
target.call();
assertTrue(target.isValid());
}

static class LateFoldTargetRootNode extends RootNode {

final CallTarget target;

protected LateFoldTargetRootNode(RootNode target) {
super(null, createFrameDescriptor());
this.target = target.getCallTarget();
}

static FrameDescriptor createFrameDescriptor() {
var b = FrameDescriptor.newBuilder();
b.addSlot(FrameSlotKind.Object, "test", null);
return b.build();
}

@Override
public Object execute(VirtualFrame frame) {
frame.setObject(0, target);
Object result = ((CallTarget) frame.getObject(0)).call(this);
if (CompilerDirectives.inCompiledCode() && CompilerDirectives.isCompilationConstant(result)) {
/*
* Unfortunately we do not yet support inlining with indirect constants. The inliner
* needs to be adapted for this to work. If it ever starts to work then this test
* will fail. Feel free to switch the condition for compilation constant.
*/
throw CompilerDirectives.shouldNotReachHere();
}

return result;
}

}

@Test
public void testLateConstantFold() {
var root0 = new LateFoldTargetRootNode(RootNode.createConstantNode(42));
var root1 = new LateFoldTargetRootNode(root0);
var root2 = new LateFoldTargetRootNode(root1);
OptimizedCallTarget target = (OptimizedCallTarget) root2.getCallTarget();
target.call();
target.compile(true);
target.call();
assertTrue(target.isValid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.runtime.OptimizedTruffleRuntime;
import com.oracle.truffle.runtime.OptimizedCallTarget;
import com.oracle.truffle.runtime.OptimizedDirectCallNode;
import com.oracle.truffle.runtime.OptimizedIndirectCallNode;
import com.oracle.truffle.runtime.OptimizedRuntimeOptions;
import com.oracle.truffle.runtime.OptimizedTruffleRuntime;

@SuppressWarnings("try")
public class IndirectCallSiteTest extends TestWithSynchronousCompiling {
Expand Down Expand Up @@ -72,11 +72,13 @@ public Object execute(VirtualFrame frame) {

@Override
public Object execute(VirtualFrame frame) {
CallTarget target;
if (frame.getArguments().length == 0) {
return indirectCallNode.call(innerTarget, noArguments);
target = innerTarget;
} else {
return indirectCallNode.call(uninitializedInnerTarget, noArguments);
target = uninitializedInnerTarget;
}
return indirectCallNode.call(target, noArguments);
}
}.getCallTarget();
final int compilationThreshold = outerTarget.getOptionValue(OptimizedRuntimeOptions.SingleTierCompilationThreshold);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.RootNode;

Expand Down Expand Up @@ -86,7 +87,7 @@ public boolean isInternal() {
}

@Override
public boolean isCaptureFramesForTrace() {
public boolean isCaptureFramesForTrace(@SuppressWarnings("hiding") Node node) {
return captureFramesForTrace;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ public long defaultPrototypeMarkWord() {
public final long verifyOopMask = getFieldValue("CompilerToVM::Data::Universe_verify_oop_mask", Long.class, "uintptr_t");
public final long verifyOopBits = getFieldValue("CompilerToVM::Data::Universe_verify_oop_bits", Long.class, "uintptr_t");

public final int logOfHRGrainBytes = getFieldValue("G1HeapRegion::LogOfHRGrainBytes", Integer.class, JDK >= 22 ? "uint" : "int");
public final int logOfHRGrainBytes = getFieldValue(JDK >= 23 ? "G1HeapRegion::LogOfHRGrainBytes" : "HeapRegion::LogOfHRGrainBytes", Integer.class, JDK >= 22 ? "uint" : "int");

public final int cardtableShift = getFieldValue("CompilerToVM::Data::cardtable_shift", Integer.class, "int");
public final long cardtableStartAddress = getFieldValue("CompilerToVM::Data::cardtable_start_address", Long.class, "CardTable::CardValue*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck {
private static final Map<String, Map<String, Version>> JVMCI_MIN_VERSIONS = Map.of(
"21", Map.of(DEFAULT_VENDOR_ENTRY, createLegacyVersion(23, 1, 33)),
"23", Map.of(
"Oracle Corporation", createLabsJDKVersion("23+24", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+24", 1)));
"Oracle Corporation", createLabsJDKVersion("23+25", 1),
DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("23+25", 1)));
private static final int NA = 0;
/**
* Minimum Java release supported by Graal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public abstract class HotSpotHostForeignCallsProvider extends HotSpotForeignCall
*
* @see sun.misc.Unsafe#copyMemory
*/
@SuppressWarnings("javadoc") //
public static final ForeignCallSignature UNSAFE_ARRAYCOPY = new ForeignCallSignature("unsafe_arraycopy", void.class, Word.class, Word.class, Word.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public class KnownTruffleTypes extends AbstractKnownTruffleTypes {
public final ResolvedJavaField OptimizedCallTarget_rootNode = findField(OptimizedCallTarget, "rootNode");

public final ResolvedJavaType OptimizedDirectCallNode = lookupTypeCached("com.oracle.truffle.runtime.OptimizedDirectCallNode");
public final ResolvedJavaField OptimizedDirectCallNode_currentCallTarget = findField(OptimizedDirectCallNode, "currentCallTarget");
public final ResolvedJavaField OptimizedDirectCallNode_inliningForced = findField(OptimizedDirectCallNode, "inliningForced");
public final ResolvedJavaField OptimizedDirectCallNode_callCount = findField(OptimizedDirectCallNode, "callCount");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,56 +28,42 @@
import java.util.List;

import org.graalvm.collections.EconomicSet;
import jdk.graal.compiler.debug.GraalError;

import jdk.graal.compiler.nodes.Invoke;
import jdk.graal.compiler.nodes.ValueNode;
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderContext;
import jdk.graal.compiler.nodes.graphbuilderconf.InlineInvokePlugin;

import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.ResolvedJavaMethod;

public final class PEAgnosticInlineInvokePlugin implements InlineInvokePlugin {
private final EconomicSet<Invoke> invokeToTruffleCallNode = EconomicSet.create();

private final EconomicSet<Invoke> directInvokes = EconomicSet.create();
private final List<Invoke> indirectInvokes = new ArrayList<>();
private final PartialEvaluator partialEvaluator;
private JavaConstant lastDirectCallNode;
private boolean indirectCall;

public PEAgnosticInlineInvokePlugin(PartialEvaluator partialEvaluator) {
this.partialEvaluator = partialEvaluator;
}

@Override
public InlineInfo shouldInlineInvoke(GraphBuilderContext builder, ResolvedJavaMethod original, ValueNode[] arguments) {
InlineInfo inlineInfo = partialEvaluator.asInlineInfo(original);
if (original.equals(partialEvaluator.types.OptimizedCallTarget_callDirect)) {
ValueNode arg0 = arguments[1];
if (!arg0.isConstant()) {
GraalError.shouldNotReachHere("The direct call node does not resolve to a constant!"); // ExcludeFromJacocoGeneratedReport
}
lastDirectCallNode = (JavaConstant) arg0.asConstant();
public InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args) {
if (method.equals(partialEvaluator.types.OptimizedCallTarget_callDirect)) {
return InlineInfo.DO_NOT_INLINE_WITH_EXCEPTION;
}
if (original.equals(partialEvaluator.types.OptimizedCallTarget_callIndirect)) {
indirectCall = true;
}
return inlineInfo;
return partialEvaluator.asInlineInfo(method);
}

@Override
public void notifyNotInlined(GraphBuilderContext b, ResolvedJavaMethod original, Invoke invoke) {
if (original.equals(partialEvaluator.types.OptimizedCallTarget_callDirect)) {
invokeToTruffleCallNode.add(invoke);
lastDirectCallNode = null;
} else if (lastDirectCallNode == null && indirectCall) {
indirectCall = false;
directInvokes.add(invoke);
} else if (original.equals(partialEvaluator.types.OptimizedCallTarget_callBoundary)) {
indirectInvokes.add(invoke);
}
}

public EconomicSet<Invoke> getInvokeToTruffleCallNode() {
return invokeToTruffleCallNode;
public EconomicSet<Invoke> getDirectInvokes() {
return directInvokes;
}

public List<Invoke> getIndirectInvokes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ protected void run(StructuredGraph graph, TruffleTierContext context) {
if (scope != null) {
scope.setCallTree(tree);
}

tree.dumpBasic("Before Inline");
if (TruffleCompilerOptions.Inlining.getValue(context.compilerOptions)) {
policy.run(tree);
Expand Down
Loading

0 comments on commit 78ec64e

Please sign in to comment.