Created
January 9, 2024 04:29
-
-
Save tonybaloney/7e12e416ad69968e297547498f7bcde1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _testinternalcapi | |
def get_executors(func): | |
code = func.__code__ | |
co_code = code.co_code | |
executors = {} | |
for i in range(0, len(co_code), 2): | |
try: | |
executors[i] = co_code[i], _testinternalcapi.get_executor(code, i) | |
except ValueError: | |
pass | |
return executors | |
def testfunc(x): | |
i = 0 | |
while i < x: | |
i += 1 | |
testfunc(20) | |
ex = get_executors(testfunc) | |
with open('jit_dump.raw', 'wb') as dumpfile: | |
for i, executor in ex.items(): | |
print(i, executor[0], executor[1]) | |
try: | |
code = executor[1].get_jit_code() | |
dumpfile.write(code) | |
except ValueError: | |
print('Failed to get JIT code for', executor[0]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment