|
43 | 43 | import static com.oracle.graal.python.builtins.PythonBuiltinClassType.ValueError; |
44 | 44 | import static com.oracle.graal.python.builtins.objects.cext.capi.NativeCAPISymbol.FUN_CHECK_BASICSIZE_FOR_GETSTATE; |
45 | 45 | import static com.oracle.graal.python.nodes.BuiltinNames.T_COPYREG; |
46 | | -import static com.oracle.graal.python.nodes.ErrorMessages.ATTR_NAME_MUST_BE_STRING; |
47 | 46 | import static com.oracle.graal.python.nodes.ErrorMessages.CANNOT_PICKLE_OBJECT_TYPE; |
48 | 47 | import static com.oracle.graal.python.nodes.ErrorMessages.MUST_BE_TYPE_A_NOT_TYPE_B; |
49 | 48 | import static com.oracle.graal.python.nodes.ErrorMessages.SHOULD_RETURN_A_NOT_B; |
|
137 | 136 | import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsAnyBuiltinObjectProfile; |
138 | 137 | import com.oracle.graal.python.nodes.object.GetClassNode; |
139 | 138 | import com.oracle.graal.python.nodes.object.IsForeignObjectNode; |
140 | | -import com.oracle.graal.python.nodes.util.CannotCastException; |
141 | 139 | import com.oracle.graal.python.nodes.util.CastToTruffleStringNode; |
142 | 140 | import com.oracle.graal.python.runtime.PythonContext; |
143 | 141 | import com.oracle.graal.python.runtime.PythonOptions; |
@@ -839,56 +837,16 @@ public abstract static class GenericSetAttrNode extends Node { |
839 | 837 | */ |
840 | 838 | public abstract void execute(Node inliningTarget, VirtualFrame frame, Object object, TruffleString key, Object value, WriteAttributeToObjectNode writeNode); |
841 | 839 |
|
842 | | - public abstract void execute(Node inliningTarget, VirtualFrame frame, Object object, Object key, Object value, WriteAttributeToObjectNode writeNode); |
843 | | - |
844 | | - @Specialization |
845 | | - static void doStringKey(Node inliningTarget, VirtualFrame frame, Object object, TruffleString key, Object value, WriteAttributeToObjectNode writeNode, |
846 | | - @SuppressWarnings("unused") @Shared @Cached CastToTruffleStringNode castKeyToStringNode, |
847 | | - @Shared @Cached GetClassNode getClassNode, |
848 | | - @Shared @Cached InlinedConditionProfile hasDescriptor, |
849 | | - @Shared @Cached GetObjectSlotsNode getDescrSlotsNode, |
850 | | - @Shared @Cached CallSlotDescrSet callSetNode, |
851 | | - @Shared @Cached(inline = false) LookupAttributeInMRONode.Dynamic getExisting, |
852 | | - @Shared @Cached(inline = false) ReadAttributeFromObjectNode attrRead, |
853 | | - @Shared @Cached InlinedBranchProfile deleteNonExistingBranchProfile, |
854 | | - @Shared @Cached PRaiseNode raiseNode) { |
855 | | - setAttr(inliningTarget, frame, object, key, value, writeNode, getClassNode, hasDescriptor, |
856 | | - getDescrSlotsNode, callSetNode, getExisting, attrRead, deleteNonExistingBranchProfile, |
857 | | - raiseNode); |
858 | | - } |
859 | | - |
860 | 840 | @Specialization |
861 | | - @InliningCutoff |
862 | | - static void doGeneric(Node inliningTarget, VirtualFrame frame, Object object, Object keyObject, Object value, WriteAttributeToObjectNode writeNode, |
863 | | - @Shared @Cached CastToTruffleStringNode castKeyToStringNode, |
864 | | - @Shared @Cached GetClassNode getClassNode, |
865 | | - @Shared @Cached InlinedConditionProfile hasDescriptor, |
866 | | - @Shared @Cached GetObjectSlotsNode getDescrSlotsNode, |
867 | | - @Shared @Cached CallSlotDescrSet callSetNode, |
868 | | - @Shared @Cached(inline = false) LookupAttributeInMRONode.Dynamic getExisting, |
869 | | - @Shared @Cached(inline = false) ReadAttributeFromObjectNode attrRead, |
870 | | - @Shared @Cached InlinedBranchProfile deleteNonExistingBranchProfile, |
871 | | - @Shared @Cached PRaiseNode raiseNode) { |
872 | | - TruffleString key = castAttributeKey(inliningTarget, keyObject, castKeyToStringNode, raiseNode); |
873 | | - setAttr(inliningTarget, frame, object, key, value, writeNode, getClassNode, hasDescriptor, |
874 | | - getDescrSlotsNode, callSetNode, getExisting, attrRead, deleteNonExistingBranchProfile, |
875 | | - raiseNode); |
876 | | - } |
877 | | - |
878 | | - public static TruffleString castAttributeKey(Node inliningTarget, Object keyObject, CastToTruffleStringNode castKeyToStringNode, PRaiseNode raiseNode) { |
879 | | - try { |
880 | | - return castKeyToStringNode.execute(inliningTarget, keyObject); |
881 | | - } catch (CannotCastException e) { |
882 | | - throw raiseNode.raise(inliningTarget, PythonBuiltinClassType.TypeError, ATTR_NAME_MUST_BE_STRING, keyObject); |
883 | | - } |
884 | | - } |
885 | | - |
886 | | - private static void setAttr(Node inliningTarget, VirtualFrame frame, Object object, TruffleString key, |
887 | | - Object value, WriteAttributeToObjectNode writeNode, GetClassNode getClassNode, |
888 | | - InlinedConditionProfile hasDescriptor, GetObjectSlotsNode getDescrSlotsNode, |
889 | | - CallSlotDescrSet callSetNode, LookupAttributeInMRONode.Dynamic getExisting, |
890 | | - ReadAttributeFromObjectNode attrRead, InlinedBranchProfile deleteNonExistingBranchProfile, |
891 | | - PRaiseNode raiseNode) { |
| 841 | + static void doGeneric(Node inliningTarget, VirtualFrame frame, Object object, TruffleString key, Object value, WriteAttributeToObjectNode writeNode, |
| 842 | + @Cached GetClassNode getClassNode, |
| 843 | + @Cached InlinedConditionProfile hasDescriptor, |
| 844 | + @Cached GetObjectSlotsNode getDescrSlotsNode, |
| 845 | + @Cached CallSlotDescrSet callSetNode, |
| 846 | + @Cached(inline = false) LookupAttributeInMRONode.Dynamic getExisting, |
| 847 | + @Cached ReadAttributeFromObjectNode attrRead, |
| 848 | + @Cached InlinedBranchProfile deleteNonExistingBranchProfile, |
| 849 | + @Cached PRaiseNode raiseNode) { |
892 | 850 | Object type = getClassNode.execute(inliningTarget, object); |
893 | 851 | Object descr = getExisting.execute(type, key); |
894 | 852 | if (hasDescriptor.profile(inliningTarget, !PGuards.isNoValue(descr))) { |
|
0 commit comments