summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index cd8b674..2d9671f 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -210,7 +210,7 @@ dummy_func(
}
inst(LOAD_CONST, (-- value)) {
- value = GETITEM(frame->f_code->co_consts, oparg);
+ value = GETITEM(FRAME_CO_CONSTS, oparg);
Py_INCREF(value);
}
@@ -711,7 +711,7 @@ dummy_func(
}
inst(RETURN_CONST, (--)) {
- PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
+ PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
Py_INCREF(retval);
assert(EMPTY());
_PyFrame_SetStackPointer(frame, stack_pointer);
@@ -727,7 +727,7 @@ dummy_func(
}
inst(INSTRUMENTED_RETURN_CONST, (--)) {
- PyObject *retval = GETITEM(frame->f_code->co_consts, oparg);
+ PyObject *retval = GETITEM(FRAME_CO_CONSTS, oparg);
int err = _Py_call_instrumentation_arg(
tstate, PY_MONITORING_EVENT_PY_RETURN,
frame, next_instr-1, retval);
@@ -924,6 +924,7 @@ dummy_func(
inst(INSTRUMENTED_YIELD_VALUE, (retval -- unused)) {
assert(frame != &entry_frame);
+ assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
PyGenObject *gen = _PyFrame_GetGenerator(frame);
gen->gi_frame_state = FRAME_SUSPENDED;
_PyFrame_SetStackPointer(frame, stack_pointer - 1);
@@ -945,6 +946,7 @@ dummy_func(
// NOTE: It's important that YIELD_VALUE never raises an exception!
// The compiler treats any exception raised here as a failed close()
// or throw() call.
+ assert(oparg >= 0); /* make the generator identify this as HAS_ARG */
assert(frame != &entry_frame);
PyGenObject *gen = _PyFrame_GetGenerator(frame);
gen->gi_frame_state = FRAME_SUSPENDED;
@@ -1040,7 +1042,7 @@ dummy_func(
inst(STORE_NAME, (v -- )) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
PyObject *ns = LOCALS();
int err;
if (ns == NULL) {
@@ -1058,7 +1060,7 @@ dummy_func(
}
inst(DELETE_NAME, (--)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
PyObject *ns = LOCALS();
int err;
if (ns == NULL) {
@@ -1150,7 +1152,7 @@ dummy_func(
inst(STORE_ATTR, (counter/1, unused/3, v, owner --)) {
#if ENABLE_SPECIALIZATION
if (ADAPTIVE_COUNTER_IS_ZERO(counter)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
next_instr--;
_Py_Specialize_StoreAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
@@ -1161,28 +1163,28 @@ dummy_func(
#else
(void)counter; // Unused.
#endif /* ENABLE_SPECIALIZATION */
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyObject_SetAttr(owner, name, v);
DECREF_INPUTS();
ERROR_IF(err, error);
}
inst(DELETE_ATTR, (owner --)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyObject_SetAttr(owner, name, (PyObject *)NULL);
DECREF_INPUTS();
ERROR_IF(err, error);
}
inst(STORE_GLOBAL, (v --)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err = PyDict_SetItem(GLOBALS(), name, v);
DECREF_INPUTS();
ERROR_IF(err, error);
}
inst(DELETE_GLOBAL, (--)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
int err;
err = PyDict_DelItem(GLOBALS(), name);
// Can't use ERROR_IF here.
@@ -1208,7 +1210,7 @@ dummy_func(
macro(LOAD_LOCALS) = _LOAD_LOCALS;
op(_LOAD_FROM_DICT_OR_GLOBALS, (mod_or_class_dict -- v)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
if (PyDict_CheckExact(mod_or_class_dict)) {
v = PyDict_GetItemWithError(mod_or_class_dict, name);
if (v != NULL) {
@@ -1280,7 +1282,7 @@ dummy_func(
#if ENABLE_SPECIALIZATION
_PyLoadGlobalCache *cache = (_PyLoadGlobalCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr--;
_Py_Specialize_LoadGlobal(GLOBALS(), BUILTINS(), next_instr, name);
DISPATCH_SAME_OPARG();
@@ -1288,7 +1290,7 @@ dummy_func(
STAT_INC(LOAD_GLOBAL, deferred);
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
#endif /* ENABLE_SPECIALIZATION */
- PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
if (PyDict_CheckExact(GLOBALS())
&& PyDict_CheckExact(BUILTINS()))
{
@@ -1630,7 +1632,7 @@ dummy_func(
};
inst(LOAD_SUPER_ATTR, (unused/1, global_super, class, self -- res2 if (oparg & 1), res)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
int load_method = oparg & 1;
#if ENABLE_SPECIALIZATION
_PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr;
@@ -1695,7 +1697,7 @@ dummy_func(
DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
STAT_INC(LOAD_SUPER_ATTR, hit);
- PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL);
DECREF_INPUTS();
ERROR_IF(res == NULL, error);
@@ -1706,7 +1708,7 @@ dummy_func(
DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR);
DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR);
STAT_INC(LOAD_SUPER_ATTR, hit);
- PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 2);
PyTypeObject *cls = (PyTypeObject *)class;
int method_found = 0;
res2 = _PySuper_Lookup(cls, self, name,
@@ -1744,7 +1746,7 @@ dummy_func(
#if ENABLE_SPECIALIZATION
_PyAttrCache *cache = (_PyAttrCache *)next_instr;
if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
next_instr--;
_Py_Specialize_LoadAttr(owner, next_instr, name);
DISPATCH_SAME_OPARG();
@@ -1752,7 +1754,7 @@ dummy_func(
STAT_INC(LOAD_ATTR, deferred);
DECREMENT_ADAPTIVE_COUNTER(cache->counter);
#endif /* ENABLE_SPECIALIZATION */
- PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
if (oparg & 1) {
/* Designed to work in tandem with CALL, pushes two values. */
PyObject* meth = NULL;
@@ -1834,7 +1836,7 @@ dummy_func(
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
DEOPT_IF(dict == NULL, LOAD_ATTR);
assert(PyDict_CheckExact((PyObject *)dict));
- PyObject *name = GETITEM(frame->f_code->co_names, oparg>>1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg>>1);
uint16_t hint = index;
DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, LOAD_ATTR);
if (DK_IS_UNICODE(dict->ma_keys)) {
@@ -1922,7 +1924,7 @@ dummy_func(
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), LOAD_ATTR);
STAT_INC(LOAD_ATTR, hit);
- PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 1);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg >> 1);
Py_INCREF(f);
_PyInterpreterFrame *new_frame = _PyFrame_PushUnchecked(tstate, f, 2);
// Manipulate stack directly because we exit with DISPATCH_INLINED().
@@ -1966,7 +1968,7 @@ dummy_func(
PyDictObject *dict = (PyDictObject *)_PyDictOrValues_GetDict(dorv);
DEOPT_IF(dict == NULL, STORE_ATTR);
assert(PyDict_CheckExact((PyObject *)dict));
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
DEOPT_IF(hint >= (size_t)dict->ma_keys->dk_nentries, STORE_ATTR);
PyObject *old_value;
uint64_t new_version;
@@ -2126,14 +2128,14 @@ dummy_func(
}
inst(IMPORT_NAME, (level, fromlist -- res)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
res = import_name(tstate, frame, name, fromlist, level);
DECREF_INPUTS();
ERROR_IF(res == NULL, error);
}
inst(IMPORT_FROM, (from -- from, res)) {
- PyObject *name = GETITEM(frame->f_code->co_names, oparg);
+ PyObject *name = GETITEM(FRAME_CO_NAMES, oparg);
res = import_from(tstate, from, name);
ERROR_IF(res == NULL, error);
}
@@ -2637,8 +2639,8 @@ dummy_func(
inst(KW_NAMES, (--)) {
assert(kwnames == NULL);
- assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts));
- kwnames = GETITEM(frame->f_code->co_consts, oparg);
+ assert(oparg < PyTuple_GET_SIZE(FRAME_CO_CONSTS));
+ kwnames = GETITEM(FRAME_CO_CONSTS, oparg);
}
inst(INSTRUMENTED_CALL, ( -- )) {