Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py/vm: Add macros to hook into various points in the VM.
These can be used to insert arbitrary checks, polling, etc into the VM. They are left general because the VM is a highly tuned loop and it should be up to a given port how that port wants to modify the VM internals. One common use would be to insert a polling check, but only done after a certain number of opcodes were executed, so as not to slow down the VM too much. For example: #define MICROPY_VM_HOOK_COUNT (30) #define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT #define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \ vm_hook_divisor = MICROPY_VM_HOOK_COUNT; extern void vm_hook_function(void); vm_hook_function(); } #define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL #define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
- Loading branch information