Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
cc44d3b4af267eea8bea2a3ad259File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
…ute it all the time when tracing.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
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 |
|---|---|---|
| @@ -9,6 +9,7 @@ | ||
| import collections | ||
| import contextlib | ||
| import os | ||
| import opcode | ||
| import re | ||
| import time | ||
| import types | ||
| @@ -20,6 +21,9 @@ | ||
| verbose = False | ||
| identifiers, strings = get_identifiers_and_strings() | ||
| RESUME = opcode.opmap["RESUME"] | ||
| del opcode | ||
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 +271,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})") | ||