Skip to content

Commit

Permalink
[GR-41738] Clean up IdentityHashCodeNode lowering
Browse files Browse the repository at this point in the history
PullRequest: graal/18479
  • Loading branch information
patrick96 committed Aug 20, 2024
2 parents ed1a832 + d143ad4 commit 30fcf53
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
import jdk.graal.compiler.replacements.nodes.ArrayEqualsNode;
import jdk.graal.compiler.replacements.nodes.BasicArrayCopyNode;
import jdk.graal.compiler.replacements.nodes.BinaryMathIntrinsicNode;
import jdk.graal.compiler.replacements.nodes.IdentityHashCodeNode;
import jdk.graal.compiler.replacements.nodes.ObjectClone;
import jdk.graal.compiler.replacements.nodes.UnaryMathIntrinsicNode;
import jdk.graal.compiler.word.WordCastNode;
Expand Down Expand Up @@ -324,8 +323,6 @@ protected void dispatch(Node node) {
lower((BlackholeNode) node);
} else if (node instanceof ReachabilityFenceNode) {
lower((ReachabilityFenceNode) node);
} else if (node instanceof IdentityHashCodeNode) {
lower((IdentityHashCodeNode) node);
} else if (node instanceof ClassIsAssignableFromNode) {
lower((ClassIsAssignableFromNode) node);
} else if (node instanceof DynamicNewInstanceNode n) {
Expand Down Expand Up @@ -490,8 +487,6 @@ protected void handleUnknownNodeType(Node node) {

protected abstract void lower(NegateNode node);

protected abstract void lower(IdentityHashCodeNode node);

protected abstract void lower(ClassIsAssignableFromNode node);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
import jdk.graal.compiler.nodes.spi.StampProvider;
import jdk.graal.compiler.nodes.type.StampTool;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.util.Providers;
import jdk.graal.compiler.replacements.DefaultJavaLoweringProvider;
import jdk.graal.compiler.replacements.IdentityHashCodeSnippets;
import jdk.graal.compiler.replacements.IsArraySnippets;
Expand Down Expand Up @@ -324,7 +325,6 @@ public void initialize(OptionValues options, Iterable<DebugHandlersFactory> fact
assertionSnippets = new AssertionSnippets.Templates(options, providers);
logSnippets = new LogSnippets.Templates(options, providers);
arraycopySnippets = arraycopySnippetTemplates;
identityHashCodeSnippets = new IdentityHashCodeSnippets.Templates(new HotSpotHashCodeSnippets(), options, providers, HotSpotReplacementsUtil.MARK_WORD_LOCATION);
isArraySnippets = new IsArraySnippets.Templates(new HotSpotIsArraySnippets(), options, providers);
objectCloneSnippets = new ObjectCloneSnippets.Templates(options, providers);
foreignCallSnippets = new ForeignCallSnippets.Templates(options, providers);
Expand Down Expand Up @@ -353,6 +353,11 @@ public final void initializeExtensions(OptionValues options, Iterable<DebugHandl
}
}

@Override
protected IdentityHashCodeSnippets.Templates createIdentityHashCodeSnippets(OptionValues options, Providers providers) {
return new IdentityHashCodeSnippets.Templates(new HotSpotHashCodeSnippets(), options, providers, HotSpotReplacementsUtil.MARK_WORD_LOCATION);
}

public HotSpotAllocationSnippets.Templates getAllocationSnippets() {
return allocationSnippets;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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 @@ -194,7 +194,7 @@ public abstract class DefaultJavaLoweringProvider implements LoweringProvider {
protected Replacements replacements;

private BoxingSnippets.Templates boxingSnippets;
protected IdentityHashCodeSnippets.Templates identityHashCodeSnippets;
private IdentityHashCodeSnippets.Templates identityHashCodeSnippets;
protected IsArraySnippets.Templates isArraySnippets;
protected StringLatin1Snippets.Templates latin1Templates;
protected StringUTF16Snippets.Templates utf16templates;
Expand All @@ -213,6 +213,7 @@ public DefaultJavaLoweringProvider(MetaAccessProvider metaAccess, ForeignCallsPr
public void initialize(OptionValues options, SnippetCounter.Group.Factory factory, Providers providers) {
replacements = providers.getReplacements();
boxingSnippets = new BoxingSnippets.Templates(options, factory, providers);
identityHashCodeSnippets = createIdentityHashCodeSnippets(options, providers);
if (EmitStringSubstitutions.getValue(options)) {
latin1Templates = new StringLatin1Snippets.Templates(options, providers);
providers.getReplacements().registerSnippetTemplateCache(latin1Templates);
Expand All @@ -223,6 +224,8 @@ public void initialize(OptionValues options, SnippetCounter.Group.Factory factor
providers.getReplacements().registerSnippetTemplateCache(new BigIntegerSnippets.Templates(options, providers));
}

protected abstract IdentityHashCodeSnippets.Templates createIdentityHashCodeSnippets(OptionValues options, Providers providers);

@Override
public boolean supportsImplicitNullChecks() {
return target.implicitNullCheckLimit > 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -87,6 +87,7 @@
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.util.Providers;
import jdk.graal.compiler.replacements.DefaultJavaLoweringProvider;
import jdk.graal.compiler.replacements.IdentityHashCodeSnippets;
import jdk.graal.compiler.replacements.IsArraySnippets;
import jdk.graal.compiler.replacements.SnippetCounter.Group;
import jdk.graal.compiler.replacements.nodes.AssertionNode;
Expand Down Expand Up @@ -121,11 +122,15 @@ public SubstrateBasicLoweringProvider(MetaAccessProvider metaAccess, ForeignCall
@Override
public void setConfiguration(RuntimeConfiguration runtimeConfig, OptionValues options, Providers providers) {
this.runtimeConfig = runtimeConfig;
this.identityHashCodeSnippets = IdentityHashCodeSupport.createSnippetTemplates(options, providers);
this.isArraySnippets = new IsArraySnippets.Templates(new SubstrateIsArraySnippets(), options, providers);
initialize(options, Group.NullFactory, providers);
}

@Override
protected IdentityHashCodeSnippets.Templates createIdentityHashCodeSnippets(OptionValues options, Providers providers) {
return IdentityHashCodeSupport.createSnippetTemplates(options, providers);
}

protected Providers getProviders() {
return runtimeConfig.getProviders();
}
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, 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 @@ -103,7 +103,7 @@ private static int mix32(long a) {
return (int) (((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);
}

private static int generateRandomHashCode() {
public static int generateRandomHashCode() {
SplittableRandom hashCodeGenerator = hashCodeGeneratorTL.get();
if (hashCodeGenerator == null) {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ public long getSize() {
return size;
}

int getIdentityHashCode() {
public int getIdentityHashCode() {
return identityHashCode;
}

Expand Down

0 comments on commit 30fcf53

Please sign in to comment.