Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23967,7 +23967,7 @@ private boolean genLookahead__tmp_328_rule(boolean match) {
return (result != null) == match;
}


@Override
protected SSTNode runParser(InputType inputType) {
SSTNode result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static Object reconstructCached(VirtualFrame frame, Object arrayType, TruffleStr
@Exclusive @Cached IsSubtypeNode isSubtypeNode,
@Exclusive @Cached ArrayBuiltins.ByteSwapNode byteSwapNode,
@Exclusive @Cached TruffleString.CodePointLengthNode lengthNode,
@Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode,
@Exclusive @Cached TruffleString.CodePointAtIndexUTF32Node atIndexNode,
@Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape,
@Exclusive @Cached PRaiseNode raiseNode) {
BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode);
Expand All @@ -124,7 +124,7 @@ static Object reconstruct(VirtualFrame frame, Object arrayType, TruffleString ty
@Exclusive @Cached IsSubtypeNode isSubtypeNode,
@Exclusive @Cached ArrayBuiltins.ByteSwapNode byteSwapNode,
@Exclusive @Cached TruffleString.CodePointLengthNode lengthNode,
@Exclusive @Cached TruffleString.CodePointAtIndexNode atIndexNode,
@Exclusive @Cached TruffleString.CodePointAtIndexUTF32Node atIndexNode,
@Exclusive @Cached TypeNodes.GetInstanceShape getInstanceShape,
@Exclusive @Cached PRaiseNode raiseNode) {
BufferFormat format = BufferFormat.forArray(typeCode, lengthNode, atIndexNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ int getBufferLength(

@ExportMessage
byte readByte(int byteOffset,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode) {
int ch = codePointAtIndexNode.execute(str, byteOffset, TS_ENCODING);
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode) {
int ch = codePointAtIndexNode.execute(str, byteOffset);
assert 0 <= ch && ch < 128; // guaranteed because str is ASCII
return (byte) ch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.strings.TruffleString;
import com.oracle.truffle.api.strings.TruffleStringBuilder;
import com.oracle.truffle.api.strings.TruffleStringBuilderUTF32;

@CoreFunctions(defineModule = J_BUILTINS, isEager = true)
public final class BuiltinFunctions extends PythonBuiltins {
Expand Down Expand Up @@ -587,7 +588,7 @@ interface LongToString {

@TruffleBoundary
private static TruffleString buildString(boolean isNegative, TruffleString prefix, TruffleString number) {
TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING, tsbCapacity(3) + number.byteLength(TS_ENCODING));
TruffleStringBuilderUTF32 sb = TruffleStringBuilder.createUTF32(tsbCapacity(3) + number.byteLength(TS_ENCODING));
if (isNegative) {
sb.appendStringUncached(T_MINUS);
}
Expand Down Expand Up @@ -1703,7 +1704,7 @@ static int ord(Object chrObj,
@Bind Node inliningTarget,
@Cached CastToTruffleStringNode castToStringNode,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Exclusive @Cached PRaiseNode raiseNode) {
TruffleString chr;
try {
Expand All @@ -1715,7 +1716,7 @@ static int ord(Object chrObj,
if (len != 1) {
throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.EXPECTED_CHARACTER_BUT_STRING_FOUND, "ord()", len);
}
return codePointAtIndexNode.execute(chr, 0, TS_ENCODING);
return codePointAtIndexNode.execute(chr, 0);
}

@Specialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ Object doHook(VirtualFrame frame, Object[] args, PKeyword[] keywords,
@Cached BuiltinFunctions.IsInstanceNode isInstanceNode,
@Cached WarningsModuleBuiltins.WarnNode warnNode,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached TruffleString.LastIndexOfCodePointNode lastIndexOfCodePointNode,
@Cached TruffleString.SubstringNode substringNode) {
TruffleString hookName = OsEnvironGetNode.lookup(frame, boundaryCallData, T_PYTHONBREAKPOINT);
Expand All @@ -1749,7 +1749,7 @@ Object doHook(VirtualFrame frame, Object[] args, PKeyword[] keywords,
}

int hookNameLen = codePointLengthNode.execute(hookName, TS_ENCODING);
if (hookNameLen == 1 && codePointAtIndexNode.execute(hookName, 0, TS_ENCODING) == '0') {
if (hookNameLen == 1 && codePointAtIndexNode.execute(hookName, 0) == '0') {
// The breakpoint is explicitly no-op'd.
return PNone.NONE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ static Object wrap(Object bufferStructPointer, Object ownerObj, long lenObj,
@CachedLibrary(limit = "2") InteropLibrary lib,
@Cached CastToJavaIntExactNode castToIntNode,
@Cached TruffleString.CodePointLengthNode lengthNode,
@Cached TruffleString.CodePointAtIndexNode atIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node atIndexNode,
@Bind PythonLanguage language) {
int ndim = castToIntNode.execute(inliningTarget, ndimObj);
int itemsize = castToIntNode.execute(inliningTarget, itemsizeObj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
import com.oracle.truffle.api.strings.TruffleString.FromNativePointerNode;
import com.oracle.truffle.api.strings.TruffleString.SwitchEncodingNode;
import com.oracle.truffle.api.strings.TruffleStringBuilder;
import com.oracle.truffle.api.strings.TruffleStringBuilderUTF32;

public final class PythonCextUnicodeBuiltins {

Expand Down Expand Up @@ -720,7 +721,7 @@ static Object join(Object separatorObj, Object itemsObj, long seqlenlong,
int seqlen = (int) seqlenlong;
assert seqlen == seqlenlong;
Object[] items = readNode.readPyObjectArray(itemsObj, seqlen);
TruffleStringBuilder sb = TruffleStringBuilder.create(TS_ENCODING);
TruffleStringBuilderUTF32 sb = TruffleStringBuilder.createUTF32();
for (int i = 0; i < items.length; i++) {
TruffleString item = toTruffleStringNode.execute(inliningTarget, items[i]);
if (i != 0) {
Expand Down Expand Up @@ -769,7 +770,7 @@ static int doGeneric(Object type, long lindex,
@Bind Node inliningTarget,
@Cached CastToTruffleStringNode castToStringNode,
@Cached TruffleString.CodePointLengthNode lengthNode,
@Cached TruffleString.CodePointAtIndexNode codepointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codepointAtIndexNode,
@Cached PRaiseNode raiseNode) {
try {
TruffleString s = castToStringNode.execute(inliningTarget, type);
Expand All @@ -778,7 +779,7 @@ static int doGeneric(Object type, long lindex,
if (index < 0 || index >= lengthNode.execute(s, TS_ENCODING)) {
throw raiseNode.raise(inliningTarget, IndexError, ErrorMessages.STRING_INDEX_OUT_OF_RANGE);
}
return codepointAtIndexNode.execute(s, index, TS_ENCODING);
return codepointAtIndexNode.execute(s, index);
} catch (CannotCastException e) {
throw raiseNode.raise(inliningTarget, TypeError, ErrorMessages.BAD_ARG_TYPE_FOR_BUILTIN_OP);
} catch (OverflowException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.InlinedConditionProfile;
import com.oracle.truffle.api.strings.TruffleString;
import com.oracle.truffle.api.strings.TruffleString.ErrorHandling;
import com.oracle.truffle.api.strings.TruffleStringBuilder;
import com.oracle.truffle.api.strings.TruffleStringBuilderUTF32;

public final class CharmapNodes {

Expand All @@ -118,7 +118,7 @@ public abstract static class PyUnicodeBuildEncodingMapNode extends Node {
@Specialization
static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached(inline = false) HashingStorageSetItem setItemNode,
@Cached PRaiseNode raiseNode) {
int len = Math.min(codePointLengthNode.execute(map, TS_ENCODING), 256);
Expand All @@ -132,11 +132,11 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map,

Arrays.fill(level1, (byte) 0xFF);
Arrays.fill(level2, (byte) 0xFF);
if (codePointAtIndexNode.execute(map, 0, TS_ENCODING, ErrorHandling.BEST_EFFORT) != 0) {
if (codePointAtIndexNode.execute(map, 0) != 0) {
return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode);
}
for (int i = 1; i < len; ++i) {
int cp = codePointAtIndexNode.execute(map, i, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(map, i);
if (cp == 0 || cp > 0xFFFF) {
return doDict(frame, inliningTarget, map, len, codePointAtIndexNode, setItemNode);
}
Expand All @@ -161,7 +161,7 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map,
Arrays.fill(level23, 0, l3Start, (byte) 0xFF);
count3 = 0;
for (int i = 1; i < len; ++i) {
int cp = codePointAtIndexNode.execute(map, i, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(map, i);
if (cp == 0xFFFE) {
continue;
}
Expand All @@ -178,10 +178,11 @@ static Object doIt(VirtualFrame frame, Node inliningTarget, TruffleString map,
return PFactory.createEncodingMap(PythonLanguage.get(inliningTarget), count2, count3, level1, level23);
}

private static Object doDict(VirtualFrame frame, Node inliningTarget, TruffleString map, int len, TruffleString.CodePointAtIndexNode codePointAtIndexNode, HashingStorageSetItem setItemNode) {
private static Object doDict(VirtualFrame frame, Node inliningTarget, TruffleString map, int len, TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
HashingStorageSetItem setItemNode) {
HashingStorage store = PDict.createNewStorage(len);
for (int i = 0; i < len; ++i) {
int cp = codePointAtIndexNode.execute(map, i, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(map, i);
store = setItemNode.execute(frame, inliningTarget, store, cp, i);
}
return PFactory.createDict(PythonLanguage.get(inliningTarget), store);
Expand All @@ -204,7 +205,7 @@ static byte[] doLatin1(TruffleString src, TruffleString errors, PNone mapping,
@Fallback
static byte[] doGenericMapping(VirtualFrame frame, Node inliningTarget, TruffleString src, TruffleString errors, Object mapping,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached CharmapEncodeOutputNode charmapEncodeOutputNode,
@Cached CharmapEncodingErrorNode charmapEncodingErrorNode) {
int len = codePointLengthNode.execute(src, TS_ENCODING);
Expand All @@ -215,7 +216,7 @@ static byte[] doGenericMapping(VirtualFrame frame, Node inliningTarget, TruffleS
int inPos = 0;
ErrorHandlerCache cache = new ErrorHandlerCache();
while (inPos < len) {
int cp = codePointAtIndexNode.execute(src, inPos, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(src, inPos);
boolean x = charmapEncodeOutputNode.execute(frame, inliningTarget, cp, mapping, builder);
if (!x) {
inPos = charmapEncodingErrorNode.execute(frame, inliningTarget, cache, src, inPos, len, errors, mapping, builder);
Expand All @@ -237,7 +238,7 @@ abstract static class CharmapEncodingErrorNode extends Node {
static int doIt(VirtualFrame frame, Node inliningTarget, ErrorHandlerCache cache, TruffleString src, int pos, int len, TruffleString errors, Object mapping, ByteArrayBuilder builder,
@Cached CastToTruffleStringNode castToTruffleStringNode,
@Cached TruffleString.CodePointLengthNode codePointLengthNode,
@Cached TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached CharmapEncodeLookupNode charmapEncodeLookupNode,
@Cached GetErrorHandlerNode getErrorHandlerNode,
@Cached CallEncodingErrorHandlerNode callEncodingErrorHandlerNode,
Expand All @@ -246,7 +247,7 @@ static int doIt(VirtualFrame frame, Node inliningTarget, ErrorHandlerCache cache
@Cached RaiseEncodeException raiseEncodeException) {
int errEnd = pos;
while (errEnd < len) {
int cp = codePointAtIndexNode.execute(src, errEnd, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(src, errEnd);
if (mapping instanceof PEncodingMap map) {
if (encodingMapLookup(cp, map) != -1) {
break;
Expand All @@ -270,7 +271,7 @@ static int doIt(VirtualFrame frame, Node inliningTarget, ErrorHandlerCache cache
TruffleString replacement = castToTruffleStringNode.execute(inliningTarget, result.replacement);
int repLen = codePointLengthNode.execute(replacement, TS_ENCODING);
for (int i = 0; i < repLen; ++i) {
int cp = codePointAtIndexNode.execute(replacement, i, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(replacement, i);
if (!charmapEncodeOutputNode.execute(frame, inliningTarget, cp, mapping, builder)) {
raiseEncodeException.execute(frame, inliningTarget, cache, T_CHARMAP, src, pos, errEnd, CHARACTER_MAPS_TO_UNDEFINED);
}
Expand Down Expand Up @@ -391,7 +392,7 @@ static TruffleString decodeStringMapping(VirtualFrame frame, Object data, Truffl
@SuppressWarnings("unused") @Cached @Exclusive PyUnicodeCheckExactNode isBuiltinString,
@Cached @Exclusive CastToTruffleStringNode castToTruffleStringNode,
@Cached @Shared TruffleString.CodePointLengthNode codePointLengthNode,
@Cached @Shared TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached @Shared TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached @Shared TruffleStringBuilder.AppendCodePointNode appendCodePointNode,
@Cached @Shared TruffleStringBuilder.AppendStringNode appendStringNode,
@Cached @Shared TruffleStringBuilder.ToStringNode toStringNode,
Expand All @@ -405,7 +406,7 @@ static TruffleString decodeStringMapping(VirtualFrame frame, Object data, Truffl
int pos = 0;
TruffleString mapping = castToTruffleStringNode.execute(inliningTarget, mappingObj);
int mappingLen = codePointLengthNode.execute(mapping, TS_ENCODING);
TruffleStringBuilder tsb = TruffleStringBuilder.create(TS_ENCODING);
TruffleStringBuilderUTF32 tsb = TruffleStringBuilder.createUTF32();
int errorStartPos;
int srcLen;
do {
Expand All @@ -420,7 +421,7 @@ static TruffleString decodeStringMapping(VirtualFrame frame, Object data, Truffl
errorStartPos = pos;
break;
}
int cp = codePointAtIndexNode.execute(mapping, index, TS_ENCODING);
int cp = codePointAtIndexNode.execute(mapping, index);
if (cp == UNDEFINED_MAPPING) {
errorStartPos = pos;
break;
Expand Down Expand Up @@ -455,7 +456,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff
@Cached PyUnicodeCheckNode pyUnicodeCheckNode,
@Cached @Exclusive CastToTruffleStringNode castToTruffleStringNode,
@Cached @Shared TruffleString.CodePointLengthNode codePointLengthNode,
@Cached @Shared TruffleString.CodePointAtIndexNode codePointAtIndexNode,
@Cached @Shared TruffleString.CodePointAtIndexUTF32Node codePointAtIndexNode,
@Cached @Shared TruffleStringBuilder.AppendCodePointNode appendCodePointNode,
@Cached @Shared TruffleStringBuilder.AppendStringNode appendStringNode,
@Cached @Shared TruffleStringBuilder.ToStringNode toStringNode,
Expand All @@ -471,7 +472,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff
ErrorHandlerCache cache = new ErrorHandlerCache();
Object srcObj = data;
int pos = 0;
TruffleStringBuilder tsb = TruffleStringBuilder.create(TS_ENCODING);
TruffleStringBuilderUTF32 tsb = TruffleStringBuilder.createUTF32();
int errorStartPos;
int srcLen;
do {
Expand Down Expand Up @@ -508,7 +509,7 @@ static TruffleString decodeGenericMapping(VirtualFrame frame, Object data, Truff
} else if (strValuesProfile.profile(inliningTarget, pyUnicodeCheckNode.execute(inliningTarget, item))) {
TruffleString ts = castToTruffleStringNode.execute(inliningTarget, item);
if (codePointLengthNode.execute(ts, TS_ENCODING) == 1) {
int cp = codePointAtIndexNode.execute(ts, 0, TS_ENCODING, ErrorHandling.BEST_EFFORT);
int cp = codePointAtIndexNode.execute(ts, 0);
if (cp == UNDEFINED_MAPPING) {
errorStartPos = pos;
break;
Expand Down
Loading
Loading