[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 09/13: Intrinsics take registers from thread
From: |
Andy Wingo |
Subject: |
[Guile-commits] 09/13: Intrinsics take registers from thread |
Date: |
Wed, 27 Jun 2018 14:00:13 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 64d114817ac080029641792db3e199f614ad5e6d
Author: Andy Wingo <address@hidden>
Date: Wed Jun 27 18:42:21 2018 +0200
Intrinsics take registers from thread
* libguile/continuations.c (scm_i_make_continuation): Remove registers
argument; instead get from thread.
* libguile/vm-engine.c (vm_engine): Adapt VM engine to not receive a
registers argument, and thus to not pass it to intrinsics either.
* libguile/intrinsics.h:
* libguile/intrinsics.c (push_prompt):
* libguile/vm.c (capture_continuation, compose_continuation)
(abort_to_prompt): Refactor these intrinsics to not take a registers
argument; it's not necessary.
(scm_call_n): Don't pass registers argument.
---
libguile/continuations.c | 4 ++--
libguile/continuations.h | 4 +---
libguile/intrinsics.c | 4 ++--
libguile/intrinsics.h | 19 ++++++++-----------
libguile/vm-engine.c | 13 ++++++-------
libguile/vm.c | 19 +++++++++----------
6 files changed, 28 insertions(+), 35 deletions(-)
diff --git a/libguile/continuations.c b/libguile/continuations.c
index 467ae4e..5380a5e 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -167,7 +167,7 @@ restore_auxiliary_stack (scm_thread *thread, scm_t_contregs
*continuation)
}
SCM
-scm_i_make_continuation (jmp_buf *registers, scm_thread *thread, SCM vm_cont)
+scm_i_make_continuation (scm_thread *thread, SCM vm_cont)
{
SCM cont;
scm_t_contregs *continuation;
@@ -187,7 +187,7 @@ scm_i_make_continuation (jmp_buf *registers, scm_thread
*thread, SCM vm_cont)
#endif
continuation->offset = continuation->stack - src;
memcpy (continuation->stack, src, sizeof (SCM_STACKITEM) * stack_size);
- memcpy (continuation->jmpbuf, registers, sizeof (*registers));
+ memcpy (continuation->jmpbuf, thread->vm.registers, sizeof (jmp_buf));
continuation->vm_cont = vm_cont;
capture_auxiliary_stack (thread, continuation);
diff --git a/libguile/continuations.h b/libguile/continuations.h
index 94a791d..8893eef 100644
--- a/libguile/continuations.h
+++ b/libguile/continuations.h
@@ -67,9 +67,7 @@ typedef struct
-SCM_INTERNAL SCM scm_i_make_continuation (jmp_buf *registers,
- scm_thread *thread,
- SCM vm_cont);
+SCM_INTERNAL SCM scm_i_make_continuation (scm_thread *thread, SCM vm_cont);
SCM_INTERNAL void scm_i_reinstate_continuation (SCM cont) SCM_NORETURN;
SCM_INTERNAL int scm_i_continuation_to_frame (SCM cont,
diff --git a/libguile/intrinsics.c b/libguile/intrinsics.c
index 42b6610..75cf2f0 100644
--- a/libguile/intrinsics.c
+++ b/libguile/intrinsics.c
@@ -348,7 +348,7 @@ current_module (scm_thread *thread)
}
static void
-push_prompt (scm_thread *thread, jmp_buf *registers, uint8_t escape_only_p,
+push_prompt (scm_thread *thread, uint8_t escape_only_p,
SCM tag, const union scm_vm_stack_element *sp, void *ra)
{
struct scm_vm *vp = &thread->vm;
@@ -357,7 +357,7 @@ push_prompt (scm_thread *thread, jmp_buf *registers,
uint8_t escape_only_p,
flags = escape_only_p ? SCM_F_DYNSTACK_PROMPT_ESCAPE_ONLY : 0;
scm_dynstack_push_prompt (&thread->dynstack, flags, tag,
vp->stack_top - vp->fp, vp->stack_top - sp,
- ra, registers);
+ ra, thread->vm.registers);
}
void
diff --git a/libguile/intrinsics.h b/libguile/intrinsics.h
index c44f832..3c35749 100644
--- a/libguile/intrinsics.h
+++ b/libguile/intrinsics.h
@@ -54,20 +54,17 @@ typedef void (*scm_t_thread_u32_u32_scm_u8_u8_intrinsic)
(scm_thread*, uint32_t,
typedef SCM (*scm_t_scm_from_scm_scm_scmp_sp_intrinsic) (SCM, SCM, SCM*,
const union
scm_vm_stack_element*);
typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_thread*, SCM)
SCM_NORETURN;
-typedef SCM (*scm_t_scm_from_thread_regs_intrinsic) (scm_thread*, jmp_buf*);
-typedef void (*scm_t_thread_regs_scm_intrinsic) (scm_thread*, jmp_buf*, SCM);
typedef int (*scm_t_int_from_scm_intrinsic) (SCM);
-typedef void (*scm_t_thread_regs_intrinsic) (scm_thread*, jmp_buf*);
typedef void (*scm_t_scm_scm_noreturn_intrinsic) (SCM, SCM) SCM_NORETURN;
typedef void (*scm_t_noreturn_intrinsic) (void) SCM_NORETURN;
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_regs_u8_scm_sp_ra_intrinsic) (scm_thread*,
jmp_buf*,
- uint8_t, SCM,
- const union
scm_vm_stack_element*,
- void*);
+typedef void (*scm_t_thread_u8_scm_sp_ra_intrinsic) (scm_thread*,
+ uint8_t, SCM,
+ const union
scm_vm_stack_element*,
+ void*);
#define SCM_FOR_ALL_VM_INTRINSICS(M) \
M(scm_from_scm_scm, add, "add", ADD) \
@@ -119,10 +116,10 @@ typedef void (*scm_t_thread_regs_u8_scm_sp_ra_intrinsic)
(scm_thread*, jmp_buf*,
M(thread, push_interrupt_frame, "push-interrupt-frame",
PUSH_INTERRUPT_FRAME) \
M(scm_from_scm_scm_scmp_sp, foreign_call, "foreign-call", FOREIGN_CALL) \
M(thread_scm_noreturn, reinstate_continuation_x, "reinstate-continuation!",
REINSTATE_CONTINUATION_X) \
- M(scm_from_thread_regs, capture_continuation, "capture-continuation",
CAPTURE_CONTINUATION) \
- M(thread_regs_scm, compose_continuation, "compose-continuation",
COMPOSE_CONTINUATION) \
+ M(scm_from_thread, capture_continuation, "capture-continuation",
CAPTURE_CONTINUATION) \
+ M(thread_scm, compose_continuation, "compose-continuation",
COMPOSE_CONTINUATION) \
M(int_from_scm, rest_arg_length, "rest-arg-length", REST_ARG_LENGTH) \
- M(thread_regs, abort_to_prompt, "abort-to-prompt", ABORT_TO_PROMPT) \
+ M(thread, 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) \
@@ -133,7 +130,7 @@ typedef void (*scm_t_thread_regs_u8_scm_sp_ra_intrinsic)
(scm_thread*, jmp_buf*,
M(thread, apply_non_program, "apply-non-program", APPLY_NON_PROGRAM) \
M(scm_from_thread_u64, allocate_words, "allocate-words", ALLOCATE_WORDS) \
M(scm_from_thread, current_module, "current-module", CURRENT_MODULE) \
- M(thread_regs_u8_scm_sp_ra, push_prompt, "push-prompt", PUSH_PROMPT) \
+ M(thread_u8_scm_sp_ra, push_prompt, "push-prompt", PUSH_PROMPT) \
/* Add new intrinsics here; also update scm_bootstrap_intrinsics. */
enum scm_vm_intrinsic
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 9ad2e7d..2409af9 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -272,7 +272,7 @@
((uintptr_t) (ptr) % alignof_type (type) == 0)
static SCM
-VM_NAME (scm_thread *thread, jmp_buf *registers, int resume)
+VM_NAME (scm_thread *thread, int resume)
{
/* Instruction pointer: A pointer to the opcode that is currently
running. */
@@ -714,7 +714,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume)
vmcont = SCM_PROGRAM_FREE_VARIABLE_REF (FP_REF (0), cont_idx);
SYNC_IP ();
- CALL_INTRINSIC (compose_continuation, (thread, registers, vmcont));
+ CALL_INTRINSIC (compose_continuation, (thread, vmcont));
CACHE_REGISTER ();
NEXT (0);
}
@@ -777,7 +777,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume)
SCM cont;
SYNC_IP ();
- cont = CALL_INTRINSIC (capture_continuation, (thread, registers));
+ cont = CALL_INTRINSIC (capture_continuation, (thread));
RESET_FRAME (2);
@@ -810,7 +810,7 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int resume)
it continues with the next instruction. */
ip++;
SYNC_IP ();
- CALL_INTRINSIC (abort_to_prompt, (thread, registers));
+ CALL_INTRINSIC (abort_to_prompt, (thread));
/* If abort_to_prompt returned, that means there were no
intervening C frames to jump over, so we just continue
@@ -1676,9 +1676,8 @@ VM_NAME (scm_thread *thread, jmp_buf *registers, int
resume)
/* Push the prompt onto the dynamic stack. */
SYNC_IP ();
- CALL_INTRINSIC (push_prompt,
- (thread, registers, escape_only_p,
- SP_REF (tag), FP_SLOT (proc_slot), ip + offset));
+ CALL_INTRINSIC (push_prompt, (thread, escape_only_p, SP_REF (tag),
+ FP_SLOT (proc_slot), ip + offset));
NEXT (3);
}
diff --git a/libguile/vm.c b/libguile/vm.c
index 442bd72..ef423b0 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -464,8 +464,7 @@ scm_i_call_with_current_continuation (SCM proc)
#undef VM_USE_HOOKS
#undef VM_NAME
-typedef SCM (*scm_t_vm_engine) (scm_thread *current_thread,
- jmp_buf *registers, int resume);
+typedef SCM (*scm_t_vm_engine) (scm_thread *current_thread, int resume);
static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] =
{ vm_regular_engine, vm_debug_engine };
@@ -1102,7 +1101,7 @@ reinstate_continuation_x (scm_thread *thread, SCM cont)
}
static SCM
-capture_continuation (scm_thread *thread, jmp_buf *registers)
+capture_continuation (scm_thread *thread)
{
struct scm_vm *vp = &thread->vm;
SCM vm_cont =
@@ -1112,7 +1111,7 @@ capture_continuation (scm_thread *thread, jmp_buf
*registers)
SCM_FRAME_RETURN_ADDRESS (vp->fp),
scm_dynstack_capture_all (&thread->dynstack),
0);
- return scm_i_make_continuation (registers, thread, vm_cont);
+ return scm_i_make_continuation (thread, vm_cont);
}
struct compose_continuation_data
@@ -1139,7 +1138,7 @@ compose_continuation_inner (void *data_ptr)
}
static void
-compose_continuation (scm_thread *thread, jmp_buf *registers, SCM cont)
+compose_continuation (scm_thread *thread, SCM cont)
{
struct scm_vm *vp = &thread->vm;
size_t nargs;
@@ -1185,7 +1184,7 @@ compose_continuation (scm_thread *thread, jmp_buf
*registers, SCM cont)
if (SCM_DYNSTACK_TAG_TYPE (tag) == SCM_DYNSTACK_TYPE_PROMPT)
scm_dynstack_wind_prompt (&thread->dynstack, walk, old_fp_offset,
- registers);
+ thread->vm.registers);
else
scm_dynstack_wind_1 (&thread->dynstack, walk);
}
@@ -1257,7 +1256,7 @@ scm_i_vm_abort (SCM *tag_and_argv, size_t n)
}
static void
-abort_to_prompt (scm_thread *thread, jmp_buf *current_registers)
+abort_to_prompt (scm_thread *thread)
{
struct scm_vm *vp = &thread->vm;
scm_t_dynstack *dynstack = &thread->dynstack;
@@ -1292,7 +1291,7 @@ abort_to_prompt (scm_thread *thread, jmp_buf
*current_registers)
captured = scm_dynstack_capture (dynstack, SCM_DYNSTACK_NEXT (prompt));
cont = capture_delimited_continuation (vp, fp, sp, ip, registers,
captured,
- current_registers);
+ thread->vm.registers);
}
/* Unwind. */
@@ -1316,7 +1315,7 @@ abort_to_prompt (scm_thread *thread, jmp_buf
*current_registers)
/* If there are intervening C frames, then jump over them, making a
nonlocal exit. Otherwise fall through and let the VM pick up where
it left off. */
- if (current_registers != registers)
+ if (thread->vm.registers != registers)
longjmp (*registers, 1);
}
@@ -1423,7 +1422,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
}
thread->vm.registers = ®isters;
- ret = vm_engines[vp->engine](thread, ®isters, resume);
+ ret = vm_engines[vp->engine](thread, resume);
thread->vm.registers = prev_registers;
return ret;
- [Guile-commits] branch master updated (7883290 -> 593e2db), Andy Wingo, 2018/06/27
- [Guile-commits] 01/13: allocate-words intrinsic, Andy Wingo, 2018/06/27
- [Guile-commits] 04/13: Intrinsic for "prompt", Andy Wingo, 2018/06/27
- [Guile-commits] 07/13: Refactor handling of active VM registers, Andy Wingo, 2018/06/27
- [Guile-commits] 05/13: bind-rest inst uses cons-rest intrinsic, Andy Wingo, 2018/06/27
- [Guile-commits] 11/13: Minor optimizations to debug hook dispatch, Andy Wingo, 2018/06/27
- [Guile-commits] 02/13: Compile current-module as intrinsic call, Andy Wingo, 2018/06/27
- [Guile-commits] 12/13: Microoptimizations to hook dispatch, Andy Wingo, 2018/06/27
- [Guile-commits] 13/13: Refactor hook dispatch in VM, Andy Wingo, 2018/06/27
- [Guile-commits] 09/13: Intrinsics take registers from thread,
Andy Wingo <=
- [Guile-commits] 06/13: Use CALL_INTRINSICS helper in VM, Andy Wingo, 2018/06/27
- [Guile-commits] 08/13: Minor scm_thread refactoring, Andy Wingo, 2018/06/27
- [Guile-commits] 03/13: Remove dedicated current-module instruction., Andy Wingo, 2018/06/27
- [Guile-commits] 10/13: Remove "resume" arg from vm engine, Andy Wingo, 2018/06/27