@@ -328,87 +328,24 @@ PyCFunction_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
328328
329329/* --- PyFunction call functions ---------------------------------- */
330330
331- static PyObject * _Py_HOT_FUNCTION
332- function_code_fastcall (PyThreadState * tstate , PyCodeObject * co ,
333- PyObject * const * args , Py_ssize_t nargs ,
334- PyFunctionObject * func )
335- {
336- assert (tstate != NULL );
337- assert (func != NULL );
338-
339- /* XXX Perhaps we should create a specialized
340- _PyFrame_New_NoTrack() that doesn't take locals, but does
341- take builtins without sanity checking them.
342- */
343- PyFrameObject * f = _PyFrame_New_NoTrack (tstate , co , func -> func_globals , func -> func_builtins , NULL );
344- if (f == NULL ) {
345- return NULL ;
346- }
347-
348- PyObject * * fastlocals = f -> f_localsplus ;
349-
350- for (Py_ssize_t i = 0 ; i < nargs ; i ++ ) {
351- Py_INCREF (* args );
352- fastlocals [i ] = * args ++ ;
353- }
354- PyObject * result = _PyEval_EvalFrame (tstate , f , 0 );
355-
356- if (Py_REFCNT (f ) > 1 ) {
357- Py_DECREF (f );
358- _PyObject_GC_TRACK (f );
359- }
360- else {
361- ++ tstate -> recursion_depth ;
362- Py_DECREF (f );
363- -- tstate -> recursion_depth ;
364- }
365- return result ;
366- }
367-
368-
369331PyObject *
370332_PyFunction_Vectorcall (PyObject * func , PyObject * const * stack ,
371333 size_t nargsf , PyObject * kwnames )
372334{
373335 assert (PyFunction_Check (func ));
374- assert (kwnames == NULL || PyTuple_CheckExact (kwnames ));
375-
336+ PyFrameConstructor * f = PyFunction_AS_FRAME_CONSTRUCTOR (func );
376337 Py_ssize_t nargs = PyVectorcall_NARGS (nargsf );
377338 assert (nargs >= 0 );
378- Py_ssize_t nkwargs = (kwnames == NULL ) ? 0 : PyTuple_GET_SIZE (kwnames );
379- assert ((nargs == 0 && nkwargs == 0 ) || stack != NULL );
380- /* kwnames must only contain strings and all keys must be unique */
381-
382339 PyThreadState * tstate = _PyThreadState_GET ();
383- PyCodeObject * co = (PyCodeObject * )PyFunction_GET_CODE (func );
384- PyObject * argdefs = PyFunction_GET_DEFAULTS (func );
385-
386- if (co -> co_kwonlyargcount == 0 && nkwargs == 0 &&
387- (co -> co_flags & ~PyCF_MASK ) == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE ))
388- {
389- if (argdefs == NULL && co -> co_argcount == nargs ) {
390- return function_code_fastcall (tstate , co , stack , nargs , (PyFunctionObject * )func );
391- }
392- else if (nargs == 0 && argdefs != NULL
393- && co -> co_argcount == PyTuple_GET_SIZE (argdefs )) {
394- /* function called with no arguments, but all parameters have
395- a default value: use default values as arguments .*/
396- stack = _PyTuple_ITEMS (argdefs );
397- return function_code_fastcall (tstate , co ,
398- stack , PyTuple_GET_SIZE (argdefs ),
399- (PyFunctionObject * )func );
400- }
340+ assert (nargs == 0 || stack != NULL );
341+ if (((PyCodeObject * )f -> fc_code )-> co_flags & CO_OPTIMIZED ) {
342+ return _PyEval_Vector (tstate , f , NULL , stack , nargs , kwnames );
343+ }
344+ else {
345+ return _PyEval_Vector (tstate , f , f -> fc_globals , stack , nargs , kwnames );
401346 }
402-
403- return _PyEval_EvalCode (tstate ,
404- PyFunction_AS_FRAME_CONSTRUCTOR (func ), (PyObject * )NULL ,
405- stack , nargs ,
406- nkwargs ? _PyTuple_ITEMS (kwnames ) : NULL ,
407- stack + nargs ,
408- nkwargs , 1 );
409347}
410348
411-
412349/* --- More complex call functions -------------------------------- */
413350
414351/* External interface to call any callable object.
0 commit comments