20
20
*
21
21
* without restriction, including without limitation the rights to copy, create
22
22
* derivative works of, display, perform, and distribute the Software and make,
23
- * use, sell, offer for sale, import, export, have made, and have sold the
23
+ * use, sell, offer for sale, import, export, have made, and have sold the// skip GIL
24
24
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25
25
* either these or other terms.
26
26
*
@@ -213,13 +213,8 @@ public DynamicObjectStorage getNativeMemberStore() {
213
213
214
214
@ ExportMessage
215
215
protected boolean isNull (
216
- @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib , @ Exclusive @ Cached GilNode gil ) {
217
- boolean mustRelease = gil .acquire ();
218
- try {
219
- return lib .getDelegate (this ) == PNone .NO_VALUE ;
220
- } finally {
221
- gil .release (mustRelease );
222
- }
216
+ @ CachedLibrary ("this" ) PythonNativeWrapperLibrary lib ) {
217
+ return lib .getDelegate (this ) == PNone .NO_VALUE ;
223
218
}
224
219
225
220
// READ
@@ -235,13 +230,8 @@ protected boolean isMemberReadable(@SuppressWarnings("unused") String member) {
235
230
}
236
231
237
232
@ ExportMessage
238
- protected Object getMembers (@ SuppressWarnings ("unused" ) boolean includeInternal , @ Exclusive @ Cached GilNode gil ) {
239
- boolean mustRelease = gil .acquire ();
240
- try {
241
- return new InteropArray (new String []{DynamicObjectNativeWrapper .GP_OBJECT });
242
- } finally {
243
- gil .release (mustRelease );
244
- }
233
+ protected Object getMembers (@ SuppressWarnings ("unused" ) boolean includeInternal ) {
234
+ return new InteropArray (new String []{DynamicObjectNativeWrapper .GP_OBJECT });
245
235
}
246
236
247
237
@ ExportMessage (name = "readMember" )
@@ -1356,13 +1346,8 @@ protected boolean isMemberModifiable(String member) {
1356
1346
}
1357
1347
1358
1348
@ ExportMessage
1359
- protected boolean isMemberInsertable (@ SuppressWarnings ("unused" ) String member , @ Exclusive @ Cached GilNode gil ) {
1360
- boolean mustRelease = gil .acquire ();
1361
- try {
1362
- return false ;
1363
- } finally {
1364
- gil .release (mustRelease );
1365
- }
1349
+ protected boolean isMemberInsertable (@ SuppressWarnings ("unused" ) String member ) {
1350
+ return false ;
1366
1351
}
1367
1352
1368
1353
@ ExportMessage
@@ -1378,33 +1363,18 @@ protected void writeMember(String member, Object value,
1378
1363
}
1379
1364
1380
1365
@ ExportMessage
1381
- protected boolean isMemberRemovable (@ SuppressWarnings ("unused" ) String member , @ Exclusive @ Cached GilNode gil ) {
1382
- boolean mustRelease = gil .acquire ();
1383
- try {
1384
- return false ;
1385
- } finally {
1386
- gil .release (mustRelease );
1387
- }
1366
+ protected boolean isMemberRemovable (@ SuppressWarnings ("unused" ) String member ) {
1367
+ return false ;
1388
1368
}
1389
1369
1390
1370
@ ExportMessage
1391
- protected void removeMember (@ SuppressWarnings ("unused" ) String member , @ Exclusive @ Cached GilNode gil ) throws UnsupportedMessageException {
1392
- boolean mustRelease = gil .acquire ();
1393
- try {
1394
- throw UnsupportedMessageException .create ();
1395
- } finally {
1396
- gil .release (mustRelease );
1397
- }
1371
+ protected void removeMember (@ SuppressWarnings ("unused" ) String member ) throws UnsupportedMessageException {
1372
+ throw UnsupportedMessageException .create ();
1398
1373
}
1399
1374
1400
1375
@ ExportMessage
1401
- protected boolean isExecutable (@ Exclusive @ Cached GilNode gil ) {
1402
- boolean mustRelease = gil .acquire ();
1403
- try {
1404
- return true ;
1405
- } finally {
1406
- gil .release (mustRelease );
1407
- }
1376
+ protected boolean isExecutable () {
1377
+ return true ;
1408
1378
}
1409
1379
1410
1380
@ ExportMessage
@@ -1563,25 +1533,15 @@ abstract static class IsMemberReadable {
1563
1533
@ Specialization (guards = {"stringEquals(cachedName, name, stringProfile)" , "isValid(cachedName)" })
1564
1534
static boolean isReadableNativeMembers (PythonObjectNativeWrapper receiver , String name ,
1565
1535
@ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ,
1566
- @ Cached (value = "name" , allowUncached = true ) String cachedName , @ Exclusive @ Cached GilNode gil ) {
1567
- boolean mustRelease = gil .acquire ();
1568
- try {
1569
- return true ;
1570
- } finally {
1571
- gil .release (mustRelease );
1572
- }
1536
+ @ Cached (value = "name" , allowUncached = true ) String cachedName ) {
1537
+ return true ;
1573
1538
}
1574
1539
1575
1540
@ SuppressWarnings ("unused" )
1576
1541
@ Specialization (guards = "stringEquals(GP_OBJECT, name, stringProfile)" )
1577
1542
static boolean isReadableCachedGP (PythonObjectNativeWrapper receiver , String name ,
1578
- @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile , @ Exclusive @ Cached GilNode gil ) {
1579
- boolean mustRelease = gil .acquire ();
1580
- try {
1581
- return true ;
1582
- } finally {
1583
- gil .release (mustRelease );
1584
- }
1543
+ @ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ) {
1544
+ return true ;
1585
1545
}
1586
1546
1587
1547
static boolean isPyTimeMemberReadable (PythonObjectNativeWrapper receiver , PythonNativeWrapperLibrary lib , PythonObjectLibrary plib , GetNameNode getNameNode ) {
@@ -1593,28 +1553,18 @@ static boolean isPyTimeMemberReadable(PythonObjectNativeWrapper receiver, Python
1593
1553
static boolean isReadablePyTime (PythonObjectNativeWrapper receiver , String name ,
1594
1554
@ CachedLibrary ("receiver" ) PythonNativeWrapperLibrary lib ,
1595
1555
@ CachedLibrary (limit = "4" ) PythonObjectLibrary plib ,
1596
- @ Cached GetNameNode getNameNode , @ Exclusive @ Cached GilNode gil ) {
1597
- boolean mustRelease = gil .acquire ();
1598
- try {
1599
- return true ;
1600
- } finally {
1601
- gil .release (mustRelease );
1602
- }
1556
+ @ Cached GetNameNode getNameNode ) {
1557
+ return true ;
1603
1558
}
1604
1559
1605
1560
@ Specialization
1606
1561
@ TruffleBoundary
1607
1562
static boolean isReadableFallback (PythonObjectNativeWrapper receiver , String name ,
1608
1563
@ CachedLibrary ("receiver" ) PythonNativeWrapperLibrary lib ,
1609
1564
@ CachedLibrary (limit = "4" ) PythonObjectLibrary plib ,
1610
- @ Cached GetNameNode getNameNode , @ Exclusive @ Cached GilNode gil ) {
1611
- boolean mustRelease = gil .acquire ();
1612
- try {
1613
- return DynamicObjectNativeWrapper .GP_OBJECT .equals (name ) || NativeMember .isValid (name ) ||
1565
+ @ Cached GetNameNode getNameNode ) {
1566
+ return DynamicObjectNativeWrapper .GP_OBJECT .equals (name ) || NativeMember .isValid (name ) ||
1614
1567
ReadObjectNativeMemberNode .isPyDateTimeCAPIType (getNameNode .execute (plib .getLazyPythonClass (lib .getDelegate (receiver ))));
1615
- } finally {
1616
- gil .release (mustRelease );
1617
- }
1618
1568
}
1619
1569
}
1620
1570
@@ -1627,13 +1577,8 @@ abstract static class IsMemberModifiable {
1627
1577
static boolean isModifiableCached (PythonObjectNativeWrapper receiver , String name ,
1628
1578
@ Cached ("createBinaryProfile()" ) ConditionProfile stringProfile ,
1629
1579
@ Cached (value = "name" , allowUncached = true ) String cachedName ,
1630
- @ Cached (value = "isValid(name)" , allowUncached = true ) boolean isValid , @ Exclusive @ Cached GilNode gil ) {
1631
- boolean mustRelease = gil .acquire ();
1632
- try {
1633
- return isValid ;
1634
- } finally {
1635
- gil .release (mustRelease );
1636
- }
1580
+ @ Cached (value = "isValid(name)" , allowUncached = true ) boolean isValid ) {
1581
+ return isValid ;
1637
1582
}
1638
1583
}
1639
1584
}
@@ -1896,73 +1841,48 @@ protected static boolean isObType(String key) {
1896
1841
1897
1842
@ ExportMessage
1898
1843
@ TruffleBoundary
1899
- int identityHashCode (@ Exclusive @ Cached GilNode gil ) {
1900
- boolean mustRelease = gil .acquire ();
1901
- try {
1902
- int val = Byte .hashCode (state ) ^ Long .hashCode (value );
1903
- if (Double .isNaN (dvalue )) {
1904
- return val ;
1905
- } else {
1906
- return val ^ Double .hashCode (dvalue );
1907
- }
1908
- } finally {
1909
- gil .release (mustRelease );
1844
+ int identityHashCode () {
1845
+ int val = Byte .hashCode (state ) ^ Long .hashCode (value );
1846
+ if (Double .isNaN (dvalue )) {
1847
+ return val ;
1848
+ } else {
1849
+ return val ^ Double .hashCode (dvalue );
1910
1850
}
1911
1851
}
1912
1852
1913
1853
@ ExportMessage
1914
- TriState isIdenticalOrUndefined (Object obj , @ Exclusive @ Cached GilNode gil ) {
1915
- boolean mustRelease = gil .acquire ();
1916
- try {
1917
- if (obj instanceof PrimitiveNativeWrapper ) {
1918
- // This basically emulates singletons for boxed values. However, we need to do
1919
- // so to
1920
- // preserve the invariant that storing an object into a list and getting it out
1921
- // (in
1922
- // the same critical region) returns the same object.
1923
- PrimitiveNativeWrapper other = (PrimitiveNativeWrapper ) obj ;
1924
- return TriState .valueOf (other .state == state && other .value == value &&
1925
- (other .dvalue == dvalue || Double .isNaN (dvalue ) && Double .isNaN (other .dvalue )));
1926
- } else {
1927
- return TriState .UNDEFINED ;
1928
- }
1929
- } finally {
1930
- gil .release (mustRelease );
1854
+ TriState isIdenticalOrUndefined (Object obj ) {
1855
+ if (obj instanceof PrimitiveNativeWrapper ) {
1856
+ // This basically emulates singletons for boxed values. However, we need to do
1857
+ // so to
1858
+ // preserve the invariant that storing an object into a list and getting it out
1859
+ // (in
1860
+ // the same critical region) returns the same object.
1861
+ PrimitiveNativeWrapper other = (PrimitiveNativeWrapper ) obj ;
1862
+ return TriState .valueOf (other .state == state && other .value == value &&
1863
+ (other .dvalue == dvalue || Double .isNaN (dvalue ) && Double .isNaN (other .dvalue )));
1864
+ } else {
1865
+ return TriState .UNDEFINED ;
1931
1866
}
1932
1867
}
1933
1868
}
1934
1869
1935
1870
@ ExportMessage
1936
1871
protected boolean isPointer (
1937
- @ Cached IsPointerNode pIsPointerNode , @ Exclusive @ Cached GilNode gil ) {
1938
- boolean mustRelease = gil .acquire ();
1939
- try {
1940
- return pIsPointerNode .execute (this );
1941
- } finally {
1942
- gil .release (mustRelease );
1943
- }
1872
+ @ Cached IsPointerNode pIsPointerNode ) {
1873
+ return pIsPointerNode .execute (this );
1944
1874
}
1945
1875
1946
1876
@ ExportMessage
1947
1877
protected long asPointer (
1948
- @ Cached PAsPointerNode pAsPointerNode , @ Exclusive @ Cached GilNode gil ) {
1949
- boolean mustRelease = gil .acquire ();
1950
- try {
1951
- return pAsPointerNode .execute (this );
1952
- } finally {
1953
- gil .release (mustRelease );
1954
- }
1878
+ @ Cached PAsPointerNode pAsPointerNode ) {
1879
+ return pAsPointerNode .execute (this );
1955
1880
}
1956
1881
1957
1882
@ ExportMessage
1958
1883
protected void toNative (
1959
- @ Cached ToNativeNode toNativeNode , @ Exclusive @ Cached GilNode gil ) {
1960
- boolean mustRelease = gil .acquire ();
1961
- try {
1962
- toNativeNode .execute (this );
1963
- } finally {
1964
- gil .release (mustRelease );
1965
- }
1884
+ @ Cached ToNativeNode toNativeNode ) {
1885
+ toNativeNode .execute (this );
1966
1886
}
1967
1887
1968
1888
@ ExportMessage
@@ -1972,12 +1892,7 @@ protected boolean hasNativeType() {
1972
1892
1973
1893
@ ExportMessage
1974
1894
protected Object getNativeType (
1975
- @ Cached PGetDynamicTypeNode getDynamicTypeNode , @ Exclusive @ Cached GilNode gil ) {
1976
- boolean mustRelease = gil .acquire ();
1977
- try {
1978
- return getDynamicTypeNode .execute (this );
1979
- } finally {
1980
- gil .release (mustRelease );
1981
- }
1895
+ @ Cached PGetDynamicTypeNode getDynamicTypeNode ) {
1896
+ return getDynamicTypeNode .execute (this );
1982
1897
}
1983
1898
}
0 commit comments