@@ -2598,13 +2598,27 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
2598
2598
});
2599
2599
}
2600
2600
2601
+ private static void generateStringRangeCheck (GraphBuilderContext b , InvocationPluginHelper helper , ValueNode array , ValueNode off , ValueNode len ) {
2602
+ helper .intrinsicRangeCheck (off , Condition .LT , ConstantNode .forInt (0 ));
2603
+ helper .intrinsicRangeCheck (len , Condition .LT , ConstantNode .forInt (0 ));
2604
+
2605
+ ValueNode arrayLength = b .add (new ArrayLengthNode (array ));
2606
+ ValueNode limit = b .add (AddNode .create (off , len , NodeView .DEFAULT ));
2607
+ helper .intrinsicRangeCheck (arrayLength , Condition .LT , limit );
2608
+ }
2609
+
2601
2610
private static void registerStringCodingPlugins (InvocationPlugins plugins , Replacements replacements ) {
2602
2611
Registration r = new Registration (plugins , "java.lang.StringCoding" , replacements );
2603
- r .register (new InvocationPlugin ("implEncodeISOArray " , byte [].class , int .class , byte [].class , int .class , int .class ) {
2612
+ r .register (new InvocationPlugin ("encodeISOArray0 " , byte [].class , int .class , byte [].class , int .class , int .class ) {
2604
2613
@ Override
2605
2614
public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode sa , ValueNode sp ,
2606
2615
ValueNode da , ValueNode dp , ValueNode len ) {
2607
2616
try (InvocationPluginHelper helper = new InvocationPluginHelper (b , targetMethod )) {
2617
+ if (b .getPlatformConfigurationProvider ().shouldVerifyIntrinsicChecks ()) {
2618
+ generateStringRangeCheck (b , helper , sa , sp , len );
2619
+ generateStringRangeCheck (b , helper , da , dp , len );
2620
+ }
2621
+
2608
2622
int charElementShift = CodeUtil .log2 (b .getMetaAccess ().getArrayIndexScale (JavaKind .Char ));
2609
2623
ValueNode src = helper .arrayElementPointer (sa , JavaKind .Byte , LeftShiftNode .create (sp , ConstantNode .forInt (charElementShift ), NodeView .DEFAULT ));
2610
2624
ValueNode dst = helper .arrayElementPointer (da , JavaKind .Byte , dp );
@@ -2613,28 +2627,30 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
2613
2627
}
2614
2628
}
2615
2629
});
2616
- r .register (new InvocationPlugin ("implEncodeAsciiArray " , char [].class , int .class , byte [].class , int .class , int .class ) {
2630
+ r .register (new InvocationPlugin ("encodeAsciiArray0 " , char [].class , int .class , byte [].class , int .class , int .class ) {
2617
2631
@ Override
2618
2632
public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode sa , ValueNode sp ,
2619
2633
ValueNode da , ValueNode dp , ValueNode len ) {
2620
2634
try (InvocationPluginHelper helper = new InvocationPluginHelper (b , targetMethod )) {
2635
+ if (b .getPlatformConfigurationProvider ().shouldVerifyIntrinsicChecks ()) {
2636
+ generateStringRangeCheck (b , helper , sa , sp , len );
2637
+ generateStringRangeCheck (b , helper , da , dp , len );
2638
+ }
2639
+
2621
2640
ValueNode src = helper .arrayElementPointer (sa , JavaKind .Char , sp );
2622
2641
ValueNode dst = helper .arrayElementPointer (da , JavaKind .Byte , dp );
2623
2642
b .addPush (JavaKind .Int , new EncodeArrayNode (src , dst , len , ASCII , JavaKind .Char ));
2624
2643
return true ;
2625
2644
}
2626
2645
}
2627
2646
});
2628
- r .register (new InvocationPlugin ("countPositives " , byte [].class , int .class , int .class ) {
2647
+ r .register (new InvocationPlugin ("countPositives0 " , byte [].class , int .class , int .class ) {
2629
2648
@ Override
2630
2649
public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode ba , ValueNode off , ValueNode len ) {
2631
2650
try (InvocationPluginHelper helper = new InvocationPluginHelper (b , targetMethod )) {
2632
- helper .intrinsicRangeCheck (off , Condition .LT , ConstantNode .forInt (0 ));
2633
- helper .intrinsicRangeCheck (len , Condition .LT , ConstantNode .forInt (0 ));
2634
-
2635
- ValueNode arrayLength = b .add (new ArrayLengthNode (ba ));
2636
- ValueNode limit = b .add (AddNode .create (off , len , NodeView .DEFAULT ));
2637
- helper .intrinsicRangeCheck (arrayLength , Condition .LT , limit );
2651
+ if (b .getPlatformConfigurationProvider ().shouldVerifyIntrinsicChecks ()) {
2652
+ generateStringRangeCheck (b , helper , ba , off , len );
2653
+ }
2638
2654
2639
2655
ValueNode array = helper .arrayElementPointer (ba , JavaKind .Byte , off );
2640
2656
b .addPush (JavaKind .Int , new CountPositivesNode (array , len ));
0 commit comments