|
56 | 56 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FastCallArgsToSulongNode;
|
57 | 57 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.FastCallWithKeywordsArgsToSulongNode;
|
58 | 58 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.PCallCapiFunction;
|
| 59 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ReleaseNativeWrapperNode; |
59 | 60 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.SSizeArgProcToSulongNode;
|
60 | 61 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.SSizeObjArgProcToSulongNode;
|
61 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.SubRefCntNode; |
62 | 62 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.TernaryFirstSecondToSulongNode;
|
63 | 63 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.TernaryFirstThirdToSulongNode;
|
64 | 64 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ToBorrowedRefNode;
|
65 | 65 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodes.ToJavaStealingNode;
|
| 66 | +import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ReleaseNativeWrapperNodeGen; |
66 | 67 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ToBorrowedRefNodeGen;
|
67 | 68 | import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.ToJavaStealingNodeGen;
|
68 | 69 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.CheckInquiryResultNodeGen;
|
|
72 | 73 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.DefaultCheckFunctionResultNodeGen;
|
73 | 74 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.InitCheckFunctionResultNodeGen;
|
74 | 75 | import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.MaterializePrimitiveNodeGen;
|
75 |
| -import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodesFactory.ReleaseNativeWrapperNodeGen; |
76 | 76 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.CheckFunctionResultNode;
|
77 | 77 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.ConvertPIntToPrimitiveNode;
|
78 | 78 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodes.GetIndexNode;
|
79 | 79 | import com.oracle.graal.python.builtins.objects.cext.common.CExtCommonNodesFactory.ConvertPIntToPrimitiveNodeGen;
|
80 | 80 | import com.oracle.graal.python.builtins.objects.cext.common.CExtContext;
|
81 |
| -import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes.ToArrayNode; |
82 | 81 | import com.oracle.graal.python.builtins.objects.exception.PBaseException;
|
83 | 82 | import com.oracle.graal.python.builtins.objects.floats.PFloat;
|
84 | 83 | import com.oracle.graal.python.builtins.objects.function.PArguments;
|
85 | 84 | import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
|
86 | 85 | import com.oracle.graal.python.builtins.objects.function.PKeyword;
|
87 | 86 | import com.oracle.graal.python.builtins.objects.function.Signature;
|
88 | 87 | import com.oracle.graal.python.builtins.objects.ints.PInt;
|
89 |
| -import com.oracle.graal.python.builtins.objects.object.PythonObject; |
90 | 88 | import com.oracle.graal.python.builtins.objects.str.PString;
|
91 | 89 | import com.oracle.graal.python.builtins.objects.tuple.PTuple;
|
92 | 90 | import com.oracle.graal.python.nodes.ErrorMessages;
|
|
126 | 124 | import com.oracle.truffle.api.dsl.Cached;
|
127 | 125 | import com.oracle.truffle.api.dsl.Cached.Exclusive;
|
128 | 126 | import com.oracle.truffle.api.dsl.Cached.Shared;
|
129 |
| -import com.oracle.truffle.api.dsl.Fallback; |
130 | 127 | import com.oracle.truffle.api.dsl.GenerateUncached;
|
131 | 128 | import com.oracle.truffle.api.dsl.ImportStatic;
|
132 | 129 | import com.oracle.truffle.api.dsl.Specialization;
|
@@ -616,71 +613,6 @@ public static ExternalFunctionInvokeNode create(CheckFunctionResultNode checkFun
|
616 | 613 | }
|
617 | 614 | }
|
618 | 615 |
|
619 |
| - /** |
620 |
| - * Decrements the ref count by one of any {@link PythonNativeWrapper} object. |
621 |
| - * <p> |
622 |
| - * This node avoids memory leaks for arguments given to native.<br> |
623 |
| - * Problem description:<br> |
624 |
| - * {@link PythonNativeWrapper} objects given to C code may go to native, i.e., a handle will be |
625 |
| - * allocated. In this case, no ref count manipulation is done since the C code considers the |
626 |
| - * reference to be borrowed and the Python code just doesn't do it because we have a GC. This |
627 |
| - * means that the handle will stay allocated and we are leaking the wrapper object. |
628 |
| - * </p> |
629 |
| - */ |
630 |
| - @ImportStatic(CApiGuards.class) |
631 |
| - abstract static class ReleaseNativeWrapperNode extends Node { |
632 |
| - |
633 |
| - public abstract void execute(Object pythonObject); |
634 |
| - |
635 |
| - @Specialization |
636 |
| - static void doNativeWrapper(PythonNativeWrapper nativeWrapper, |
637 |
| - @Cached TraverseNativeWrapperNode traverseNativeWrapperNode, |
638 |
| - @Cached SubRefCntNode subRefCntNode) { |
639 |
| - // in the cached case, refCntNode acts as a branch profile |
640 |
| - if (subRefCntNode.dec(nativeWrapper) == 0) { |
641 |
| - traverseNativeWrapperNode.execute(nativeWrapper.getDelegateSlowPath()); |
642 |
| - } |
643 |
| - } |
644 |
| - |
645 |
| - @Specialization(guards = "!isNativeWrapper(object)") |
646 |
| - @SuppressWarnings("unused") |
647 |
| - static void doOther(Object object) { |
648 |
| - // just do nothing; this is an implicit profile |
649 |
| - } |
650 |
| - } |
651 |
| - |
652 |
| - /** |
653 |
| - * Traverses the items of a tuple and applies {@link ReleaseNativeWrapperNode} on the items if |
654 |
| - * the tuple is up to be released. |
655 |
| - */ |
656 |
| - abstract static class TraverseNativeWrapperNode extends Node { |
657 |
| - |
658 |
| - public abstract void execute(Object containerObject); |
659 |
| - |
660 |
| - @Specialization |
661 |
| - static void doTuple(PTuple tuple, |
662 |
| - @Cached ToArrayNode toArrayNode, |
663 |
| - @Cached SubRefCntNode subRefCntNode) { |
664 |
| - |
665 |
| - Object[] values = toArrayNode.execute(tuple.getSequenceStorage()); |
666 |
| - for (int i = 0; i < values.length; i++) { |
667 |
| - Object value = values[i]; |
668 |
| - if (value instanceof PythonObject) { |
669 |
| - DynamicObjectNativeWrapper nativeWrapper = ((PythonObject) value).getNativeWrapper(); |
670 |
| - // only traverse if refCnt != 0; this will break the cycle |
671 |
| - if (nativeWrapper != null) { |
672 |
| - subRefCntNode.dec(nativeWrapper); |
673 |
| - } |
674 |
| - } |
675 |
| - } |
676 |
| - } |
677 |
| - |
678 |
| - @Fallback |
679 |
| - static void doOther(@SuppressWarnings("unused") Object other) { |
680 |
| - // do nothing |
681 |
| - } |
682 |
| - } |
683 |
| - |
684 | 616 | abstract static class MethodDescriptorRoot extends PRootNode {
|
685 | 617 | @Child private CalleeContext calleeContext = CalleeContext.create();
|
686 | 618 | @Child private CallVarargsMethodNode invokeNode;
|
@@ -765,18 +697,6 @@ protected Object[] preparePArguments(VirtualFrame frame) {
|
765 | 697 | return arguments;
|
766 | 698 | }
|
767 | 699 |
|
768 |
| - static Object[] copyPArguments(VirtualFrame frame) { |
769 |
| - return copyPArguments(frame, PArguments.getUserArgumentLength(frame)); |
770 |
| - } |
771 |
| - |
772 |
| - static Object[] copyPArguments(VirtualFrame frame, int newUserArgumentLength) { |
773 |
| - Object[] objects = PArguments.create(newUserArgumentLength); |
774 |
| - PArguments.setGlobals(objects, PArguments.getGlobals(frame)); |
775 |
| - PArguments.setClosure(objects, PArguments.getClosure(frame)); |
776 |
| - PArguments.setSpecialArgument(objects, PArguments.getSpecialArgument(frame)); |
777 |
| - return objects; |
778 |
| - } |
779 |
| - |
780 | 700 | private ReadIndexedArgumentNode ensureReadCallableNode() {
|
781 | 701 | if (readCallableNode == null) {
|
782 | 702 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
@@ -1594,10 +1514,6 @@ abstract static class GetSetRootNode extends MethodDescriptorRoot {
|
1594 | 1514 |
|
1595 | 1515 | @Child private ReadIndexedArgumentNode readClosureNode;
|
1596 | 1516 |
|
1597 |
| - GetSetRootNode(PythonLanguage language, String name) { |
1598 |
| - super(language, name, false); |
1599 |
| - } |
1600 |
| - |
1601 | 1517 | GetSetRootNode(PythonLanguage language, String name, PExternalFunctionWrapper provider) {
|
1602 | 1518 | super(language, name, false, provider);
|
1603 | 1519 | }
|
|
0 commit comments