Skip to content

Commit 1add88d

Browse files
committed
[GR-62804] Avoid resolving java.* classes where possible.
PullRequest: graal/20761
2 parents da41764 + d5c4a14 commit 1add88d

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ protected HotSpotPlatformConfigurationProvider createConfigInfoProvider(GraalHot
102102
return new HotSpotPlatformConfigurationProvider(config, barrierSet);
103103
}
104104

105-
protected HotSpotMetaAccessExtensionProvider createMetaAccessExtensionProvider(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) {
106-
return new HotSpotMetaAccessExtensionProvider(metaAccess, constantReflection);
105+
protected HotSpotMetaAccessExtensionProvider createMetaAccessExtensionProvider(ConstantReflectionProvider constantReflection) {
106+
return new HotSpotMetaAccessExtensionProvider(constantReflection);
107107
}
108108

109109
protected HotSpotReplacementsImpl createReplacements(TargetDescription target, HotSpotProviders p, BytecodeProvider bytecodeProvider) {
@@ -171,7 +171,7 @@ public final HotSpotBackend createBackend(HotSpotGraalRuntimeProvider graalRunti
171171
}
172172
HotSpotMetaAccessExtensionProvider metaAccessExtensionProvider;
173173
try (InitTimer rt = timer("create MetaAccessExtensionProvider")) {
174-
metaAccessExtensionProvider = createMetaAccessExtensionProvider(metaAccess, constantReflection);
174+
metaAccessExtensionProvider = createMetaAccessExtensionProvider(constantReflection);
175175
}
176176
HotSpotStampProvider stampProvider;
177177
try (InitTimer rt = timer("create stamp provider")) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/meta/HotSpotMetaAccessExtensionProvider.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,15 @@
3030
import jdk.vm.ci.meta.JavaConstant;
3131
import jdk.vm.ci.meta.JavaKind;
3232
import jdk.vm.ci.meta.JavaType;
33-
import jdk.vm.ci.meta.MetaAccessProvider;
3433
import jdk.vm.ci.meta.ResolvedJavaField;
3534
import jdk.vm.ci.meta.ResolvedJavaMethod;
3635
import jdk.vm.ci.meta.ResolvedJavaType;
3736

3837
public class HotSpotMetaAccessExtensionProvider implements MetaAccessExtensionProvider {
3938
private final ConstantReflectionProvider constantReflection;
40-
private final ResolvedJavaType jlClassType;
4139

42-
public HotSpotMetaAccessExtensionProvider(MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection) {
40+
public HotSpotMetaAccessExtensionProvider(ConstantReflectionProvider constantReflection) {
4341
this.constantReflection = constantReflection;
44-
this.jlClassType = metaAccess.lookupJavaType(Class.class);
4542
}
4643

4744
@Override
@@ -80,7 +77,7 @@ public ResolvedJavaField getStaticFieldForAccess(JavaConstant base, long offset,
8077
ResolvedJavaType type = constantReflection.asJavaType(base);
8178
// check that it's indeed a j.l.Class when we get a result since constant reflection will
8279
// also return a type if the constant wraps a ResolvedJavaType
83-
if (type == null || !objectConstant.getType().equals(jlClassType)) {
80+
if (type == null || !objectConstant.getType().getName().equals("Ljava/lang/Class;")) {
8481
return null;
8582
}
8683
for (ResolvedJavaField field : type.getStaticFields()) {

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/java/BytecodeParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5078,7 +5078,7 @@ public boolean currentBlockCatchesOOME() {
50785078
if (handler != null) {
50795079
JavaType catchType = handler.getCatchType();
50805080
// catch type can be null for java.lang.Throwable which catches everything
5081-
inOOMETry = catchType != null && catchType.equals(getMetaAccess().lookupJavaType(OutOfMemoryError.class));
5081+
inOOMETry = catchType != null && catchType.getName().equals("Ljava/lang/OutOfMemoryError;");
50825082
}
50835083
}
50845084
return inOOMETry;

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/calc/ObjectEqualsNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ public static LogicNode virtualizeComparison(ValueNode x, ValueNode y, Structure
178178
} else if (!xVirtual.hasIdentity() && !yVirtual.hasIdentity()) {
179179
ResolvedJavaType type = xVirtual.type();
180180
if (type.equals(yVirtual.type())) {
181-
MetaAccessProvider metaAccess = tool.getMetaAccess();
182-
if (type.equals(metaAccess.lookupJavaType(Integer.class)) || type.equals(metaAccess.lookupJavaType(Long.class))) {
181+
if (type.getName().equals("Ljava/lang/Integer;") || type.getName().equals("Ljava/lang/Long;")) {
183182
// both are virtual without identity: check contents
184183
assert xVirtual.entryCount() == 1 && yVirtual.entryCount() == 1 : Assertions.errorMessageContext("x", xVirtual, "y", yVirtual);
185184
assert xVirtual.entryKind(tool.getMetaAccessExtensionProvider(), 0).getStackKind() == JavaKind.Int ||

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/java/DynamicNewInstanceNode.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import jdk.graal.compiler.nodes.spi.Canonicalizable;
3939
import jdk.graal.compiler.nodes.spi.CanonicalizerTool;
4040
import jdk.graal.compiler.nodes.spi.CoreProviders;
41-
import jdk.vm.ci.meta.MetaAccessProvider;
4241
import jdk.vm.ci.meta.ResolvedJavaType;
4342

4443
@NodeInfo
@@ -60,7 +59,7 @@ public ValueNode getInstanceType() {
6059
static ResolvedJavaType tryConvertToNonDynamic(ValueNode clazz, CoreProviders tool) {
6160
if (clazz.isConstant()) {
6261
ResolvedJavaType type = tool.getConstantReflection().asJavaType(clazz.asConstant());
63-
if (type != null && !throwsInstantiationException(type, tool.getMetaAccess()) && tool.getMetaAccessExtensionProvider().canConstantFoldDynamicAllocation(type)) {
62+
if (type != null && !throwsInstantiationException(type) && tool.getMetaAccessExtensionProvider().canConstantFoldDynamicAllocation(type)) {
6463
return type;
6564
}
6665
}
@@ -88,7 +87,7 @@ public static boolean throwsInstantiationExceptionInjectedProbability(double pro
8887
probability(probability, type == classClass);
8988
}
9089

91-
public static boolean throwsInstantiationException(ResolvedJavaType type, MetaAccessProvider metaAccess) {
92-
return type.isPrimitive() || type.isArray() || type.isInterface() || Modifier.isAbstract(type.getModifiers()) || type.equals(metaAccess.lookupJavaType(Class.class));
90+
public static boolean throwsInstantiationException(ResolvedJavaType type) {
91+
return type.isPrimitive() || type.isArray() || type.isInterface() || Modifier.isAbstract(type.getModifiers()) || type.getName().equals("Ljava/lang/Class;");
9392
}
9493
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private void lowerBinaryMath(BinaryMathIntrinsicNode math, LoweringTool tool) {
407407
// lowering to emit the stub assembly code instead of the Node lowering.
408408
return;
409409
}
410-
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
410+
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && method.getDeclaringClass().getName().equals("Ljava/lang/Math;")) {
411411
// A root compilation of the intrinsic method should emit the full assembly
412412
// implementation.
413413
return;
@@ -428,7 +428,7 @@ private void lowerUnaryMath(UnaryMathIntrinsicNode math, LoweringTool tool) {
428428
}
429429
ResolvedJavaMethod method = math.graph().method();
430430
if (method != null) {
431-
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
431+
if (method.getName().equalsIgnoreCase(math.getOperation().name()) && method.getDeclaringClass().getName().equals("Ljava/lang/Math;")) {
432432
// A root compilation of the intrinsic method should emit the full assembly
433433
// implementation.
434434
return;

0 commit comments

Comments
 (0)