Skip to content

Instantly share code, notes, and snippets.

@tonybaloney
Created January 9, 2024 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonybaloney/7e12e416ad69968e297547498f7bcde1 to your computer and use it in GitHub Desktop.
Save tonybaloney/7e12e416ad69968e297547498f7bcde1 to your computer and use it in GitHub Desktop.
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