Skip to content

Commit b227d9f

Browse files
committed
Pass frame to MemoryViewBuiltins.ReleaseNode for indirect call setup
1 parent 38a94bc commit b227d9f

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ Object setitem(VirtualFrame frame, PMemoryView self, PSlice slice, Object object
226226
}
227227
return PNone.NONE;
228228
} finally {
229-
releaseNode.execute(destView);
229+
releaseNode.execute(frame, destView);
230230
}
231231
} finally {
232-
releaseNode.execute(srcView);
232+
releaseNode.execute(frame, srcView);
233233
}
234234
}
235235

@@ -312,7 +312,7 @@ Object eq(VirtualFrame frame, PMemoryView self, Object other,
312312
try {
313313
return eq(frame, self, memoryView, eqNode, readSelf, readOther);
314314
} finally {
315-
releaseNode.execute(memoryView);
315+
releaseNode.execute(frame, memoryView);
316316
}
317317
}
318318

@@ -699,9 +699,9 @@ Object enter(PMemoryView self) {
699699
public abstract static class ExitNode extends PythonQuaternaryBuiltinNode {
700700
@Specialization
701701
@SuppressWarnings("unused")
702-
static Object exit(PMemoryView self, Object type, Object val, Object tb,
702+
static Object exit(VirtualFrame frame, PMemoryView self, Object type, Object val, Object tb,
703703
@Cached MemoryViewNodes.ReleaseNode releaseNode) {
704-
releaseNode.execute(self);
704+
releaseNode.execute(frame, self);
705705
return PNone.NONE;
706706
}
707707
}
@@ -710,9 +710,9 @@ static Object exit(PMemoryView self, Object type, Object val, Object tb,
710710
@GenerateNodeFactory
711711
public abstract static class ReleaseNode extends PythonUnaryBuiltinNode {
712712
@Specialization
713-
Object release(PMemoryView self,
713+
Object release(VirtualFrame frame, PMemoryView self,
714714
@Cached MemoryViewNodes.ReleaseNode releaseNode) {
715-
releaseNode.execute(self);
715+
releaseNode.execute(frame, self);
716716
return PNone.NONE;
717717
}
718718
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/MemoryViewNodes.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.TypeError;
4747
import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError;
4848

49-
import com.oracle.graal.python.PythonLanguage;
5049
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
5150
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes;
5251
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction;
@@ -62,11 +61,10 @@
6261
import com.oracle.graal.python.lib.PyNumberAsSizeNode;
6362
import com.oracle.graal.python.nodes.ErrorMessages;
6463
import com.oracle.graal.python.nodes.PGuards;
65-
import com.oracle.graal.python.nodes.PNodeWithContext;
6664
import com.oracle.graal.python.nodes.PNodeWithRaise;
65+
import com.oracle.graal.python.nodes.PNodeWithRaiseAndIndirectCall;
6766
import com.oracle.graal.python.nodes.PRaiseNode;
6867
import com.oracle.graal.python.nodes.call.CallNode;
69-
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
7068
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
7169
import com.oracle.graal.python.nodes.util.CastToByteNode;
7270
import com.oracle.graal.python.runtime.ExecutionContext.IndirectCallContext;
@@ -719,9 +717,13 @@ public static ToJavaBytesFortranOrderNode create() {
719717
}
720718
}
721719

722-
@GenerateUncached
723-
public abstract static class ReleaseNode extends PNodeWithContext {
724-
public abstract void execute(PMemoryView self);
720+
public abstract static class ReleaseNode extends PNodeWithRaiseAndIndirectCall {
721+
722+
public final void execute(PMemoryView self) {
723+
execute(null, self);
724+
}
725+
726+
public abstract void execute(VirtualFrame frame, PMemoryView self);
725727

726728
@Specialization(guards = "self.getReference() == null")
727729
static void releaseSimple(PMemoryView self,
@@ -731,12 +733,12 @@ static void releaseSimple(PMemoryView self,
731733
}
732734

733735
@Specialization(guards = {"self.getReference() != null"})
734-
static void releaseNative(PMemoryView self,
736+
void releaseNative(VirtualFrame frame, PMemoryView self,
735737
@Cached ReleaseBufferNode releaseNode,
736738
@Shared("raise") @Cached PRaiseNode raiseNode) {
737739
self.checkExports(raiseNode);
738740
if (self.checkShouldReleaseBuffer()) {
739-
releaseNode.execute(self.getLifecycleManager());
741+
releaseNode.execute(frame, this, self.getLifecycleManager());
740742
}
741743
self.setReleased();
742744
}
@@ -747,12 +749,12 @@ public abstract static class ReleaseBufferNode extends Node {
747749

748750
public abstract void execute(BufferLifecycleManager buffer);
749751

750-
public final void execute(VirtualFrame frame, PythonLanguage language, PythonBuiltinBaseNode caller, BufferLifecycleManager buffer) {
751-
Object state = IndirectCallContext.enter(frame, language, caller.getContext(), caller);
752+
public final void execute(VirtualFrame frame, PNodeWithRaiseAndIndirectCall caller, BufferLifecycleManager buffer) {
753+
Object state = IndirectCallContext.enter(frame, caller);
752754
try {
753755
execute(buffer);
754756
} finally {
755-
IndirectCallContext.exit(frame, language, caller.getContext(), state);
757+
IndirectCallContext.exit(frame, caller, state);
756758
}
757759
}
758760

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/memoryview/PMemoryView.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.oracle.graal.python.builtins.objects.buffer.BufferFlags;
4949
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
5050
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAcquireLibrary;
51+
import com.oracle.graal.python.builtins.objects.memoryview.MemoryViewNodes.ReleaseBufferNode;
5152
import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject;
5253
import com.oracle.graal.python.nodes.ErrorMessages;
5354
import com.oracle.graal.python.nodes.PNodeWithRaise;
@@ -315,14 +316,19 @@ Object acquire(int requestedFlags,
315316

316317
@ExportMessage
317318
void release(
318-
@Cached MemoryViewNodes.ReleaseNode releaseNode) {
319+
@Cached PRaiseNode raiseNode,
320+
@Cached ReleaseBufferNode releaseNode) {
319321
/*
320322
* This is a bit hacky - the shouldReleaseImmediately marker is used when this is a helper
321323
* memoryview that was created to hold a buffer for native object. In the future there
322324
* should be no such helper memoryviews, the C buffer should have a separate implementation.
323325
*/
324326
if (shouldReleaseImmediately) {
325-
releaseNode.execute(this);
327+
checkExports(raiseNode);
328+
if (checkShouldReleaseBuffer()) {
329+
releaseNode.execute(getLifecycleManager());
330+
}
331+
setReleased();
326332
} else {
327333
long l = exports.decrementAndGet();
328334
assert l >= 0;

0 commit comments

Comments
 (0)