Kaydet (Commit) 8d97e33b authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Patch #966493: Cleanup generator/eval_frame exposure.

üst 634893d1
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
#include "sliceobject.h" #include "sliceobject.h"
#include "cellobject.h" #include "cellobject.h"
#include "iterobject.h" #include "iterobject.h"
#include "genobject.h"
#include "descrobject.h" #include "descrobject.h"
#include "weakrefobject.h" #include "weakrefobject.h"
......
...@@ -64,7 +64,7 @@ PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *); ...@@ -64,7 +64,7 @@ PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *);
PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *); PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *);
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
PyAPI_FUNC(PyObject *) PyEval_EvaluateFrame(PyObject *); PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
/* this used to be handled on a per-thread basis - now just two globals */ /* this used to be handled on a per-thread basis - now just two globals */
PyAPI_DATA(volatile int) _Py_Ticker; PyAPI_DATA(volatile int) _Py_Ticker;
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
extern "C" { extern "C" {
#endif #endif
struct _frame; /* Avoid including frameobject.h */
typedef struct { typedef struct {
PyObject_HEAD PyObject_HEAD
/* The gi_ prefix is intended to remind of generator-iterator. */ /* The gi_ prefix is intended to remind of generator-iterator. */
PyFrameObject *gi_frame; struct _frame *gi_frame;
/* True if generator is being executed. */ /* True if generator is being executed. */
int gi_running; int gi_running;
...@@ -25,7 +27,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type; ...@@ -25,7 +27,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type) #define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *); PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -44,7 +44,7 @@ gen_iternext(PyGenObject *gen) ...@@ -44,7 +44,7 @@ gen_iternext(PyGenObject *gen)
f->f_back = tstate->frame; f->f_back = tstate->frame;
gen->gi_running = 1; gen->gi_running = 1;
result = PyEval_EvaluateFrame((PyObject *)f); result = PyEval_EvalFrame(f);
gen->gi_running = 0; gen->gi_running = 0;
/* Don't keep the reference to f_back any longer than necessary. It /* Don't keep the reference to f_back any longer than necessary. It
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "compile.h" #include "compile.h"
#include "frameobject.h" #include "frameobject.h"
#include "genobject.h"
#include "eval.h" #include "eval.h"
#include "opcode.h" #include "opcode.h"
#include "structmember.h" #include "structmember.h"
...@@ -49,7 +48,6 @@ void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1, ...@@ -49,7 +48,6 @@ void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,
typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *); typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
/* Forward declarations */ /* Forward declarations */
static PyObject *eval_frame(PyFrameObject *);
#ifdef WITH_TSC #ifdef WITH_TSC
static PyObject *call_function(PyObject ***, int, uint64*, uint64*); static PyObject *call_function(PyObject ***, int, uint64*, uint64*);
#else #else
...@@ -458,8 +456,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) ...@@ -458,8 +456,8 @@ PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
/* Interpreter main loop */ /* Interpreter main loop */
static PyObject * PyObject *
eval_frame(PyFrameObject *f) PyEval_EvalFrame(PyFrameObject *f)
{ {
#ifdef DXPAIRS #ifdef DXPAIRS
int lastopcode = 0; int lastopcode = 0;
...@@ -2455,8 +2453,8 @@ fast_yield: ...@@ -2455,8 +2453,8 @@ fast_yield:
} }
/* this is gonna seem *real weird*, but if you put some other code between /* this is gonna seem *real weird*, but if you put some other code between
eval_frame() and PyEval_EvalCodeEx() you will need to adjust the test in PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
the if statement in Misc/gdbinit:ppystack */ the test in the if statement in Misc/gdbinit:ppystack */
PyObject * PyObject *
PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
...@@ -2684,7 +2682,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, ...@@ -2684,7 +2682,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
return PyGen_New(f); return PyGen_New(f);
} }
retval = eval_frame(f); retval = PyEval_EvalFrame(f);
fail: /* Jump here from prelude on failure */ fail: /* Jump here from prelude on failure */
...@@ -3415,12 +3413,6 @@ PyEval_GetFuncDesc(PyObject *func) ...@@ -3415,12 +3413,6 @@ PyEval_GetFuncDesc(PyObject *func)
} }
} }
PyObject *
PyEval_EvaluateFrame(PyObject *fo)
{
return eval_frame((PyFrameObject *)fo);
}
#define EXT_POP(STACK_POINTER) (*--(STACK_POINTER)) #define EXT_POP(STACK_POINTER) (*--(STACK_POINTER))
static void static void
...@@ -3597,7 +3589,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) ...@@ -3597,7 +3589,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
Py_INCREF(*stack); Py_INCREF(*stack);
fastlocals[i] = *stack++; fastlocals[i] = *stack++;
} }
retval = eval_frame(f); retval = PyEval_EvalFrame(f);
assert(tstate != NULL); assert(tstate != NULL);
++tstate->recursion_depth; ++tstate->recursion_depth;
Py_DECREF(f); Py_DECREF(f);
......
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