Skip to content

Commit feec6c4

Browse files
committed
removed legacy JDK version support
1 parent 95ff8d4 commit feec6c4

File tree

6 files changed

+22
-137
lines changed

6 files changed

+22
-137
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/test/HotSpotManagedFailedSpeculationListTest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import jdk.graal.compiler.options.OptionValues;
3030
import jdk.graal.compiler.serviceprovider.SpeculationReasonGroup;
3131
import org.junit.Assert;
32-
import org.junit.Assume;
3332
import org.junit.Test;
3433

3534
import jdk.vm.ci.code.InstalledCode;
@@ -60,24 +59,8 @@ public static int deoptimizeSnippet() {
6059

6160
InstalledCode compiledMethod;
6261

63-
/**
64-
* Determines if {@link HotSpotNmethod} declares
65-
* {@code setSpeculationLog(HotSpotSpeculationLog)}. Only such versions properly add a tether
66-
* from an nmethod to the failed speculation list.
67-
*/
68-
private static boolean hasSpeculationLogTether() {
69-
try {
70-
HotSpotNmethod.class.getDeclaredMethod("setSpeculationLog", HotSpotSpeculationLog.class);
71-
return true;
72-
} catch (NoSuchMethodException e) {
73-
return false;
74-
}
75-
}
76-
7762
@Test
7863
public void testDeoptimize() throws Exception {
79-
Assume.assumeTrue(hasSpeculationLogTether());
80-
8164
// Compile and run deoptimizeSnippet
8265
test("deoptimizeSnippet");
8366

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/type/IntegerStamp.java

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import static jdk.graal.compiler.core.common.calc.FloatConvert.L2F;
3131
import static jdk.vm.ci.code.CodeUtil.isPowerOf2;
3232

33-
import java.lang.reflect.InvocationTargetException;
34-
import java.lang.reflect.Method;
3533
import java.nio.ByteBuffer;
3634

3735
import jdk.graal.compiler.core.common.LIRKind;
@@ -2434,34 +2432,16 @@ public Stamp foldStamp(Stamp resultStamp, Stamp input) {
24342432
private static final long INT_MASK = CodeUtil.mask(32);
24352433
private static final long LONG_MASK = CodeUtil.mask(64);
24362434

2437-
private static int integerCompress(int i, int mask) {
2438-
try {
2439-
Method compress = Integer.class.getDeclaredMethod("compress", int.class, int.class);
2440-
return (Integer) compress.invoke(null, i, mask);
2441-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
2442-
throw GraalError.shouldNotReachHere(e, "Integer.compress is introduced in Java 19");
2443-
}
2444-
}
2445-
2446-
private static long longCompress(long i, long mask) {
2447-
try {
2448-
Method compress = Long.class.getDeclaredMethod("compress", long.class, long.class);
2449-
return (Long) compress.invoke(null, i, mask);
2450-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
2451-
throw GraalError.shouldNotReachHere(e, "Long.compress is introduced in Java 19");
2452-
}
2453-
}
2454-
24552435
@Override
24562436
public Constant foldConstant(Constant a, Constant b) {
24572437
PrimitiveConstant i = (PrimitiveConstant) a;
24582438
PrimitiveConstant mask = (PrimitiveConstant) b;
24592439

24602440
if (i.getJavaKind() == JavaKind.Int) {
2461-
return JavaConstant.forInt(integerCompress(i.asInt(), mask.asInt()));
2441+
return JavaConstant.forInt(Integer.compress(i.asInt(), mask.asInt()));
24622442
} else {
24632443
GraalError.guarantee(i.getJavaKind() == JavaKind.Long, "unexpected Java kind %s", i.getJavaKind());
2464-
return JavaConstant.forLong(longCompress(i.asLong(), mask.asLong()));
2444+
return JavaConstant.forLong(Long.compress(i.asLong(), mask.asLong()));
24652445
}
24662446
}
24672447

@@ -2477,10 +2457,10 @@ protected Stamp foldStampImpl(Stamp a, Stamp b) {
24772457
}
24782458
// compress result will always be positive
24792459
return IntegerStamp.create(32,
2480-
integerCompress((int) valueStamp.mustBeSet(), (int) maskStamp.mustBeSet()) & INT_MASK,
2481-
integerCompress((int) valueStamp.mayBeSet(), (int) maskStamp.mayBeSet()) & INT_MASK,
2460+
Integer.compress((int) valueStamp.mustBeSet(), (int) maskStamp.mustBeSet()) & INT_MASK,
2461+
Integer.compress((int) valueStamp.mayBeSet(), (int) maskStamp.mayBeSet()) & INT_MASK,
24822462
0,
2483-
integerCompress((int) INT_MASK, (int) maskStamp.mayBeSet()) & INT_MASK);
2463+
Integer.compress((int) INT_MASK, (int) maskStamp.mayBeSet()) & INT_MASK);
24842464
} else {
24852465
GraalError.guarantee(valueStamp.getStackKind() == JavaKind.Long, "unexpected Java kind %s", valueStamp.getStackKind());
24862466
if (maskStamp.mayBeSet() == LONG_MASK && valueStamp.canBeNegative()) {
@@ -2489,44 +2469,26 @@ protected Stamp foldStampImpl(Stamp a, Stamp b) {
24892469
}
24902470
// compress result will always be positive
24912471
return IntegerStamp.create(64,
2492-
longCompress(valueStamp.mustBeSet(), maskStamp.mustBeSet()),
2493-
longCompress(valueStamp.mayBeSet(), maskStamp.mayBeSet()),
2472+
Long.compress(valueStamp.mustBeSet(), maskStamp.mustBeSet()),
2473+
Long.compress(valueStamp.mayBeSet(), maskStamp.mayBeSet()),
24942474
0,
2495-
longCompress(LONG_MASK, maskStamp.mayBeSet()));
2475+
Long.compress(LONG_MASK, maskStamp.mayBeSet()));
24962476
}
24972477
}
24982478
},
24992479

25002480
new BinaryOp.Expand(false, false) {
25012481

2502-
private static int integerExpand(int i, int mask) {
2503-
try {
2504-
Method expand = Integer.class.getDeclaredMethod("expand", int.class, int.class);
2505-
return (Integer) expand.invoke(null, i, mask);
2506-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
2507-
throw GraalError.shouldNotReachHere(e, "Integer.expand is introduced in Java 19");
2508-
}
2509-
}
2510-
2511-
private static long longExpand(long i, long mask) {
2512-
try {
2513-
Method expand = Long.class.getDeclaredMethod("expand", long.class, long.class);
2514-
return (Long) expand.invoke(null, i, mask);
2515-
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
2516-
throw GraalError.shouldNotReachHere(e, "Long.expand is introduced in Java 19");
2517-
}
2518-
}
2519-
25202482
@Override
25212483
public Constant foldConstant(Constant a, Constant b) {
25222484
PrimitiveConstant i = (PrimitiveConstant) a;
25232485
PrimitiveConstant mask = (PrimitiveConstant) b;
25242486

25252487
if (i.getJavaKind() == JavaKind.Int) {
2526-
return JavaConstant.forInt(integerExpand(i.asInt(), mask.asInt()));
2488+
return JavaConstant.forInt(Integer.expand(i.asInt(), mask.asInt()));
25272489
} else {
25282490
GraalError.guarantee(i.getJavaKind() == JavaKind.Long, "unexpected Java kind %s", i.getJavaKind());
2529-
return JavaConstant.forLong(longExpand(i.asLong(), mask.asLong()));
2491+
return JavaConstant.forLong(Long.expand(i.asLong(), mask.asLong()));
25302492
}
25312493
}
25322494

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotBytecodeParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ public static FixedGuardNode doIntrinsicRangeCheck(GraphBuilderContext context,
105105
}
106106

107107
/**
108-
* {@code OnStackReplacementPhase.initLocal()} can only clear non-live oop locals if JVMCI can
109-
* supply the oop map for a method at specific BCI. Without this, we need to fall back to
110-
* compiler liveness analysis to do the clearing.
108+
* {@code OnStackReplacementPhase.initLocal()} can clear non-live oop locals since JVMCI can
109+
* supply the oop map for a method at a specific BCI.
111110
*/
112111
@Override
113112
protected boolean mustClearNonLiveLocalsAtOSREntry() {
114-
return !HotSpotGraalServices.hasGetOopMapAt();
113+
return false;
115114
}
116115

117116
@Override

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalServices.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@
2525
package jdk.graal.compiler.hotspot;
2626

2727
import java.lang.reflect.Field;
28-
import java.lang.reflect.InvocationTargetException;
29-
import java.lang.reflect.Method;
30-
import java.util.BitSet;
3128
import java.util.Objects;
3229

3330
import jdk.graal.compiler.core.common.LibGraalSupport;
3431
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
3532
import jdk.vm.ci.hotspot.HotSpotObjectConstantScope;
3633
import jdk.vm.ci.hotspot.HotSpotProfilingInfo;
37-
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
3834
import jdk.vm.ci.hotspot.HotSpotSpeculationLog;
3935
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
4036
import jdk.vm.ci.meta.JavaConstant;
@@ -48,46 +44,6 @@
4844
*/
4945
public class HotSpotGraalServices {
5046

51-
private static final Method methodGetOopMapAt;
52-
53-
static {
54-
Method getOopMapAt = null;
55-
56-
try {
57-
getOopMapAt = HotSpotResolvedJavaMethod.class.getDeclaredMethod("getOopMapAt", Integer.TYPE);
58-
} catch (NoSuchMethodException e) {
59-
}
60-
61-
methodGetOopMapAt = getOopMapAt;
62-
}
63-
64-
/**
65-
* Returns true if the JDK includes {@code HotSpotResolvedJavaMethod.getOopMapAt(int, BitSet)}.
66-
*/
67-
public static boolean hasGetOopMapAt() {
68-
return methodGetOopMapAt != null;
69-
}
70-
71-
/**
72-
* Calls {@code HotSpotResolvedJavaMethod.getOopMapAt(int, BitSet)}.
73-
*/
74-
public static BitSet getOopMapAt(ResolvedJavaMethod method, int bci) {
75-
if (methodGetOopMapAt != null) {
76-
try {
77-
try {
78-
return (BitSet) methodGetOopMapAt.invoke(method, bci);
79-
} catch (InvocationTargetException e) {
80-
throw e.getCause();
81-
}
82-
} catch (Error | RuntimeException e) {
83-
throw e;
84-
} catch (Throwable throwable) {
85-
throw new InternalError(throwable);
86-
}
87-
}
88-
throw new InternalError("This JDK doesn't support ResolvedJavaMethod.getOopMapAt(int, BitSet)");
89-
}
90-
9147
/**
9248
* Read the decompile count from the {@code HotSpotMethodData} and either bail out if the count
9349
* is too high or enable some debugging logic to detect the cause of the cycle.

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/phases/OnStackReplacementPhase.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import jdk.graal.compiler.debug.GraalError;
4141
import jdk.graal.compiler.graph.Node;
4242
import jdk.graal.compiler.graph.iterators.NodeIterable;
43-
import jdk.graal.compiler.hotspot.HotSpotGraalServices;
4443
import jdk.graal.compiler.loop.phases.LoopTransformations;
4544
import jdk.graal.compiler.nodeinfo.InputType;
4645
import jdk.graal.compiler.nodeinfo.Verbosity;
@@ -84,6 +83,7 @@
8483
import jdk.graal.compiler.phases.BasePhase;
8584
import jdk.graal.compiler.phases.common.DeadCodeEliminationPhase;
8685
import jdk.graal.compiler.serviceprovider.SpeculationReasonGroup;
86+
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
8787
import jdk.vm.ci.meta.DeoptimizationAction;
8888
import jdk.vm.ci.meta.DeoptimizationReason;
8989
import jdk.vm.ci.meta.JavaKind;
@@ -385,11 +385,7 @@ private static ValueNode initLocal(StructuredGraph graph, Stamp unrestrictedStam
385385
* {@code bci}
386386
*/
387387
private static BitSet getOopMapAt(ResolvedJavaMethod method, int bci) {
388-
if (!HotSpotGraalServices.hasGetOopMapAt()) {
389-
return null;
390-
} else {
391-
return HotSpotGraalServices.getOopMapAt(method, bci);
392-
}
388+
return ((HotSpotResolvedJavaMethod) method).getOopMapAt(bci);
393389
}
394390

395391
private static EntryMarkerNode getEntryMarker(StructuredGraph graph) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/StandardGraphBuilderPlugins.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,15 +2551,6 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
25512551
});
25522552
}
25532553

2554-
private static boolean hasEnsureMaterializedForStackWalk() {
2555-
try {
2556-
Thread.class.getDeclaredMethod("ensureMaterializedForStackWalk", Object.class);
2557-
} catch (Exception e) {
2558-
return false;
2559-
}
2560-
return true;
2561-
}
2562-
25632554
private static void registerThreadPlugins(InvocationPlugins plugins, Replacements replacements) {
25642555
Registration r = new Registration(plugins, Thread.class, replacements);
25652556
r.register(new InvocationPlugin("onSpinWait") {
@@ -2569,15 +2560,13 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
25692560
return true;
25702561
}
25712562
});
2572-
if (hasEnsureMaterializedForStackWalk()) {
2573-
r.register(new InvocationPlugin("ensureMaterializedForStackWalk", Object.class) {
2574-
@Override
2575-
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
2576-
b.add(new BlackholeNode(object, "ensureMaterializedForStackWalk"));
2577-
return true;
2578-
}
2579-
});
2580-
}
2563+
r.register(new InvocationPlugin("ensureMaterializedForStackWalk", Object.class) {
2564+
@Override
2565+
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
2566+
b.add(new BlackholeNode(object, "ensureMaterializedForStackWalk"));
2567+
return true;
2568+
}
2569+
});
25812570
}
25822571

25832572
public static class MessageDigestPlugin extends InvocationPlugin {

0 commit comments

Comments
 (0)