- /* Trampoline entry point.
- * The sole purpose of the trampoline is to cheese Lightning not to
- * save/restore the callee-saved register LIGHTREC_REG_CYCLE, since we
- * do want to return to the caller with this register modified. */
- jit_prolog();
- jit_tramp(256);
- jit_patch(to_tramp);
-
- /* Retrieve the wrapper function */
- jit_ldxi(JIT_R0, LIGHTREC_REG_STATE,
- offsetof(struct lightrec_state, c_wrappers));
-
- /* Restore LIGHTREC_REG_STATE to its correct value */
- jit_movi(LIGHTREC_REG_STATE, (uintptr_t) state);
+ /* delta = state->target_cycle - state->current_cycle */;
+ jit_ldxi_ui(LIGHTREC_REG_CYCLE, LIGHTREC_REG_STATE,
+ offsetof(struct lightrec_state, current_cycle));
+ jit_ldxi_ui(JIT_R1, LIGHTREC_REG_STATE,
+ offsetof(struct lightrec_state, target_cycle));
+ jit_subr(LIGHTREC_REG_CYCLE, JIT_R1, LIGHTREC_REG_CYCLE);