@@ -328,87 +328,24 @@ PyCFunction_Call(PyObject *callable, PyObject *args, PyObject *kwargs)
328
328
329
329
/* --- PyFunction call functions ---------------------------------- */
330
330
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
-
369
331
PyObject *
370
332
_PyFunction_Vectorcall (PyObject * func , PyObject * const * stack ,
371
333
size_t nargsf , PyObject * kwnames )
372
334
{
373
335
assert (PyFunction_Check (func ));
374
- assert (kwnames == NULL || PyTuple_CheckExact (kwnames ));
375
-
336
+ PyFrameConstructor * f = PyFunction_AS_FRAME_CONSTRUCTOR (func );
376
337
Py_ssize_t nargs = PyVectorcall_NARGS (nargsf );
377
338
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
-
382
339
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 );
401
346
}
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 );
409
347
}
410
348
411
-
412
349
/* --- More complex call functions -------------------------------- */
413
350
414
351
/* External interface to call any callable object.
0 commit comments