@@ -3014,32 +3014,34 @@ public abstract static class ClearNativeWrapperNode extends Node {
3014
3014
public abstract void execute (Object delegate , PythonNativeWrapper nativeWrapper );
3015
3015
3016
3016
@ Specialization (guards = "!isPrimitiveNativeWrapper(nativeWrapper)" )
3017
- static void doPythonAbstractObject (PythonAbstractObject delegate , PythonNativeWrapper nativeWrapper ) {
3017
+ static void doPythonAbstractObject (PythonAbstractObject delegate , PythonNativeWrapper nativeWrapper ,
3018
+ @ Cached ("createCountingProfile()" ) ConditionProfile hasHandleValidAssumptionProfile ) {
3018
3019
// For non-temporary wrappers (all wrappers that need to preserve identity):
3019
3020
// If this assertion fails, it indicates that the native code still uses a free'd native
3020
3021
// wrapper.
3021
3022
// TODO(fa): explicitly mark native wrappers to be identity preserving
3022
3023
assert !(nativeWrapper instanceof PythonObjectNativeWrapper ) || delegate .getNativeWrapper () == nativeWrapper : "inconsistent native wrappers" ;
3023
- delegate .clearNativeWrapper ();
3024
+ delegate .clearNativeWrapper (hasHandleValidAssumptionProfile );
3024
3025
}
3025
3026
3026
3027
@ Specialization (guards = "delegate == null" )
3027
3028
static void doPrimitiveNativeWrapper (@ SuppressWarnings ("unused" ) Object delegate , PrimitiveNativeWrapper nativeWrapper ,
3028
- @ Cached ("createBinaryProfile ()" ) ConditionProfile profile ,
3029
+ @ Cached ("createCountingProfile ()" ) ConditionProfile hasHandleValidAssumptionProfile ,
3029
3030
@ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
3030
3031
assert !isSmallIntegerWrapperSingleton (contextRef , nativeWrapper ) : "clearing primitive native wrapper singleton of small integer" ;
3031
- if (profile .profile (nativeWrapper .getHandleValidAssumption () != null )) {
3032
+ if (hasHandleValidAssumptionProfile .profile (nativeWrapper .getHandleValidAssumption () != null )) {
3032
3033
nativeWrapper .getHandleValidAssumption ().invalidate ("releasing handle for native wrapper" );
3033
3034
}
3034
3035
}
3035
3036
3036
3037
@ Specialization (guards = "delegate != null" )
3037
3038
static void doPrimitiveNativeWrapperMaterialized (PythonAbstractObject delegate , PrimitiveNativeWrapper nativeWrapper ,
3038
3039
@ Cached ("createBinaryProfile()" ) ConditionProfile profile ,
3040
+ @ Cached ("createCountingProfile()" ) ConditionProfile hasHandleValidAssumptionProfile ,
3039
3041
@ Shared ("contextRef" ) @ CachedContext (PythonLanguage .class ) ContextReference <PythonContext > contextRef ) {
3040
3042
if (profile .profile (delegate .getNativeWrapper () == nativeWrapper )) {
3041
3043
assert !isSmallIntegerWrapperSingleton (contextRef , nativeWrapper ) : "clearing primitive native wrapper singleton of small integer" ;
3042
- delegate .clearNativeWrapper ();
3044
+ delegate .clearNativeWrapper (hasHandleValidAssumptionProfile );
3043
3045
}
3044
3046
}
3045
3047
0 commit comments