@@ -1402,28 +1402,30 @@ protected RubyString mutableNative(RubyString string, RubyEncoding newEncoding,
1402
1402
}
1403
1403
1404
1404
@ Specialization (guards = "libEncoding.isRubyString(newEncoding)" , limit = "1" )
1405
- protected RubyString forceEncodingString (RubyString string , Object newEncoding ,
1405
+ protected static RubyString forceEncodingString (RubyString string , Object newEncoding ,
1406
1406
@ Cached @ Exclusive RubyStringLibrary libEncoding ,
1407
1407
@ Cached ToJavaStringNode toJavaStringNode ,
1408
- @ Cached (inline = false ) BranchProfile errorProfile ) {
1408
+ @ Cached InlinedBranchProfile errorProfile ,
1409
+ @ Cached @ Exclusive ForceEncodingNode forceEncodingNode ,
1410
+ @ Bind ("this" ) Node node ) {
1409
1411
final String stringName = toJavaStringNode .executeToJavaString (newEncoding );
1410
- final RubyEncoding rubyEncoding = getContext ().getEncodingManager ().getRubyEncoding (stringName );
1412
+ final RubyEncoding rubyEncoding = getContext (node ).getEncodingManager ().getRubyEncoding (stringName );
1411
1413
1412
1414
if (rubyEncoding == null ) {
1413
- errorProfile .enter ();
1415
+ errorProfile .enter (node );
1414
1416
throw new RaiseException (
1415
- getContext (),
1416
- coreExceptions ().argumentError (Utils .concat ("unknown encoding name - " , stringName ),
1417
- getNode ()));
1417
+ getContext (node ),
1418
+ coreExceptions (node ).argumentError (Utils .concat ("unknown encoding name - " , stringName ),
1419
+ getNode (node )));
1418
1420
}
1419
1421
1420
- return execute (string , rubyEncoding );
1422
+ return forceEncodingNode . execute (string , rubyEncoding );
1421
1423
}
1422
1424
1423
1425
@ Specialization (guards = { "!isRubyEncoding(newEncoding)" , "isNotRubyString(newEncoding)" })
1424
1426
protected RubyString forceEncoding (RubyString string , Object newEncoding ,
1425
1427
@ Cached ToStrNode toStrNode ,
1426
- @ Cached ForceEncodingNode forceEncodingNode ) {
1428
+ @ Cached @ Exclusive ForceEncodingNode forceEncodingNode ) {
1427
1429
return forceEncodingNode .execute (string , toStrNode .execute (newEncoding ));
1428
1430
}
1429
1431
}
0 commit comments