Commit 93bbdc16 authored by Stefan Behnel's avatar Stefan Behnel

inline PyObject_Call()

parent 12706ee0
...@@ -2536,7 +2536,9 @@ class WithExitCallNode(ExprNode): ...@@ -2536,7 +2536,9 @@ class WithExitCallNode(ExprNode):
result_var = code.funcstate.allocate_temp(py_object_type, manage_ref=False) result_var = code.funcstate.allocate_temp(py_object_type, manage_ref=False)
code.mark_pos(self.pos) code.mark_pos(self.pos)
code.putln("%s = PyObject_Call(%s, %s, NULL);" % ( code.globalstate.use_utility_code(UtilityCode.load_cached(
"PyObjectCall", "ObjectHandling.c"))
code.putln("%s = __Pyx_PyObject_Call(%s, %s, NULL);" % (
result_var, result_var,
self.with_stat.exit_var, self.with_stat.exit_var,
self.args.result())) self.args.result()))
...@@ -4657,8 +4659,10 @@ class SimpleCallNode(CallNode): ...@@ -4657,8 +4659,10 @@ class SimpleCallNode(CallNode):
code.globalstate.use_utility_code(self.function.entry.utility_code) code.globalstate.use_utility_code(self.function.entry.utility_code)
if func_type.is_pyobject: if func_type.is_pyobject:
arg_code = self.arg_tuple.py_result() arg_code = self.arg_tuple.py_result()
code.globalstate.use_utility_code(UtilityCode.load_cached(
"PyObjectCall", "ObjectHandling.c"))
code.putln( code.putln(
"%s = PyObject_Call(%s, %s, NULL); %s" % ( "%s = __Pyx_PyObject_Call(%s, %s, NULL); %s" % (
self.result(), self.result(),
self.function.py_result(), self.function.py_result(),
arg_code, arg_code,
...@@ -5087,8 +5091,10 @@ class GeneralCallNode(CallNode): ...@@ -5087,8 +5091,10 @@ class GeneralCallNode(CallNode):
kwargs = self.keyword_args.py_result() kwargs = self.keyword_args.py_result()
else: else:
kwargs = 'NULL' kwargs = 'NULL'
code.globalstate.use_utility_code(UtilityCode.load_cached(
"PyObjectCall", "ObjectHandling.c"))
code.putln( code.putln(
"%s = PyObject_Call(%s, %s, %s); %s" % ( "%s = __Pyx_PyObject_Call(%s, %s, %s); %s" % (
self.result(), self.result(),
self.function.py_result(), self.function.py_result(),
self.positional_args.py_result(), self.positional_args.py_result(),
......
...@@ -1093,6 +1093,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr ...@@ -1093,6 +1093,7 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr
/////////////// PyObjectCallMethod.proto /////////////// /////////////// PyObjectCallMethod.proto ///////////////
//@requires: PyObjectGetAttrStr //@requires: PyObjectGetAttrStr
//@requires: PyObjectCall
//@substitute: naming //@substitute: naming
static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) { static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) {
...@@ -1100,7 +1101,7 @@ static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_ ...@@ -1100,7 +1101,7 @@ static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_
if (unlikely(!args)) return NULL; if (unlikely(!args)) return NULL;
method = __Pyx_PyObject_GetAttrStr(obj, method_name); method = __Pyx_PyObject_GetAttrStr(obj, method_name);
if (unlikely(!method)) goto bad; if (unlikely(!method)) goto bad;
result = PyObject_Call(method, args, NULL); result = __Pyx_PyObject_Call(method, args, NULL);
Py_DECREF(method); Py_DECREF(method);
bad: bad:
Py_DECREF(args); Py_DECREF(args);
...@@ -1123,3 +1124,38 @@ bad: ...@@ -1123,3 +1124,38 @@ bad:
static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) { static CYTHON_INLINE PyObject* __Pyx_tp_new_kwargs(PyObject* type_obj, PyObject* args, PyObject* kwargs) {
return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs)); return (PyObject*) (((PyTypeObject*)type_obj)->tp_new((PyTypeObject*)type_obj, args, kwargs));
} }
/////////////// PyObjectCall.proto ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif
/////////////// PyObjectCall ///////////////
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
PyObject *result;
ternaryfunc call = func->ob_type->tp_call;
if (unlikely(!call))
return PyObject_Call(func, arg, kw);
#if PY_VERSION_HEX >= 0x02060000
if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
return NULL;
#endif
result = (*call)(func, arg, kw);
#if PY_VERSION_HEX >= 0x02060000
Py_LeaveRecursiveCall();
#endif
if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
PyErr_SetString(
PyExc_SystemError,
"NULL result without error in PyObject_Call");
}
return result;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment