diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aafe40804c9b59..dbc2bb04da532b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -299,7 +299,7 @@ jobs: build_ubuntu: name: 'Ubuntu' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' @@ -366,7 +366,7 @@ jobs: build_ubuntu_ssltests: name: 'Ubuntu SSL tests with OpenSSL' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' @@ -420,7 +420,7 @@ jobs: test_hypothesis: name: "Hypothesis tests on Ubuntu" - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true' @@ -529,7 +529,7 @@ jobs: build_asan: name: 'Address sanitizer' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' diff --git a/.github/workflows/build_min.yml b/.github/workflows/build_min.yml index e50d4ed8ea3ef2..92b1106ee71f1a 100644 --- a/.github/workflows/build_min.yml +++ b/.github/workflows/build_min.yml @@ -286,7 +286,7 @@ jobs: build_ubuntu: name: 'Ubuntu' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' @@ -356,7 +356,7 @@ jobs: # # build_ubuntu_ssltests: # name: 'Ubuntu SSL tests with OpenSSL' - # runs-on: ubuntu-20.04 + # runs-on: ubuntu-22.04 # timeout-minutes: 60 # needs: check_source # if: needs.check_source.outputs.run_tests == 'true' @@ -410,7 +410,7 @@ jobs: test_hypothesis: name: "Hypothesis tests on Ubuntu" - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true' @@ -520,7 +520,7 @@ jobs: build_asan: name: 'Address sanitizer' - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 60 needs: check_source if: needs.check_source.outputs.run_tests == 'true' diff --git a/Include/internal/pycore_regions.h b/Include/internal/pycore_regions.h index 6a2c808ec2987a..55116964184c44 100644 --- a/Include/internal/pycore_regions.h +++ b/Include/internal/pycore_regions.h @@ -58,10 +58,10 @@ PyObject* _Py_ResetInvariant(void); // Invariant placeholder bool _Py_RegionAddReference(PyObject* src, PyObject* new_tgt); -#define Py_REGIONADDREFERENCE(a, b) _Py_RegionAddReference(_PyObject_CAST(a), b) +#define Py_REGIONADDREFERENCE(a, b) _Py_RegionAddReference(_PyObject_CAST(a), _PyObject_CAST(b)) void _Py_RegionAddLocalReference(PyObject* new_tgt); -#define Py_REGIONADDLOCALREFERENCE(b) _Py_RegionAddLocalReference(b) +#define Py_REGIONADDLOCALREFERENCE(b) _Py_RegionAddLocalReference(_PyObject_CAST(b)) // Helper macros to count the number of arguments #define _COUNT_ARGS(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N @@ -70,8 +70,11 @@ void _Py_RegionAddLocalReference(PyObject* new_tgt); bool _Py_RegionAddReferences(PyObject* src, int new_tgtc, ...); #define Py_REGIONADDREFERENCES(a, ...) _Py_RegionAddReferences(_PyObject_CAST(a), COUNT_ARGS(__VA_ARGS__), __VA_ARGS__) +bool _Py_RegionChangeReference(PyObject* src, PyObject* old_tgt, PyObject* new_tgt); +#define Py_REGIONCHANGEREFERENCE(a, b, c) _Py_RegionChangeReference(_PyObject_CAST(a), _PyObject_CAST(b), _PyObject_CAST(c)) + void _Py_RegionRemoveReference(PyObject* src, PyObject* old_tgt); -#define Py_REGIONREMOVEREFERENCE(a, b) _Py_RegionRemoveReference(_PyObject_CAST(a), b) +#define Py_REGIONREMOVEREFERENCE(a, b) _Py_RegionRemoveReference(_PyObject_CAST(a), _PyObject_CAST(b)) #ifdef NDEBUG #define _Py_VPYDBG(fmt, ...) @@ -97,8 +100,8 @@ int _PyRegion_is_closed(PyObject* op); #ifdef _Py_TYPEOF #define Py_CLEAR_OBJECT_FIELD(op, field) \ do { \ - _Py_TYPEOF(op)* _tmp_field_ptr = &(field); \ - _Py_TYPEOF(op) _tmp_old_field = (*_tmp_field_ptr); \ + _Py_TYPEOF(field)* _tmp_field_ptr = &(field); \ + _Py_TYPEOF(field) _tmp_old_field = (*_tmp_field_ptr); \ if (_tmp_old_field != NULL) { \ *_tmp_field_ptr = _Py_NULL; \ Py_REGIONREMOVEREFERENCE(op, _tmp_old_field); \ diff --git a/Lib/test/test_veronapy_writebarrier.py b/Lib/test/test_veronapy_writebarrier.py new file mode 100644 index 00000000000000..49c3110e023598 --- /dev/null +++ b/Lib/test/test_veronapy_writebarrier.py @@ -0,0 +1,238 @@ +import unittest +import dis + +class TestCellWriteBarrier(unittest.TestCase): + class A: + pass + + # Create a cell by capturing a variable in a closure + # The content of the cell is an instance of A which can be added to regions. + def make_cell(self): + x = self.A() + return (lambda: x).__closure__[0] + + def setUp(self): + # This freezes A and super and meta types of A namely `type` and `object` + makeimmutable(self.A) + + def test_cell_region_propagates(self): + c = self.make_cell() + r = Region() + + # Move c into the region r + r.c = c + + # Make sure region r now owns the cell and its content + self.assertTrue(r.owns_object(c)) + self.assertTrue(r.owns_object(c.cell_contents)) + + def test_cell_add_ref(self): + c = self.make_cell() + r = Region() + + # Move c into the region r + r.c = c + + # Make sure region r takes ownership of new references from c + self.assertTrue(r.owns_object(c)) + self.assertTrue(r.owns_object(c.cell_contents)) + + def test_cell_remove_ref(self): + c = self.make_cell() + r1 = Region() + child = Region() + + # Move c into the region r1 + r1.c = c + self.assertTrue(r1.owns_object(c)) + + # Make `child` a subregion of `r1` + c.cell_contents = child + self.assertEqual(c.cell_contents, child) + + # Replaceing the value in `c` should unparent the child region + # We can test this by reparenting it to `r2` without an exception + r2 = Region() + c.cell_contents = None + r2.child = child + + def test_cell_replace_same_bridge(self): + # This test makes sure that reassigning a pointer to a bridge object with + # the same value doesn't throw an exception, due the write barrier + # believing that there are two owning references to the same bridge object. + c = self.make_cell() + r = Region() + child = Region() + + # Move c into the region r + r.c = c + self.assertTrue(r.owns_object(c)) + + # Make `child` a subregion of `r1` + c.cell_contents = child + self.assertEqual(c.cell_contents, child) + + # Reassigning the owning pointer to the bridge should be fine + # since this writes replaces the previous owning reference + c.cell_contents = child + +# It's not possible to test the existance of all bytecodes. The dis only +# shows the unoptimized version of the bytecode. For testing specilized or +# optimized it's therefore not possible to check for the presence of that +# bytecode in the `dis`. Instead we can only check for the effects of the +# bytecodes. +# +# During test development it's also possible to verify that the expected +# bytecode is triggered by setting a breakpoint in it. Note that it's also +# run during the startup of the runtime and by other tests, so make sure +# the test in question actually started, when the breakpoint is triggered. +class TestBytecodeWriteBarrier(unittest.TestCase): + # Define a class with __slots__ + class ClassWithSlots: + # Use `__slots__` to get the `STORE_ATTR_SLOT` bytecode + __slots__ = ('slot',) + + def __init__(self): + self.slot = None + + class ClassWithAttr: + def __init__(self): + self.attr = None + + def setUp(self): + # This freezes A and super and meta types of A namely `type` and `object` + makeimmutable(self.ClassWithSlots) + makeimmutable(self.ClassWithAttr) + + def test_delete_deref(self): + r = Region() + r.field = {} + x = r.field + + # Make sure the region knows about local reference from x + self.assertFalse(r.try_close()) + + def del_x(): + nonlocal x + del x # This triggers the DELETE_DEREF opcode + + # Create the function and disassemble to confirm DELETE_DEREF is present + bytecode = dis.Bytecode(del_x) + self.assertIn("DELETE_DEREF", [instr.opname for instr in bytecode]) + + self.assertTrue(r.is_open()) + + # Call the function forcing the deletion of x which should + # close the region. + del_x() + + self.assertFalse(r.is_open()) + + # This tests that references stored by `STORE_ATTR_SLOT` are known + # by the write barrier + def test_store_attr_slot_add_reference(self): + def set_value(obj, val): + obj.slot = val # This triggers the STORE_ATTR_SLOT opcode + + # Setup a region and a class with slots + r = Region() + r.slots = self.ClassWithSlots() + self.assertTrue(r.owns_object(r.slots)) + + # Run `set_value` multiple times to optimize it + set_value(r.slots, None) + set_value(r.slots, {}) + + # Create a new local object + new_object = {} + new_object["data"] = {} + + # Store the object in slots + set_value(r.slots, new_object) + + # Verify the region ownership + self.assertTrue(r.owns_object(new_object)) + self.assertTrue(r.owns_object(new_object["data"])) + + # This tests that references removed by `STORE_ATTR_SLOT` are known + # by the write barrier + def test_store_attr_slot_remove_reference(self): + def set_value(obj, val): + obj.slot = val # This triggers the STORE_ATTR_SLOT opcode + + # Setup a region and a class with slots + r = Region() + r.data = {} + slots = self.ClassWithSlots() + + # Run `set_value` multiple times to optimize it + set_value(slots, None) + set_value(slots, {}) + + # Create local reference into the region + set_value(slots, r.data) + + # Make sure the region knows about the reference from the slot + self.assertFalse(r.try_close()) + + # Clear the reference from slots + set_value(slots, None) + + # Check that the region was closed. + self.assertFalse(r.is_open()) + + # This tests that references stored by `STORE_ATTR_INSTANCE_VALUE` are known + # by the write barrier + def test_store_attr_instance_value_add_reference(self): + def set_value(obj, val): + obj.attr = val # This triggers the STORE_ATTR_INSTANCE_VALUE opcode + + # Setup a region and a class with attributes + r = Region() + r.attr = self.ClassWithAttr() + self.assertTrue(r.owns_object(r.attr)) + + # Run `set_value` multiple times to optimize it + set_value(r.attr, None) + set_value(r.attr, {}) + + # Create a new local object + new_object = {} + new_object["data"] = {} + + # Store the object in attributes + set_value(r.attr, new_object) + + # Verify the region ownership + self.assertTrue(r.owns_object(new_object)) + self.assertTrue(r.owns_object(new_object["data"])) + + # This tests that references removed by `STORE_ATTR_INSTANCE_VALUE` are known + # by the write barrier + def test_store_attr_instance_value_remove_reference(self): + def set_value(obj, val): + obj.attr = val # This triggers the STORE_ATTR_INSTANCE_VALUE opcode + + # Setup a region and a class with attributes + r = Region() + r.data = {} + attr = self.ClassWithAttr() + + # Run `set_value` multiple times to optimize it + set_value(attr, None) + set_value(attr, {}) + + # Create local reference into the region + set_value(attr, r.data) + + # Make sure the region knows about the reference from the slot + self.assertFalse(r.try_close()) + + # Clear the reference from attributes + set_value(attr, None) + + # Check that the region was closed. + self.assertFalse(r.is_open()) + +if __name__ == "__main__": + unittest.main() diff --git a/Objects/cellobject.c b/Objects/cellobject.c index 0c7b648605e440..f97edcd7830e0d 100644 --- a/Objects/cellobject.c +++ b/Objects/cellobject.c @@ -74,6 +74,13 @@ PyCell_Set(PyObject *op, PyObject *value) } PyObject *old_value = PyCell_GET(op); + + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(op, old_value, value)) { + // Propagate the error from attempting to add the reference + return -1; + } + PyCell_SET(op, Py_XNewRef(value)); Py_XDECREF(old_value); return 0; @@ -133,7 +140,7 @@ cell_clear(PyCellObject *op) return -1; } - Py_CLEAR(op->ob_ref); + Py_CLEAR_OBJECT_FIELD(op, op->ob_ref); return 0; } @@ -156,6 +163,14 @@ cell_set_contents(PyCellObject *op, PyObject *obj, void *Py_UNUSED(ignored)) return -1; } + PyObject *old_value = PyCell_GET(op); + + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(op, old_value, obj)) { + // Propagate the error from attempting to add the reference + return -1; + } + Py_XSETREF(op->ob_ref, Py_XNewRef(obj)); return 0; } @@ -186,7 +201,7 @@ PyTypeObject PyCell_Type = { PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_REGION_AWARE, /* tp_flags */ cell_new_doc, /* tp_doc */ (traverseproc)cell_traverse, /* tp_traverse */ (inquiry)cell_clear, /* tp_clear */ diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 30c8d3c5270cad..4a61a0c21d2400 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1433,6 +1433,17 @@ _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear) if (cell != NULL) { oldvalue = PyCell_GET(cell); if (value != oldvalue) { + // Check that the cell can be mutated + if (!Py_CHECKWRITE(cell)) { + PyErr_WriteToImmutable(cell); + return; + } + + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(cell, oldvalue, value)) { + return; + } + PyCell_SET(cell, Py_XNewRef(value)); Py_XDECREF(oldvalue); } diff --git a/Objects/regions.c b/Objects/regions.c index ab7e602e211663..9be47ed793f51f 100644 --- a/Objects/regions.c +++ b/Objects/regions.c @@ -253,6 +253,33 @@ static void regionmetadata_inc_osc(Py_region_ptr_t self_ptr) #define regionmetadata_inc_osc(self) \ (regionmetadata_inc_osc(REGION_PTR_CAST(self))) +/// This function checks the internal state, meaning the LRC, OSC and dirty +/// status, to determine if the region should be closed. If possible, it will +/// close the region and propagate the state to any parent region or cowns. +/// +/// Returns `0` on success. An error might come from closing the region +/// see `regionmetadata_close` for potential errors. +static int regionmetadata_check_for_close(regionmetadata* self) { + // If the region is marked as dirty, we can't trust the LRC or OSC + // to update the status. The region has to be cleaned before it can + // be closed + if (regionmetadata_is_dirty(self)) { + return 0; + } + + // The region has to remain open, if there are open subregions + if (self->osc != 0) { + return 0; + } + + // The region has to remain open, if there are references into the region. + if (self->lrc != 0) { + return 0; + } + + return regionmetadata_close(self); +} + /// Decrements the OSC of the region. This might close the region if the LRC /// and ORC both hit zero and the region is not marked as dirty. /// @@ -268,11 +295,7 @@ static int regionmetadata_dec_osc(Py_region_ptr_t self_ptr) self->osc -= 1; // Check if the OSC decrease has closed this region as well. - if (self->osc == 0 && self->lrc == 0 && !regionmetadata_is_dirty(self)) { - return regionmetadata_close(self); - } - - return 0; + return regionmetadata_check_for_close(self); } #define regionmetadata_dec_osc(self) \ (regionmetadata_dec_osc(REGION_PTR_CAST(self))) @@ -322,6 +345,31 @@ static int regionmetadata_dec_rc(Py_region_ptr_t self_ptr) #define regionmetadata_dec_rc(self) \ (regionmetadata_dec_rc(REGION_PTR_CAST(self))) +static void regionmetadata_inc_lrc(regionmetadata* self) +{ + assert(HAS_METADATA(self)); + + self->lrc += 1; + regionmetadata_open(self); +} +#define regionmetadata_inc_lrc(self) \ + (regionmetadata_inc_lrc(REGION_DATA_CAST(self))) + +/// Decrements the LRC of the region. This might close the region if the LRC +/// and ORC both hit zero and the region is not marked as dirty. +/// +/// Returns `0` on success. An error might come from closing the region +/// see `regionmetadata_close` for potential errors. +static int regionmetadata_dec_lrc(regionmetadata* self) +{ + assert(HAS_METADATA(self)); + + self->lrc -= 1; + return regionmetadata_check_for_close(self); +} +#define regionmetadata_dec_lrc(self) \ + (regionmetadata_dec_lrc(REGION_DATA_CAST(self))) + static void regionmetadata_set_parent(regionmetadata* self, regionmetadata* parent) { // Just a sanity check, since these cases should never happen assert(HAS_METADATA(self) && "Can't set the parent on the immutable and local region"); @@ -473,7 +521,9 @@ int _Py_IsCown(PyObject *op) Py_region_ptr_t _Py_REGION(PyObject *ob) { if (!ob) { - return REGION_PTR_CAST(NULL); + // NULL is not really an object, but we want to allow pointers to be NULL + // so we can simply return the immutable region. + return _Py_IMMUTABLE; } Py_region_ptr_t field_value = Py_region_ptr(Py_REGION_FIELD(ob)); @@ -1935,7 +1985,7 @@ bool _Py_RegionAddReference(PyObject *src, PyObject *tgt) { if (_Py_IsLocal(src)) { // Record the borrowed reference in the LRC of the target region // _Py_VPYDBG("Added borrowed ref %p --> %p (owner: '%s')\n", tgt, new_ref, get_region_name(tgt)); - Py_REGION_DATA(tgt)->lrc += 1; + regionmetadata_inc_lrc(Py_REGION_DATA(tgt)); return true; } @@ -1953,7 +2003,7 @@ void _Py_RegionAddLocalReference(PyObject *tgt) { return; } - Py_REGION_DATA(tgt)->lrc += 1; + regionmetadata_inc_lrc(Py_REGION_DATA(tgt)); } // Convenience function for moving multiple references into tgt at once @@ -1977,6 +2027,29 @@ void _PyRegion_set_cown_parent(PyObject* bridge, PyObject* cown) { Py_XSETREF(data->cown, cown); } +bool _Py_RegionChangeReference(PyObject* src, PyObject* old_tgt, PyObject* new_tgt) { + // Only run the write barrier(WB) if the reference targets are different. + // This is important for bridge objects, as there can only be one owning + // reference at a time and adding a new reference first would throw a + // region error due to the WB believing that it would result in a second + // owning reference being created. + // + // Removing the reference before the new one also doesn't work. As it + // could cause a parent region to close prematurely and release a cown. + // It would also require adding the removed reference again, if the + // `_Py_RegionAddReference` fails. + if (old_tgt == new_tgt) { + return true; + } + + if (!_Py_RegionAddReference(src, new_tgt)) { + return false; + } + + _Py_RegionRemoveReference(src, old_tgt); + return true; +} + void _Py_RegionRemoveReference(PyObject *src, PyObject *tgt) { if (Py_REGION(src) == Py_REGION(tgt)) { // Nothing to do -- intra-region references have no accounting. @@ -1995,9 +2068,8 @@ void _Py_RegionRemoveReference(PyObject *src, PyObject *tgt) { regionmetadata* tgt_md = Py_REGION_DATA(tgt); if (_Py_IsLocal(src)) { // Dec LRC of the previously referenced region - // TODO should this decrement be a function, if it hits zero, - // then a region could become unreachable. - tgt_md->lrc -= 1; + // TODO should errors be propagated? + regionmetadata_dec_lrc(tgt_md); return; } diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b22ce9205aa724..6f1d49d4b4d6f9 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1411,12 +1411,13 @@ dummy_func( goto error; } - if (!Py_CHECKWRITE(cell)){ + if (!Py_CHECKWRITE(cell)) { format_exc_notwriteable(tstate, frame->f_code, oparg); goto error; } PyCell_SET(cell, NULL); + Py_REGIONREMOVEREFERENCE(cell, oldobj); Py_DECREF(oldobj); } @@ -1476,6 +1477,11 @@ dummy_func( goto error; } + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(cell, oldobj, v)) { + goto error; + } + PyCell_SET(cell, v); Py_XDECREF(oldobj); } @@ -1974,6 +1980,13 @@ dummy_func( } PyDictValues *values = _PyDictOrValues_GetValues(dorv); PyObject *old_value = values->values[index]; + + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + values->values[index] = value; if (old_value == NULL) { _PyDictValues_AddToInsertionOrder(values, index); @@ -2009,11 +2022,16 @@ dummy_func( DEOPT_IF(ep->me_key != name, STORE_ATTR); old_value = _PyDictEntry_Value(ep); DEOPT_IF(old_value == NULL, STORE_ATTR); - new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); - if(_PyDictEntry_IsImmutable(ep)){ + if (_PyDictEntry_IsImmutable(ep)) { format_exc_notwriteable(tstate, frame->f_code, oparg); + Py_DECREF(owner); + goto error; + } + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); goto error; } + new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); _PyDictEntry_SetValue(ep, value); } else { @@ -2021,11 +2039,16 @@ dummy_func( DEOPT_IF(ep->me_key != name, STORE_ATTR); old_value = _PyDictEntry_Value(ep); DEOPT_IF(old_value == NULL, STORE_ATTR); - new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); - if(_PyDictEntry_IsImmutable(ep)){ + if (_PyDictEntry_IsImmutable(ep)) { format_exc_notwriteable(tstate, frame->f_code, oparg); + Py_DECREF(owner); goto error; } + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); _PyDictEntry_SetValue(ep, value); } Py_DECREF(old_value); @@ -2049,9 +2072,16 @@ dummy_func( Py_DECREF(owner); goto error; } + char *addr = (char *)owner + index; STAT_INC(STORE_ATTR, hit); PyObject *old_value = *(PyObject **)addr; + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 4f171e0f8d004a..0acde60642b656 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -1920,21 +1920,22 @@ goto error; } - if (!Py_CHECKWRITE(cell)){ + if (!Py_CHECKWRITE(cell)) { format_exc_notwriteable(tstate, frame->f_code, oparg); goto error; } PyCell_SET(cell, NULL); + Py_REGIONREMOVEREFERENCE(cell, oldobj); Py_DECREF(oldobj); - #line 1931 "Python/generated_cases.c.h" + #line 1932 "Python/generated_cases.c.h" DISPATCH(); } TARGET(LOAD_FROM_DICT_OR_DEREF) { PyObject *class_dict = stack_pointer[-1]; PyObject *value; - #line 1424 "Python/bytecodes.c" + #line 1425 "Python/bytecodes.c" PyObject *name; assert(class_dict); assert(oparg >= 0 && oparg < frame->f_code->co_nlocalsplus); @@ -1969,14 +1970,14 @@ } Py_INCREF(value); } - #line 1973 "Python/generated_cases.c.h" + #line 1974 "Python/generated_cases.c.h" stack_pointer[-1] = value; DISPATCH(); } TARGET(LOAD_DEREF) { PyObject *value; - #line 1461 "Python/bytecodes.c" + #line 1462 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); value = PyCell_GET(cell); if (value == NULL) { @@ -1984,7 +1985,7 @@ if (true) goto error; } Py_INCREF(value); - #line 1988 "Python/generated_cases.c.h" + #line 1989 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = value; DISPATCH(); @@ -1992,7 +1993,7 @@ TARGET(STORE_DEREF) { PyObject *v = stack_pointer[-1]; - #line 1471 "Python/bytecodes.c" + #line 1472 "Python/bytecodes.c" PyObject *cell = GETLOCAL(oparg); PyObject *oldobj = PyCell_GET(cell); @@ -2001,15 +2002,20 @@ goto error; } + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(cell, oldobj, v)) { + goto error; + } + PyCell_SET(cell, v); Py_XDECREF(oldobj); - #line 2007 "Python/generated_cases.c.h" + #line 2013 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(COPY_FREE_VARS) { - #line 1484 "Python/bytecodes.c" + #line 1490 "Python/bytecodes.c" /* Copy closure variables to free variables */ PyCodeObject *co = frame->f_code; assert(PyFunction_Check(frame->f_funcobj)); @@ -2020,22 +2026,22 @@ PyObject *o = PyTuple_GET_ITEM(closure, i); frame->localsplus[offset + i] = Py_NewRef(o); } - #line 2024 "Python/generated_cases.c.h" + #line 2030 "Python/generated_cases.c.h" DISPATCH(); } TARGET(BUILD_STRING) { PyObject **pieces = (stack_pointer - oparg); PyObject *str; - #line 1497 "Python/bytecodes.c" + #line 1503 "Python/bytecodes.c" str = _PyUnicode_JoinArray(&_Py_STR(empty), pieces, oparg); - #line 2033 "Python/generated_cases.c.h" + #line 2039 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(pieces[_i]); } - #line 1499 "Python/bytecodes.c" + #line 1505 "Python/bytecodes.c" if (str == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2039 "Python/generated_cases.c.h" + #line 2045 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = str; @@ -2045,10 +2051,10 @@ TARGET(BUILD_TUPLE) { PyObject **values = (stack_pointer - oparg); PyObject *tup; - #line 1503 "Python/bytecodes.c" + #line 1509 "Python/bytecodes.c" tup = _PyTuple_FromArraySteal(values, oparg); if (tup == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2052 "Python/generated_cases.c.h" + #line 2058 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = tup; @@ -2058,10 +2064,10 @@ TARGET(BUILD_LIST) { PyObject **values = (stack_pointer - oparg); PyObject *list; - #line 1508 "Python/bytecodes.c" + #line 1514 "Python/bytecodes.c" list = _PyList_FromArraySteal(values, oparg); if (list == NULL) { STACK_SHRINK(oparg); goto error; } - #line 2065 "Python/generated_cases.c.h" + #line 2071 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = list; @@ -2071,7 +2077,7 @@ TARGET(LIST_EXTEND) { PyObject *iterable = stack_pointer[-1]; PyObject *list = stack_pointer[-(2 + (oparg-1))]; - #line 1513 "Python/bytecodes.c" + #line 1519 "Python/bytecodes.c" PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable); if (none_val == NULL) { if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) && @@ -2082,13 +2088,13 @@ "Value after * must be an iterable, not %.200s", Py_TYPE(iterable)->tp_name); } - #line 2086 "Python/generated_cases.c.h" + #line 2092 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1524 "Python/bytecodes.c" + #line 1530 "Python/bytecodes.c" if (true) goto pop_1_error; } assert(Py_IsNone(none_val)); - #line 2092 "Python/generated_cases.c.h" + #line 2098 "Python/generated_cases.c.h" Py_DECREF(iterable); STACK_SHRINK(1); DISPATCH(); @@ -2097,13 +2103,13 @@ TARGET(SET_UPDATE) { PyObject *iterable = stack_pointer[-1]; PyObject *set = stack_pointer[-(2 + (oparg-1))]; - #line 1531 "Python/bytecodes.c" + #line 1537 "Python/bytecodes.c" int err = _PySet_Update(set, iterable); - #line 2103 "Python/generated_cases.c.h" + #line 2109 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 1533 "Python/bytecodes.c" + #line 1539 "Python/bytecodes.c" if (err < 0) goto pop_1_error; - #line 2107 "Python/generated_cases.c.h" + #line 2113 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } @@ -2111,7 +2117,7 @@ TARGET(BUILD_SET) { PyObject **values = (stack_pointer - oparg); PyObject *set; - #line 1537 "Python/bytecodes.c" + #line 1543 "Python/bytecodes.c" set = PySet_New(NULL); if (set == NULL) goto error; @@ -2126,7 +2132,7 @@ Py_DECREF(set); if (true) { STACK_SHRINK(oparg); goto error; } } - #line 2130 "Python/generated_cases.c.h" + #line 2136 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_GROW(1); stack_pointer[-1] = set; @@ -2136,7 +2142,7 @@ TARGET(BUILD_MAP) { PyObject **values = (stack_pointer - oparg*2); PyObject *map; - #line 1554 "Python/bytecodes.c" + #line 1560 "Python/bytecodes.c" map = _PyDict_FromItems( values, 2, values+1, 2, @@ -2144,13 +2150,13 @@ if (map == NULL) goto error; - #line 2148 "Python/generated_cases.c.h" + #line 2154 "Python/generated_cases.c.h" for (int _i = oparg*2; --_i >= 0;) { Py_DECREF(values[_i]); } - #line 1562 "Python/bytecodes.c" + #line 1568 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg*2); goto error; } - #line 2154 "Python/generated_cases.c.h" + #line 2160 "Python/generated_cases.c.h" STACK_SHRINK(oparg*2); STACK_GROW(1); stack_pointer[-1] = map; @@ -2158,7 +2164,7 @@ } TARGET(SETUP_ANNOTATIONS) { - #line 1566 "Python/bytecodes.c" + #line 1572 "Python/bytecodes.c" int err; PyObject *ann_dict; if (LOCALS() == NULL) { @@ -2198,7 +2204,7 @@ Py_DECREF(ann_dict); } } - #line 2202 "Python/generated_cases.c.h" + #line 2208 "Python/generated_cases.c.h" DISPATCH(); } @@ -2206,7 +2212,7 @@ PyObject *keys = stack_pointer[-1]; PyObject **values = (stack_pointer - (1 + oparg)); PyObject *map; - #line 1608 "Python/bytecodes.c" + #line 1614 "Python/bytecodes.c" if (!PyTuple_CheckExact(keys) || PyTuple_GET_SIZE(keys) != (Py_ssize_t)oparg) { _PyErr_SetString(tstate, PyExc_SystemError, @@ -2216,14 +2222,14 @@ map = _PyDict_FromItems( &PyTuple_GET_ITEM(keys, 0), 1, values, 1, oparg); - #line 2220 "Python/generated_cases.c.h" + #line 2226 "Python/generated_cases.c.h" for (int _i = oparg; --_i >= 0;) { Py_DECREF(values[_i]); } Py_DECREF(keys); - #line 1618 "Python/bytecodes.c" + #line 1624 "Python/bytecodes.c" if (map == NULL) { STACK_SHRINK(oparg); goto pop_1_error; } - #line 2227 "Python/generated_cases.c.h" + #line 2233 "Python/generated_cases.c.h" STACK_SHRINK(oparg); stack_pointer[-1] = map; DISPATCH(); @@ -2231,7 +2237,7 @@ TARGET(DICT_UPDATE) { PyObject *update = stack_pointer[-1]; - #line 1622 "Python/bytecodes.c" + #line 1628 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (PyDict_Update(dict, update) < 0) { if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) { @@ -2239,12 +2245,12 @@ "'%.200s' object is not a mapping", Py_TYPE(update)->tp_name); } - #line 2243 "Python/generated_cases.c.h" + #line 2249 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1630 "Python/bytecodes.c" + #line 1636 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2248 "Python/generated_cases.c.h" + #line 2254 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); DISPATCH(); @@ -2252,17 +2258,17 @@ TARGET(DICT_MERGE) { PyObject *update = stack_pointer[-1]; - #line 1636 "Python/bytecodes.c" + #line 1642 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 1); // update is still on the stack if (_PyDict_MergeEx(dict, update, 2) < 0) { format_kwargs_error(tstate, PEEK(3 + oparg), update); - #line 2261 "Python/generated_cases.c.h" + #line 2267 "Python/generated_cases.c.h" Py_DECREF(update); - #line 1641 "Python/bytecodes.c" + #line 1647 "Python/bytecodes.c" if (true) goto pop_1_error; } - #line 2266 "Python/generated_cases.c.h" + #line 2272 "Python/generated_cases.c.h" Py_DECREF(update); STACK_SHRINK(1); PREDICT(CALL_FUNCTION_EX); @@ -2272,26 +2278,26 @@ TARGET(MAP_ADD) { PyObject *value = stack_pointer[-1]; PyObject *key = stack_pointer[-2]; - #line 1648 "Python/bytecodes.c" + #line 1654 "Python/bytecodes.c" PyObject *dict = PEEK(oparg + 2); // key, value are still on the stack assert(PyDict_CheckExact(dict)); /* dict[key] = value */ // Do not DECREF INPUTS because the function steals the references if (_PyDict_SetItem_Take2((PyDictObject *)dict, key, value) != 0) goto pop_2_error; - #line 2282 "Python/generated_cases.c.h" + #line 2288 "Python/generated_cases.c.h" STACK_SHRINK(2); PREDICT(JUMP_BACKWARD); DISPATCH(); } TARGET(INSTRUMENTED_LOAD_SUPER_ATTR) { - #line 1657 "Python/bytecodes.c" + #line 1663 "Python/bytecodes.c" _PySuperAttrCache *cache = (_PySuperAttrCache *)next_instr; // cancel out the decrement that will happen in LOAD_SUPER_ATTR; we // don't want to specialize instrumented instructions INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(LOAD_SUPER_ATTR); - #line 2295 "Python/generated_cases.c.h" + #line 2301 "Python/generated_cases.c.h" } TARGET(LOAD_SUPER_ATTR) { @@ -2302,7 +2308,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1671 "Python/bytecodes.c" + #line 1677 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg >> 2); int load_method = oparg & 1; #if ENABLE_SPECIALIZATION @@ -2344,16 +2350,16 @@ } } } - #line 2348 "Python/generated_cases.c.h" + #line 2354 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1713 "Python/bytecodes.c" + #line 1719 "Python/bytecodes.c" if (super == NULL) goto pop_3_error; res = PyObject_GetAttr(super, name); Py_DECREF(super); if (res == NULL) goto pop_3_error; - #line 2357 "Python/generated_cases.c.h" + #line 2363 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2368,20 +2374,20 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2 = NULL; PyObject *res; - #line 1720 "Python/bytecodes.c" + #line 1726 "Python/bytecodes.c" assert(!(oparg & 1)); 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); res = _PySuper_Lookup((PyTypeObject *)class, self, name, NULL); - #line 2379 "Python/generated_cases.c.h" + #line 2385 "Python/generated_cases.c.h" Py_DECREF(global_super); Py_DECREF(class); Py_DECREF(self); - #line 1727 "Python/bytecodes.c" + #line 1733 "Python/bytecodes.c" if (res == NULL) goto pop_3_error; - #line 2385 "Python/generated_cases.c.h" + #line 2391 "Python/generated_cases.c.h" STACK_SHRINK(2); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2396,7 +2402,7 @@ PyObject *global_super = stack_pointer[-3]; PyObject *res2; PyObject *res; - #line 1731 "Python/bytecodes.c" + #line 1737 "Python/bytecodes.c" assert(oparg & 1); DEOPT_IF(global_super != (PyObject *)&PySuper_Type, LOAD_SUPER_ATTR); DEOPT_IF(!PyType_Check(class), LOAD_SUPER_ATTR); @@ -2419,7 +2425,7 @@ res = res2; res2 = NULL; } - #line 2423 "Python/generated_cases.c.h" + #line 2429 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; stack_pointer[-2] = res2; @@ -2433,7 +2439,7 @@ PyObject *owner = stack_pointer[-1]; PyObject *res2 = NULL; PyObject *res; - #line 1770 "Python/bytecodes.c" + #line 1776 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyAttrCache *cache = (_PyAttrCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2467,9 +2473,9 @@ NULL | meth | arg1 | ... | argN */ - #line 2471 "Python/generated_cases.c.h" + #line 2477 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1804 "Python/bytecodes.c" + #line 1810 "Python/bytecodes.c" if (meth == NULL) goto pop_1_error; res2 = NULL; res = meth; @@ -2478,12 +2484,12 @@ else { /* Classic, pushes one value. */ res = PyObject_GetAttr(owner, name); - #line 2482 "Python/generated_cases.c.h" + #line 2488 "Python/generated_cases.c.h" Py_DECREF(owner); - #line 1813 "Python/bytecodes.c" + #line 1819 "Python/bytecodes.c" if (res == NULL) goto pop_1_error; } - #line 2487 "Python/generated_cases.c.h" + #line 2493 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -2497,7 +2503,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1818 "Python/bytecodes.c" + #line 1824 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2510,7 +2516,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2514 "Python/generated_cases.c.h" + #line 2520 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2525,7 +2531,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1834 "Python/bytecodes.c" + #line 1840 "Python/bytecodes.c" DEOPT_IF(!PyModule_CheckExact(owner), LOAD_ATTR); PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner)->md_dict; assert(dict != NULL); @@ -2538,7 +2544,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2542 "Python/generated_cases.c.h" + #line 2548 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2553,7 +2559,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1850 "Python/bytecodes.c" + #line 1856 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2580,7 +2586,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2584 "Python/generated_cases.c.h" + #line 2590 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2595,7 +2601,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1880 "Python/bytecodes.c" + #line 1886 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR); @@ -2605,7 +2611,7 @@ STAT_INC(LOAD_ATTR, hit); Py_INCREF(res); res2 = NULL; - #line 2609 "Python/generated_cases.c.h" + #line 2615 "Python/generated_cases.c.h" Py_DECREF(owner); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2620,7 +2626,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 1893 "Python/bytecodes.c" + #line 1899 "Python/bytecodes.c" DEOPT_IF(!PyType_Check(cls), LOAD_ATTR); DEOPT_IF(((PyTypeObject *)cls)->tp_version_tag != type_version, @@ -2632,7 +2638,7 @@ res = descr; assert(res != NULL); Py_INCREF(res); - #line 2636 "Python/generated_cases.c.h" + #line 2642 "Python/generated_cases.c.h" Py_DECREF(cls); STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; @@ -2646,7 +2652,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *fget = read_obj(&next_instr[5].cache); - #line 1908 "Python/bytecodes.c" + #line 1914 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); @@ -2670,7 +2676,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2674 "Python/generated_cases.c.h" + #line 2680 "Python/generated_cases.c.h" } TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) { @@ -2678,7 +2684,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t func_version = read_u32(&next_instr[3].cache); PyObject *getattribute = read_obj(&next_instr[5].cache); - #line 1934 "Python/bytecodes.c" + #line 1940 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, LOAD_ATTR); PyTypeObject *cls = Py_TYPE(owner); DEOPT_IF(cls->tp_version_tag != type_version, LOAD_ATTR); @@ -2704,7 +2710,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_LOAD_ATTR); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 2708 "Python/generated_cases.c.h" + #line 2714 "Python/generated_cases.c.h" } TARGET(STORE_ATTR_INSTANCE_VALUE) { @@ -2712,7 +2718,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 1962 "Python/bytecodes.c" + #line 1968 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2728,6 +2734,13 @@ } PyDictValues *values = _PyDictOrValues_GetValues(dorv); PyObject *old_value = values->values[index]; + + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + values->values[index] = value; if (old_value == NULL) { _PyDictValues_AddToInsertionOrder(values, index); @@ -2736,7 +2749,7 @@ Py_DECREF(old_value); } Py_DECREF(owner); - #line 2740 "Python/generated_cases.c.h" + #line 2753 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2747,7 +2760,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t hint = read_u16(&next_instr[3].cache); - #line 1988 "Python/bytecodes.c" + #line 2001 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2772,11 +2785,16 @@ DEOPT_IF(ep->me_key != name, STORE_ATTR); old_value = _PyDictEntry_Value(ep); DEOPT_IF(old_value == NULL, STORE_ATTR); - new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); - if(_PyDictEntry_IsImmutable(ep)){ + if (_PyDictEntry_IsImmutable(ep)) { format_exc_notwriteable(tstate, frame->f_code, oparg); + Py_DECREF(owner); goto error; } + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); _PyDictEntry_SetValue(ep, value); } else { @@ -2784,11 +2802,16 @@ DEOPT_IF(ep->me_key != name, STORE_ATTR); old_value = _PyDictEntry_Value(ep); DEOPT_IF(old_value == NULL, STORE_ATTR); - new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); - if(_PyDictEntry_IsImmutable(ep)){ + if (_PyDictEntry_IsImmutable(ep)) { format_exc_notwriteable(tstate, frame->f_code, oparg); + Py_DECREF(owner); goto error; } + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + new_version = _PyDict_NotifyEvent(tstate->interp, PyDict_EVENT_MODIFIED, dict, name, value); _PyDictEntry_SetValue(ep, value); } Py_DECREF(old_value); @@ -2800,7 +2823,7 @@ /* PEP 509 */ dict->ma_version_tag = new_version; Py_DECREF(owner); - #line 2804 "Python/generated_cases.c.h" + #line 2827 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2811,7 +2834,7 @@ PyObject *value = stack_pointer[-2]; uint32_t type_version = read_u32(&next_instr[1].cache); uint16_t index = read_u16(&next_instr[3].cache); - #line 2043 "Python/bytecodes.c" + #line 2066 "Python/bytecodes.c" PyTypeObject *tp = Py_TYPE(owner); assert(type_version != 0); DEOPT_IF(tp->tp_version_tag != type_version, STORE_ATTR); @@ -2821,13 +2844,20 @@ Py_DECREF(owner); goto error; } + char *addr = (char *)owner + index; STAT_INC(STORE_ATTR, hit); PyObject *old_value = *(PyObject **)addr; + // Check that the reference can be created + if (!Py_REGIONCHANGEREFERENCE(owner, old_value, value)) { + Py_DECREF(owner); + goto error; + } + *(PyObject **)addr = value; Py_XDECREF(old_value); Py_DECREF(owner); - #line 2831 "Python/generated_cases.c.h" + #line 2861 "Python/generated_cases.c.h" STACK_SHRINK(2); next_instr += 4; DISPATCH(); @@ -2839,7 +2869,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2068 "Python/bytecodes.c" + #line 2098 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyCompareOpCache *cache = (_PyCompareOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -2852,12 +2882,12 @@ #endif /* ENABLE_SPECIALIZATION */ assert((oparg >> 4) <= Py_GE); res = PyObject_RichCompare(left, right, oparg>>4); - #line 2856 "Python/generated_cases.c.h" + #line 2886 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2081 "Python/bytecodes.c" + #line 2111 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 2861 "Python/generated_cases.c.h" + #line 2891 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2868,7 +2898,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2085 "Python/bytecodes.c" + #line 2115 "Python/bytecodes.c" DEOPT_IF(!PyFloat_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyFloat_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2879,7 +2909,7 @@ _Py_DECREF_SPECIALIZED(left, _PyFloat_ExactDealloc); _Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc); res = (sign_ish & oparg) ? Py_True : Py_False; - #line 2883 "Python/generated_cases.c.h" + #line 2913 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2890,7 +2920,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2099 "Python/bytecodes.c" + #line 2129 "Python/bytecodes.c" DEOPT_IF(!PyLong_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyLong_CheckExact(right), COMPARE_OP); DEOPT_IF(!_PyLong_IsCompact((PyLongObject *)left), COMPARE_OP); @@ -2905,7 +2935,7 @@ _Py_DECREF_SPECIALIZED(left, (destructor)PyObject_Free); _Py_DECREF_SPECIALIZED(right, (destructor)PyObject_Free); res = (sign_ish & oparg) ? Py_True : Py_False; - #line 2909 "Python/generated_cases.c.h" + #line 2939 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2916,7 +2946,7 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *res; - #line 2117 "Python/bytecodes.c" + #line 2147 "Python/bytecodes.c" DEOPT_IF(!PyUnicode_CheckExact(left), COMPARE_OP); DEOPT_IF(!PyUnicode_CheckExact(right), COMPARE_OP); STAT_INC(COMPARE_OP, hit); @@ -2928,7 +2958,7 @@ assert((oparg & 0xf) == COMPARISON_NOT_EQUALS || (oparg & 0xf) == COMPARISON_EQUALS); assert(COMPARISON_NOT_EQUALS + 1 == COMPARISON_EQUALS); res = ((COMPARISON_NOT_EQUALS + eq) & oparg) ? Py_True : Py_False; - #line 2932 "Python/generated_cases.c.h" + #line 2962 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -2939,14 +2969,14 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2131 "Python/bytecodes.c" + #line 2161 "Python/bytecodes.c" int res = Py_Is(left, right) ^ oparg; - #line 2945 "Python/generated_cases.c.h" + #line 2975 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2133 "Python/bytecodes.c" + #line 2163 "Python/bytecodes.c" b = res ? Py_True : Py_False; - #line 2950 "Python/generated_cases.c.h" + #line 2980 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2956,15 +2986,15 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2137 "Python/bytecodes.c" + #line 2167 "Python/bytecodes.c" int res = PySequence_Contains(right, left); - #line 2962 "Python/generated_cases.c.h" + #line 2992 "Python/generated_cases.c.h" Py_DECREF(left); Py_DECREF(right); - #line 2139 "Python/bytecodes.c" + #line 2169 "Python/bytecodes.c" if (res < 0) goto pop_2_error; b = (res ^ oparg) ? Py_True : Py_False; - #line 2968 "Python/generated_cases.c.h" + #line 2998 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = b; DISPATCH(); @@ -2975,12 +3005,12 @@ PyObject *exc_value = stack_pointer[-2]; PyObject *rest; PyObject *match; - #line 2144 "Python/bytecodes.c" + #line 2174 "Python/bytecodes.c" if (check_except_star_type_valid(tstate, match_type) < 0) { - #line 2981 "Python/generated_cases.c.h" + #line 3011 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2146 "Python/bytecodes.c" + #line 2176 "Python/bytecodes.c" if (true) goto pop_2_error; } @@ -2988,10 +3018,10 @@ rest = NULL; int res = exception_group_match(exc_value, match_type, &match, &rest); - #line 2992 "Python/generated_cases.c.h" + #line 3022 "Python/generated_cases.c.h" Py_DECREF(exc_value); Py_DECREF(match_type); - #line 2154 "Python/bytecodes.c" + #line 2184 "Python/bytecodes.c" if (res < 0) goto pop_2_error; assert((match == NULL) == (rest == NULL)); @@ -3000,7 +3030,7 @@ if (!Py_IsNone(match)) { PyErr_SetHandledException(match); } - #line 3004 "Python/generated_cases.c.h" + #line 3034 "Python/generated_cases.c.h" stack_pointer[-1] = match; stack_pointer[-2] = rest; DISPATCH(); @@ -3010,21 +3040,21 @@ PyObject *right = stack_pointer[-1]; PyObject *left = stack_pointer[-2]; PyObject *b; - #line 2165 "Python/bytecodes.c" + #line 2195 "Python/bytecodes.c" assert(PyExceptionInstance_Check(left)); if (check_except_type_valid(tstate, right) < 0) { - #line 3017 "Python/generated_cases.c.h" + #line 3047 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2168 "Python/bytecodes.c" + #line 2198 "Python/bytecodes.c" if (true) goto pop_1_error; } int res = PyErr_GivenExceptionMatches(left, right); - #line 3024 "Python/generated_cases.c.h" + #line 3054 "Python/generated_cases.c.h" Py_DECREF(right); - #line 2173 "Python/bytecodes.c" + #line 2203 "Python/bytecodes.c" b = res ? Py_True : Py_False; - #line 3028 "Python/generated_cases.c.h" + #line 3058 "Python/generated_cases.c.h" stack_pointer[-1] = b; DISPATCH(); } @@ -3033,15 +3063,15 @@ PyObject *fromlist = stack_pointer[-1]; PyObject *level = stack_pointer[-2]; PyObject *res; - #line 2177 "Python/bytecodes.c" + #line 2207 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_name(tstate, frame, name, fromlist, level); - #line 3040 "Python/generated_cases.c.h" + #line 3070 "Python/generated_cases.c.h" Py_DECREF(level); Py_DECREF(fromlist); - #line 2180 "Python/bytecodes.c" + #line 2210 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 3045 "Python/generated_cases.c.h" + #line 3075 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; DISPATCH(); @@ -3050,29 +3080,29 @@ TARGET(IMPORT_FROM) { PyObject *from = stack_pointer[-1]; PyObject *res; - #line 2184 "Python/bytecodes.c" + #line 2214 "Python/bytecodes.c" PyObject *name = GETITEM(frame->f_code->co_names, oparg); res = import_from(tstate, from, name); if (res == NULL) goto error; - #line 3058 "Python/generated_cases.c.h" + #line 3088 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); } TARGET(JUMP_FORWARD) { - #line 2190 "Python/bytecodes.c" + #line 2220 "Python/bytecodes.c" JUMPBY(oparg); - #line 3067 "Python/generated_cases.c.h" + #line 3097 "Python/generated_cases.c.h" DISPATCH(); } TARGET(JUMP_BACKWARD) { PREDICTED(JUMP_BACKWARD); - #line 2194 "Python/bytecodes.c" + #line 2224 "Python/bytecodes.c" assert(oparg < INSTR_OFFSET()); JUMPBY(-oparg); - #line 3076 "Python/generated_cases.c.h" + #line 3106 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } @@ -3080,15 +3110,15 @@ TARGET(POP_JUMP_IF_FALSE) { PREDICTED(POP_JUMP_IF_FALSE); PyObject *cond = stack_pointer[-1]; - #line 2200 "Python/bytecodes.c" + #line 2230 "Python/bytecodes.c" if (Py_IsFalse(cond)) { JUMPBY(oparg); } else if (!Py_IsTrue(cond)) { int err = PyObject_IsTrue(cond); - #line 3090 "Python/generated_cases.c.h" + #line 3120 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2206 "Python/bytecodes.c" + #line 2236 "Python/bytecodes.c" if (err == 0) { JUMPBY(oparg); } @@ -3096,22 +3126,22 @@ if (err < 0) goto pop_1_error; } } - #line 3100 "Python/generated_cases.c.h" + #line 3130 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_TRUE) { PyObject *cond = stack_pointer[-1]; - #line 2216 "Python/bytecodes.c" + #line 2246 "Python/bytecodes.c" if (Py_IsTrue(cond)) { JUMPBY(oparg); } else if (!Py_IsFalse(cond)) { int err = PyObject_IsTrue(cond); - #line 3113 "Python/generated_cases.c.h" + #line 3143 "Python/generated_cases.c.h" Py_DECREF(cond); - #line 2222 "Python/bytecodes.c" + #line 2252 "Python/bytecodes.c" if (err > 0) { JUMPBY(oparg); } @@ -3119,63 +3149,63 @@ if (err < 0) goto pop_1_error; } } - #line 3123 "Python/generated_cases.c.h" + #line 3153 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NOT_NONE) { PyObject *value = stack_pointer[-1]; - #line 2232 "Python/bytecodes.c" + #line 2262 "Python/bytecodes.c" if (!Py_IsNone(value)) { - #line 3132 "Python/generated_cases.c.h" + #line 3162 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2234 "Python/bytecodes.c" + #line 2264 "Python/bytecodes.c" JUMPBY(oparg); } - #line 3137 "Python/generated_cases.c.h" + #line 3167 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(POP_JUMP_IF_NONE) { PyObject *value = stack_pointer[-1]; - #line 2239 "Python/bytecodes.c" + #line 2269 "Python/bytecodes.c" if (Py_IsNone(value)) { JUMPBY(oparg); } else { - #line 3149 "Python/generated_cases.c.h" + #line 3179 "Python/generated_cases.c.h" Py_DECREF(value); - #line 2244 "Python/bytecodes.c" + #line 2274 "Python/bytecodes.c" } - #line 3153 "Python/generated_cases.c.h" + #line 3183 "Python/generated_cases.c.h" STACK_SHRINK(1); DISPATCH(); } TARGET(JUMP_BACKWARD_NO_INTERRUPT) { - #line 2248 "Python/bytecodes.c" + #line 2278 "Python/bytecodes.c" /* This bytecode is used in the `yield from` or `await` loop. * If there is an interrupt, we want it handled in the innermost * generator or coroutine, so we deliberately do not check it here. * (see bpo-30039). */ JUMPBY(-oparg); - #line 3166 "Python/generated_cases.c.h" + #line 3196 "Python/generated_cases.c.h" DISPATCH(); } TARGET(GET_LEN) { PyObject *obj = stack_pointer[-1]; PyObject *len_o; - #line 2257 "Python/bytecodes.c" + #line 2287 "Python/bytecodes.c" // PUSH(len(TOS)) Py_ssize_t len_i = PyObject_Length(obj); if (len_i < 0) goto error; len_o = PyLong_FromSsize_t(len_i); if (len_o == NULL) goto error; - #line 3179 "Python/generated_cases.c.h" + #line 3209 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = len_o; DISPATCH(); @@ -3186,16 +3216,16 @@ PyObject *type = stack_pointer[-2]; PyObject *subject = stack_pointer[-3]; PyObject *attrs; - #line 2265 "Python/bytecodes.c" + #line 2295 "Python/bytecodes.c" // Pop TOS and TOS1. Set TOS to a tuple of attributes on success, or // None on failure. assert(PyTuple_CheckExact(names)); attrs = match_class(tstate, subject, type, oparg, names); - #line 3195 "Python/generated_cases.c.h" + #line 3225 "Python/generated_cases.c.h" Py_DECREF(subject); Py_DECREF(type); Py_DECREF(names); - #line 2270 "Python/bytecodes.c" + #line 2300 "Python/bytecodes.c" if (attrs) { assert(PyTuple_CheckExact(attrs)); // Success! } @@ -3203,7 +3233,7 @@ if (_PyErr_Occurred(tstate)) goto pop_3_error; attrs = Py_None; // Failure! } - #line 3207 "Python/generated_cases.c.h" + #line 3237 "Python/generated_cases.c.h" STACK_SHRINK(2); stack_pointer[-1] = attrs; DISPATCH(); @@ -3212,10 +3242,10 @@ TARGET(MATCH_MAPPING) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2280 "Python/bytecodes.c" + #line 2310 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_MAPPING; res = match ? Py_True : Py_False; - #line 3219 "Python/generated_cases.c.h" + #line 3249 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3225,10 +3255,10 @@ TARGET(MATCH_SEQUENCE) { PyObject *subject = stack_pointer[-1]; PyObject *res; - #line 2286 "Python/bytecodes.c" + #line 2316 "Python/bytecodes.c" int match = Py_TYPE(subject)->tp_flags & Py_TPFLAGS_SEQUENCE; res = match ? Py_True : Py_False; - #line 3232 "Python/generated_cases.c.h" + #line 3262 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; PREDICT(POP_JUMP_IF_FALSE); @@ -3239,11 +3269,11 @@ PyObject *keys = stack_pointer[-1]; PyObject *subject = stack_pointer[-2]; PyObject *values_or_none; - #line 2292 "Python/bytecodes.c" + #line 2322 "Python/bytecodes.c" // On successful match, PUSH(values). Otherwise, PUSH(None). values_or_none = match_keys(tstate, subject, keys); if (values_or_none == NULL) goto error; - #line 3247 "Python/generated_cases.c.h" + #line 3277 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = values_or_none; DISPATCH(); @@ -3252,14 +3282,14 @@ TARGET(GET_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2298 "Python/bytecodes.c" + #line 2328 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ iter = PyObject_GetIter(iterable); - #line 3259 "Python/generated_cases.c.h" + #line 3289 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2301 "Python/bytecodes.c" + #line 2331 "Python/bytecodes.c" if (iter == NULL) goto pop_1_error; - #line 3263 "Python/generated_cases.c.h" + #line 3293 "Python/generated_cases.c.h" stack_pointer[-1] = iter; DISPATCH(); } @@ -3267,7 +3297,7 @@ TARGET(GET_YIELD_FROM_ITER) { PyObject *iterable = stack_pointer[-1]; PyObject *iter; - #line 2305 "Python/bytecodes.c" + #line 2335 "Python/bytecodes.c" /* before: [obj]; after [getiter(obj)] */ if (PyCoro_CheckExact(iterable)) { /* `iterable` is a coroutine */ @@ -3290,11 +3320,11 @@ if (iter == NULL) { goto error; } - #line 3294 "Python/generated_cases.c.h" + #line 3324 "Python/generated_cases.c.h" Py_DECREF(iterable); - #line 2328 "Python/bytecodes.c" + #line 2358 "Python/bytecodes.c" } - #line 3298 "Python/generated_cases.c.h" + #line 3328 "Python/generated_cases.c.h" stack_pointer[-1] = iter; PREDICT(LOAD_CONST); DISPATCH(); @@ -3305,7 +3335,7 @@ static_assert(INLINE_CACHE_ENTRIES_FOR_ITER == 1, "incorrect cache size"); PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2347 "Python/bytecodes.c" + #line 2377 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyForIterCache *cache = (_PyForIterCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -3336,7 +3366,7 @@ DISPATCH(); } // Common case: no jump, leave it to the code generator - #line 3340 "Python/generated_cases.c.h" + #line 3370 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3344,7 +3374,7 @@ } TARGET(INSTRUMENTED_FOR_ITER) { - #line 2380 "Python/bytecodes.c" + #line 2410 "Python/bytecodes.c" _Py_CODEUNIT *here = next_instr-1; _Py_CODEUNIT *target; PyObject *iter = TOP(); @@ -3370,14 +3400,14 @@ target = next_instr + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1; } INSTRUMENTED_JUMP(here, target, PY_MONITORING_EVENT_BRANCH); - #line 3374 "Python/generated_cases.c.h" + #line 3404 "Python/generated_cases.c.h" DISPATCH(); } TARGET(FOR_ITER_LIST) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2408 "Python/bytecodes.c" + #line 2438 "Python/bytecodes.c" DEOPT_IF(Py_TYPE(iter) != &PyListIter_Type, FOR_ITER); _PyListIterObject *it = (_PyListIterObject *)iter; STAT_INC(FOR_ITER, hit); @@ -3397,7 +3427,7 @@ DISPATCH(); end_for_iter_list: // Common case: no jump, leave it to the code generator - #line 3401 "Python/generated_cases.c.h" + #line 3431 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3407,7 +3437,7 @@ TARGET(FOR_ITER_TUPLE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2430 "Python/bytecodes.c" + #line 2460 "Python/bytecodes.c" _PyTupleIterObject *it = (_PyTupleIterObject *)iter; DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3427,7 +3457,7 @@ DISPATCH(); end_for_iter_tuple: // Common case: no jump, leave it to the code generator - #line 3431 "Python/generated_cases.c.h" + #line 3461 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3437,7 +3467,7 @@ TARGET(FOR_ITER_RANGE) { PyObject *iter = stack_pointer[-1]; PyObject *next; - #line 2452 "Python/bytecodes.c" + #line 2482 "Python/bytecodes.c" _PyRangeIterObject *r = (_PyRangeIterObject *)iter; DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER); STAT_INC(FOR_ITER, hit); @@ -3455,7 +3485,7 @@ if (next == NULL) { goto error; } - #line 3459 "Python/generated_cases.c.h" + #line 3489 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = next; next_instr += 1; @@ -3464,7 +3494,7 @@ TARGET(FOR_ITER_GEN) { PyObject *iter = stack_pointer[-1]; - #line 2472 "Python/bytecodes.c" + #line 2502 "Python/bytecodes.c" DEOPT_IF(tstate->interp->eval_frame, FOR_ITER); PyGenObject *gen = (PyGenObject *)iter; DEOPT_IF(Py_TYPE(gen) != &PyGen_Type, FOR_ITER); @@ -3480,14 +3510,14 @@ assert(next_instr[oparg].op.code == END_FOR || next_instr[oparg].op.code == INSTRUMENTED_END_FOR); DISPATCH_INLINED(gen_frame); - #line 3484 "Python/generated_cases.c.h" + #line 3514 "Python/generated_cases.c.h" } TARGET(BEFORE_ASYNC_WITH) { PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2490 "Python/bytecodes.c" + #line 2520 "Python/bytecodes.c" PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__aenter__)); if (enter == NULL) { if (!_PyErr_Occurred(tstate)) { @@ -3510,16 +3540,16 @@ Py_DECREF(enter); goto error; } - #line 3514 "Python/generated_cases.c.h" + #line 3544 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2513 "Python/bytecodes.c" + #line 2543 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3523 "Python/generated_cases.c.h" + #line 3553 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3531,7 +3561,7 @@ PyObject *mgr = stack_pointer[-1]; PyObject *exit; PyObject *res; - #line 2523 "Python/bytecodes.c" + #line 2553 "Python/bytecodes.c" /* pop the context manager, push its __exit__ and the * value returned from calling its __enter__ */ @@ -3557,16 +3587,16 @@ Py_DECREF(enter); goto error; } - #line 3561 "Python/generated_cases.c.h" + #line 3591 "Python/generated_cases.c.h" Py_DECREF(mgr); - #line 2549 "Python/bytecodes.c" + #line 2579 "Python/bytecodes.c" res = _PyObject_CallNoArgs(enter); Py_DECREF(enter); if (res == NULL) { Py_DECREF(exit); if (true) goto pop_1_error; } - #line 3570 "Python/generated_cases.c.h" + #line 3600 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; stack_pointer[-2] = exit; @@ -3578,7 +3608,7 @@ PyObject *lasti = stack_pointer[-3]; PyObject *exit_func = stack_pointer[-4]; PyObject *res; - #line 2558 "Python/bytecodes.c" + #line 2588 "Python/bytecodes.c" /* At the top of the stack are 4 values: - val: TOP = exc_info() - unused: SECOND = previous exception @@ -3604,7 +3634,7 @@ res = PyObject_Vectorcall(exit_func, stack + 1, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); if (res == NULL) goto error; - #line 3608 "Python/generated_cases.c.h" + #line 3638 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = res; DISPATCH(); @@ -3613,7 +3643,7 @@ TARGET(PUSH_EXC_INFO) { PyObject *new_exc = stack_pointer[-1]; PyObject *prev_exc; - #line 2586 "Python/bytecodes.c" + #line 2616 "Python/bytecodes.c" _PyErr_StackItem *exc_info = tstate->exc_info; if (exc_info->exc_value != NULL) { prev_exc = exc_info->exc_value; @@ -3623,7 +3653,7 @@ } assert(PyExceptionInstance_Check(new_exc)); exc_info->exc_value = Py_NewRef(new_exc); - #line 3627 "Python/generated_cases.c.h" + #line 3657 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = new_exc; stack_pointer[-2] = prev_exc; @@ -3637,7 +3667,7 @@ uint32_t type_version = read_u32(&next_instr[1].cache); uint32_t keys_version = read_u32(&next_instr[3].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2598 "Python/bytecodes.c" + #line 2628 "Python/bytecodes.c" /* Cached method object */ PyTypeObject *self_cls = Py_TYPE(self); assert(type_version != 0); @@ -3654,7 +3684,7 @@ assert(_PyType_HasFeature(Py_TYPE(res2), Py_TPFLAGS_METHOD_DESCRIPTOR)); res = self; assert(oparg & 1); - #line 3658 "Python/generated_cases.c.h" + #line 3688 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3668,7 +3698,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2617 "Python/bytecodes.c" + #line 2647 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); assert(self_cls->tp_dictoffset == 0); @@ -3678,7 +3708,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3682 "Python/generated_cases.c.h" + #line 3712 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3692,7 +3722,7 @@ PyObject *res; uint32_t type_version = read_u32(&next_instr[1].cache); PyObject *descr = read_obj(&next_instr[5].cache); - #line 2629 "Python/bytecodes.c" + #line 2659 "Python/bytecodes.c" PyTypeObject *self_cls = Py_TYPE(self); DEOPT_IF(self_cls->tp_version_tag != type_version, LOAD_ATTR); Py_ssize_t dictoffset = self_cls->tp_dictoffset; @@ -3706,7 +3736,7 @@ res2 = Py_NewRef(descr); res = self; assert(oparg & 1); - #line 3710 "Python/generated_cases.c.h" + #line 3740 "Python/generated_cases.c.h" STACK_GROW(((oparg & 1) ? 1 : 0)); stack_pointer[-1] = res; if (oparg & 1) { stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))] = res2; } @@ -3715,16 +3745,16 @@ } TARGET(KW_NAMES) { - #line 2645 "Python/bytecodes.c" + #line 2675 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg < PyTuple_GET_SIZE(frame->f_code->co_consts)); kwnames = GETITEM(frame->f_code->co_consts, oparg); - #line 3723 "Python/generated_cases.c.h" + #line 3753 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_CALL) { - #line 2651 "Python/bytecodes.c" + #line 2681 "Python/bytecodes.c" int is_meth = PEEK(oparg+2) != NULL; int total_args = oparg + is_meth; PyObject *function = PEEK(total_args + 1); @@ -3737,7 +3767,7 @@ _PyCallCache *cache = (_PyCallCache *)next_instr; INCREMENT_ADAPTIVE_COUNTER(cache->counter); GO_TO_INSTRUCTION(CALL); - #line 3741 "Python/generated_cases.c.h" + #line 3771 "Python/generated_cases.c.h" } TARGET(CALL) { @@ -3747,7 +3777,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2696 "Python/bytecodes.c" + #line 2726 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -3829,7 +3859,7 @@ Py_DECREF(args[i]); } if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3833 "Python/generated_cases.c.h" + #line 3863 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3841,7 +3871,7 @@ TARGET(CALL_BOUND_METHOD_EXACT_ARGS) { PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 2784 "Python/bytecodes.c" + #line 2814 "Python/bytecodes.c" DEOPT_IF(method != NULL, CALL); DEOPT_IF(Py_TYPE(callable) != &PyMethod_Type, CALL); STAT_INC(CALL, hit); @@ -3851,7 +3881,7 @@ PEEK(oparg + 2) = Py_NewRef(meth); // method Py_DECREF(callable); GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS); - #line 3855 "Python/generated_cases.c.h" + #line 3885 "Python/generated_cases.c.h" } TARGET(CALL_PY_EXACT_ARGS) { @@ -3860,7 +3890,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2796 "Python/bytecodes.c" + #line 2826 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3886,7 +3916,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3890 "Python/generated_cases.c.h" + #line 3920 "Python/generated_cases.c.h" } TARGET(CALL_PY_WITH_DEFAULTS) { @@ -3894,7 +3924,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; uint32_t func_version = read_u32(&next_instr[1].cache); - #line 2824 "Python/bytecodes.c" + #line 2854 "Python/bytecodes.c" assert(kwnames == NULL); DEOPT_IF(tstate->interp->eval_frame, CALL); int is_meth = method != NULL; @@ -3930,7 +3960,7 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL); frame->return_offset = 0; DISPATCH_INLINED(new_frame); - #line 3934 "Python/generated_cases.c.h" + #line 3964 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_TYPE_1) { @@ -3938,7 +3968,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2862 "Python/bytecodes.c" + #line 2892 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3948,7 +3978,7 @@ res = Py_NewRef(Py_TYPE(obj)); Py_DECREF(obj); Py_DECREF(&PyType_Type); // I.e., callable - #line 3952 "Python/generated_cases.c.h" + #line 3982 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3961,7 +3991,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2874 "Python/bytecodes.c" + #line 2904 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3972,7 +4002,7 @@ Py_DECREF(arg); Py_DECREF(&PyUnicode_Type); // I.e., callable if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 3976 "Python/generated_cases.c.h" + #line 4006 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -3986,7 +4016,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *null = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2888 "Python/bytecodes.c" + #line 2918 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); DEOPT_IF(null != NULL, CALL); @@ -3997,7 +4027,7 @@ Py_DECREF(arg); Py_DECREF(&PyTuple_Type); // I.e., tuple if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4001 "Python/generated_cases.c.h" + #line 4031 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4011,7 +4041,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2902 "Python/bytecodes.c" + #line 2932 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4033,7 +4063,7 @@ } Py_DECREF(tp); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4037 "Python/generated_cases.c.h" + #line 4067 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4047,7 +4077,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2927 "Python/bytecodes.c" + #line 2957 "Python/bytecodes.c" /* Builtin METH_O functions */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4075,7 +4105,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4079 "Python/generated_cases.c.h" + #line 4109 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4089,7 +4119,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2958 "Python/bytecodes.c" + #line 2988 "Python/bytecodes.c" /* Builtin METH_FASTCALL functions, without keywords */ assert(kwnames == NULL); int is_meth = method != NULL; @@ -4121,7 +4151,7 @@ 'invalid'). In those cases an exception is set, so we must handle it. */ - #line 4125 "Python/generated_cases.c.h" + #line 4155 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4135,7 +4165,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 2993 "Python/bytecodes.c" + #line 3023 "Python/bytecodes.c" /* Builtin METH_FASTCALL | METH_KEYWORDS functions */ int is_meth = method != NULL; int total_args = oparg; @@ -4167,7 +4197,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4171 "Python/generated_cases.c.h" + #line 4201 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4181,7 +4211,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3028 "Python/bytecodes.c" + #line 3058 "Python/bytecodes.c" assert(kwnames == NULL); /* len(o) */ int is_meth = method != NULL; @@ -4206,7 +4236,7 @@ Py_DECREF(callable); Py_DECREF(arg); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4210 "Python/generated_cases.c.h" + #line 4240 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4219,7 +4249,7 @@ PyObject *callable = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3055 "Python/bytecodes.c" + #line 3085 "Python/bytecodes.c" assert(kwnames == NULL); /* isinstance(o, o2) */ int is_meth = method != NULL; @@ -4246,7 +4276,7 @@ Py_DECREF(cls); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4250 "Python/generated_cases.c.h" + #line 4280 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4258,7 +4288,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *self = stack_pointer[-(1 + oparg)]; PyObject *method = stack_pointer[-(2 + oparg)]; - #line 3085 "Python/bytecodes.c" + #line 3115 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 1); PyInterpreterState *interp = _PyInterpreterState_GET(); @@ -4276,14 +4306,14 @@ JUMPBY(INLINE_CACHE_ENTRIES_CALL + 1); assert(next_instr[-1].op.code == POP_TOP); DISPATCH(); - #line 4280 "Python/generated_cases.c.h" + #line 4310 "Python/generated_cases.c.h" } TARGET(CALL_NO_KW_METHOD_DESCRIPTOR_O) { PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3105 "Python/bytecodes.c" + #line 3135 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4314,7 +4344,7 @@ Py_DECREF(arg); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4318 "Python/generated_cases.c.h" + #line 4348 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4327,7 +4357,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3139 "Python/bytecodes.c" + #line 3169 "Python/bytecodes.c" int is_meth = method != NULL; int total_args = oparg; if (is_meth) { @@ -4356,7 +4386,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4360 "Python/generated_cases.c.h" + #line 4390 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4369,7 +4399,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3171 "Python/bytecodes.c" + #line 3201 "Python/bytecodes.c" assert(kwnames == NULL); assert(oparg == 0 || oparg == 1); int is_meth = method != NULL; @@ -4398,7 +4428,7 @@ Py_DECREF(self); Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4402 "Python/generated_cases.c.h" + #line 4432 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4411,7 +4441,7 @@ PyObject **args = (stack_pointer - oparg); PyObject *method = stack_pointer[-(2 + oparg)]; PyObject *res; - #line 3203 "Python/bytecodes.c" + #line 3233 "Python/bytecodes.c" assert(kwnames == NULL); int is_meth = method != NULL; int total_args = oparg; @@ -4439,7 +4469,7 @@ } Py_DECREF(callable); if (res == NULL) { STACK_SHRINK(oparg); goto pop_2_error; } - #line 4443 "Python/generated_cases.c.h" + #line 4473 "Python/generated_cases.c.h" STACK_SHRINK(oparg); STACK_SHRINK(1); stack_pointer[-1] = res; @@ -4449,9 +4479,9 @@ } TARGET(INSTRUMENTED_CALL_FUNCTION_EX) { - #line 3234 "Python/bytecodes.c" + #line 3264 "Python/bytecodes.c" GO_TO_INSTRUCTION(CALL_FUNCTION_EX); - #line 4455 "Python/generated_cases.c.h" + #line 4485 "Python/generated_cases.c.h" } TARGET(CALL_FUNCTION_EX) { @@ -4460,7 +4490,7 @@ PyObject *callargs = stack_pointer[-(1 + ((oparg & 1) ? 1 : 0))]; PyObject *func = stack_pointer[-(2 + ((oparg & 1) ? 1 : 0))]; PyObject *result; - #line 3238 "Python/bytecodes.c" + #line 3268 "Python/bytecodes.c" // DICT_MERGE is called before this opcode if there are kwargs. // It converts all dict subtypes in kwargs into regular dicts. assert(kwargs == NULL || PyDict_CheckExact(kwargs)); @@ -4522,14 +4552,14 @@ } result = PyObject_Call(func, callargs, kwargs); } - #line 4526 "Python/generated_cases.c.h" + #line 4556 "Python/generated_cases.c.h" Py_DECREF(func); Py_DECREF(callargs); Py_XDECREF(kwargs); - #line 3300 "Python/bytecodes.c" + #line 3330 "Python/bytecodes.c" assert(PEEK(3 + (oparg & 1)) == NULL); if (result == NULL) { STACK_SHRINK(((oparg & 1) ? 1 : 0)); goto pop_3_error; } - #line 4533 "Python/generated_cases.c.h" + #line 4563 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 1) ? 1 : 0)); STACK_SHRINK(2); stack_pointer[-1] = result; @@ -4544,7 +4574,7 @@ PyObject *kwdefaults = (oparg & 0x02) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0))] : NULL; PyObject *defaults = (oparg & 0x01) ? stack_pointer[-(1 + ((oparg & 0x08) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x01) ? 1 : 0))] : NULL; PyObject *func; - #line 3310 "Python/bytecodes.c" + #line 3340 "Python/bytecodes.c" PyFunctionObject *func_obj = (PyFunctionObject *) PyFunction_New(codeobj, GLOBALS()); @@ -4573,14 +4603,14 @@ func_obj->func_version = ((PyCodeObject *)codeobj)->co_version; func = (PyObject *)func_obj; - #line 4577 "Python/generated_cases.c.h" + #line 4607 "Python/generated_cases.c.h" STACK_SHRINK(((oparg & 0x01) ? 1 : 0) + ((oparg & 0x02) ? 1 : 0) + ((oparg & 0x04) ? 1 : 0) + ((oparg & 0x08) ? 1 : 0)); stack_pointer[-1] = func; DISPATCH(); } TARGET(RETURN_GENERATOR) { - #line 3341 "Python/bytecodes.c" + #line 3371 "Python/bytecodes.c" assert(PyFunction_Check(frame->f_funcobj)); PyFunctionObject *func = (PyFunctionObject *)frame->f_funcobj; PyGenObject *gen = (PyGenObject *)_Py_MakeCoro(func); @@ -4601,7 +4631,7 @@ frame = cframe.current_frame = prev; _PyFrame_StackPush(frame, (PyObject *)gen); goto resume_frame; - #line 4605 "Python/generated_cases.c.h" + #line 4635 "Python/generated_cases.c.h" } TARGET(BUILD_SLICE) { @@ -4609,15 +4639,15 @@ PyObject *stop = stack_pointer[-(1 + ((oparg == 3) ? 1 : 0))]; PyObject *start = stack_pointer[-(2 + ((oparg == 3) ? 1 : 0))]; PyObject *slice; - #line 3364 "Python/bytecodes.c" + #line 3394 "Python/bytecodes.c" slice = PySlice_New(start, stop, step); - #line 4615 "Python/generated_cases.c.h" + #line 4645 "Python/generated_cases.c.h" Py_DECREF(start); Py_DECREF(stop); Py_XDECREF(step); - #line 3366 "Python/bytecodes.c" + #line 3396 "Python/bytecodes.c" if (slice == NULL) { STACK_SHRINK(((oparg == 3) ? 1 : 0)); goto pop_2_error; } - #line 4621 "Python/generated_cases.c.h" + #line 4651 "Python/generated_cases.c.h" STACK_SHRINK(((oparg == 3) ? 1 : 0)); STACK_SHRINK(1); stack_pointer[-1] = slice; @@ -4628,7 +4658,7 @@ PyObject *fmt_spec = ((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? stack_pointer[-((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))] : NULL; PyObject *value = stack_pointer[-(1 + (((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0))]; PyObject *result; - #line 3370 "Python/bytecodes.c" + #line 3400 "Python/bytecodes.c" /* Handles f-string value formatting. */ PyObject *(*conv_fn)(PyObject *); int which_conversion = oparg & FVC_MASK; @@ -4663,7 +4693,7 @@ Py_DECREF(value); Py_XDECREF(fmt_spec); if (result == NULL) { STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); goto pop_1_error; } - #line 4667 "Python/generated_cases.c.h" + #line 4697 "Python/generated_cases.c.h" STACK_SHRINK((((oparg & FVS_MASK) == FVS_HAVE_SPEC) ? 1 : 0)); stack_pointer[-1] = result; DISPATCH(); @@ -4672,10 +4702,10 @@ TARGET(COPY) { PyObject *bottom = stack_pointer[-(1 + (oparg-1))]; PyObject *top; - #line 3407 "Python/bytecodes.c" + #line 3437 "Python/bytecodes.c" assert(oparg > 0); top = Py_NewRef(bottom); - #line 4679 "Python/generated_cases.c.h" + #line 4709 "Python/generated_cases.c.h" STACK_GROW(1); stack_pointer[-1] = top; DISPATCH(); @@ -4687,7 +4717,7 @@ PyObject *rhs = stack_pointer[-1]; PyObject *lhs = stack_pointer[-2]; PyObject *res; - #line 3412 "Python/bytecodes.c" + #line 3442 "Python/bytecodes.c" #if ENABLE_SPECIALIZATION _PyBinaryOpCache *cache = (_PyBinaryOpCache *)next_instr; if (ADAPTIVE_COUNTER_IS_ZERO(cache->counter)) { @@ -4702,12 +4732,12 @@ assert((unsigned)oparg < Py_ARRAY_LENGTH(binary_ops)); assert(binary_ops[oparg]); res = binary_ops[oparg](lhs, rhs); - #line 4706 "Python/generated_cases.c.h" + #line 4736 "Python/generated_cases.c.h" Py_DECREF(lhs); Py_DECREF(rhs); - #line 3427 "Python/bytecodes.c" + #line 3457 "Python/bytecodes.c" if (res == NULL) goto pop_2_error; - #line 4711 "Python/generated_cases.c.h" + #line 4741 "Python/generated_cases.c.h" STACK_SHRINK(1); stack_pointer[-1] = res; next_instr += 1; @@ -4717,16 +4747,16 @@ TARGET(SWAP) { PyObject *top = stack_pointer[-1]; PyObject *bottom = stack_pointer[-(2 + (oparg-2))]; - #line 3432 "Python/bytecodes.c" + #line 3462 "Python/bytecodes.c" assert(oparg >= 2); - #line 4723 "Python/generated_cases.c.h" + #line 4753 "Python/generated_cases.c.h" stack_pointer[-1] = bottom; stack_pointer[-(2 + (oparg-2))] = top; DISPATCH(); } TARGET(INSTRUMENTED_INSTRUCTION) { - #line 3436 "Python/bytecodes.c" + #line 3466 "Python/bytecodes.c" int next_opcode = _Py_call_instrumentation_instruction( tstate, frame, next_instr-1); if (next_opcode < 0) goto error; @@ -4738,26 +4768,26 @@ assert(next_opcode > 0 && next_opcode < 256); opcode = next_opcode; DISPATCH_GOTO(); - #line 4742 "Python/generated_cases.c.h" + #line 4772 "Python/generated_cases.c.h" } TARGET(INSTRUMENTED_JUMP_FORWARD) { - #line 3450 "Python/bytecodes.c" + #line 3480 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr+oparg, PY_MONITORING_EVENT_JUMP); - #line 4748 "Python/generated_cases.c.h" + #line 4778 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_JUMP_BACKWARD) { - #line 3454 "Python/bytecodes.c" + #line 3484 "Python/bytecodes.c" INSTRUMENTED_JUMP(next_instr-1, next_instr-oparg, PY_MONITORING_EVENT_JUMP); - #line 4755 "Python/generated_cases.c.h" + #line 4785 "Python/generated_cases.c.h" CHECK_EVAL_BREAKER(); DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_TRUE) { - #line 3459 "Python/bytecodes.c" + #line 3489 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4766,12 +4796,12 @@ assert(err == 0 || err == 1); int offset = err*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4770 "Python/generated_cases.c.h" + #line 4800 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_FALSE) { - #line 3470 "Python/bytecodes.c" + #line 3500 "Python/bytecodes.c" PyObject *cond = POP(); int err = PyObject_IsTrue(cond); Py_DECREF(cond); @@ -4780,12 +4810,12 @@ assert(err == 0 || err == 1); int offset = (1-err)*oparg; INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4784 "Python/generated_cases.c.h" + #line 4814 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NONE) { - #line 3481 "Python/bytecodes.c" + #line 3511 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4797,12 +4827,12 @@ offset = 0; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4801 "Python/generated_cases.c.h" + #line 4831 "Python/generated_cases.c.h" DISPATCH(); } TARGET(INSTRUMENTED_POP_JUMP_IF_NOT_NONE) { - #line 3495 "Python/bytecodes.c" + #line 3525 "Python/bytecodes.c" PyObject *value = POP(); _Py_CODEUNIT *here = next_instr-1; int offset; @@ -4814,30 +4844,30 @@ offset = oparg; } INSTRUMENTED_JUMP(here, next_instr + offset, PY_MONITORING_EVENT_BRANCH); - #line 4818 "Python/generated_cases.c.h" + #line 4848 "Python/generated_cases.c.h" DISPATCH(); } TARGET(EXTENDED_ARG) { - #line 3509 "Python/bytecodes.c" + #line 3539 "Python/bytecodes.c" assert(oparg); opcode = next_instr->op.code; oparg = oparg << 8 | next_instr->op.arg; PRE_DISPATCH_GOTO(); DISPATCH_GOTO(); - #line 4829 "Python/generated_cases.c.h" + #line 4859 "Python/generated_cases.c.h" } TARGET(CACHE) { - #line 3517 "Python/bytecodes.c" + #line 3547 "Python/bytecodes.c" assert(0 && "Executing a cache."); Py_UNREACHABLE(); - #line 4836 "Python/generated_cases.c.h" + #line 4866 "Python/generated_cases.c.h" } TARGET(RESERVED) { - #line 3522 "Python/bytecodes.c" + #line 3552 "Python/bytecodes.c" assert(0 && "Executing RESERVED instruction."); Py_UNREACHABLE(); - #line 4843 "Python/generated_cases.c.h" + #line 4873 "Python/generated_cases.c.h" }