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
OracleLabsAutomation committed May 31, 2024
2 parents f1a2d95 + 49c5ecd commit 2a04dde
Show file tree
Hide file tree
Showing 37 changed files with 808 additions and 359 deletions.
2 changes: 1 addition & 1 deletion common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.25.0",
"mx_version": "7.25.5",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ public static boolean isAddSubtractConstant(JavaConstant constValue) {
case Long:
return AArch64MacroAssembler.isAddSubtractImmediate(constValue.asLong(), true);
case Object:
return constValue.isNull();
/* Object constants can't be encoded as immediates in add/subtract. */
return false;
default:
throw GraalError.shouldNotReachHereUnexpectedValue(constValue.getJavaKind().getStackKind()); // ExcludeFromJacocoGeneratedReport
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@

import jdk.graal.compiler.code.CompilationResult;
import jdk.graal.compiler.core.LIRGenerationPhase;
import jdk.graal.compiler.core.common.GraalOptions;
import jdk.graal.compiler.core.common.alloc.LinearScanOrder;
import jdk.graal.compiler.core.common.alloc.RegisterAllocationConfig;
import jdk.graal.compiler.core.common.cfg.CodeEmissionOrder;
import jdk.graal.compiler.core.common.cfg.CodeEmissionOrder.ComputationTime;
import jdk.graal.compiler.core.target.Backend;
import jdk.graal.compiler.debug.Assertions;
import jdk.graal.compiler.debug.CounterKey;
import jdk.graal.compiler.debug.DebugCloseable;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.GraalError;
import jdk.graal.compiler.debug.TimerKey;
import jdk.graal.compiler.core.common.GraalOptions;
import jdk.graal.compiler.core.common.cfg.CodeEmissionOrder;
import jdk.graal.compiler.core.common.cfg.CodeEmissionOrder.ComputationTime;
import jdk.graal.compiler.core.target.Backend;
import jdk.graal.compiler.lir.ComputeCodeEmissionOrder;
import jdk.graal.compiler.lir.LIR;
import jdk.graal.compiler.lir.alloc.OutOfRegistersException;
Expand All @@ -59,8 +60,6 @@
import jdk.graal.compiler.nodes.StructuredGraph.ScheduleResult;
import jdk.graal.compiler.nodes.cfg.HIRBlock;
import jdk.graal.compiler.nodes.spi.NodeLIRBuilderTool;
import jdk.graal.compiler.debug.Assertions;

import jdk.vm.ci.code.RegisterConfig;
import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.code.site.ConstantReference;
Expand Down Expand Up @@ -168,6 +167,11 @@ private static LIRGenerationResult emitLIR0(Backend backend,
// Dump LIR along with HIR (the LIR is looked up from context)
debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "After LIR generation");
LIRGenerationResult result = emitLowLevel(backend.getTarget(), lirGenRes, lirGen, lirSuites, registerAllocationConfig, blockOrder);
/*
* LIRGeneration may have changed the CFG, so in case a schedule is needed afterward
* we make sure it will be recomputed.
*/
graph.clearLastSchedule();
return result;
} catch (Throwable e) {
throw debug.handle(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,14 @@ public void profileReplayEpilogue(DebugContext debug, CompilationResult result,
String codeSignature = null;
String graphSignature = null;
if (result != null) {
codeSignature = result.getCodeSignature();
assert graph != null;
String s = getCanonicalGraphString(graph);
graphSignature = CompilationResult.getSignature(s.getBytes(StandardCharsets.UTF_8));
try {
codeSignature = result.getCodeSignature();
assert graph != null;
String s = getCanonicalGraphString(graph);
graphSignature = CompilationResult.getSignature(s.getBytes(StandardCharsets.UTF_8));
} catch (Throwable t) {
throw debug.handle(t);
}
}
if (Options.WarnAboutCodeSignatureMismatch.getValue(debug.getOptions())) {
if (expectedCodeSignature != null && !Objects.equals(codeSignature, expectedCodeSignature)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ public void clear() {
protected int[] nodeStartOffsets;

public EncodedGraph(byte[] encoding, int startOffset, Object[] objects, NodeClass<?>[] types, StructuredGraph sourceGraph) {
this(encoding, startOffset, objects, types, sourceGraph.getAssumptions(), sourceGraph.getMethods(), sourceGraph.hasUnsafeAccess(), sourceGraph.trackNodeSourcePosition());
this(encoding,
startOffset,
objects,
types,
sourceGraph.getAssumptions(),
sourceGraph.isRecordingInlinedMethods() ? sourceGraph.getMethods() : null,
sourceGraph.hasUnsafeAccess(),
sourceGraph.trackNodeSourcePosition());
}

public EncodedGraph(byte[] encoding, int startOffset, Object[] objects, NodeClass<?>[] types, Assumptions assumptions, List<ResolvedJavaMethod> inlinedMethods,
Expand Down Expand Up @@ -140,6 +147,10 @@ public Assumptions getAssumptions() {
return assumptions;
}

public boolean isRecordingInlinedMethods() {
return inlinedMethods != null;
}

public List<ResolvedJavaMethod> getInlinedMethods() {
return inlinedMethods;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ protected IntrinsicGraphBuilder(OptionValues options,
if (graphBuilderConfig != null && !method.isNative()) {
graph.start().setStateAfter(createStateAfterStartOfReplacementGraph(method, graphBuilderConfig));
}
// Record method dependency in the graph
graph.recordMethod(method);

Signature sig = method.getSignature();
int max = sig.getParameterCount(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ public class Classfile {
private final List<ClassfileBytecode> codeAttributes;

private static final int MAJOR_VERSION_JAVA_MIN = 51; // JDK7
private static final int MAJOR_VERSION_JAVA_MAX = 67; // JDK23
private static final int MAGIC = 0xCAFEBABE;

// An upper limit on the major class version is not set as it doesn't
// make much of a difference whether a ClassFormatError or the more specific
// a UnsupportedClassVersionError is thrown and it avoids the need for an
// Graal change when updating to a newer JDK.

/**
* Creates a {@link Classfile} by parsing the class file bytes for {@code type} loadable from
* {@code context}.
Expand All @@ -67,26 +71,30 @@ public Classfile(ResolvedJavaType type, DataInputStream stream, ClassfileBytecod

int minor = stream.readUnsignedShort();
int major = stream.readUnsignedShort();
if (major < MAJOR_VERSION_JAVA_MIN || major > MAJOR_VERSION_JAVA_MAX) {
if (major < MAJOR_VERSION_JAVA_MIN) {
throw new UnsupportedClassVersionError("Unsupported class file version: " + major + "." + minor);
}

ClassfileConstantPool cp = new ClassfileConstantPool(stream, context);
try {
ClassfileConstantPool cp = new ClassfileConstantPool(stream, context);

// access_flags, this_class, super_class
skipFully(stream, 6);
// access_flags, this_class, super_class
skipFully(stream, 6);

// interfaces
skipFully(stream, stream.readUnsignedShort() * 2);
// interfaces
skipFully(stream, stream.readUnsignedShort() * 2);

// fields
skipFields(stream);
// fields
skipFields(stream);

// methods
codeAttributes = readMethods(stream, cp);
// methods
codeAttributes = readMethods(stream, cp);

// attributes
skipAttributes(stream);
// attributes
skipAttributes(stream);
} catch (ClassFormatError cfe) {
throw (ClassFormatError) new ClassFormatError("Error reading class file with version " + major + "." + minor).initCause(cfe);
}
}

public ClassfileBytecode getCode(String name, String descriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static final ClassfileConstant readConstant(DataInputStream stream) throws IOExc
skipFully(stream, 4); // bootstrap_method_attr_index, name_and_type_index
return new ClassfileConstant.Unsupported(tag, "CONSTANT_InvokeDynamic_info");
default:
throw new GraalError("Invalid constant pool tag: " + tag);
throw new ClassFormatError("Invalid constant pool tag: " + tag);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@
import jdk.graal.compiler.graph.Node;
import jdk.graal.compiler.lir.asm.CompilationResultBuilderFactory;
import jdk.graal.compiler.lir.phases.LIRSuites;
import jdk.graal.compiler.nodes.NodeView;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.calc.NarrowNode;
import jdk.graal.compiler.nodes.calc.ZeroExtendNode;
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.BytecodeExceptionMode;
import jdk.graal.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
Expand All @@ -96,8 +93,6 @@
import jdk.graal.compiler.phases.tiers.Suites;
import jdk.graal.compiler.phases.util.Providers;
import jdk.graal.compiler.serviceprovider.GraalServices;
import jdk.graal.compiler.truffle.nodes.AnyExtendNode;
import jdk.graal.compiler.truffle.nodes.AnyNarrowNode;
import jdk.graal.compiler.truffle.nodes.TruffleAssumption;
import jdk.graal.compiler.truffle.phases.InstrumentPhase;
import jdk.graal.compiler.truffle.phases.InstrumentationSuite;
Expand Down Expand Up @@ -559,6 +554,7 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont
} catch (Throwable e) {
throw context.debug.handle(e);
}

}
if (wrapper.statistics != null) {
wrapper.statistics.afterTruffleTier(wrapper.compilable, graph);
Expand All @@ -569,17 +565,6 @@ private StructuredGraph truffleTier(TruffleCompilationWrapper wrapper, DebugCont
return graph;
}

private static void replaceAnyExtendNodes(StructuredGraph graph) {
// replace all AnyExtendNodes with ZeroExtendNodes
for (AnyExtendNode node : graph.getNodes(AnyExtendNode.TYPE)) {
node.replaceAndDelete(graph.addOrUnique(ZeroExtendNode.create(node.getValue(), 64, NodeView.DEFAULT)));
}
// replace all AnyNarrowNodes with NarrowNodes
for (AnyNarrowNode node : graph.getNodes(AnyNarrowNode.TYPE)) {
node.replaceAndDelete(graph.addOrUnique(NarrowNode.create(node.getValue(), 32, NodeView.DEFAULT)));
}
}

/**
* Compiles a graph produced by {@link TruffleTier}, i.e.
* {@link #truffleTier(TruffleCompilationWrapper, DebugContext)}.
Expand All @@ -601,7 +586,6 @@ public CompilationResult compilePEGraph(StructuredGraph graph,
InstalledCode[] outInstalledCode,
TruffleInliningScope inlining) {

replaceAnyExtendNodes(graph);
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("TruffleFinal")) {
debug.dump(DebugContext.BASIC_LEVEL, graph, "After TruffleTier");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2013, 2022, 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.phases;

import jdk.graal.compiler.nodes.NodeView;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.calc.NarrowNode;
import jdk.graal.compiler.nodes.calc.ZeroExtendNode;
import jdk.graal.compiler.phases.BasePhase;
import jdk.graal.compiler.truffle.TruffleTierContext;
import jdk.graal.compiler.truffle.nodes.AnyExtendNode;
import jdk.graal.compiler.truffle.nodes.AnyNarrowNode;

public final class ReplaceAnyExtendNodePhase extends BasePhase<TruffleTierContext> {
@Override
protected void run(StructuredGraph graph, TruffleTierContext context) {
// replace all AnyExtendNodes with ZeroExtendNodes
for (AnyExtendNode node : graph.getNodes(AnyExtendNode.TYPE)) {
node.replaceAndDelete(graph.addOrUnique(ZeroExtendNode.create(node.getValue(), 64, NodeView.DEFAULT)));
}
// replace all AnyNarrowNodes with NarrowNodes
for (AnyNarrowNode node : graph.getNodes(AnyNarrowNode.TYPE)) {
node.replaceAndDelete(graph.addOrUnique(NarrowNode.create(node.getValue(), 32, NodeView.DEFAULT)));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* 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
Expand Down Expand Up @@ -43,6 +43,7 @@ public TruffleTier(OptionValues options, PartialEvaluator partialEvaluator, Inst
appendPhase(new NeverPartOfCompilationPhase());
appendPhase(new MaterializeFramesPhase());
appendPhase(new SetIdentityForValueTypesPhase());
appendPhase(new ReplaceAnyExtendNodePhase());
if (!TruffleCompilerOptions.InlineAcrossTruffleBoundary.getValue(options)) {
appendPhase(new InliningAcrossTruffleBoundaryPhase());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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
Expand Down Expand Up @@ -421,10 +421,11 @@ public interface JDWPContext {
/**
* Returns the entry count for the monitor on the current thread.
*
* @param monitorOwnerThread the owner thread of the monitor
* @param monitor the monitor
* @return entry count of monitor
*/
int getMonitorEntryCount(Object monitor);
int getMonitorEntryCount(Object monitorOwnerThread, Object monitor);

/**
* Returns all owned guest-language monitor object of the input call frames.
Expand Down
Loading

0 comments on commit 2a04dde

Please sign in to comment.