Skip to content

Commit 83f31ef

Browse files
committed
Profile if wrapper has a pointer.
1 parent 3c3c0b0 commit 83f31ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeWrapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.oracle.truffle.api.interop.TruffleObject;
5151
import com.oracle.truffle.api.library.ExportLibrary;
5252
import com.oracle.truffle.api.library.ExportMessage;
53+
import com.oracle.truffle.api.profiles.ConditionProfile;
5354

5455
@ExportLibrary(PythonNativeWrapperLibrary.class)
5556
public abstract class PythonNativeWrapper implements TruffleObject {
@@ -186,8 +187,9 @@ protected static boolean isCachedNative(@SuppressWarnings("unused") PythonNative
186187
}
187188

188189
@Specialization(replaces = "isCachedNative")
189-
protected static boolean isNative(PythonNativeWrapper wrapper) {
190-
if (wrapper.nativePointer != null) {
190+
protected static boolean isNative(PythonNativeWrapper wrapper,
191+
@Cached ConditionProfile hasNativePointerProfile) {
192+
if (hasNativePointerProfile.profile(wrapper.nativePointer != null)) {
191193
Assumption handleValidAssumption = wrapper.getHandleValidAssumption();
192194
// If an assumption exists, it must be valid
193195
return handleValidAssumption == null || isValid(handleValidAssumption);

0 commit comments

Comments
 (0)