@@ -2598,13 +2598,27 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
25982598 });
25992599 }
26002600
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+
26012610 private static void registerStringCodingPlugins (InvocationPlugins plugins , Replacements replacements ) {
26022611 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 ) {
26042613 @ Override
26052614 public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode sa , ValueNode sp ,
26062615 ValueNode da , ValueNode dp , ValueNode len ) {
26072616 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+
26082622 int charElementShift = CodeUtil .log2 (b .getMetaAccess ().getArrayIndexScale (JavaKind .Char ));
26092623 ValueNode src = helper .arrayElementPointer (sa , JavaKind .Byte , LeftShiftNode .create (sp , ConstantNode .forInt (charElementShift ), NodeView .DEFAULT ));
26102624 ValueNode dst = helper .arrayElementPointer (da , JavaKind .Byte , dp );
@@ -2613,28 +2627,30 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
26132627 }
26142628 }
26152629 });
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 ) {
26172631 @ Override
26182632 public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode sa , ValueNode sp ,
26192633 ValueNode da , ValueNode dp , ValueNode len ) {
26202634 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+
26212640 ValueNode src = helper .arrayElementPointer (sa , JavaKind .Char , sp );
26222641 ValueNode dst = helper .arrayElementPointer (da , JavaKind .Byte , dp );
26232642 b .addPush (JavaKind .Int , new EncodeArrayNode (src , dst , len , ASCII , JavaKind .Char ));
26242643 return true ;
26252644 }
26262645 }
26272646 });
2628- r .register (new InvocationPlugin ("countPositives " , byte [].class , int .class , int .class ) {
2647+ r .register (new InvocationPlugin ("countPositives0 " , byte [].class , int .class , int .class ) {
26292648 @ Override
26302649 public boolean apply (GraphBuilderContext b , ResolvedJavaMethod targetMethod , Receiver receiver , ValueNode ba , ValueNode off , ValueNode len ) {
26312650 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+ }
26382654
26392655 ValueNode array = helper .arrayElementPointer (ba , JavaKind .Byte , off );
26402656 b .addPush (JavaKind .Int , new CountPositivesNode (array , len ));
0 commit comments