Skip to content

Commit ec0c78d

Browse files
committed
Move unsafe call out of the loop
1 parent 293d178 commit ec0c78d

File tree

1 file changed

+2
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory

1 file changed

+2
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/memory/PointerNodes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,12 @@ static long doZero(Node inliningTarget, MemoryBlock memory, ZeroStorage storage,
646646
static long doPointerArray(Node inliningTarget, MemoryBlock memory, PointerArrayStorage storage, int offset,
647647
@Cached(inline = false) GetPointerValueAsLongNode toNativeNode) {
648648
PythonContext context = PythonContext.get(inliningTarget);
649+
Unsafe unsafe = context.getUnsafe();
649650
long pointer = context.allocateNativeMemory(storage.pointers.length * 8L);
650651
for (int i = 0; i < storage.pointers.length; i++) {
651652
Pointer itemPointer = storage.pointers[i];
652653
long subpointer = toNativeNode.execute(inliningTarget, itemPointer.memory, itemPointer.memory.storage, itemPointer.offset);
653-
context.getUnsafe().putLong(pointer + i * 8L, subpointer);
654+
unsafe.putLong(pointer + i * 8L, subpointer);
654655
}
655656
memory.storage = new LongPointerStorage(pointer);
656657
return pointer + offset;

0 commit comments

Comments
 (0)