Skip to content

Commit d944124

Browse files
committed
Remove LookupAndCallTernaryNode
1 parent afb998d commit d944124

File tree

4 files changed

+15
-201
lines changed

4 files changed

+15
-201
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_string.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
# Copyright (C) 1996-2017 Python Software Foundation
33
#
44
# Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
@@ -1195,3 +1195,12 @@ class S(str): pass
11951195
def test_literal_with_nonbmp_and_escapes():
11961196
# Check that escape processing didn't accidentally break the emoji into surrogates
11971197
assert len("\\🤗\\") == 3
1198+
1199+
1200+
def test_str_from_mmap():
1201+
import mmap
1202+
size = len("GraalPy")
1203+
with mmap.mmap(-1, size) as mm:
1204+
mm.write(b"GraalPy")
1205+
mm.seek(0)
1206+
assert str(mm, encoding='utf-8') == 'GraalPy'

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
import com.oracle.graal.python.builtins.objects.PNotImplemented;
113113
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
114114
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAcquireLibrary;
115+
import com.oracle.graal.python.builtins.objects.bytes.BytesCommonBuiltins;
115116
import com.oracle.graal.python.builtins.objects.bytes.BytesNodes;
116117
import com.oracle.graal.python.builtins.objects.bytes.PByteArray;
117118
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
@@ -207,7 +208,6 @@
207208
import com.oracle.graal.python.nodes.builtins.TupleNodes;
208209
import com.oracle.graal.python.nodes.call.CallNode;
209210
import com.oracle.graal.python.nodes.call.special.CallUnaryMethodNode;
210-
import com.oracle.graal.python.nodes.call.special.LookupAndCallTernaryNode;
211211
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
212212
import com.oracle.graal.python.nodes.call.special.LookupSpecialMethodSlotNode;
213213
import com.oracle.graal.python.nodes.classes.IsSubtypeNode;
@@ -1823,7 +1823,7 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi
18231823
@Exclusive @Cached InlinedConditionProfile isPStringProfile,
18241824
@Exclusive @CachedLibrary("obj") PythonBufferAcquireLibrary acquireLib,
18251825
@Exclusive @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib,
1826-
@Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode,
1826+
@Exclusive @Cached BytesCommonBuiltins.DecodeNode decodeNode,
18271827
@Shared @Cached TypeNodes.GetInstanceShape getInstanceShape,
18281828
@Exclusive @Cached PRaiseNode raiseNode) {
18291829
Object buffer;
@@ -1837,7 +1837,7 @@ static Object doBuffer(VirtualFrame frame, Object cls, Object obj, Object encodi
18371837
// TODO don't copy, CPython creates a memoryview
18381838
PBytes bytesObj = PFactory.createBytes(PythonLanguage.get(inliningTarget), bufferLib.getCopiedByteArray(buffer));
18391839
Object en = encoding == PNone.NO_VALUE ? T_UTF8 : encoding;
1840-
Object result = assertNoJavaString(callDecodeNode.execute(frame, bytesObj, en, errors));
1840+
Object result = assertNoJavaString(decodeNode.execute(frame, bytesObj, en, errors));
18411841
if (isStringProfile.profile(inliningTarget, result instanceof TruffleString)) {
18421842
return asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, getInstanceShape);
18431843
} else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) {
@@ -1882,7 +1882,7 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o
18821882
@Exclusive @Cached InlinedConditionProfile isPStringProfile,
18831883
@Exclusive @CachedLibrary("obj") PythonBufferAcquireLibrary acquireLib,
18841884
@Exclusive @CachedLibrary(limit = "1") PythonBufferAccessLibrary bufferLib,
1885-
@Exclusive @Cached("create(T_DECODE)") LookupAndCallTernaryNode callDecodeNode,
1885+
@Exclusive @Cached BytesCommonBuiltins.DecodeNode decodeNode,
18861886
@Shared @Cached(neverDefault = true) CExtNodes.StringSubtypeNew subtypeNew,
18871887
@Shared @Cached TypeNodes.GetInstanceShape getInstanceShape,
18881888
@Exclusive @Cached PRaiseNode raiseNode) {
@@ -1895,7 +1895,7 @@ static Object doNativeSubclassEncodeErr(VirtualFrame frame, Object cls, Object o
18951895
try {
18961896
PBytes bytesObj = PFactory.createBytes(PythonLanguage.get(inliningTarget), bufferLib.getCopiedByteArray(buffer));
18971897
Object en = encoding == PNone.NO_VALUE ? T_UTF8 : encoding;
1898-
Object result = assertNoJavaString(callDecodeNode.execute(frame, bytesObj, en, errors));
1898+
Object result = assertNoJavaString(decodeNode.execute(frame, bytesObj, en, errors));
18991899
if (isStringProfile.profile(inliningTarget, result instanceof TruffleString)) {
19001900
return subtypeNew.call(cls, asPString(cls, (TruffleString) result, inliningTarget, isPrimitiveProfile, getInstanceShape));
19011901
} else if (isPStringProfile.profile(inliningTarget, result instanceof PString)) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallNonReversibleTernaryNode.java

-119
This file was deleted.

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/call/special/LookupAndCallTernaryNode.java

-76
This file was deleted.

0 commit comments

Comments
 (0)