Skip to content

Commit 483b93d

Browse files
committed
Remove unused PInteropXXX nodes
1 parent 7a6651b commit 483b93d

File tree

1 file changed

+6
-222
lines changed

1 file changed

+6
-222
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 6 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@
4848
import static com.oracle.graal.python.nodes.ErrorMessages.S_MUST_BE_A_S_TUPLE;
4949
import static com.oracle.graal.python.nodes.SpecialMethodNames.T_KEYS;
5050
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELETE__;
51-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___DELITEM__;
5251
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTRIBUTE__;
53-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GETATTR__;
5452
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___GET__;
55-
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SETITEM__;
5653
import static com.oracle.graal.python.nodes.SpecialMethodNames.T___SET__;
5754
import static com.oracle.graal.python.nodes.StringLiterals.T_LBRACKET;
5855
import static com.oracle.graal.python.nodes.truffle.TruffleStringMigrationHelpers.isJavaString;
@@ -71,7 +68,6 @@
7168

7269
import com.oracle.graal.python.PythonLanguage;
7370
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
74-
import com.oracle.graal.python.builtins.objects.PythonAbstractObjectFactory.PInteropGetAttributeNodeGen;
7571
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
7672
import com.oracle.graal.python.builtins.objects.cext.capi.CApiGuards;
7773
import com.oracle.graal.python.builtins.objects.cext.capi.PythonNativeWrapper.PythonAbstractObjectNativeWrapper;
@@ -119,7 +115,6 @@
119115
import com.oracle.graal.python.lib.PySequenceSizeNode;
120116
import com.oracle.graal.python.lib.PyTupleSizeNode;
121117
import com.oracle.graal.python.nodes.BuiltinNames;
122-
import com.oracle.graal.python.nodes.ErrorMessages;
123118
import com.oracle.graal.python.nodes.HiddenAttr;
124119
import com.oracle.graal.python.nodes.PGuards;
125120
import com.oracle.graal.python.nodes.PRaiseNode;
@@ -129,7 +124,6 @@
129124
import com.oracle.graal.python.nodes.attributes.ReadAttributeFromObjectNode;
130125
import com.oracle.graal.python.nodes.call.CallNode;
131126
import com.oracle.graal.python.nodes.call.special.CallBinaryMethodNode;
132-
import com.oracle.graal.python.nodes.call.special.CallTernaryMethodNode;
133127
import com.oracle.graal.python.nodes.call.special.CallVarargsMethodNode;
134128
import com.oracle.graal.python.nodes.expression.CastToListExpressionNode.CastToListInteropNode;
135129
import com.oracle.graal.python.nodes.interop.GetInteropBehaviorNode;
@@ -232,8 +226,8 @@ public final void clearNativeWrapper() {
232226
@ExportMessage
233227
public void writeMember(String key, Object value,
234228
@Bind("$node") Node inliningTarget,
235-
@Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
236-
@Cached PyObjectSetAttr setAttributeNode,
229+
@Exclusive @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
230+
@Exclusive @Cached PyObjectSetAttr setAttributeNode,
237231
// GR-44020: make shared:
238232
@Exclusive @Cached IsBuiltinObjectProfile attrErrorProfile,
239233
@Exclusive @Cached GilNode gil) throws UnsupportedMessageException, UnknownIdentifierException {
@@ -252,7 +246,7 @@ public void writeMember(String key, Object value,
252246
@ExportMessage
253247
public Object readMember(String key,
254248
@Bind("$node") Node inliningTarget,
255-
@Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
249+
@Exclusive @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
256250
// GR-44020: make shared:
257251
@Exclusive @Cached PyObjectLookupAttr lookup,
258252
@Exclusive @Cached GilNode gil) throws UnknownIdentifierException {
@@ -604,7 +598,7 @@ public boolean hasMemberWriteSideEffects(String member,
604598
@ExportMessage
605599
public Object invokeMember(String member, Object[] arguments,
606600
@Bind("$node") Node inliningTarget,
607-
@Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
601+
@Exclusive @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
608602
@Exclusive @Cached LookupInheritedAttributeNode.Dynamic lookupGetattributeNode,
609603
@Exclusive @Cached CallBinaryMethodNode callGetattributeNode,
610604
@Exclusive @Cached PExecuteNode executeNode,
@@ -750,8 +744,8 @@ public Object getMembers(boolean includeInternal,
750744
@ExportMessage
751745
public void removeMember(String member,
752746
@Bind("$node") Node inliningTarget,
753-
@Cached PyObjectSetAttr deleteAttributeNode,
754-
@Shared("js2ts") @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
747+
@Exclusive @Cached PyObjectSetAttr deleteAttributeNode,
748+
@Exclusive @Cached TruffleString.FromJavaStringNode fromJavaStringNode,
755749
// GR-44020: make shared:
756750
@Exclusive @Cached IsBuiltinObjectProfile attrErrorProfile,
757751
@Exclusive @Cached GilNode gil) throws UnsupportedMessageException, UnknownIdentifierException {
@@ -1268,37 +1262,6 @@ public static boolean isImmutable(Node inliningTarget, Object object,
12681262
}
12691263
}
12701264

1271-
/*
1272-
* Basically the same as 'com.oracle.graal.python.nodes.subscript.GetItemNode' but with an
1273-
* uncached version.
1274-
*/
1275-
@GenerateUncached
1276-
@ImportStatic(SpecialMethodSlot.class)
1277-
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 19
1278-
public abstract static class PInteropSubscriptNode extends Node {
1279-
1280-
public abstract Object execute(Object primary, Object index);
1281-
1282-
@Specialization
1283-
static Object doSpecialObject(Object primary, Object index,
1284-
@Bind("this") Node inliningTarget,
1285-
@Cached GetClassNode getClassNode,
1286-
@Cached(parameters = "GetItem") LookupCallableSlotInMRONode lookupInMRONode,
1287-
@Cached CallBinaryMethodNode callGetItemNode,
1288-
@Cached PRaiseNode raiseNode,
1289-
@Cached InlinedConditionProfile profile) {
1290-
Object attrGetItem = lookupInMRONode.execute(getClassNode.execute(inliningTarget, primary));
1291-
if (profile.profile(inliningTarget, attrGetItem == PNone.NO_VALUE)) {
1292-
throw raiseNode.raise(PythonBuiltinClassType.TypeError, ErrorMessages.OBJ_NOT_SUBSCRIPTABLE, primary);
1293-
}
1294-
return callGetItemNode.executeObject(attrGetItem, primary, index);
1295-
}
1296-
1297-
public static PInteropSubscriptNode getUncached() {
1298-
return PythonAbstractObjectFactory.PInteropSubscriptNodeGen.getUncached();
1299-
}
1300-
}
1301-
13021265
@GenerateUncached
13031266
@ReportPolymorphism
13041267
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 17
@@ -1418,185 +1381,6 @@ boolean isArrayElementReadable(long index) {
14181381
}
14191382
}
14201383

1421-
/*
1422-
* Basically the same as 'com.oracle.graal.python.nodes.attributes.GetAttributeNode' but with an
1423-
* uncached version.
1424-
*/
1425-
@GenerateUncached
1426-
@GenerateInline
1427-
@GenerateCached(false)
1428-
public abstract static class PInteropGetAttributeNode extends Node {
1429-
1430-
public abstract Object execute(Node inliningTarget, Object object, Object attrName);
1431-
1432-
public static Object executeUncached(Object object, Object attrName) {
1433-
return PInteropGetAttributeNodeGen.getUncached().execute(null, object, attrName);
1434-
}
1435-
1436-
@Specialization(limit = "2")
1437-
static Object doIt(Node inliningTarget, Object object, Object attrName,
1438-
@CachedLibrary("attrName") InteropLibrary libAttrName,
1439-
// GR-44020: make shared:
1440-
@Exclusive @Cached PRaiseNode.Lazy raiseNode,
1441-
@Cached LookupInheritedAttributeNode.Dynamic lookupGetattributeNode,
1442-
@Cached(inline = false) CallBinaryMethodNode callGetattributeNode,
1443-
@Cached LookupInheritedAttributeNode.Dynamic lookupGetattrNode,
1444-
@Cached(inline = false) CallBinaryMethodNode callGetattrNode,
1445-
@Cached(inline = false) TruffleString.SwitchEncodingNode switchEncodingNode,
1446-
@Cached IsBuiltinObjectProfile isBuiltinClassProfile,
1447-
@Cached InlinedConditionProfile hasGetattrProfile) {
1448-
if (!libAttrName.isString(attrName)) {
1449-
throw raiseNode.get(inliningTarget).raise(TypeError, ErrorMessages.ATTR_NAME_MUST_BE_STRING, attrName);
1450-
}
1451-
1452-
TruffleString attrNameStr;
1453-
try {
1454-
attrNameStr = switchEncodingNode.execute(libAttrName.asTruffleString(attrName), TS_ENCODING);
1455-
} catch (UnsupportedMessageException e) {
1456-
CompilerDirectives.transferToInterpreterAndInvalidate();
1457-
throw new IllegalStateException("should not be reached");
1458-
}
1459-
1460-
try {
1461-
Object attrGetattribute = lookupGetattributeNode.execute(inliningTarget, object, T___GETATTRIBUTE__);
1462-
return callGetattributeNode.executeObject(attrGetattribute, object, attrNameStr);
1463-
} catch (PException pe) {
1464-
pe.expect(inliningTarget, AttributeError, isBuiltinClassProfile);
1465-
Object attrGetattr = lookupGetattrNode.execute(inliningTarget, object, T___GETATTR__);
1466-
if (hasGetattrProfile.profile(inliningTarget, attrGetattr != PNone.NO_VALUE)) {
1467-
return callGetattrNode.executeObject(attrGetattr, object, attrNameStr);
1468-
}
1469-
throw pe;
1470-
}
1471-
}
1472-
}
1473-
1474-
/*
1475-
* Basically the same as 'com.oracle.graal.python.nodes.subscript.SetItemNode' but with an
1476-
* uncached version.
1477-
*/
1478-
@GenerateUncached
1479-
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 17
1480-
public abstract static class PInteropSubscriptAssignNode extends Node {
1481-
1482-
public abstract void execute(PythonAbstractObject primary, Object key, Object value) throws UnsupportedMessageException;
1483-
1484-
@Specialization
1485-
static void doSpecialObject(PythonAbstractObject primary, Object key, Object value,
1486-
@Bind("this") Node inliningTarget,
1487-
@Cached PForeignToPTypeNode convert,
1488-
@Cached PInteropGetAttributeNode getAttributeNode,
1489-
@Cached CallBinaryMethodNode callSetItemNode,
1490-
@Cached InlinedConditionProfile profile) throws UnsupportedMessageException {
1491-
1492-
Object attrSetitem = getAttributeNode.execute(inliningTarget, primary, T___SETITEM__);
1493-
if (profile.profile(inliningTarget, attrSetitem != PNone.NO_VALUE)) {
1494-
callSetItemNode.executeObject(attrSetitem, key, convert.executeConvert(value));
1495-
} else {
1496-
throw UnsupportedMessageException.create();
1497-
}
1498-
}
1499-
}
1500-
1501-
/*
1502-
* Basically the same as 'com.oracle.graal.python.nodes.attributes.SetAttributeNode' but with an
1503-
* uncached version.
1504-
*/
1505-
@GenerateUncached
1506-
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 19
1507-
public abstract static class PInteropSetAttributeNode extends Node {
1508-
1509-
public abstract void execute(Object primary, TruffleString attrName, Object value) throws UnsupportedMessageException, UnknownIdentifierException;
1510-
1511-
@Specialization
1512-
public static void doSpecialObject(PythonAbstractObject primary, TruffleString attrName, Object value,
1513-
@Bind("this") Node inliningTarget,
1514-
@Cached PForeignToPTypeNode convert,
1515-
@Cached LookupInheritedAttributeNode.Dynamic lookupSetAttrNode,
1516-
@Cached CallTernaryMethodNode callSetAttrNode,
1517-
@Cached InlinedConditionProfile profile,
1518-
@Cached IsBuiltinObjectProfile attrErrorProfile) throws UnsupportedMessageException, UnknownIdentifierException {
1519-
Object attrSetattr = lookupSetAttrNode.execute(inliningTarget, primary, SpecialMethodNames.T___SETATTR__);
1520-
if (profile.profile(inliningTarget, attrSetattr != PNone.NO_VALUE)) {
1521-
try {
1522-
callSetAttrNode.execute(null, attrSetattr, primary, attrName, convert.executeConvert(value));
1523-
} catch (PException e) {
1524-
e.expectAttributeError(inliningTarget, attrErrorProfile);
1525-
// TODO(fa) not accurate; distinguish between read-only and non-existing
1526-
throw UnknownIdentifierException.create(attrName.toJavaStringUncached());
1527-
}
1528-
} else {
1529-
throw UnsupportedMessageException.create();
1530-
}
1531-
}
1532-
1533-
public static PInteropSetAttributeNode getUncached() {
1534-
return PythonAbstractObjectFactory.PInteropSetAttributeNodeGen.getUncached();
1535-
}
1536-
}
1537-
1538-
/*
1539-
* Basically the same as 'com.oracle.graal.python.nodes.subscript.DelItemNode' but with an
1540-
* uncached version.
1541-
*/
1542-
@GenerateUncached
1543-
@GenerateInline
1544-
@GenerateCached(false)
1545-
public abstract static class PInteropDeleteItemNode extends Node {
1546-
1547-
public abstract void execute(Node inliningTarget, Object primary, Object key) throws UnsupportedMessageException;
1548-
1549-
@Specialization
1550-
public static void doSpecialObject(Node inliningTarget, PythonAbstractObject primary, Object key,
1551-
@Cached LookupInheritedAttributeNode.Dynamic lookupSetAttrNode,
1552-
@Cached(inline = false) CallBinaryMethodNode callSetAttrNode,
1553-
@Cached InlinedConditionProfile profile) throws UnsupportedMessageException {
1554-
Object attrDelattr = lookupSetAttrNode.execute(inliningTarget, primary, T___DELITEM__);
1555-
if (profile.profile(inliningTarget, attrDelattr != PNone.NO_VALUE)) {
1556-
callSetAttrNode.executeObject(attrDelattr, primary, key);
1557-
} else {
1558-
throw UnsupportedMessageException.create();
1559-
}
1560-
}
1561-
}
1562-
1563-
/*
1564-
* Basically the same as 'com.oracle.graal.python.nodes.attributes.DeleteAttributeNode' but with
1565-
* an uncached version.
1566-
*/
1567-
@GenerateUncached
1568-
@SuppressWarnings("truffle-inlining") // footprint reduction 36 -> 19
1569-
public abstract static class PInteropDeleteAttributeNode extends Node {
1570-
1571-
public abstract void execute(Object primary, String attrName) throws UnsupportedMessageException, UnknownIdentifierException;
1572-
1573-
@Specialization
1574-
public void doSpecialObject(PythonAbstractObject primary, String attrName,
1575-
@Bind("this") Node inliningTarget,
1576-
@Cached TruffleString.FromJavaStringNode fromJavaStringNode,
1577-
@Cached LookupInheritedAttributeNode.Dynamic lookupSetAttrNode,
1578-
@Cached CallBinaryMethodNode callSetAttrNode,
1579-
@Cached InlinedConditionProfile profile,
1580-
@Cached IsBuiltinObjectProfile attrErrorProfile) throws UnsupportedMessageException, UnknownIdentifierException {
1581-
Object attrDelattr = lookupSetAttrNode.execute(inliningTarget, primary, SpecialMethodNames.T___DELATTR__);
1582-
if (profile.profile(inliningTarget, attrDelattr != PNone.NO_VALUE)) {
1583-
try {
1584-
callSetAttrNode.executeObject(attrDelattr, primary, fromJavaStringNode.execute(attrName, TS_ENCODING));
1585-
} catch (PException e) {
1586-
e.expectAttributeError(inliningTarget, attrErrorProfile);
1587-
// TODO(fa) not accurate; distinguish between read-only and non-existing
1588-
throw UnknownIdentifierException.create(attrName);
1589-
}
1590-
} else {
1591-
throw UnsupportedMessageException.create();
1592-
}
1593-
}
1594-
1595-
public static PInteropDeleteAttributeNode getUncached() {
1596-
return PythonAbstractObjectFactory.PInteropDeleteAttributeNodeGen.getUncached();
1597-
}
1598-
}
1599-
16001384
@ExportMessage
16011385
public boolean hasLanguage() {
16021386
return true;

0 commit comments

Comments
 (0)