26
26
27
27
import static jdk .graal .compiler .core .common .spi .ForeignCallDescriptor .CallSideEffect .NO_SIDE_EFFECT ;
28
28
import static jdk .graal .compiler .nodes .extended .BranchProbabilityNode .LIKELY_PROBABILITY ;
29
- import static jdk .graal .compiler .nodes .extended .BranchProbabilityNode .NOT_FREQUENT_PROBABILITY ;
30
29
import static jdk .graal .compiler .nodes .extended .BranchProbabilityNode .SLOW_PATH_PROBABILITY ;
31
30
import static jdk .graal .compiler .nodes .extended .BranchProbabilityNode .probability ;
32
31
@@ -53,6 +52,9 @@ final class SubstrateIdentityHashCodeSnippets extends IdentityHashCodeSnippets {
53
52
static final SubstrateForeignCallDescriptor GENERATE_IDENTITY_HASH_CODE = SnippetRuntime .findForeignCall (
54
53
IdentityHashCodeSupport .class , "generateIdentityHashCode" , NO_SIDE_EFFECT , IdentityHashCodeSupport .IDENTITY_HASHCODE_LOCATION );
55
54
55
+ static final SubstrateForeignCallDescriptor COMPUTE_ABSENT_IDENTITY_HASH_CODE = SnippetRuntime .findForeignCall (
56
+ IdentityHashCodeSupport .class , "computeAbsentIdentityHashCode" , NO_SIDE_EFFECT );
57
+
56
58
static Templates createTemplates (OptionValues options , Providers providers ) {
57
59
return new Templates (new SubstrateIdentityHashCodeSnippets (), options , providers , IdentityHashCodeSupport .IDENTITY_HASHCODE_LOCATION );
58
60
}
@@ -63,29 +65,24 @@ protected int computeIdentityHashCode(Object obj) {
63
65
if (ol .isIdentityHashFieldOptional ()) {
64
66
int identityHashCode ;
65
67
ObjectHeader oh = Heap .getHeap ().getObjectHeader ();
66
- Word objPtr = Word .objectToUntrackedPointer (obj );
67
- Word header = ObjectHeader .readHeaderFromPointer (objPtr );
68
+ Word header = ObjectHeader .readHeaderFromObject (obj );
68
69
if (probability (LIKELY_PROBABILITY , oh .hasOptionalIdentityHashField (header ))) {
69
70
int offset = LayoutEncoding .getIdentityHashOffset (obj );
70
71
identityHashCode = ObjectAccess .readInt (obj , offset , IdentityHashCodeSupport .IDENTITY_HASHCODE_LOCATION );
71
72
} else {
72
- identityHashCode = IdentityHashCodeSupport .computeHashCodeFromAddress (obj );
73
- if (probability (NOT_FREQUENT_PROBABILITY , !oh .hasIdentityHashFromAddress (header ))) {
74
- // This write leads to frame state issues that break scheduling if done earlier
75
- oh .setIdentityHashFromAddress (objPtr , header );
76
- }
73
+ identityHashCode = foreignCall (COMPUTE_ABSENT_IDENTITY_HASH_CODE , obj );
77
74
}
78
75
return identityHashCode ;
79
76
}
80
77
81
78
int offset = LayoutEncoding .getIdentityHashOffset (obj );
82
79
int identityHashCode = ObjectAccess .readInt (obj , offset , IdentityHashCodeSupport .IDENTITY_HASHCODE_LOCATION );
83
80
if (probability (SLOW_PATH_PROBABILITY , identityHashCode == 0 )) {
84
- identityHashCode = generateIdentityHashCode (GENERATE_IDENTITY_HASH_CODE , obj );
81
+ identityHashCode = foreignCall (GENERATE_IDENTITY_HASH_CODE , obj );
85
82
}
86
83
return identityHashCode ;
87
84
}
88
85
89
86
@ NodeIntrinsic (ForeignCallNode .class )
90
- private static native int generateIdentityHashCode (@ ConstantNodeParameter ForeignCallDescriptor descriptor , Object obj );
87
+ private static native int foreignCall (@ ConstantNodeParameter ForeignCallDescriptor descriptor , Object obj );
91
88
}
0 commit comments