Skip to content

gh-143946: Show JitOptSymbol on abstract stack when set PYTHON_OPT_DEBUG > 4#143957

Merged
Fidget-Spinner merged 7 commits intopython:mainfrom
cocolato:add_debug_info
Jan 17, 2026
Merged

gh-143946: Show JitOptSymbol on abstract stack when set PYTHON_OPT_DEBUG > 4#143957
Fidget-Spinner merged 7 commits intopython:mainfrom
cocolato:add_debug_info

Conversation

@cocolato
Copy link
Copy Markdown
Member

@cocolato cocolato commented Jan 17, 2026

Now we can get more debug info when set PYTHON_OPT_DEBUG > 4:

test_code:

def foo():
    total = 0
    for i in range(4002):
        total = total + i
    return total

foo()

Run PYTHON_OPT_DEBUG=5 ./python test.py

will get output:
debug.log

Comment thread Python/optimizer_symbols.c
@Fidget-Spinner Fidget-Spinner changed the title gh-143946: Show _JitSymType on abstract stack when set PYTHON_OPT_DEBUG > 4 gh-143946: Show JitOptSymbol on abstract stack when set PYTHON_OPT_DEBUG > 4 Jan 17, 2026
@Fidget-Spinner
Copy link
Copy Markdown
Member

I think we also need to add an invalid tag to the JIT ref tags. Otherwise, this might crash when we push an abstract frame onto the stack. The abstract frame should be marked as invalid.

@cocolato
Copy link
Copy Markdown
Member Author

updated!

@Fidget-Spinner
Copy link
Copy Markdown
Member

Fidget-Spinner commented Jan 17, 2026

Sorry that's the wrong tag, it should the tag in pycore_optimizer.h. E.g. #define REF_IS_BORROWED 1 is one of them. I think the invalid tag should follow pycore_stackref.h's number

@cocolato
Copy link
Copy Markdown
Member Author

I think we also need to add an invalid tag to the JIT ref tags. Otherwise, this might crash when we push an abstract frame onto the stack. The abstract frame should be marked as invalid.

Sorry about that, I've just figured out the bitwise operations here.

Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@Fidget-Spinner Fidget-Spinner merged commit 61ec66a into python:main Jan 17, 2026
67 checks passed
@cocolato cocolato deleted the add_debug_info branch January 20, 2026 14:13
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants