bpo-43693: Un-revert commit f3fa63e. (#26609)

This was reverted in GH-26596 (commit 6d518bb) due to some bad memory accesses.

* Add the MAKE_CELL opcode. (gh-26396)

The memory accesses have been fixed.

https://bugs.python.org/issue43693
This commit is contained in:
Eric Snow 2021-06-08 16:01:34 -06:00 committed by GitHub
parent ab36b9f834
commit 3e1c7167d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 4470 additions and 4234 deletions

View file

@ -2,9 +2,16 @@
# error "this header file must not be included directly"
#endif
/* Each instruction in a code object is a fixed-width value,
* currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG
* opcode allows for larger values but the current limit is 3 uses
* of EXTENDED_ARG (see Python/wordcode_helpers.h), for a maximum
* 32-bit value. This aligns with the note in Python/compile.c
* (compiler_addop_i_line) indicating that the max oparg value is
* 2**32 - 1, rather than INT_MAX.
*/
typedef uint16_t _Py_CODEUNIT;
// Each oparg must fit in the second half of _Py_CODEUNIT, hence 8 bits.
#define _Py_MAX_OPARG 255
#ifdef WORDS_BIGENDIAN
# define _Py_OPCODE(word) ((word) >> 8)

View file

@ -32,6 +32,8 @@ _PyFrame_GetBuiltins(PyFrameObject *f)
int _PyFrame_TakeLocals(PyFrameObject *f);
PyAPI_FUNC(int) _PyFrame_OpAlreadyRan(PyFrameObject *f, int opcode, int oparg);
#ifdef __cplusplus
}
#endif

9
Include/opcode.h generated
View file

@ -113,10 +113,11 @@ extern "C" {
#define CALL_FUNCTION 131
#define MAKE_FUNCTION 132
#define BUILD_SLICE 133
#define LOAD_CLOSURE 135
#define LOAD_DEREF 136
#define STORE_DEREF 137
#define DELETE_DEREF 138
#define MAKE_CELL 135
#define LOAD_CLOSURE 136
#define LOAD_DEREF 137
#define STORE_DEREF 138
#define DELETE_DEREF 139
#define CALL_FUNCTION_KW 141
#define CALL_FUNCTION_EX 142
#define EXTENDED_ARG 144