diff options
author | Mark Shannon <mark@hotpy.org> | 2021-08-25 13:44:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-25 13:44:20 +0100 |
commit | f9242d50b18572ef0d584a1c815ed08d1a38e4f4 (patch) | |
tree | 0c7c137c701b1dd69f89227dee85aaee95ff5dfb /Objects/genobject.c | |
parent | 214c2e5d916d3ce5e7b1db800210b93001850bbb (diff) | |
download | cpython-git-f9242d50b18572ef0d584a1c815ed08d1a38e4f4.tar.gz |
bpo-44990: Change layout of evaluation frames. "Layout B" (GH-27933)
Places the locals between the specials and stack. This is the more "natural" layout for a C struct, makes the code simpler and gives a slight speedup (~1%)
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 86cd9cf725..7a687ce7f7 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -190,8 +190,7 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult, /* Push arg onto the frame's value stack */ result = arg ? arg : Py_None; Py_INCREF(result); - frame->stack[frame->stackdepth] = result; - frame->stackdepth++; + _PyFrame_StackPush(frame, result); frame->previous = tstate->frame; @@ -350,8 +349,7 @@ _PyGen_yf(PyGenObject *gen) if (code[(frame->f_lasti+1)*sizeof(_Py_CODEUNIT)] != YIELD_FROM) return NULL; - assert(frame->stackdepth > 0); - yf = frame->stack[frame->stackdepth-1]; + yf = _PyFrame_StackPeek(frame); Py_INCREF(yf); } @@ -469,9 +467,7 @@ _gen_throw(PyGenObject *gen, int close_on_genexit, if (!ret) { PyObject *val; /* Pop subiterator from stack */ - assert(gen->gi_xframe->stackdepth > 0); - gen->gi_xframe->stackdepth--; - ret = gen->gi_xframe->stack[gen->gi_xframe->stackdepth]; + ret = _PyFrame_StackPop(gen->gi_xframe); assert(ret == yf); Py_DECREF(ret); /* Termination repetition of YIELD_FROM */ |