|
75 | 75 | import com.oracle.truffle.api.dsl.Cached;
|
76 | 76 | import com.oracle.truffle.api.dsl.Cached.Exclusive;
|
77 | 77 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
| 78 | +import com.oracle.truffle.api.dsl.Fallback; |
78 | 79 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
79 | 80 | import com.oracle.truffle.api.dsl.Specialization;
|
80 | 81 | import com.oracle.truffle.api.interop.ArityException;
|
@@ -291,14 +292,31 @@ int identityHashCode(@CachedLibrary("this.object") InteropLibrary lib) throws Un
|
291 | 292 |
|
292 | 293 | @ExportMessage
|
293 | 294 | boolean isIdentical(Object other, InteropLibrary otherInterop,
|
294 |
| - @CachedLibrary("this.object") InteropLibrary lib) { |
295 |
| - return lib.isIdentical(object, other, otherInterop); |
| 295 | + @Cached("createClassProfile()") ValueProfile otherProfile, |
| 296 | + @CachedLibrary(limit = "1") InteropLibrary thisLib, |
| 297 | + @CachedLibrary("this.object") InteropLibrary objLib, |
| 298 | + @CachedLibrary(limit = "1") InteropLibrary otherObjLib) { |
| 299 | + Object profiled = otherProfile.profile(other); |
| 300 | + if (profiled instanceof PythonAbstractNativeObject) { |
| 301 | + return objLib.isIdentical(object, ((PythonAbstractNativeObject) profiled).object, otherObjLib); |
| 302 | + } |
| 303 | + return otherInterop.isIdentical(profiled, this, thisLib); |
296 | 304 | }
|
297 | 305 |
|
298 | 306 | @ExportMessage
|
299 |
| - TriState isIdenticalOrUndefined(Object other, |
300 |
| - @CachedLibrary(limit = "3") InteropLibrary lib) { |
301 |
| - return TriState.valueOf(lib.isIdentical(object, other, lib)); |
| 307 | + @SuppressWarnings("unused") |
| 308 | + static final class IsIdenticalOrUndefined { |
| 309 | + @Specialization |
| 310 | + static TriState doPythonAbstractNativeObject(PythonAbstractNativeObject receiver, PythonAbstractNativeObject other, |
| 311 | + @CachedLibrary("receiver.object") InteropLibrary objLib, |
| 312 | + @CachedLibrary(limit = "1") InteropLibrary otherObjectLib) { |
| 313 | + return TriState.valueOf(objLib.isIdentical(receiver.object, other.object, otherObjectLib)); |
| 314 | + } |
| 315 | + |
| 316 | + @Fallback |
| 317 | + static TriState doOther(PythonAbstractNativeObject receiver, Object other) { |
| 318 | + return TriState.UNDEFINED; |
| 319 | + } |
302 | 320 | }
|
303 | 321 |
|
304 | 322 | @ExportMessage(library = PythonObjectLibrary.class, name = "isLazyPythonClass")
|
|
0 commit comments