@@ -92,25 +92,27 @@ static Object noRegisteredClass(Object foreignObject,
92
92
return getForeignObjectClassNode .execute (foreignObject );
93
93
}
94
94
95
- // Always return ForeignObject for meta objects (classes), because custom behavior should only
96
- // be added to instances.
95
+ // Always delegate to GetForeignObjectClassNode for meta objects (classes), because custom
96
+ // behavior should only be added to instances.
97
97
@ Specialization (guards = "objectLibrary.isMetaObject(foreignObject) || !objectLibrary.hasMetaObject(foreignObject)" )
98
98
static Object getClassLookup (Object foreignObject ,
99
- @ SuppressWarnings ( "unused" ) @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) @ Exclusive InteropLibrary objectLibrary ,
99
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) @ Exclusive InteropLibrary objectLibrary ,
100
100
@ Shared @ Cached GetForeignObjectClassNode getForeignObjectClassNode ) {
101
101
return getForeignObjectClassNode .execute (foreignObject );
102
102
}
103
103
104
+ // Note: libraries except objectLibrary must not use @CachedLibrary("receiver") style as that
105
+ // would cause getMetaObject() to get called before the hasMetaObject guard, which can then
106
+ // cause a UnsupportedMessageException
104
107
@ Specialization (guards = {"isSingleContext()" ,
105
108
"!objectLibrary.isMetaObject(foreignObject)" ,
106
109
"objectLibrary.hasMetaObject(foreignObject)" ,
107
- "metaObjectLibrary.isIdentical(metaObject, cachedMetaObject, cachedMetaObjectLibrary)" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "getContext().interopTypeRegistryCacheValidAssumption.getAssumption()" )
108
- static Object getCachedClassLookup (@ SuppressWarnings ("unused" ) Object foreignObject ,
109
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("foreignObject" ) InteropLibrary objectLibrary ,
110
- @ SuppressWarnings ("unused" ) @ Bind ("getMetaObject(objectLibrary, foreignObject)" ) Object metaObject ,
111
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("metaObject" ) InteropLibrary metaObjectLibrary ,
112
- @ SuppressWarnings ("unused" ) @ Cached ("metaObject" ) Object cachedMetaObject ,
113
- @ SuppressWarnings ("unused" ) @ CachedLibrary ("cachedMetaObject" ) InteropLibrary cachedMetaObjectLibrary ,
110
+ "metaObjectLibrary.isIdentical(metaObject, cachedMetaObject, metaObjectLibrary)" }, limit = "getCallSiteInlineCacheMaxDepth()" , assumptions = "getContext().interopTypeRegistryCacheValidAssumption.getAssumption()" )
111
+ static Object getCachedClassLookup (Object foreignObject ,
112
+ @ CachedLibrary ("foreignObject" ) InteropLibrary objectLibrary ,
113
+ @ Bind ("getMetaObject(objectLibrary, foreignObject)" ) Object metaObject ,
114
+ @ CachedLibrary (limit = "getCallSiteInlineCacheMaxDepth()" ) @ Exclusive InteropLibrary metaObjectLibrary ,
115
+ @ Cached ("metaObject" ) Object cachedMetaObject ,
114
116
@ Cached (value = "lookupUncached($node, foreignObject, cachedMetaObject)" ) Object pythonClass ) {
115
117
return pythonClass ;
116
118
}
0 commit comments