Skip to content

Commit 4903057

Browse files
committed
Add profile for hasArrayElements
1 parent 08a5541 commit 4903057

File tree

1 file changed

+3
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
import com.oracle.truffle.api.object.DynamicObject;
124124
import com.oracle.truffle.api.object.DynamicObjectLibrary;
125125
import com.oracle.truffle.api.profiles.BranchProfile;
126+
import com.oracle.truffle.api.profiles.ConditionProfile;
126127

127128
public abstract class CExtCommonNodes {
128129
private static final int SIGABRT_EXIT_CODE = 134;
@@ -612,13 +613,14 @@ public abstract static class GetIntArrayNode extends Node {
612613

613614
@Specialization(limit = "2")
614615
static int[] doPointer(Object obj, int n, LLVMType sourceElementType,
616+
@Cached ConditionProfile isArrayProfile,
615617
@Cached GetLLVMType getLLVMType,
616618
@Cached PCallCapiFunction callFromTyped,
617619
@Cached PCallCapiFunction callGetByteArrayTypeId,
618620
@CachedLibrary("obj") InteropLibrary ptrLib,
619621
@CachedLibrary(limit = "1") InteropLibrary elementLib) throws UnsupportedTypeException {
620622
Object arrayPtr = obj;
621-
if (!ptrLib.hasArrayElements(obj)) {
623+
if (!isArrayProfile.profile(ptrLib.hasArrayElements(obj))) {
622624
// we first need to attach a type to the pointer object
623625
Object typeId = callGetByteArrayTypeId.call(NativeCAPISymbol.FUN_POLYGLOT_ARRAY_TYPEID, getLLVMType.execute(sourceElementType), n);
624626
arrayPtr = callFromTyped.call(NativeCAPISymbol.FUN_POLYGLOT_FROM_TYPED, obj, typeId);

0 commit comments

Comments
 (0)