24
24
*/
25
25
package jdk .graal .compiler .hotspot .replacements ;
26
26
27
+ import static jdk .graal .compiler .hotspot .replacements .HotSpotReplacementsUtil .OPTIMIZING_PRIMARY_SUPERS_LOCATION ;
27
28
import static jdk .graal .compiler .hotspot .replacements .HotSpotReplacementsUtil .PRIMARY_SUPERS_LOCATION ;
28
29
import static jdk .graal .compiler .hotspot .replacements .HotSpotReplacementsUtil .SECONDARY_SUPER_CACHE_LOCATION ;
29
30
import static jdk .graal .compiler .hotspot .replacements .HotSpotReplacementsUtil .loadHubIntrinsic ;
74
75
import jdk .graal .compiler .replacements .SnippetTemplate .SnippetInfo ;
75
76
import jdk .graal .compiler .replacements .Snippets ;
76
77
import jdk .graal .compiler .replacements .nodes .ExplodeLoopNode ;
77
- import jdk .graal .compiler .serviceprovider .JavaVersionUtil ;
78
78
import jdk .vm .ci .hotspot .HotSpotResolvedObjectType ;
79
79
import jdk .vm .ci .meta .Assumptions ;
80
80
import jdk .vm .ci .meta .DeoptimizationAction ;
85
85
/**
86
86
* Snippets used for implementing the type test of an instanceof instruction. Since instanceof is a
87
87
* floating node, it is lowered separately for each of its usages.
88
- *
88
+ * <p>
89
89
* The type tests implemented are described in the paper
90
90
* <a href="http://dl.acm.org/citation.cfm?id=583821"> Fast subtype checking in the HotSpot JVM</a>
91
91
* by Cliff Click and John Rose, with the adaption on the secondary supers hashed lookup algorithm
92
- * described in JDK-8180450 (see comments in {@link TypeCheckSnippetUtils#checkSelfAndSupers }).
92
+ * described in JDK-8180450 (see comments in {@link TypeCheckSnippetUtils#checkSecondarySubType }).
93
93
*/
94
94
public class InstanceOfSnippets implements Snippets {
95
95
@@ -167,8 +167,8 @@ public static Object instanceofPrimary(KlassPointer hub, Object object, @Constan
167
167
* A test against a restricted secondary type.
168
168
*/
169
169
@ Snippet (allowMissingProbabilities = true )
170
- public static Object instanceofSecondary (KlassPointer hub , Object object , @ VarargsParameter KlassPointer [] hints , @ VarargsParameter boolean [] hintIsPositive , Object trueValue , Object falseValue ,
171
- @ ConstantParameter Counters counters ) {
170
+ public static Object instanceofSecondary (KlassPointer hub , Object object , @ VarargsParameter KlassPointer [] hints , @ VarargsParameter boolean [] hintIsPositive ,
171
+ @ ConstantParameter boolean isHubAbstract , Object trueValue , Object falseValue , @ ConstantParameter Counters counters ) {
172
172
if (probability (NOT_FREQUENT_PROBABILITY , object == null )) {
173
173
counters .isNull .inc ();
174
174
return falseValue ;
@@ -186,7 +186,7 @@ public static Object instanceofSecondary(KlassPointer hub, Object object, @Varar
186
186
}
187
187
}
188
188
counters .hintsMiss .inc ();
189
- if (!checkSecondarySubType (hub , objectHub , counters )) {
189
+ if (!checkSecondarySubType (hub , objectHub , isHubAbstract , counters )) {
190
190
return falseValue ;
191
191
}
192
192
return trueValue ;
@@ -267,15 +267,9 @@ public Templates(OptionValues options, SnippetCounter.Group.Factory factory, Hot
267
267
this .instanceofWithProfile = snippet (providers , InstanceOfSnippets .class , "instanceofWithProfile" );
268
268
this .instanceofExact = snippet (providers , InstanceOfSnippets .class , "instanceofExact" );
269
269
this .instanceofPrimary = snippet (providers , InstanceOfSnippets .class , "instanceofPrimary" , PRIMARY_SUPERS_LOCATION );
270
- if (JavaVersionUtil .JAVA_SPEC == 21 ) {
271
- this .instanceofSecondary = snippet (providers , InstanceOfSnippets .class , "instanceofSecondary" , SECONDARY_SUPER_CACHE_LOCATION );
272
- this .instanceofDynamic = snippet (providers , InstanceOfSnippets .class , "instanceofDynamic" , PRIMARY_SUPERS_LOCATION , SECONDARY_SUPER_CACHE_LOCATION );
273
- this .isAssignableFrom = snippet (providers , InstanceOfSnippets .class , "isAssignableFrom" , PRIMARY_SUPERS_LOCATION , SECONDARY_SUPER_CACHE_LOCATION );
274
- } else {
275
- this .instanceofSecondary = snippet (providers , InstanceOfSnippets .class , "instanceofSecondary" );
276
- this .instanceofDynamic = snippet (providers , InstanceOfSnippets .class , "instanceofDynamic" , PRIMARY_SUPERS_LOCATION );
277
- this .isAssignableFrom = snippet (providers , InstanceOfSnippets .class , "isAssignableFrom" , PRIMARY_SUPERS_LOCATION );
278
- }
270
+ this .instanceofSecondary = snippet (providers , InstanceOfSnippets .class , "instanceofSecondary" , SECONDARY_SUPER_CACHE_LOCATION );
271
+ this .instanceofDynamic = snippet (providers , InstanceOfSnippets .class , "instanceofDynamic" , OPTIMIZING_PRIMARY_SUPERS_LOCATION , SECONDARY_SUPER_CACHE_LOCATION );
272
+ this .isAssignableFrom = snippet (providers , InstanceOfSnippets .class , "isAssignableFrom" , OPTIMIZING_PRIMARY_SUPERS_LOCATION , SECONDARY_SUPER_CACHE_LOCATION );
279
273
280
274
this .counters = new Counters (factory );
281
275
}
@@ -319,6 +313,7 @@ protected Arguments makeArguments(InstanceOfUsageReplacer replacer, LoweringTool
319
313
args .add ("object" , object );
320
314
args .addVarargs ("hints" , KlassPointer .class , KlassPointerStamp .klassNonNull (), hints .hubs );
321
315
args .addVarargs ("hintIsPositive" , boolean .class , StampFactory .forKind (JavaKind .Boolean ), hints .isPositive );
316
+ args .addConst ("isHubAbstract" , type .isAbstract () || type .isInterface ());
322
317
}
323
318
args .add ("trueValue" , replacer .trueValue );
324
319
args .add ("falseValue" , replacer .falseValue );
0 commit comments