48
48
import static com .oracle .graal .python .nodes .ErrorMessages .S_MUST_BE_A_S_TUPLE ;
49
49
import static com .oracle .graal .python .nodes .SpecialMethodNames .T_KEYS ;
50
50
import static com .oracle .graal .python .nodes .SpecialMethodNames .T___DELETE__ ;
51
- import static com .oracle .graal .python .nodes .SpecialMethodNames .T___DELITEM__ ;
52
51
import static com .oracle .graal .python .nodes .SpecialMethodNames .T___GETATTRIBUTE__ ;
53
- import static com .oracle .graal .python .nodes .SpecialMethodNames .T___GETATTR__ ;
54
52
import static com .oracle .graal .python .nodes .SpecialMethodNames .T___GET__ ;
55
- import static com .oracle .graal .python .nodes .SpecialMethodNames .T___SETITEM__ ;
56
53
import static com .oracle .graal .python .nodes .SpecialMethodNames .T___SET__ ;
57
54
import static com .oracle .graal .python .nodes .StringLiterals .T_LBRACKET ;
58
55
import static com .oracle .graal .python .nodes .truffle .TruffleStringMigrationHelpers .isJavaString ;
71
68
72
69
import com .oracle .graal .python .PythonLanguage ;
73
70
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
74
- import com .oracle .graal .python .builtins .objects .PythonAbstractObjectFactory .PInteropGetAttributeNodeGen ;
75
71
import com .oracle .graal .python .builtins .objects .buffer .PythonBufferAccessLibrary ;
76
72
import com .oracle .graal .python .builtins .objects .cext .capi .CApiGuards ;
77
73
import com .oracle .graal .python .builtins .objects .cext .capi .PythonNativeWrapper .PythonAbstractObjectNativeWrapper ;
119
115
import com .oracle .graal .python .lib .PySequenceSizeNode ;
120
116
import com .oracle .graal .python .lib .PyTupleSizeNode ;
121
117
import com .oracle .graal .python .nodes .BuiltinNames ;
122
- import com .oracle .graal .python .nodes .ErrorMessages ;
123
118
import com .oracle .graal .python .nodes .HiddenAttr ;
124
119
import com .oracle .graal .python .nodes .PGuards ;
125
120
import com .oracle .graal .python .nodes .PRaiseNode ;
129
124
import com .oracle .graal .python .nodes .attributes .ReadAttributeFromObjectNode ;
130
125
import com .oracle .graal .python .nodes .call .CallNode ;
131
126
import com .oracle .graal .python .nodes .call .special .CallBinaryMethodNode ;
132
- import com .oracle .graal .python .nodes .call .special .CallTernaryMethodNode ;
133
127
import com .oracle .graal .python .nodes .call .special .CallVarargsMethodNode ;
134
128
import com .oracle .graal .python .nodes .expression .CastToListExpressionNode .CastToListInteropNode ;
135
129
import com .oracle .graal .python .nodes .interop .GetInteropBehaviorNode ;
@@ -232,8 +226,8 @@ public final void clearNativeWrapper() {
232
226
@ ExportMessage
233
227
public void writeMember (String key , Object value ,
234
228
@ 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 ,
237
231
// GR-44020: make shared:
238
232
@ Exclusive @ Cached IsBuiltinObjectProfile attrErrorProfile ,
239
233
@ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException , UnknownIdentifierException {
@@ -252,7 +246,7 @@ public void writeMember(String key, Object value,
252
246
@ ExportMessage
253
247
public Object readMember (String key ,
254
248
@ Bind ("$node" ) Node inliningTarget ,
255
- @ Shared ( "js2ts" ) @ Cached TruffleString .FromJavaStringNode fromJavaStringNode ,
249
+ @ Exclusive @ Cached TruffleString .FromJavaStringNode fromJavaStringNode ,
256
250
// GR-44020: make shared:
257
251
@ Exclusive @ Cached PyObjectLookupAttr lookup ,
258
252
@ Exclusive @ Cached GilNode gil ) throws UnknownIdentifierException {
@@ -604,7 +598,7 @@ public boolean hasMemberWriteSideEffects(String member,
604
598
@ ExportMessage
605
599
public Object invokeMember (String member , Object [] arguments ,
606
600
@ Bind ("$node" ) Node inliningTarget ,
607
- @ Shared ( "js2ts" ) @ Cached TruffleString .FromJavaStringNode fromJavaStringNode ,
601
+ @ Exclusive @ Cached TruffleString .FromJavaStringNode fromJavaStringNode ,
608
602
@ Exclusive @ Cached LookupInheritedAttributeNode .Dynamic lookupGetattributeNode ,
609
603
@ Exclusive @ Cached CallBinaryMethodNode callGetattributeNode ,
610
604
@ Exclusive @ Cached PExecuteNode executeNode ,
@@ -750,8 +744,8 @@ public Object getMembers(boolean includeInternal,
750
744
@ ExportMessage
751
745
public void removeMember (String member ,
752
746
@ 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 ,
755
749
// GR-44020: make shared:
756
750
@ Exclusive @ Cached IsBuiltinObjectProfile attrErrorProfile ,
757
751
@ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException , UnknownIdentifierException {
@@ -1268,37 +1262,6 @@ public static boolean isImmutable(Node inliningTarget, Object object,
1268
1262
}
1269
1263
}
1270
1264
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
-
1302
1265
@ GenerateUncached
1303
1266
@ ReportPolymorphism
1304
1267
@ SuppressWarnings ("truffle-inlining" ) // footprint reduction 36 -> 17
@@ -1418,185 +1381,6 @@ boolean isArrayElementReadable(long index) {
1418
1381
}
1419
1382
}
1420
1383
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
-
1600
1384
@ ExportMessage
1601
1385
public boolean hasLanguage () {
1602
1386
return true ;
0 commit comments