Skip to content

Commit 92fefeb

Browse files
committed
[GR-27559] Remove more POL messages
PullRequest: graalpython/1984
2 parents a48aebd + 901ca2e commit 92fefeb

File tree

76 files changed

+1663
-2154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1663
-2154
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/PythonBuiltinClassType.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import com.oracle.graal.python.builtins.objects.function.PArguments;
5757
import com.oracle.graal.python.builtins.objects.function.PArguments.ThreadState;
5858
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
59-
import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
6059
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
6160
import com.oracle.graal.python.runtime.GilNode;
6261
import com.oracle.graal.python.runtime.PythonContext;
@@ -66,8 +65,6 @@
6665
import com.oracle.truffle.api.dsl.Cached;
6766
import com.oracle.truffle.api.dsl.Cached.Exclusive;
6867
import com.oracle.truffle.api.dsl.Cached.Shared;
69-
import com.oracle.truffle.api.dsl.Fallback;
70-
import com.oracle.truffle.api.dsl.Specialization;
7168
import com.oracle.truffle.api.frame.VirtualFrame;
7269
import com.oracle.truffle.api.interop.TruffleObject;
7370
import com.oracle.truffle.api.library.CachedLibrary;
@@ -750,31 +747,6 @@ public Object lookupAttributeOnTypeInternal(String attributeName, boolean strict
750747
}
751748
}
752749

753-
@ExportMessage
754-
static class IsSame {
755-
@Specialization
756-
static boolean tt(PythonBuiltinClassType receiver, PythonBuiltinClassType other) {
757-
return receiver == other;
758-
}
759-
760-
@Specialization
761-
static boolean tc(PythonBuiltinClassType receiver, PythonBuiltinClass other) {
762-
return receiver == other.getType();
763-
}
764-
765-
@Fallback
766-
@SuppressWarnings("unused")
767-
static boolean tO(PythonBuiltinClassType receiver, Object other) {
768-
return false;
769-
}
770-
}
771-
772-
@ExportMessage
773-
static int equalsInternal(PythonBuiltinClassType self, Object other, @SuppressWarnings("unused") ThreadState state,
774-
@CachedLibrary("self") PythonObjectLibrary selfLib) {
775-
return selfLib.isSame(self, other) ? 1 : 0;
776-
}
777-
778750
@ExportMessage
779751
@SuppressWarnings("static-method")
780752
public boolean isCallable() {
@@ -787,12 +759,6 @@ public Object callObjectWithState(ThreadState state, Object[] arguments,
787759
return lib.callObjectWithState(PythonContext.get(lib).getCore().lookupType(this), state, arguments);
788760
}
789761

790-
@ExportMessage
791-
@SuppressWarnings("static-method")
792-
public boolean isLazyPythonClass() {
793-
return true;
794-
}
795-
796762
public static boolean isExceptionType(PythonBuiltinClassType type) {
797763
return type.isException;
798764
}

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltinsFactory;
160160
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltinsFactory.DictNodeGen;
161161
import com.oracle.graal.python.builtins.objects.object.PythonObject;
162-
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
163162
import com.oracle.graal.python.builtins.objects.property.PProperty;
164163
import com.oracle.graal.python.builtins.objects.range.PBigRange;
165164
import com.oracle.graal.python.builtins.objects.range.PIntRange;
@@ -1512,17 +1511,10 @@ public static boolean bool(VirtualFrame frame, @SuppressWarnings("unused") Objec
15121511
@Builtin(name = LIST, minNumOfPositionalArgs = 1, takesVarArgs = true, takesVarKeywordArgs = true, constructsClass = PythonBuiltinClassType.PList)
15131512
@GenerateNodeFactory
15141513
public abstract static class ListNode extends PythonVarargsBuiltinNode {
1515-
@Specialization(guards = "lib.isLazyPythonClass(cls)")
1516-
protected PList constructList(Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords,
1517-
@SuppressWarnings("unused") @CachedLibrary(limit = "3") PythonObjectLibrary lib) {
1514+
@Specialization
1515+
protected PList constructList(Object cls, @SuppressWarnings("unused") Object[] arguments, @SuppressWarnings("unused") PKeyword[] keywords) {
15181516
return factory().createList(cls);
15191517
}
1520-
1521-
@Fallback
1522-
@SuppressWarnings("unused")
1523-
public PList listObject(Object cls, Object[] arguments, PKeyword[] keywords) {
1524-
throw raise(TypeError, ErrorMessages.IS_NOT_TYPE_OBJ, "'cls'", cls);
1525-
}
15261518
}
15271519

15281520
// object()
@@ -2737,7 +2729,7 @@ public static TypeNode create() {
27372729
@Specialization(guards = {"!isNoValue(bases)", "!isNoValue(dict)"})
27382730
Object typeGeneric(VirtualFrame frame, Object cls, Object name, Object bases, Object dict, PKeyword[] kwds,
27392731
@Cached TypeNode nextTypeNode,
2740-
@CachedLibrary(limit = "3") PythonObjectLibrary lib) {
2732+
@Cached IsTypeNode isTypeNode) {
27412733
if (PGuards.isNoValue(bases) && !PGuards.isNoValue(dict) || !PGuards.isNoValue(bases) && PGuards.isNoValue(dict)) {
27422734
throw raise(TypeError, ErrorMessages.TAKES_D_OR_D_ARGS, "type()", 1, 3);
27432735
} else if (!(name instanceof String || name instanceof PString)) {
@@ -2746,7 +2738,7 @@ Object typeGeneric(VirtualFrame frame, Object cls, Object name, Object bases, Ob
27462738
throw raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 2", bases);
27472739
} else if (!(dict instanceof PDict)) {
27482740
throw raise(TypeError, ErrorMessages.MUST_BE_STRINGS_NOT_P, "type() argument 3", dict);
2749-
} else if (!lib.isLazyPythonClass(cls)) {
2741+
} else if (!isTypeNode.execute(cls)) {
27502742
// TODO: this is actually allowed, deal with it
27512743
throw raise(NotImplementedError, "creating a class with non-class metaclass");
27522744
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
import com.oracle.graal.python.builtins.objects.module.PythonModule;
120120
import com.oracle.graal.python.builtins.objects.object.ObjectNodes;
121121
import com.oracle.graal.python.builtins.objects.object.PythonObject;
122-
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
123122
import com.oracle.graal.python.builtins.objects.str.PString;
124123
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
125124
import com.oracle.graal.python.builtins.objects.type.SpecialMethodSlot;
@@ -140,6 +139,7 @@
140139
import com.oracle.graal.python.lib.PyObjectSizeNode;
141140
import com.oracle.graal.python.lib.PyObjectStrAsJavaStringNode;
142141
import com.oracle.graal.python.lib.PyObjectStrAsObjectNode;
142+
import com.oracle.graal.python.lib.PyUnicodeFSDecoderNode;
143143
import com.oracle.graal.python.nodes.BuiltinNames;
144144
import com.oracle.graal.python.nodes.ErrorMessages;
145145
import com.oracle.graal.python.nodes.GraalPythonTranslationErrorNode;
@@ -839,7 +839,7 @@ PCode generic(VirtualFrame frame, Object wSource, Object wFilename, Object wMode
839839
@Cached CodecsModuleBuiltins.HandleDecodingErrorNode handleDecodingErrorNode,
840840
@Cached PyObjectStrAsJavaStringNode asStrNode,
841841
@CachedLibrary("wSource") InteropLibrary interopLib,
842-
@CachedLibrary(limit = "4") PythonObjectLibrary lib,
842+
@Cached PyUnicodeFSDecoderNode asPath,
843843
@Cached WarnNode warnNode) {
844844
if (wSource instanceof PCode) {
845845
return (PCode) wSource;
@@ -857,7 +857,7 @@ PCode generic(VirtualFrame frame, Object wSource, Object wFilename, Object wMode
857857
bufferLib.release(filenameBuffer);
858858
}
859859
} else {
860-
filename = lib.asPathWithState(wFilename, PArguments.getThreadState(frame));
860+
filename = asPath.execute(frame, wFilename);
861861
}
862862
String mode;
863863
try {

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
import com.oracle.graal.python.builtins.objects.module.PythonModule;
199199
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
200200
import com.oracle.graal.python.builtins.objects.object.PythonObject;
201-
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
202201
import com.oracle.graal.python.builtins.objects.set.PBaseSet;
203202
import com.oracle.graal.python.builtins.objects.set.PSet;
204203
import com.oracle.graal.python.builtins.objects.str.NativeCharSequence;
@@ -226,6 +225,7 @@
226225
import com.oracle.graal.python.nodes.BuiltinNames;
227226
import com.oracle.graal.python.nodes.ErrorMessages;
228227
import com.oracle.graal.python.nodes.PGuards;
228+
import com.oracle.graal.python.nodes.PNodeWithContext;
229229
import com.oracle.graal.python.nodes.PRaiseNode;
230230
import com.oracle.graal.python.nodes.SpecialAttributeNames;
231231
import com.oracle.graal.python.nodes.SpecialMethodNames;
@@ -542,42 +542,41 @@ Object importCExtFunction(String name, Object capiLibrary,
542542
}
543543

544544
@GenerateUncached
545-
@ImportStatic(PGuards.class)
546-
abstract static class CreateFunctionNode extends Node {
545+
abstract static class CreateFunctionNode extends PNodeWithContext {
547546

548547
abstract Object execute(String name, Object callable, Object wrapper, Object type, Object flags, PythonObjectFactory factory);
549548

550-
@Specialization(guards = {"lib.isLazyPythonClass(type)", "isNoValue(wrapper)"}, limit = "3")
549+
@Specialization(guards = {"isTypeNode.execute(type)", "isNoValue(wrapper)"}, limit = "3")
551550
static Object doPythonCallableWithoutWrapper(@SuppressWarnings("unused") String name, PythonNativeWrapper callable,
552551
@SuppressWarnings("unused") PNone wrapper,
553552
@SuppressWarnings("unused") Object type,
554553
@SuppressWarnings("unused") Object flags,
555554
@SuppressWarnings("unused") PythonObjectFactory factory,
556555
@CachedLibrary("callable") PythonNativeWrapperLibrary nativeWrapperLibrary,
557-
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
556+
@SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) {
558557
// This can happen if a native type inherits slots from a managed type. Therefore,
559558
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
560559
// case, we assume that the object is already callable.
561560
return nativeWrapperLibrary.getDelegate(callable);
562561
}
563562

564-
@Specialization(guards = "lib.isLazyPythonClass(type)")
563+
@Specialization(guards = "isTypeNode.execute(type)", limit = "1")
565564
@TruffleBoundary
566-
static Object doPythonCallable(String name, PythonNativeWrapper callable, int signature, Object type, int flags, PythonObjectFactory factory,
567-
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
565+
Object doPythonCallable(String name, PythonNativeWrapper callable, int signature, Object type, int flags, PythonObjectFactory factory,
566+
@SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) {
568567
// This can happen if a native type inherits slots from a managed type. Therefore,
569568
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
570569
// case, we assume that the object is already callable.
571570
Object managedCallable = callable.getDelegateSlowPath();
572-
PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, PythonLanguage.get(lib), factory, false);
571+
PBuiltinFunction function = PExternalFunctionWrapper.createWrapperFunction(name, managedCallable, type, flags, signature, getLanguage(), factory, false);
573572
return function != null ? function : managedCallable;
574573
}
575574

576-
@Specialization(guards = {"lib.isLazyPythonClass(type)", "isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"})
575+
@Specialization(guards = {"isTypeNode.execute(type)", "isDecoratedManagedFunction(callable)", "isNoValue(wrapper)"}, limit = "1")
577576
@SuppressWarnings("unused")
578577
static Object doDecoratedManagedWithoutWrapper(@SuppressWarnings("unused") String name, PyCFunctionDecorator callable, PNone wrapper, Object type, Object flags, PythonObjectFactory factory,
579578
@CachedLibrary(limit = "3") PythonNativeWrapperLibrary nativeWrapperLibrary,
580-
@CachedLibrary(limit = "2") PythonObjectLibrary lib) {
579+
@Cached TypeNodes.IsTypeNode isTypeNode) {
581580
// This can happen if a native type inherits slots from a managed type. Therefore,
582581
// something like 'base->tp_new' will be a wrapper of the managed '__new__'. So, in this
583582
// case, we assume that the object is already callable.
@@ -608,33 +607,33 @@ static Object doDecoratedManaged(String name, PyCFunctionDecorator callable, int
608607
return managedCallable;
609608
}
610609

611-
@Specialization(guards = {"lib.isLazyPythonClass(type)", "!isNativeWrapper(callable)"})
610+
@Specialization(guards = {"isTypeNode.execute(type)", "!isNativeWrapper(callable)"}, limit = "1")
612611
@TruffleBoundary
613-
static PBuiltinFunction doNativeCallableWithType(String name, Object callable, int signature, Object type, int flags, PythonObjectFactory factory,
614-
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
612+
PBuiltinFunction doNativeCallableWithType(String name, Object callable, int signature, Object type, int flags, PythonObjectFactory factory,
613+
@SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) {
615614
return PExternalFunctionWrapper.createWrapperFunction(name, callable, type, flags,
616-
signature, PythonLanguage.get(lib), factory, true);
615+
signature, getLanguage(), factory, true);
617616
}
618617

619618
@Specialization(guards = {"isNoValue(type)", "!isNativeWrapper(callable)"})
620619
@TruffleBoundary
621-
static PBuiltinFunction doNativeCallableWithoutType(String name, Object callable, int signature, @SuppressWarnings("unused") PNone type, int flags, PythonObjectFactory factory) {
620+
PBuiltinFunction doNativeCallableWithoutType(String name, Object callable, int signature, @SuppressWarnings("unused") PNone type, int flags, PythonObjectFactory factory) {
622621
return doNativeCallableWithType(name, callable, signature, null, flags, factory, null);
623622
}
624623

625-
@Specialization(guards = {"lib.isLazyPythonClass(type)", "isNoValue(wrapper)", "!isNativeWrapper(callable)"})
624+
@Specialization(guards = {"isTypeNode.execute(type)", "isNoValue(wrapper)", "!isNativeWrapper(callable)"}, limit = "1")
626625
@TruffleBoundary
627-
static PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Object type,
626+
PBuiltinFunction doNativeCallableWithoutWrapper(String name, Object callable, Object type,
628627
@SuppressWarnings("unused") PNone wrapper,
629628
@SuppressWarnings("unused") Object flags, PythonObjectFactory factory,
630-
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
629+
@SuppressWarnings("unused") @Cached TypeNodes.IsTypeNode isTypeNode) {
631630
return PExternalFunctionWrapper.createWrapperFunction(name, callable, type, 0,
632-
PExternalFunctionWrapper.DIRECT, PythonLanguage.get(lib), factory, true);
631+
PExternalFunctionWrapper.DIRECT, getLanguage(), factory, true);
633632
}
634633

635634
@Specialization(guards = {"isNoValue(wrapper)", "isNoValue(type)", "!isNativeWrapper(callable)"})
636635
@TruffleBoundary
637-
static PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object callable, PNone wrapper, @SuppressWarnings("unused") PNone type, Object flags, PythonObjectFactory factory) {
636+
PBuiltinFunction doNativeCallableWithoutWrapperAndType(String name, Object callable, PNone wrapper, @SuppressWarnings("unused") PNone type, Object flags, PythonObjectFactory factory) {
638637
return doNativeCallableWithoutWrapper(name, callable, null, wrapper, flags, factory, null);
639638
}
640639

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
import com.oracle.graal.python.annotations.ArgumentClinic;
6464
import com.oracle.graal.python.builtins.Builtin;
6565
import com.oracle.graal.python.builtins.CoreFunctions;
66+
import com.oracle.graal.python.builtins.Python3Core;
6667
import com.oracle.graal.python.builtins.PythonBuiltins;
6768
import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum;
6869
import com.oracle.graal.python.builtins.objects.module.PythonModule;
69-
import com.oracle.graal.python.builtins.objects.object.PythonObjectLibrary;
7070
import com.oracle.graal.python.builtins.objects.ssl.ALPNHelper;
7171
import com.oracle.graal.python.builtins.objects.ssl.CertUtils;
7272
import com.oracle.graal.python.builtins.objects.ssl.SSLCipher;
@@ -76,23 +76,23 @@
7676
import com.oracle.graal.python.builtins.objects.ssl.SSLOptions;
7777
import com.oracle.graal.python.builtins.objects.ssl.SSLProtocol;
7878
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
79+
import com.oracle.graal.python.lib.PyUnicodeFSDecoderNode;
7980
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
8081
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
8182
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryBuiltinNode;
8283
import com.oracle.graal.python.nodes.function.builtins.PythonBinaryClinicBuiltinNode;
8384
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
8485
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
85-
import com.oracle.graal.python.builtins.Python3Core;
8686
import com.oracle.graal.python.runtime.exception.PException;
8787
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
8888
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
8989
import com.oracle.truffle.api.TruffleFile;
9090
import com.oracle.truffle.api.TruffleLogger;
91+
import com.oracle.truffle.api.dsl.Cached;
9192
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
9293
import com.oracle.truffle.api.dsl.NodeFactory;
9394
import com.oracle.truffle.api.dsl.Specialization;
9495
import com.oracle.truffle.api.frame.VirtualFrame;
95-
import com.oracle.truffle.api.library.CachedLibrary;
9696

9797
@CoreFunctions(defineModule = "_ssl")
9898
public class SSLModuleBuiltins extends PythonBuiltins {
@@ -358,10 +358,10 @@ Object getDefaultPaths() {
358358
@Builtin(name = "_test_decode_cert", minNumOfPositionalArgs = 1, numOfPositionalOnlyArgs = 1, parameterNames = {"path"})
359359
@GenerateNodeFactory
360360
abstract static class DecodeCertNode extends PythonUnaryBuiltinNode {
361-
@Specialization(limit = "2")
361+
@Specialization
362362
Object decode(VirtualFrame frame, Object path,
363-
@CachedLibrary("path") PythonObjectLibrary lib) {
364-
return decode(toTruffleFile(frame, lib, path));
363+
@Cached PyUnicodeFSDecoderNode asPath) {
364+
return decode(toTruffleFile(frame, asPath, path));
365365
}
366366

367367
@TruffleBoundary
@@ -387,10 +387,10 @@ private Object decode(TruffleFile file) throws PException {
387387
}
388388
}
389389

390-
private TruffleFile toTruffleFile(VirtualFrame frame, PythonObjectLibrary lib, Object fileObject) throws PException {
390+
private TruffleFile toTruffleFile(VirtualFrame frame, PyUnicodeFSDecoderNode asPath, Object fileObject) throws PException {
391391
TruffleFile file;
392392
try {
393-
file = getContext().getEnv().getPublicTruffleFile(lib.asPath(fileObject));
393+
file = getContext().getEnv().getPublicTruffleFile(asPath.execute(frame, fileObject));
394394
if (!file.exists()) {
395395
throw raiseOSError(frame, OSErrorEnum.ENOENT);
396396
}

0 commit comments

Comments
 (0)