@@ -1022,17 +1022,17 @@ public static _PyUnicode_AsUTF8String create() {
1022
1022
}
1023
1023
}
1024
1024
1025
- @ CApiBuiltin (ret = ConstCharPtr , args = {PyObject , PY_SSIZE_T_PTR }, call = Direct )
1026
- abstract static class PyUnicode_AsUTF8AndSize extends CApiBinaryBuiltinNode {
1025
+ @ CApiBuiltin (ret = ConstCharPtr , args = {PyObject , PY_SSIZE_T_PTR }, call = Ignored )
1026
+ abstract static class PyTruffleUnicode_AsUTF8AndSize extends CApiBinaryBuiltinNode {
1027
1027
1028
1028
@ Specialization
1029
1029
static Object doUnicode (PString s , Object sizePtr ,
1030
1030
@ Bind ("this" ) Node inliningTarget ,
1031
- @ Shared @ CachedLibrary (limit = "2" ) InteropLibrary lib ,
1032
- @ Shared @ Cached InlinedConditionProfile hasSizeProfile ,
1033
- @ Shared @ Cached InlinedConditionProfile hasUtf8Profile ,
1034
- @ Shared @ Cached CStructAccess .WriteLongNode writeLongNode ,
1035
- @ Shared @ Cached _PyUnicode_AsUTF8String asUTF8String ) {
1031
+ @ CachedLibrary (limit = "2" ) InteropLibrary lib ,
1032
+ @ Cached InlinedConditionProfile hasSizeProfile ,
1033
+ @ Cached InlinedConditionProfile hasUtf8Profile ,
1034
+ @ Cached CStructAccess .WriteLongNode writeLongNode ,
1035
+ @ Cached _PyUnicode_AsUTF8String asUTF8String ) {
1036
1036
if (hasUtf8Profile .profile (inliningTarget , s .getUtf8Bytes () == null )) {
1037
1037
PBytes bytes = (PBytes ) asUTF8String .execute (s , T_STRICT );
1038
1038
s .setUtf8Bytes (bytes );
@@ -1043,40 +1043,6 @@ static Object doUnicode(PString s, Object sizePtr,
1043
1043
return PySequenceArrayWrapper .ensureNativeSequence (s .getUtf8Bytes ());
1044
1044
}
1045
1045
1046
- @ Specialization
1047
- static Object doNative (PythonAbstractNativeObject s , Object sizePtr ,
1048
- @ Bind ("this" ) Node inliningTarget ,
1049
- @ Shared @ CachedLibrary (limit = "2" ) InteropLibrary lib ,
1050
- @ Shared @ Cached InlinedConditionProfile hasSizeProfile ,
1051
- @ Shared @ Cached InlinedConditionProfile hasUtf8Profile ,
1052
- @ Shared @ Cached CStructAccess .WriteLongNode writeLongNode ,
1053
- @ Shared @ Cached _PyUnicode_AsUTF8String asUTF8String ,
1054
- @ CachedLibrary (limit = "1" ) PythonBufferAccessLibrary bufferLib ,
1055
- @ Cached CStructAccess .ReadPointerNode readPointerNode ,
1056
- @ Cached CStructAccess .WritePointerNode writePointerNode ,
1057
- @ Cached CStructAccess .AllocateNode allocateNode ,
1058
- @ Cached CStructAccess .WriteByteNode writeByteNode ,
1059
- @ Cached CStructAccess .ReadI64Node readI64Node ) {
1060
- Object utf8 = readPointerNode .readFromObj (s , CFields .PyCompactUnicodeObject__utf8 );
1061
- if (hasUtf8Profile .profile (inliningTarget , lib .isNull (utf8 ))) {
1062
- PBytes bytes = (PBytes ) asUTF8String .execute (s , T_STRICT );
1063
- int len = bufferLib .getBufferLength (bytes );
1064
- Object mem = allocateNode .alloc (len + 1 , true );
1065
- writeByteNode .writeByteArray (mem , bufferLib .getInternalOrCopiedByteArray (bytes ), len , 0 , 0 );
1066
- writePointerNode .writeToObj (s , CFields .PyCompactUnicodeObject__utf8 , mem );
1067
- writeLongNode .writeToObject (s , CFields .PyCompactUnicodeObject__utf8_length , len );
1068
- if (hasSizeProfile .profile (inliningTarget , !lib .isNull (sizePtr ))) {
1069
- writeLongNode .write (sizePtr , len );
1070
- }
1071
- return mem ;
1072
- } else {
1073
- if (hasSizeProfile .profile (inliningTarget , !lib .isNull (sizePtr ))) {
1074
- writeLongNode .write (sizePtr , readI64Node .readFromObj (s , CFields .PyCompactUnicodeObject__utf8_length ));
1075
- }
1076
- return utf8 ;
1077
- }
1078
- }
1079
-
1080
1046
@ Fallback
1081
1047
@ SuppressWarnings ("unused" )
1082
1048
static Object doError (Object s , Object sizePtr ,
@@ -1085,6 +1051,27 @@ static Object doError(Object s, Object sizePtr,
1085
1051
}
1086
1052
}
1087
1053
1054
+ @ CApiBuiltin (ret = Int , args = {PyObject }, call = Ignored )
1055
+ abstract static class PyTruffleUnicode_FillUtf8 extends CApiUnaryBuiltinNode {
1056
+
1057
+ @ Specialization
1058
+ static Object doNative (PythonAbstractNativeObject s ,
1059
+ @ Cached CStructAccess .WriteLongNode writeLongNode ,
1060
+ @ Cached _PyUnicode_AsUTF8String asUTF8String ,
1061
+ @ CachedLibrary (limit = "1" ) PythonBufferAccessLibrary bufferLib ,
1062
+ @ Cached CStructAccess .WritePointerNode writePointerNode ,
1063
+ @ Cached CStructAccess .AllocateNode allocateNode ,
1064
+ @ Cached CStructAccess .WriteByteNode writeByteNode ) {
1065
+ PBytes bytes = (PBytes ) asUTF8String .execute (s , T_STRICT );
1066
+ int len = bufferLib .getBufferLength (bytes );
1067
+ Object mem = allocateNode .alloc (len + 1 , true );
1068
+ writeByteNode .writeByteArray (mem , bufferLib .getInternalOrCopiedByteArray (bytes ), len , 0 , 0 );
1069
+ writePointerNode .writeToObj (s , CFields .PyCompactUnicodeObject__utf8 , mem );
1070
+ writeLongNode .writeToObject (s , CFields .PyCompactUnicodeObject__utf8_length , len );
1071
+ return 0 ;
1072
+ }
1073
+ }
1074
+
1088
1075
@ CApiBuiltin (ret = PY_UNICODE_PTR , args = {PyObject }, call = Direct )
1089
1076
abstract static class PyTruffle_Unicode_AsUnicodeAndSize_CharPtr extends CApiUnaryBuiltinNode {
1090
1077
0 commit comments