diff options
author | Mark Shannon <mark@hotpy.org> | 2021-08-16 11:23:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 11:23:13 (GMT) |
commit | 4f51fa9e2d3ea9316e674fb9a9f3e3112e83661c (patch) | |
tree | e53e8b3f636de346a7abba7875aae03d234ce299 /Python/ceval.c | |
parent | 1a511dc92dd10ee8fc2e5da9f52f795924bdc89a (diff) | |
download | cpython-4f51fa9e2d3ea9316e674fb9a9f3e3112e83661c.zip cpython-4f51fa9e2d3ea9316e674fb9a9f3e3112e83661c.tar.gz cpython-4f51fa9e2d3ea9316e674fb9a9f3e3112e83661c.tar.bz2 |
bpo-44900: Add five superinstructions. (GH-27741)
* LOAD_FAST LOAD_FAST
* STORE_FAST LOAD_FAST
* LOAD_FAST LOAD_CONST
* LOAD_CONST LOAD_FAST
* STORE_FAST STORE_FAST
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 95 |
1 files changed, 86 insertions, 9 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 111689f..4878749 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1266,16 +1266,21 @@ eval_frame_handle_pending(PyThreadState *tstate) #define PRE_DISPATCH_GOTO() do { LLTRACE_INSTR(); RECORD_DXPROFILE(); } while (0) #endif +#define NOTRACE_DISPATCH() \ + { \ + frame->f_lasti = INSTR_OFFSET(); \ + NEXTOPARG(); \ + PRE_DISPATCH_GOTO(); \ + DISPATCH_GOTO(); \ + } + /* Do interpreter dispatch accounting for tracing and instrumentation */ #define DISPATCH() \ { \ if (cframe.use_tracing OR_DTRACE_LINE) { \ goto tracing_dispatch; \ } \ - frame->f_lasti = INSTR_OFFSET(); \ - NEXTOPARG(); \ - PRE_DISPATCH_GOTO(); \ - DISPATCH_GOTO(); \ + NOTRACE_DISPATCH(); \ } #define CHECK_EVAL_BREAKER() \ @@ -1682,11 +1687,7 @@ check_eval_breaker: TARGET(LOAD_FAST): { PyObject *value = GETLOCAL(oparg); if (value == NULL) { - format_exc_check_arg(tstate, PyExc_UnboundLocalError, - UNBOUNDLOCAL_ERROR_MSG, - PyTuple_GetItem(co->co_localsplusnames, - oparg)); - goto error; + goto unbound_local_error; } Py_INCREF(value); PUSH(value); @@ -1708,6 +1709,73 @@ check_eval_breaker: DISPATCH(); } + TARGET(LOAD_FAST__LOAD_FAST): { + PyObject *value = GETLOCAL(oparg); + if (value == NULL) { + goto unbound_local_error; + } + NEXTOPARG(); + Py_INCREF(value); + PUSH(value); + value = GETLOCAL(oparg); + if (value == NULL) { + goto unbound_local_error; + } + Py_INCREF(value); + PUSH(value); + NOTRACE_DISPATCH(); + } + + TARGET(LOAD_FAST__LOAD_CONST): { + PyObject *value = GETLOCAL(oparg); + if (value == NULL) { + goto unbound_local_error; + } + NEXTOPARG(); + Py_INCREF(value); + PUSH(value); + value = GETITEM(consts, oparg); + Py_INCREF(value); + PUSH(value); + NOTRACE_DISPATCH(); + } + + TARGET(STORE_FAST__LOAD_FAST): { + PyObject *value = POP(); + SETLOCAL(oparg, value); + NEXTOPARG(); + value = GETLOCAL(oparg); + if (value == NULL) { + goto unbound_local_error; + } + Py_INCREF(value); + PUSH(value); + NOTRACE_DISPATCH(); + } + + TARGET(STORE_FAST__STORE_FAST): { + PyObject *value = POP(); + SETLOCAL(oparg, value); + NEXTOPARG(); + value = POP(); + SETLOCAL(oparg, value); + NOTRACE_DISPATCH(); + } + + TARGET(LOAD_CONST__LOAD_FAST): { + PyObject *value = GETITEM(consts, oparg); + NEXTOPARG(); + Py_INCREF(value); + PUSH(value); + value = GETLOCAL(oparg); + if (value == NULL) { + goto unbound_local_error; + } + Py_INCREF(value); + PUSH(value); + NOTRACE_DISPATCH(); + } + TARGET(POP_TOP): { PyObject *value = POP(); Py_DECREF(value); @@ -4592,6 +4660,15 @@ binary_subscr_dict_error: goto error; } +unbound_local_error: + { + format_exc_check_arg(tstate, PyExc_UnboundLocalError, + UNBOUNDLOCAL_ERROR_MSG, + PyTuple_GetItem(co->co_localsplusnames, oparg) + ); + goto error; + } + error: /* Double-check exception status. */ #ifdef NDEBUG |