-
Notifications
You must be signed in to change notification settings - Fork 33.8k
GH-93516: Store offset of first traceable instruction in code object #93769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cc44d3b
4af267e
ea8bea2
a3ad259
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Store offset of first traceable instruction in code object to avoid having | ||
| to recompute it for each instruction when tracing. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,9 @@ | |
| verbose = False | ||
| identifiers, strings = get_identifiers_and_strings() | ||
|
|
||
| # This must be kept in sync with opcode.py | ||
| RESUME = 151 | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this be
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that would introduce a dependency on the latest opcode.py which would mean you cannot run deepfreeze.py with e.g. Python 3.10. On Windows and for cross compilations we need to be able to do that. (Windows doesn't have a separate bootstrap Python because it would near-doubel build times.) We started with this (see #93771). |
||
| def isprintable(b: bytes) -> bool: | ||
| return all(0x20 <= c < 0x7f for c in b) | ||
|
|
||
|
|
@@ -267,6 +270,10 @@ def generate_code(self, name: str, code: types.CodeType) -> str: | |
| self.write(f".co_qualname = {co_qualname},") | ||
| self.write(f".co_linetable = {co_linetable},") | ||
| self.write(f".co_code_adaptive = {co_code_adaptive},") | ||
| for i, op in enumerate(code.co_code[::2]): | ||
| if op == RESUME: | ||
| self.write(f"._co_firsttraceable = {i},") | ||
| break | ||
| name_as_code = f"(PyCodeObject *)&{name}" | ||
| self.deallocs.append(f"_PyStaticCode_Dealloc({name_as_code});") | ||
| self.interns.append(f"_PyStaticCode_InternStrings({name_as_code})") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.