Skip to content

Conversation

@pfalcon
Copy link
Contributor

@pfalcon pfalcon commented Dec 10, 2018

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).

@pfalcon
Copy link
Contributor Author

pfalcon commented Dec 10, 2018

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.

@malinah
Copy link
Contributor

malinah commented Dec 12, 2018

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.

@pfalcon
Copy link
Contributor Author

pfalcon commented Dec 12, 2018

I think your patch will break after a function/generator return.

Will look into that.

I had to do the same thing for my branch #4265 but I have yet to push the new code.

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).
@dpgeorge
Copy link
Member

This functionality was added as part of the profiling support in 310b3d1

@dpgeorge dpgeorge closed this Sep 26, 2019
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Mar 9, 2021
Enable EVE low-level for Teensy 4.0 and 4.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants