gh-105481: remove HAS_ARG, HAS_CONST, IS_JUMP_OPCODE, IS_PSEUDO_OPCODE and replace by their new versions (#105865)

This commit is contained in:
Irit Katriel 2023-06-17 17:00:16 +01:00 committed by GitHub
parent 34e93d3998
commit 14d01262da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 38 additions and 138 deletions

View file

@ -12,24 +12,11 @@ extern "C" {
#include "opcode.h"
extern const uint32_t _PyOpcode_Jump[9];
extern const uint8_t _PyOpcode_Caches[256];
extern const uint8_t _PyOpcode_Deopt[256];
#ifdef NEED_OPCODE_TABLES
const uint32_t _PyOpcode_Jump[9] = {
0U,
0U,
536870912U,
135020544U,
4163U,
0U,
0U,
0U,
48U,
};
const uint8_t _PyOpcode_Caches[256] = {
[BINARY_SUBSCR] = 1,

View file

@ -15,10 +15,7 @@ extern "C" {
#define IS_WITHIN_OPCODE_RANGE(opcode) \
(((opcode) >= 0 && (opcode) <= MAX_REAL_OPCODE) || \
IS_PSEUDO_OPCODE(opcode))
#define IS_JUMP_OPCODE(opcode) \
is_bit_set_in_table(_PyOpcode_Jump, opcode)
IS_PSEUDO_INSTR(opcode))
#define IS_BLOCK_PUSH_OPCODE(opcode) \
((opcode) == SETUP_FINALLY || \
@ -55,27 +52,6 @@ extern "C" {
(opcode) == RAISE_VARARGS || \
(opcode) == RERAISE)
#define LOG_BITS_PER_INT 5
#define MASK_LOW_LOG_BITS 31
static inline int
is_bit_set_in_table(const uint32_t *table, int bitindex) {
/* Is the relevant bit set in the relevant word? */
/* 512 bits fit into 9 32-bits words.
* Word is indexed by (bitindex>>ln(size of int in bits)).
* Bit within word is the low bits of bitindex.
*/
if (bitindex >= 0 && bitindex < 512) {
uint32_t word = table[bitindex >> LOG_BITS_PER_INT];
return (word >> (bitindex & MASK_LOW_LOG_BITS)) & 1;
}
else {
return 0;
}
}
#undef LOG_BITS_PER_INT
#undef MASK_LOW_LOG_BITS
/* Flags used in the oparg for MAKE_FUNCTION */
#define MAKE_FUNCTION_DEFAULTS 0x01

19
Include/opcode.h generated
View file

@ -50,7 +50,6 @@ extern "C" {
#define SETUP_ANNOTATIONS 85
#define LOAD_LOCALS 87
#define POP_EXCEPT 89
#define HAVE_ARGUMENT 90
#define STORE_NAME 90
#define DELETE_NAME 91
#define UNPACK_SEQUENCE 92
@ -219,22 +218,6 @@ extern "C" {
#define UNPACK_SEQUENCE_TWO_TUPLE 160
#define SEND_GEN 161
#define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\
|| ((op) == JUMP) \
|| ((op) == JUMP_NO_INTERRUPT) \
|| ((op) == LOAD_METHOD) \
|| ((op) == LOAD_SUPER_METHOD) \
|| ((op) == LOAD_ZERO_SUPER_METHOD) \
|| ((op) == LOAD_ZERO_SUPER_ATTR) \
|| ((op) == STORE_FAST_MAYBE_NULL) \
)
#define HAS_CONST(op) (false\
|| ((op) == LOAD_CONST) \
|| ((op) == RETURN_CONST) \
|| ((op) == KW_NAMES) \
)
#define NB_ADD 0
#define NB_AND 1
#define NB_FLOOR_DIVIDE 2
@ -265,8 +248,6 @@ extern "C" {
/* Defined in Lib/opcode.py */
#define ENABLE_SPECIALIZATION 1
#define IS_PSEUDO_OPCODE(op) (((op) >= MIN_PSEUDO_OPCODE) && ((op) <= MAX_PSEUDO_OPCODE))
#ifdef __cplusplus
}
#endif