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/dynstack.c | |
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/dynstack.c')
-rw-r--r-- | libguile/dynstack.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/libguile/dynstack.c b/libguile/dynstack.c index 032545028..2eec7a7eb 100644 --- a/libguile/dynstack.c +++ b/libguile/dynstack.c @@ -38,14 +38,15 @@ -#define PROMPT_WORDS 5 +#define PROMPT_WORDS 6 #define PROMPT_KEY(top) (SCM_PACK ((top)[0])) #define PROMPT_FP(top) ((ptrdiff_t) ((top)[1])) #define SET_PROMPT_FP(top, fp) do { top[1] = (scm_t_bits)(fp); } while (0) #define PROMPT_SP(top) ((ptrdiff_t) ((top)[2])) #define SET_PROMPT_SP(top, sp) do { top[2] = (scm_t_bits)(sp); } while (0) -#define PROMPT_IP(top) ((uint32_t *) ((top)[3])) -#define PROMPT_JMPBUF(top) ((jmp_buf *) ((top)[4])) +#define PROMPT_VRA(top) ((uint32_t *) ((top)[3])) +#define PROMPT_MRA(top) ((uint8_t *) ((top)[4])) +#define PROMPT_JMPBUF(top) ((jmp_buf *) ((top)[5])) #define WINDER_WORDS 2 #define WINDER_PROC(top) ((scm_t_guard) ((top)[0])) @@ -197,7 +198,7 @@ scm_dynstack_push_prompt (scm_t_dynstack *dynstack, scm_t_dynstack_prompt_flags flags, SCM key, ptrdiff_t fp_offset, ptrdiff_t sp_offset, - uint32_t *ip, jmp_buf *registers) + uint32_t *vra, uint8_t *mra, jmp_buf *registers) { scm_t_bits *words; @@ -206,8 +207,9 @@ scm_dynstack_push_prompt (scm_t_dynstack *dynstack, words[0] = SCM_UNPACK (key); words[1] = (scm_t_bits) fp_offset; words[2] = (scm_t_bits) sp_offset; - words[3] = (scm_t_bits) ip; - words[4] = (scm_t_bits) registers; + words[3] = (scm_t_bits) vra; + words[4] = (scm_t_bits) mra; + words[5] = (scm_t_bits) registers; } void @@ -500,7 +502,7 @@ scm_t_bits* scm_dynstack_find_prompt (scm_t_dynstack *dynstack, SCM key, scm_t_dynstack_prompt_flags *flags, ptrdiff_t *fp_offset, ptrdiff_t *sp_offset, - uint32_t **ip, jmp_buf **registers) + uint32_t **vra, uint8_t **mra, jmp_buf **registers) { scm_t_bits *walk; @@ -518,8 +520,10 @@ scm_dynstack_find_prompt (scm_t_dynstack *dynstack, SCM key, *fp_offset = PROMPT_FP (walk); if (sp_offset) *sp_offset = PROMPT_SP (walk); - if (ip) - *ip = PROMPT_IP (walk); + if (vra) + *vra = PROMPT_VRA (walk); + if (mra) + *mra = PROMPT_MRA (walk); if (registers) *registers = PROMPT_JMPBUF (walk); return walk; @@ -593,7 +597,8 @@ scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item, PROMPT_KEY (item), PROMPT_FP (item) + base_fp_offset, PROMPT_SP (item) + base_fp_offset, - PROMPT_IP (item), + PROMPT_VRA (item), + PROMPT_MRA (item), registers); } |