8000 set IS_NULL as a flag · python/cpython@40a19f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 40a19f7

Browse files
set IS_NULL as a flag
1 parent 35227f8 commit 40a19f7

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Python/optimizer_analysis.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
// Flags for below.
6464
#define KNOWN_TYPE 1 << 0 // Just to differentiate NULL in typ
6565
#define TRUE_CONST 1 << 1
66-
#define NOT_NULL 1 << 2
66+
#define IS_NULL 1 << 2
67+
#define NOT_NULL 1 << 3
6768

6869
typedef struct {
6970
int flags;
@@ -255,6 +256,12 @@ sym_set_flag(_Py_UOpsSymType *sym, int flag)
255256
sym->flags |= flag;
256257
}
257258

259+
static inline void
260+
sym_clear_flag(_Py_UOpsSymType *sym, int flag)
261+
{
262+
sym->flags &= (~flag);
263+
}
264+
258265
static inline bool
259266
sym_has_flag(_Py_UOpsSymType *sym, int flag)
260267
{
@@ -269,6 +276,13 @@ sym_set_type(_Py_UOpsSymType *sym, PyTypeObject *tp)
269276
sym_set_flag(sym, KNOWN_TYPE);
270277
}
271278

279+
static inline void
280+
sym_set_null(_Py_UOpsSymType *sym)
281+
{
282+
sym_set_flag(sym, IS_NULL);
283+
sym_clear_flag(sym, NOT_NULL);
284+
}
285+
272286

273287
static inline _Py_UOpsSymType*
274288
sym_new_unknown(_Py_UOpsAbstractInterpContext *ctx)
@@ -326,7 +340,7 @@ sym_new_null(_Py_UOpsAbstractInterpContext *ctx)
326340
if (null_sym == NULL) {
327341
return NULL;
328342
}
329-
sym_set_type(null_sym, NULL);
343+
sym_set_null(null_sym);
330344
ctx->frequent_syms.push_nulL_sym = null_sym;
331345
return null_sym;
332346
}

Python/tier2_redundancy_eliminator_bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dummy_func(void) {
3232
op(_LOAD_FAST_CHECK, (-- value)) {
3333
value = GETLOCAL(oparg);
3434
// We guarantee this will error - just bail and don't optimize it.
35-
if (sym_matches_type(value, NULL)) {
35+
if (sym_has_flag(value, IS_NULL)) {
3636
goto out_of_space;
3737
}
3838
}
@@ -179,7 +179,7 @@ dummy_func(void) {
179179
}
180180

181181
op(_CHECK_CALL_BOUND_METHOD_EXACT_ARGS, (callable, null, unused[oparg] -- callable, null, unused[oparg])) {
182-
sym_set_type(null, NULL);
182+
sym_set_null(null);
183183
sym_set_type(callable, &PyMethod_Type);
184184
}
185185

Python/tier2_redundancy_eliminator_cases.c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
_Py_UOpsSymType *value;
1818
value = GETLOCAL(oparg);
1919
// We guarantee this will error - just bail and don't optimize it.
20-
if (sym_matches_type(value, NULL)) {
20+
if (sym_has_flag(value, IS_NULL)) {
2121
goto out_of_space;
2222
}
2323
stack_pointer[0] = value;
@@ -1243,7 +1243,7 @@
12431243
_Py_UOpsSymType *callable;
12441244
null = stack_pointer[-1 - oparg];
12451245
callable = stack_pointer[-2 - oparg];
1246-
sym_set_type(null, NULL);
1246+
sym_set_null(null);
12471247
sym_set_type(callable, &PyMethod_Type);
12481248
break;
12491249
}

0 commit comments

Comments
 (0)
0