diff options
author | Andy Wingo <wingo@pobox.com> | 2018-08-12 15:57:53 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2018-08-12 15:57:53 +0200 |
commit | a20feea43e3a8cf2460c254fb65d5e3aed6bd756 (patch) | |
tree | 0db0ea0e21515d6eddc3055c4ad4a5b1613c4904 /libguile/intrinsics.h | |
parent | 939b1ae23f680365fb6fd0a78653a281aaed95b6 (diff) | |
download | guile-a20feea43e3a8cf2460c254fb65d5e3aed6bd756.tar.gz |
Continuations capture machine code address
* libguile/continuations.c (scm_i_continuation_to_frame): Adapt to vra
field renaming.
(scm_i_reinstate_continuation, grow_stack, copy_stack_and_call)
(scm_dynthrow): Take mra of continuation. Set on the vp before the
longjmp.
* libguile/continuations.h: Update scm_i_reinstate_continuation
prototype.
* libguile/dynstack.h:
* libguile/control.c (scm_suspendable_continuation_p):
* libguile/dynstack.c (PROMPT_WORDS, PROMPT_VRA, PROMPT_MRA):
(PROMPT_JMPBUF, scm_dynstack_push_prompt, scm_dynstack_find_prompt)
(scm_dynstack_wind_prompt): Store both virtual and machine return
addresses on the dynstack, for prompts.
* libguile/eval.c (eval): Pass NULL for mra.
* libguile/intrinsics.c (push_prompt): Add mra arg, and pass it to the
dynstack.
* libguile/intrinsics.h: Update prototypes so that continuation-related
intrinsics can save and restore the MRA.
* libguile/jit.h:
* libguile/jit.c: Return VRA when JIT code needs to tier down.
* libguile/stacks.c (find_prompt, scm_make_stack)
* libguile/throw.c (catch): Adapt find-prompt calls.
* libguile/vm-engine.c (instrument-entry, instrument-loop): Add logic to
continue with vcode after the mcode finishes.
(compose-continuation, capture-continuation, abort, prompt): Add logic
to pass NULL as captured MRA, but continue with mcode from new
continuations, if appropriate.
* libguile/vm.c (scm_i_vm_cont_to_frame, capture_stack)
(scm_i_capture_current_stack, reinstate_continuation_x)
(capture_continuation, compose_continuation_inner, compose_continuation)
(capture_delimited_continuation, abort_to_prompt): Adapt to plumb
around machine code continuations.
(scm_call_n): Check "mra_after_abort" field for machine code
continuation, if any.
* libguile/vm.h (struct scm_vm): Add "mra_after_abort" field.
(struct scm_vm_cont): Rename "ra" field to "vra" and add "mra" field.
Diffstat (limited to 'libguile/intrinsics.h')
-rw-r--r-- | libguile/intrinsics.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libguile/intrinsics.h b/libguile/intrinsics.h index 877aced04..aa2355bf1 100644 --- a/libguile/intrinsics.h +++ b/libguile/intrinsics.h @@ -61,12 +61,15 @@ typedef void (*scm_t_scm_noreturn_intrinsic) (SCM) SCM_NORETURN; typedef void (*scm_t_u32_noreturn_intrinsic) (uint32_t) SCM_NORETURN; typedef SCM (*scm_t_scm_from_thread_u64_intrinsic) (scm_thread*, uint64_t); typedef SCM (*scm_t_scm_from_thread_intrinsic) (scm_thread*); -typedef void (*scm_t_thread_u8_scm_sp_vra_intrinsic) (scm_thread*, - uint8_t, SCM, - const union scm_vm_stack_element*, - uint32_t*); +typedef void (*scm_t_thread_u8_scm_sp_vra_mra_intrinsic) (scm_thread*, + uint8_t, SCM, + const union scm_vm_stack_element*, + uint32_t*, uint8_t*); typedef void (*scm_t_thread_mra_intrinsic) (scm_thread*, uint8_t*); typedef uint32_t* (*scm_t_vra_from_thread_intrinsic) (scm_thread*); +typedef uint8_t* (*scm_t_mra_from_thread_scm_intrinsic) (scm_thread*, SCM); +typedef uint8_t* (*scm_t_mra_from_thread_mra_intrinsic) (scm_thread*, uint8_t*); +typedef SCM (*scm_t_scm_from_thread_mra_intrinsic) (scm_thread*, uint8_t*); #define SCM_FOR_ALL_VM_INTRINSICS(M) \ M(scm_from_scm_scm, add, "add", ADD) \ @@ -118,10 +121,10 @@ typedef uint32_t* (*scm_t_vra_from_thread_intrinsic) (scm_thread*); M(thread_mra, push_interrupt_frame, "push-interrupt-frame", PUSH_INTERRUPT_FRAME) \ M(thread_scm_scm, foreign_call, "foreign-call", FOREIGN_CALL) \ M(thread_scm_noreturn, reinstate_continuation_x, "reinstate-continuation!", REINSTATE_CONTINUATION_X) \ - M(scm_from_thread, capture_continuation, "capture-continuation", CAPTURE_CONTINUATION) \ - M(thread_scm, compose_continuation, "compose-continuation", COMPOSE_CONTINUATION) \ + M(scm_from_thread_mra, capture_continuation, "capture-continuation", CAPTURE_CONTINUATION) \ + M(mra_from_thread_scm, compose_continuation, "compose-continuation", COMPOSE_CONTINUATION) \ M(int_from_scm, rest_arg_length, "rest-arg-length", REST_ARG_LENGTH) \ - M(thread, abort_to_prompt, "abort-to-prompt", ABORT_TO_PROMPT) \ + M(mra_from_thread_mra, abort_to_prompt, "abort-to-prompt", ABORT_TO_PROMPT) \ M(scm_scm_noreturn, throw_, "throw", THROW) \ M(scm_scm_noreturn, throw_with_value, "throw/value", THROW_WITH_VALUE) \ M(scm_scm_noreturn, throw_with_value_and_data, "throw/value+data", THROW_WITH_VALUE_AND_DATA) \ @@ -132,7 +135,7 @@ typedef uint32_t* (*scm_t_vra_from_thread_intrinsic) (scm_thread*); M(vra_from_thread, get_callee_vcode, "get-callee-vcode", GET_CALLEE_VCODE) \ M(scm_from_thread_u64, allocate_words, "allocate-words", ALLOCATE_WORDS) \ M(scm_from_thread, current_module, "current-module", CURRENT_MODULE) \ - M(thread_u8_scm_sp_vra, push_prompt, "push-prompt", PUSH_PROMPT) \ + M(thread_u8_scm_sp_vra_mra, push_prompt, "push-prompt", PUSH_PROMPT) \ M(thread_scm, unpack_values_object, "unpack-values-object", UNPACK_VALUES_OBJECT) \ M(thread, invoke_apply_hook, "invoke-apply-hook", INVOKE_APPLY_HOOK) \ M(thread, invoke_return_hook, "invoke-return-hook", INVOKE_RETURN_HOOK) \ |