Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/mx.compiler/mx_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def compiler_gate_benchmark_runner(tasks, extraVMarguments=None, prefix='', task
# ensure we can run with --enable-preview
with Task(prefix + 'DaCapo_enable-preview:fop', tasks, tags=GraalTags.test, report=task_report_component) as t:
if t:
_gate_dacapo('fop', 8, ['--enable-preview', '-Djdk.graal.CompilationFailureAction=ExitVM'])
_gate_dacapo('fop', 8, benchVmArgs + ['--enable-preview', '-Djdk.graal.CompilationFailureAction=ExitVM'])

# run Scala DaCapo benchmarks #
###############################
Expand Down
4 changes: 3 additions & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,14 @@
],
},
"uses" : [
"jdk.graal.compiler.hotspot.meta.DefaultHotSpotLoweringProvider.Extensions",
"jdk.graal.compiler.hotspot.meta.HotSpotInvocationPluginProvider",
"jdk.graal.compiler.lir.LIRInstructionVerifier",
"jdk.graal.compiler.core.common.CompilerProfiler",
"jdk.graal.compiler.truffle.substitutions.GraphBuilderInvocationPluginProvider",
"jdk.graal.compiler.truffle.phases.inlining.InliningPolicyProvider",
"jdk.graal.compiler.truffle.host.TruffleHostEnvironment.Lookup",
"jdk.graal.compiler.truffle.substitutions.GraphDecoderInvocationPluginProvider"
],
"annotationProcessors" : [
"GRAAL_PROCESSOR"
Expand Down Expand Up @@ -557,7 +560,6 @@
"jdk.graal.compiler.debug.DebugHandlersFactory",
"jdk.graal.compiler.debug.TTYStreamProvider",
"jdk.graal.compiler.debug.PathUtilitiesProvider",
"jdk.graal.compiler.hotspot.HotSpotCodeCacheListener",
"jdk.graal.compiler.hotspot.HotSpotBackendFactory",
"jdk.graal.compiler.hotspot.meta.HotSpotInvocationPluginProvider",
"jdk.graal.compiler.nodes.graphbuilderconf.GeneratedPluginFactory",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ private static void disambiguateNames(List<GeneratedPlugin> plugins) {
disambiguateWith(plugins, plugin -> plugin.getPluginName() + "__" + nextId[0]++);
}

/**
* Map from an architecture's name as it appears in a package name to its name returned by
* {@code jdk.vm.ci.code.Architecture.getName()}.
*/
private static final Map<String, String> SUPPORTED_JVMCI_ARCHITECTURES = Map.of(
"amd64", "AMD64",
"aarch64", "aarch64",
"riscv64", "riscv64");

private static void createPluginFactory(AbstractProcessor processor, Element topLevelClass, List<GeneratedPlugin> plugins) {
PackageElement pkg = (PackageElement) topLevelClass.getEnclosingElement();

String genClassName = "PluginFactory_" + topLevelClass.getSimpleName();
String arch = SUPPORTED_JVMCI_ARCHITECTURES.get(pkg.getSimpleName().toString());

String qualifiedGenClassName = pkg.getQualifiedName() + "." + genClassName;
try {
Expand All @@ -131,7 +141,15 @@ private static void createPluginFactory(AbstractProcessor processor, Element top
plugin.generate(processor, out);
out.printf("\n");
}
out.printf("public class %s implements GeneratedPluginFactory {\n", genClassName);
if (arch != null) {
out.printf("public class %s implements GeneratedPluginFactory, jdk.graal.compiler.core.ArchitectureSpecific {\n", genClassName);
out.printf(" @Override\n");
out.printf(" public String getArchitecture() {\n");
out.printf(" return \"%s\";\n", arch);
out.printf(" }\n");
} else {
out.printf("public class %s implements GeneratedPluginFactory {\n", genClassName);
}
createPluginFactoryMethod(out, plugins);
out.printf("}\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
package jdk.graal.compiler.core.test;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import jdk.graal.compiler.api.replacements.Fold;
import jdk.graal.compiler.nodes.PluginReplacementNode;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.graphbuilderconf.GeneratedInvocationPlugin;
import jdk.graal.compiler.nodes.java.MethodCallTargetNode;
Expand All @@ -39,7 +41,9 @@
import jdk.vm.ci.meta.ResolvedJavaType;

/**
* Verifies that all {@link Fold} annotated methods have at least one caller.
* Verifies that all {@link Fold} annotated methods have at least one caller from non-generated
* code. Ideally, the class should verify that foldable methods are only called from snippets but
* that requires a more global analysis (i.e., to know whether a caller is used within a snippet).
*/
public class VerifyFoldableMethods extends VerifyPhase<CoreProviders> {

Expand All @@ -48,32 +52,59 @@ public boolean checkContract() {
return false;
}

private final Map<ResolvedJavaMethod, Boolean> foldables = new ConcurrentHashMap<>();
ResolvedJavaType generatedInvocationPluginType;
/**
* Map from a foldable method to one of its callers. The absence of a caller is represented a
* foldable method mapping to itself.
*/
private final Map<ResolvedJavaMethod, ResolvedJavaMethod> foldableCallers = new ConcurrentHashMap<>();

/*
* Super types or interfaces for generated classes. Calls from methods in these classes are
* ignored.
*/
Set<ResolvedJavaType> generatedClassSupertypes;

/**
* Determines if {@code method} is in a generated class.
*/
private boolean isGenerated(ResolvedJavaMethod method, CoreProviders context) {
if (generatedClassSupertypes == null) {
generatedClassSupertypes = Set.of(
context.getMetaAccess().lookupJavaType(GeneratedInvocationPlugin.class),
context.getMetaAccess().lookupJavaType(PluginReplacementNode.ReplacementFunction.class));
}
ResolvedJavaType declaringClass = method.getDeclaringClass();
for (ResolvedJavaType t : generatedClassSupertypes) {
if (t.isAssignableFrom(declaringClass)) {
return true;
}
}
return false;
}

@Override
protected void verify(StructuredGraph graph, CoreProviders context) {
ResolvedJavaMethod method = graph.method();
if (method.getAnnotation(Fold.class) != null) {
foldables.putIfAbsent(method, false);
foldableCallers.putIfAbsent(method, method);
} else {
if (generatedInvocationPluginType == null) {
generatedInvocationPluginType = context.getMetaAccess().lookupJavaType(GeneratedInvocationPlugin.class);
}
if (!generatedInvocationPluginType.isAssignableFrom(method.getDeclaringClass())) {
if (!isGenerated(method, context)) {
for (MethodCallTargetNode t : graph.getNodes(MethodCallTargetNode.TYPE)) {
ResolvedJavaMethod callee = t.targetMethod();
if (callee.getAnnotation(Fold.class) != null) {
foldables.put(callee, true);
foldableCallers.put(callee, method);
}
}
}
}
}

public void finish() {
String uncalled = foldables.entrySet().stream().filter(e -> e.getValue() == false).map(e -> e.getKey().format("%H.%n(%p)")).collect(Collectors.joining(System.lineSeparator() + " "));
if (uncalled.length() != 0) {
String uncalled = foldableCallers.entrySet().stream()//
.filter(e -> e.getValue() == e.getKey())//
.map(e -> e.getKey().format("%H.%n(%p)"))//
.collect(Collectors.joining(System.lineSeparator() + " "));
if (!uncalled.isEmpty()) {
throw new VerificationError(String.format("Methods annotated with @" + Fold.class.getSimpleName() + " appear to have no usages:%n %s", uncalled));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
*/
package jdk.graal.compiler.code;

import jdk.graal.compiler.serviceprovider.LibGraalService;
import jdk.vm.ci.code.CodeCacheProvider;
import jdk.vm.ci.code.InstalledCode;
import jdk.graal.compiler.options.OptionValues;

/**
* Interface providing capability for disassembling machine code.
*/
@LibGraalService
public interface DisassemblerProvider {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
public interface ArchitectureSpecific {
/**
* Gets the {@linkplain Architecture#getName() name} of the architecture this Graal component is
* associated with.
* associated with. Note that the JVMCI architecture names are somewhat inconsistent wrt case
* (i.e., "AMD64", "aarch64" and "riscv64").
*/
String getArchitecture();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
*/
package jdk.graal.compiler.core.common;

import jdk.graal.compiler.serviceprovider.LibGraalService;
import jdk.vm.ci.meta.ResolvedJavaMethod;

/**
* A profiling service that consumes compilation related events. The Java Flight Recorder (JFR) is
* an example of such a service that can be exposed via this interface.
*/
@LibGraalService
public interface CompilerProfiler {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static synchronized EconomicMap<Class<? extends Node>, List<MatchStatemen
}
}

if (result.size() == 0) {
if (result.isEmpty()) {
return null;
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import jdk.graal.compiler.core.ArchitectureSpecific;
import jdk.graal.compiler.core.gen.NodeLIRBuilder;
import jdk.graal.compiler.core.gen.NodeMatchRules;
import jdk.graal.compiler.serviceprovider.LibGraalService;

@LibGraalService
public interface MatchStatementSet extends ArchitectureSpecific {
/**
* @return the {@link NodeLIRBuilder} subclass which defined this set of {@link MatchStatement}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@

import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.serviceprovider.GraalServices;
import jdk.graal.compiler.serviceprovider.LibGraalService;

/**
* Factory for creating {@link DebugHandler}s.
*/
@LibGraalService
public interface DebugHandlersFactory {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package jdk.graal.compiler.debug;

import jdk.graal.compiler.serviceprovider.LibGraalService;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -51,6 +53,7 @@
* image. Delegating to {@link StandardPathUtilitiesProvider} is the recommended way to work in the
* context of building a native image.
*/
@LibGraalService
public interface PathUtilitiesProvider {
/**
* Gets a value based on {@code name} that can be passed to {@link #getPath(String, String...)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
*/
package jdk.graal.compiler.debug;

import jdk.graal.compiler.serviceprovider.LibGraalService;

import java.io.PrintStream;

/**
* Provides a {@link PrintStream} that writes to the underlying log stream of the VM.
*/
@LibGraalService
public interface TTYStreamProvider {
PrintStream getStream();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import jdk.graal.compiler.serviceprovider.LibGraalService;
import org.graalvm.collections.EconomicMap;
import jdk.graal.compiler.core.Instrumentation;
import jdk.graal.compiler.core.common.SuppressFBWarnings;
Expand All @@ -58,6 +59,7 @@
* have a unique {@link #name} and {@link #autoSelectionPriority}. The latter imposes a total
* ordering between factories for the purpose of auto-selecting the factory to use.
*/
@LibGraalService
public abstract class CompilerConfigurationFactory implements Comparable<CompilerConfigurationFactory> {

public enum ShowConfigurationLevel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ public NodeClass<?>[] getSnippetNodeClasses() {
return snippetNodeClasses;
}

ResolvedJavaType lookupSnippetType(Class<?> clazz) {
public ResolvedJavaType lookupSnippetType(Class<?> clazz) {
SnippetResolvedJavaType type = snippetTypes.get(clazz);
if (type == null && isGraalClass(clazz)) {
// During libgraal image building references to Graal classes from snippets are tracked.
// During image building, references to Graal classes from snippets are tracked.
// If a class isn't found in this path at runtime it means something was missed.
throw new GraalError("Missing Graal class " + clazz.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ private HotSpotGraalRuntime.HotSpotGC getSelectedGC() throws GraalError {
// of the mark word.
public final int lockingMode = getFlag("LockingMode", Integer.class);

public final int lockingModeMonitor = getConstant("LockingMode::LM_MONITOR", Integer.class, 0, JDK >= 22);
public final int lockingModeStack = getConstant("LockingMode::LM_LEGACY", Integer.class, 1, JDK >= 22);
public final int lockingModeLightweight = getConstant("LockingMode::LM_LIGHTWEIGHT", Integer.class, 2, JDK >= 22);

Expand Down Expand Up @@ -348,7 +347,6 @@ public int threadLastJavaFpOffset() {
public final int frameInterpreterFrameLastSpOffset = getConstant("frame::interpreter_frame_last_sp_offset", Integer.class, 0, osArch.equals("amd64"));

public final int lockMaskInPlace = getConstant("markWord::lock_mask_in_place", Integer.class);
public final int ageMaskInPlace = getConstant("markWord::age_mask_in_place", Integer.class);
public final int unlockedMask = getConstant("markWord::unlocked_value", Integer.class);
public final int monitorMask = getConstant("markWord::monitor_value", Integer.class);

Expand All @@ -359,8 +357,6 @@ public int threadLastJavaFpOffset() {
public final int objectMonitorEntryList = getFieldOffset("ObjectMonitor::_EntryList", Integer.class, "ObjectWaiter*");
public final int objectMonitorSucc = getFieldOffset("ObjectMonitor::_succ", Integer.class, "JavaThread*");

public final long objectMonitorAnonymousOwner = getConstant("ObjectMonitor::ANONYMOUS_OWNER", Long.class, 1L, JDK >= 22);

public final int markWordNoHashInPlace = getConstant("markWord::no_hash_in_place", Integer.class);
public final int markWordNoLockInPlace = getConstant("markWord::no_lock_in_place", Integer.class);

Expand All @@ -380,11 +376,6 @@ public long defaultPrototypeMarkWord() {

public final int methodCompiledEntryOffset = getFieldOffset("Method::_from_compiled_entry", Integer.class, "address");

public final int invocationCounterOffset = getFieldOffset("MethodCounters::_invocation_counter", Integer.class, "InvocationCounter");
public final int backedgeCounterOffset = getFieldOffset("MethodCounters::_backedge_counter", Integer.class, "InvocationCounter");
public final int invocationCounterIncrement = getConstant("InvocationCounter::count_increment", Integer.class);
public final int invocationCounterShift = getConstant("InvocationCounter::count_shift", Integer.class);

public final int compilationLevelFullOptimization = getConstant("CompLevel_full_optimization", Integer.class);

public final int heapWordSize = getConstant("HeapWordSize", Integer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.tiers.CompilerConfiguration;
import jdk.graal.compiler.replacements.classfile.ClassfileBytecodeProvider;
import jdk.graal.compiler.serviceprovider.LibGraalService;
import jdk.vm.ci.code.RegisterConfig;
import jdk.vm.ci.code.TargetDescription;
import jdk.vm.ci.common.InitTimer;
Expand All @@ -80,6 +81,7 @@
import jdk.vm.ci.meta.Value;
import jdk.vm.ci.runtime.JVMCIBackend;

@LibGraalService
public abstract class HotSpotBackendFactory implements ArchitectureSpecific {

protected HotSpotGraalConstantFieldProvider createConstantFieldProvider(GraalHotSpotVMConfig config, MetaAccessProvider metaAccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public int cardQueueIndexOffset() {

@Override
public byte dirtyCardValue() {
return HotSpotReplacementsUtil.dirtyCardValue(config);
return config.dirtyCardValue;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
*/
package jdk.graal.compiler.hotspot;

import java.util.ArrayList;
import java.util.List;

import jdk.graal.compiler.code.CompilationResult;
import jdk.graal.compiler.debug.DebugContext;
import jdk.graal.compiler.debug.DebugOptions;
import jdk.graal.compiler.serviceprovider.GraalServices;
import jdk.vm.ci.code.CompiledCode;
import jdk.vm.ci.code.InstalledCode;
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
Expand All @@ -39,14 +35,9 @@
public class HotSpotGraalVMEventListener implements HotSpotVMEventListener {

private HotSpotGraalRuntime runtime;
private List<HotSpotCodeCacheListener> listeners;

HotSpotGraalVMEventListener(HotSpotGraalRuntime runtime) {
setRuntime(runtime);
listeners = new ArrayList<>();
for (HotSpotCodeCacheListener listener : GraalServices.load(HotSpotCodeCacheListener.class)) {
listeners.add(listener);
}
}

void setRuntime(HotSpotGraalRuntime runtime) {
Expand All @@ -72,9 +63,6 @@ public void notifyInstall(HotSpotCodeCacheProvider codeCache, InstalledCode inst
if (debug.isLogEnabled()) {
debug.log("%s", codeCache.disassemble(installedCode));
}
for (HotSpotCodeCacheListener listener : listeners) {
listener.notifyInstall(codeCache, installedCode, compiledCode);
}
}

@Override
Expand Down
Loading