Closed
Description
Feature or enhancement
Proposal:
I would like to add a method to the UOpExecutor type to expose the JIT code via a byte string using the jit_code
and jit_size
fields of the executor object. This would be useful for testing and debugging, as well as verification code.
from _opcode import get_executor
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], 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])
def f():
a = [0, 1, 2, 3]
return a[1]
Has this already been discussed elsewhere?
Links to previous discussion of this feature:
No response