py/objfun: Store/allow to access code state structure of current code.#4342
py/objfun: Store/allow to access code state structure of current code.#4342pfalcon wants to merge 1 commit intomicropython:masterfrom
Conversation
|
I had an adhoc version of this patch in my local branch since 2014, to support introspection into VM execution context (e.g. for JIT experiments). #4265 likewise adds this feature, but again named in adhoc way as profiling-specific feature. Finally, I got the need for the same looking into implementing line number information for warnings for #4309, hence this generalized patch. |
|
Hi. I think your patch will break after a function/generator return. The MP_STATE_THREAD(code_state) will hold old pointer. You have to wrap every instruction calling mp_execute_bytecode (MP_BC_CALL_FUNCTION, MP_BC_CALL_METHOD, ...) inside the mp_execute_bytecode function to re-set the actual code_state when the instruction is done. I had to do the same thing for my branch #4265 but I have yet to push the new code. |
Will look into that.
Yeah, the idea is that this would replace that code. |
Store pointer to mp_code_state_t of the currently running function/generator in MP_STATE_THREAD, thus allowing to access it outside the VM mainloop. The immediate usecase for this is implementing line number reporting for warnings, but it has more usages, e.g. introspection of bytecode execution (profiling, etc).
|
This functionality was added as part of the profiling support in 310b3d1 |
Enable EVE low-level for Teensy 4.0 and 4.1
Store pointer to mp_code_state_t of the currently running function/generator
in MP_STATE_THREAD, thus allowing to access it outside the VM mainloop.
The immediate usecase for this is implementing line number reporting for
warnings, but it has more usages, e.g. introspection of bytecode execution
(profiling, etc).