91
91
import com .oracle .truffle .api .object .Shape ;
92
92
import com .oracle .truffle .api .profiles .ConditionProfile ;
93
93
import com .oracle .truffle .api .profiles .ValueProfile ;
94
+ import com .oracle .truffle .api .utilities .TriState ;
94
95
import com .oracle .truffle .llvm .spi .ReferenceLibrary ;
95
96
96
97
@ ExportLibrary (PythonObjectLibrary .class )
@@ -228,9 +229,8 @@ public static Assumption getSingleContextAssumption() {
228
229
return PythonLanguage .getCurrent ().singleContextAssumption ;
229
230
}
230
231
231
- @ Specialization (guards = "object == cachedObject.get()" , limit = "1" , assumptions = "singleContextAssumption " )
232
+ @ Specialization (guards = "object == cachedObject.get()" , limit = "1" , assumptions = "getSingleContextAssumption() " )
232
233
static Object getNativeClassCachedIdentity (PythonAbstractNativeObject object ,
233
- @ Shared ("assumption" ) @ Cached (value = "getSingleContextAssumption()" ) Assumption singleContextAssumption ,
234
234
@ Exclusive @ Cached ("weak(object)" ) WeakReference <PythonAbstractNativeObject > cachedObject ,
235
235
@ Exclusive @ Cached ("getNativeClassUncached(object)" ) Object cachedClass ) {
236
236
// TODO: (tfel) is this really something we can do? It's so rare for this class to
@@ -240,12 +240,11 @@ static Object getNativeClassCachedIdentity(PythonAbstractNativeObject object,
240
240
return cachedClass ;
241
241
}
242
242
243
- @ Specialization (guards = "isSame(referenceLibrary , cachedObject, object)" , limit = "1" , assumptions = "singleContextAssumption " )
243
+ @ Specialization (guards = "isSame(lib , cachedObject, object)" , assumptions = "getSingleContextAssumption() " )
244
244
static Object getNativeClassCached (PythonAbstractNativeObject object ,
245
- @ Shared ("assumption" ) @ Cached (value = "getSingleContextAssumption()" ) Assumption singleContextAssumption ,
246
245
@ Exclusive @ Cached ("weak(object)" ) WeakReference <PythonAbstractNativeObject > cachedObject ,
247
246
@ Exclusive @ Cached ("getNativeClassUncached(object)" ) Object cachedClass ,
248
- @ CachedLibrary ("object.object " ) @ SuppressWarnings ("unused" ) ReferenceLibrary referenceLibrary ) {
247
+ @ CachedLibrary (limit = "3 " ) @ SuppressWarnings ("unused" ) InteropLibrary lib ) {
249
248
// TODO same as for 'getNativeClassCachedIdentity'
250
249
return cachedClass ;
251
250
}
@@ -274,10 +273,10 @@ static WeakReference<PythonAbstractNativeObject> weak(PythonAbstractNativeObject
274
273
return new WeakReference <>(object );
275
274
}
276
275
277
- static boolean isSame (ReferenceLibrary referenceLibrary , WeakReference <PythonAbstractNativeObject > cachedObjectRef , PythonAbstractNativeObject object ) {
276
+ static boolean isSame (InteropLibrary lib , WeakReference <PythonAbstractNativeObject > cachedObjectRef , PythonAbstractNativeObject object ) {
278
277
PythonAbstractNativeObject cachedObject = cachedObjectRef .get ();
279
278
if (cachedObject != null ) {
280
- return referenceLibrary . isSame (cachedObject .object , object .object );
279
+ return lib . isIdentical (cachedObject .object , object .object , lib );
281
280
}
282
281
return false ;
283
282
}
@@ -288,6 +287,23 @@ public static Object getNativeClassUncached(PythonAbstractNativeObject object) {
288
287
}
289
288
}
290
289
290
+ @ ExportMessage
291
+ int identityHashCode (@ CachedLibrary ("this.object" ) InteropLibrary lib ) throws UnsupportedMessageException {
292
+ return lib .identityHashCode (object );
293
+ }
294
+
295
+ @ ExportMessage
296
+ boolean isIdentical (Object other , InteropLibrary otherInterop ,
297
+ @ CachedLibrary ("this.object" ) InteropLibrary lib ) {
298
+ return lib .isIdentical (object , other , otherInterop );
299
+ }
300
+
301
+ @ ExportMessage
302
+ TriState isIdenticalOrUndefined (Object other ,
303
+ @ CachedLibrary (limit = "3" ) InteropLibrary lib ) {
304
+ return TriState .valueOf (lib .isIdentical (object , other , lib ));
305
+ }
306
+
291
307
@ ExportMessage
292
308
static class IsSame {
293
309
0 commit comments