Skip to content

[GR-62356] Replace ASM in compiler with ClassFile API #10758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
49 changes: 5 additions & 44 deletions compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,6 @@
"urls" : ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/batik-all-1.7.jar"],
},

"ASM_9.7.1" : {
"digest" : "sha512:4767b01603dad5c79cc1e2b5f3722f72b1059d928f184f446ba11badeb1b381b3a3a9a801cc43d25d396df950b09d19597c73173c411b1da890de808b94f1f50",
"sourceDigest" : "sha512:d7c0de5912d04949a3d06cad366ff35a877da2682d9c74579625d62686032ea9349aff6102b17f92e9ec7eb4e9b1cd906b649c6a3ac798bfb9e31e5425de009d",
"maven" : {
"groupId" : "org.ow2.asm",
"artifactId" : "asm",
"version" : "9.7.1",
},
"license" : "BSD-new",
},

"ASM_TREE_9.7.1" : {
"digest" : "sha512:e55008c392fdd35e95d3404766b12dd4b46e13d5c362fcd0ab42a65751a82737eaf0ebc857691d1916190d34407adfde4437615d69c278785416fd911e00978d",
"sourceDigest" : "sha512:3cea80bc7b55679dfa3d2065c6cb6951007cc7817082e9fcf4c5e3cdc073c22eddf7c7899cff60b1092049ec9038e8d3aa9a8828ef731739bda8b5afcec30e86",
"maven" : {
"groupId" : "org.ow2.asm",
"artifactId" : "asm-tree",
"version" : "9.7.1",
},
"dependencies" : ["ASM_9.7.1"],
"license" : "BSD-new",
},

"ASM_UTIL_9.7.1" : {
"digest" : "sha512:522d793d15a2c5ea6504a50222cf0750f1eab7b881cf289675042539b1aba8b3868197b1bebe729de728dd10020eb028ae16252dcd5d84fdcbf7f925832bc269",
"sourceDigest" : "sha512:387aa887bfec24aec287d9aacebfdc0c2e1ab16a4adce933aecac6fc41545ce43a3eea0ed139db52dd0d0af910cfd2162aa4d6330a81b32b64b36f03b49db66a",
"maven" : {
"groupId" : "org.ow2.asm",
"artifactId" : "asm-util",
"version" : "9.7.1",
},
"dependencies" : ["ASM_9.7.1"],
"license" : "BSD-new",
},

"HSDIS" : {
"urlbase" : "https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/hsdis",
"packedResource" : True,
Expand Down Expand Up @@ -248,8 +213,6 @@
"dependencies" : [
"jdk.graal.compiler",
"mx:JUNIT",
"ASM_TREE_9.7.1",
"ASM_UTIL_9.7.1",
"JAVA_ALLOCATION_INSTRUMENTER",
"truffle:TRUFFLE_SL_TEST",
"truffle:TRUFFLE_TEST",
Expand Down Expand Up @@ -295,7 +258,7 @@
"truffle:TRUFFLE_DSL_PROCESSOR"
],
"checkstyle" : "jdk.graal.compiler",
"javaCompliance" : "21+",
"javaCompliance" : "23+",
"jacoco" : "exclude",
"graalCompilerSourceEdition": "ignore",
},
Expand Down Expand Up @@ -336,8 +299,8 @@
},
"jacoco" : "exclude",
"checkstyle": "jdk.graal.compiler",
"javaCompliance" : "21+",
"javaPreviewNeeded": "21+",
"javaCompliance" : "23+",
"javaPreviewNeeded": "23+",
"workingSets" : "Graal,HotSpot,Test",
"graalCompilerSourceEdition": "ignore",
},
Expand All @@ -347,7 +310,7 @@
"sourceDirs" : ["src"],
"dependencies" : ["mx:JMH_1_21", "jdk.graal.compiler.microbenchmarks"],
"checkstyle" : "jdk.graal.compiler",
"javaCompliance" : "21+",
"javaCompliance" : "23+",
"annotationProcessors" : ["mx:JMH_1_21"],
"spotbugsIgnoresGenerated" : True,
"workingSets" : "Graal,Bench",
Expand All @@ -370,7 +333,7 @@
],
},
"checkstyle" : "jdk.graal.compiler",
"javaCompliance" : "21+",
"javaCompliance" : "23+",
"checkPackagePrefix" : "false",
"annotationProcessors" : ["mx:JMH_1_21"],
"spotbugsIgnoresGenerated" : True,
Expand Down Expand Up @@ -519,8 +482,6 @@
"truffle:TRUFFLE_COMPILER",
"truffle:TRUFFLE_RUNTIME",
"regex:TREGEX",
"ASM_TREE_9.7.1",
"ASM_UTIL_9.7.1",
],
"exclude" : [
"mx:JUNIT",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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 @@ -39,7 +39,6 @@
import java.util.Set;

import jdk.graal.compiler.debug.DebugOptions;

import jdk.internal.module.Modules;

public class ModuleSupport {
Expand Down Expand Up @@ -110,7 +109,7 @@ public static List<String> getJRTGraalClassNames() throws IOException {

Path top = fs.getPath("/modules/");
Files.find(top, Integer.MAX_VALUE,
(path, attrs) -> attrs.isRegularFile()).forEach(p -> {
(_, attrs) -> attrs.isRegularFile()).forEach(p -> {
int nameCount = p.getNameCount();
if (nameCount > 2) {
String base = p.getName(nameCount - 1).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, 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 All @@ -26,6 +26,9 @@

import static org.junit.Assume.assumeTrue;

import org.junit.Before;
import org.junit.Test;

import jdk.graal.compiler.core.common.cfg.BasicBlock;
import jdk.graal.compiler.core.test.MatchRuleTest;
import jdk.graal.compiler.lir.LIR;
Expand All @@ -37,9 +40,6 @@
import jdk.graal.compiler.lir.amd64.AMD64ControlFlow.CmpConstBranchOp;
import jdk.graal.compiler.lir.amd64.AMD64ControlFlow.CmpDataBranchOp;
import jdk.graal.compiler.lir.amd64.AMD64Unary;
import org.junit.Before;
import org.junit.Test;

import jdk.vm.ci.amd64.AMD64;
import jdk.vm.ci.amd64.AMD64Kind;

Expand Down Expand Up @@ -103,7 +103,7 @@ public void testVolatileExtension() {
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Unary.MemoryOp) {
ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
ins.visitEachOutput((value, _, _) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
assertFalse("MemoryOp expected only once in first block", found);
found = true;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public void testVolatileExtensionDifferentBlocks() {
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Unary.MemoryOp) {
ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
ins.visitEachOutput((value, _, _) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
assertFalse("MemoryOp expected only once in first block", found);
found = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2025, 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 @@ -58,7 +58,7 @@ private static List<Class<?>> gatherClasses() throws IOException {
FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), Collections.emptyMap());
Path top = fs.getPath("/modules/");
Files.find(top, Integer.MAX_VALUE,
(path, attrs) -> attrs.isRegularFile()).forEach(p -> {
(_, attrs) -> attrs.isRegularFile()).forEach(p -> {
int nameCount = p.getNameCount();
if (nameCount > 2) {
String base = p.getName(nameCount - 1).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2025, 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 @@ -238,7 +238,6 @@ public void test() {
runTest(new InvariantsTool());
}

@SuppressWarnings("try")
public static void runTest(InvariantsTool tool) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
Expand Down Expand Up @@ -383,7 +382,7 @@ public static void runTest(InvariantsTool tool) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
try (DebugContext debug = new Builder(options).build()) {
StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(method).build();
try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
try (DebugCloseable _ = debug.disableIntercept(); DebugContext.Scope _ = debug.scope("CheckingGraph", graph, method)) {
graphBuilderSuite.apply(graph, context);
// update phi stamps
graph.getNodes().filter(PhiNode.class).forEach(PhiNode::inferStamp);
Expand Down Expand Up @@ -437,7 +436,7 @@ public static void runTest(InvariantsTool tool) {
try (DebugContext debug = new Builder(options).build()) {
boolean isSubstitution = method.getAnnotation(Snippet.class) != null;
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).setIsSubstitution(isSubstitution).build();
try (DebugCloseable s = debug.disableIntercept(); DebugContext.Scope ds = debug.scope("CheckingGraph", graph, method)) {
try (DebugCloseable _ = debug.disableIntercept(); DebugContext.Scope _ = debug.scope("CheckingGraph", graph, method)) {
checkMethod(method);
graphBuilderSuite.apply(graph, context);
// update phi stamps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, 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 @@ -104,7 +104,6 @@ protected InstalledCode getCode(ResolvedJavaMethod installedCodeOwner, Structure
}
}

@SuppressWarnings("try")
private InstalledCode getCodeHelper(ResolvedJavaMethod installedCodeOwner, StructuredGraph graph, boolean forceCompile, boolean installAsDefault, OptionValues options) {
CompilationIdentifier compilation = new CompilationIdentifier() {
@Override
Expand Down Expand Up @@ -138,9 +137,9 @@ public void onStuckCompilation(CompilationWatchDog watchDog, Thread watched, Com
};

CompilationWatchDog watch = CompilationWatchDog.watch(compilation, options, false, longCompilationHandler, null);
try (CompilationWatchDog watchScope = watch) {
try (CompilationWatchDog _ = watch) {
event("start compiling");
try (TTY.Filter f = new TTY.Filter()) {
try (TTY.Filter _ = new TTY.Filter()) {
return super.getCode(installedCodeOwner, graph, forceCompile, installAsDefault, options);
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, 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 @@ -61,15 +61,14 @@ protected void testConditionalElimination(String snippet, String referenceSnippe
testConditionalElimination(snippet, referenceSnippet, false, false);
}

@SuppressWarnings("try")
protected void testConditionalElimination(String snippet, String referenceSnippet, boolean applyConditionalEliminationOnReference, boolean applyLowering) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
CoreProviders context = getProviders();
CanonicalizerPhase canonicalizer1 = createCanonicalizerPhase();
CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest", graph)) {
try (DebugContext.Scope _ = debug.scope("ConditionalEliminationTest", graph)) {
prepareGraph(graph, canonicalizer1, context, applyLowering);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
canonicalizer.apply(graph, context);
Expand All @@ -78,7 +77,7 @@ protected void testConditionalElimination(String snippet, String referenceSnippe
debug.handle(t);
}
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
try (DebugContext.Scope _ = debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
prepareGraph(referenceGraph, canonicalizer, context, applyLowering);
if (applyConditionalEliminationOnReference) {
new ConditionalEliminationPhase(canonicalizer, true).apply(referenceGraph, context);
Expand Down
Loading
Loading