Skip to content

Commit 4100934

Browse files
Fix bugs
1 parent ca6e42c commit 4100934

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ dummy_func(
346346
}
347347

348348
op(_POP_TOP_NOP, (value --)) {
349-
assert(!PyStackRef_RefcountOnObject(value) ||
349+
assert(PyStackRef_IsNull(value) || (!PyStackRef_RefcountOnObject(value)) ||
350350
_Py_IsImmortal((PyStackRef_AsPyObjectBorrow(value))));
351351
DEAD(value);
352352
}

Python/executor_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_analysis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
345345
#define sym_new_tuple _Py_uop_sym_new_tuple
346346
#define sym_tuple_getitem _Py_uop_sym_tuple_getitem
347347
#define sym_tuple_length _Py_uop_sym_tuple_length
348-
#define sym_is_immortal _Py_uop_sym_is_immortal
348+
#define sym_is_immortal _Py_uop_symbol_is_immortal
349349
#define sym_is_compact_int _Py_uop_sym_is_compact_int
350350
#define sym_new_compact_int _Py_uop_sym_new_compact_int
351351
#define sym_new_truthiness _Py_uop_sym_new_truthiness

Python/optimizer_bytecodes.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame;
3434
#define sym_new_tuple _Py_uop_sym_new_tuple
3535
#define sym_tuple_getitem _Py_uop_sym_tuple_getitem
3636
#define sym_tuple_length _Py_uop_sym_tuple_length
37-
#define sym_is_immortal _Py_uop_sym_is_immortal
37+
#define sym_is_immortal _Py_uop_symbol_is_immortal
3838
#define sym_new_compact_int _Py_uop_sym_new_compact_int
3939
#define sym_is_compact_int _Py_uop_sym_is_compact_int
4040
#define sym_new_truthiness _Py_uop_sym_new_truthiness
@@ -535,15 +535,15 @@ dummy_func(void) {
535535
}
536536

537537
op(_LOAD_CONST_INLINE, (ptr/4 -- value)) {
538-
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
538+
value = sym_new_const(ctx, ptr);
539539
}
540540

541541
op(_LOAD_CONST_INLINE_BORROW, (ptr/4 -- value)) {
542542
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
543543
}
544544

545545
op(_POP_TOP_LOAD_CONST_INLINE, (ptr/4, pop -- value)) {
546-
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
546+
value = sym_new_const(ctx, ptr);
547547
}
548548

549549
op(_POP_TOP_LOAD_CONST_INLINE_BORROW, (ptr/4, pop -- value)) {
@@ -564,9 +564,8 @@ dummy_func(void) {
564564

565565
op(_POP_TOP, (value -- )) {
566566
PyTypeObject *typ = sym_get_type(value);
567-
PyObject *const_val = sym_get_const(ctx, value);
568567
if (PyJitRef_IsBorrowed(value) ||
569-
sym_is_immortal(value) ||
568+
sym_is_immortal(PyJitRef_Unwrap(value)) ||
570569
sym_is_null(value)) {
571570
REPLACE_OP(this_instr, _POP_TOP_NOP, 0, 0);
572571
}
@@ -823,7 +822,9 @@ dummy_func(void) {
823822
}
824823

825824
op(_RETURN_VALUE, (retval -- res)) {
826-
JitOptRef temp = retval;
825+
// We wrap and unwrap the value to mimic PyStackRef_MakeHeapSafe
826+
// in bytecodes.c
827+
JitOptRef temp = PyJitRef_Wrap(PyJitRef_Unwrap(retval));
827828
DEAD(retval);
828829
SAVE_STACK();
829830
ctx->frame->stack_pointer = stack_pointer;

Python/optimizer_cases.c.h

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer_symbols.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,6 @@ _Py_uop_symbol_is_immortal(JitOptSymbol *sym)
668668
if (sym->tag == JIT_SYM_KNOWN_CLASS_TAG) {
669669
return sym->cls.type == &PyBool_Type;
670670
}
671-
if (sym->tag == JIT_SYM_TRUTHINESS_TAG) {
672-
return true;
673-
}
674671
return false;
675672
}
676673

0 commit comments

Comments
 (0)