@@ -1117,7 +1117,6 @@ public PFrozenSet frozensetIterable(VirtualFrame frame, Object cls, Object itera
1117
1117
// int(x, base=10)
1118
1118
@ Builtin (name = INT , minNumOfPositionalArgs = 1 , parameterNames = {"cls" , "x" , "base" }, numOfPositionalOnlyArgs = 2 , constructsClass = PythonBuiltinClassType .PInt )
1119
1119
@ GenerateNodeFactory
1120
- @ ReportPolymorphism
1121
1120
public abstract static class IntNode extends PythonTernaryBuiltinNode {
1122
1121
1123
1122
private final ConditionProfile invalidBase = ConditionProfile .createBinaryProfile ();
@@ -1390,17 +1389,20 @@ Object createInt(Object cls, double arg, @SuppressWarnings("unused") PNone base,
1390
1389
// String
1391
1390
1392
1391
@ Specialization (guards = "isNoValue(base)" )
1392
+ @ Megamorphic
1393
1393
Object createInt (VirtualFrame frame , Object cls , String arg , @ SuppressWarnings ("unused" ) PNone base ) {
1394
1394
return stringToInt (frame , cls , arg , 10 , arg );
1395
1395
}
1396
1396
1397
1397
@ Specialization
1398
+ @ Megamorphic
1398
1399
Object parsePIntError (VirtualFrame frame , Object cls , String number , int base ) {
1399
1400
checkBase (base );
1400
1401
return stringToInt (frame , cls , number , base , number );
1401
1402
}
1402
1403
1403
1404
@ Specialization (guards = "!isNoValue(base)" , limit = "getCallSiteInlineCacheMaxDepth()" )
1405
+ @ Megamorphic
1404
1406
Object createIntError (VirtualFrame frame , Object cls , String number , Object base ,
1405
1407
@ CachedLibrary ("base" ) PythonObjectLibrary lib ) {
1406
1408
int intBase = lib .asSizeWithState (base , null , PArguments .getThreadState (frame ));
@@ -1410,18 +1412,21 @@ Object createIntError(VirtualFrame frame, Object cls, String number, Object base
1410
1412
1411
1413
// PIBytesLike
1412
1414
@ Specialization
1415
+ @ Megamorphic
1413
1416
Object parseBytesError (VirtualFrame frame , Object cls , PBytesLike arg , int base ) {
1414
1417
checkBase (base );
1415
1418
return stringToInt (frame , cls , toString (arg ), base , arg );
1416
1419
}
1417
1420
1418
1421
@ Specialization (guards = "isNoValue(base)" )
1422
+ @ Megamorphic
1419
1423
Object parseBytesError (VirtualFrame frame , Object cls , PBytesLike arg , @ SuppressWarnings ("unused" ) PNone base ) {
1420
1424
return parseBytesError (frame , cls , arg , 10 );
1421
1425
}
1422
1426
1423
1427
// PString
1424
1428
@ Specialization (guards = "isNoValue(base)" , limit = "1" )
1429
+ @ Megamorphic
1425
1430
Object parsePInt (VirtualFrame frame , Object cls , PString arg , @ SuppressWarnings ("unused" ) PNone base ,
1426
1431
@ CachedLibrary ("arg" ) PythonObjectLibrary lib ,
1427
1432
@ CachedLibrary (limit = "1" ) PythonObjectLibrary methodLib ) {
@@ -1433,6 +1438,7 @@ Object parsePInt(VirtualFrame frame, Object cls, PString arg, @SuppressWarnings(
1433
1438
}
1434
1439
1435
1440
@ Specialization (limit = "1" )
1441
+ @ Megamorphic
1436
1442
Object parsePInt (VirtualFrame frame , Object cls , PString arg , int base ,
1437
1443
@ CachedLibrary ("arg" ) PythonObjectLibrary lib ,
1438
1444
@ CachedLibrary (limit = "1" ) PythonObjectLibrary methodLib ) {
@@ -1471,6 +1477,7 @@ Object fail(Object cls, Object arg, Object base) {
1471
1477
}
1472
1478
1473
1479
@ Specialization (guards = {"isNoValue(base)" , "!isNoValue(obj)" , "!isHandledType(obj)" }, limit = "5" )
1480
+ @ Megamorphic
1474
1481
Object createIntGeneric (VirtualFrame frame , Object cls , Object obj , @ SuppressWarnings ("unused" ) PNone base ,
1475
1482
@ CachedLibrary (value = "obj" ) PythonObjectLibrary objectLib ,
1476
1483
@ CachedLibrary (limit = "1" ) PythonObjectLibrary methodLib ) {
@@ -1492,7 +1499,7 @@ Object createIntGeneric(VirtualFrame frame, Object cls, Object obj, @SuppressWar
1492
1499
if (objectLib .isBuffer (obj )) {
1493
1500
try {
1494
1501
byte [] bytes = objectLib .getBufferBytes (obj );
1495
- return stringToInt (frame , cls , toString (bytes ), 10 , obj );
1502
+ return stringToInt (frame , cls , PythonUtils . newString (bytes ), 10 , obj );
1496
1503
} catch (UnsupportedMessageException e ) {
1497
1504
CompilerDirectives .transferToInterpreterAndInvalidate ();
1498
1505
throw new IllegalStateException ("Object claims to be a buffer but does not support getBufferBytes()" );
@@ -1591,14 +1598,8 @@ private String toString(PBytesLike pByteArray) {
1591
1598
CompilerDirectives .transferToInterpreterAndInvalidate ();
1592
1599
toByteArrayNode = insert (BytesNodes .ToBytesNode .create ());
1593
1600
}
1594
- return toString (toByteArrayNode .execute (pByteArray ));
1595
- }
1596
-
1597
- @ TruffleBoundary
1598
- private static String toString (byte [] barr ) {
1599
- return new String (barr );
1601
+ return PythonUtils .newString (toByteArrayNode .execute (pByteArray ));
1600
1602
}
1601
-
1602
1603
}
1603
1604
1604
1605
// bool([x])
0 commit comments