Skip to content

Commit f6d3305

Browse files
committed
Fix non-exploded case in HPyCloseArrayWrapperNode
1 parent 3d4c0ef commit f6d3305

File tree

1 file changed

+11
-6
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,21 @@ static void doCachedLen(GraalHPyContext hPyContext, HPyArrayWrapper wrapper,
335335
}
336336
}
337337

338-
@Specialization(replaces = "doCachedLen")
338+
@Specialization(replaces = "doCachedLen", limit = "1")
339339
static void doLoop(GraalHPyContext hPyContext, HPyArrayWrapper wrapper,
340+
@CachedLibrary("wrapper") InteropLibrary lib,
340341
@Cached ConditionProfile isAllocatedProfile,
341342
@Cached ConditionProfile profile) {
342-
Object[] array = wrapper.getDelegate();
343-
for (int i = 0; i < array.length; i++) {
344-
Object element = array[i];
345-
if (profile.profile(isAllocatedHandle(element))) {
346-
((GraalHPyHandle) element).close(hPyContext, isAllocatedProfile);
343+
int n = size(lib, wrapper);
344+
try {
345+
for (int i = 0; i < n; i++) {
346+
Object element = lib.readArrayElement(wrapper, i);
347+
if (profile.profile(isAllocatedHandle(element))) {
348+
((GraalHPyHandle) element).close(hPyContext, isAllocatedProfile);
349+
}
347350
}
351+
} catch (InteropException e) {
352+
throw CompilerDirectives.shouldNotReachHere(e);
348353
}
349354
}
350355

0 commit comments

Comments
 (0)