mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
Refactor handling of auxiliary stacks and setjmp/longjmp
* libguile/__scm.h (scm_i_jmp_buf): Remove definition, which was a shim for ia64. Instead, always use setjmp/longjmp and jmp_buf. * libguile/_scm.h (SCM_I_SETJMP, SCM_I_LONGJMP): Remove; instead use setjmp and longjmp. * libguile/continuations.c (capture_auxiliary_stack): (restore_auxiliary_stack): New helpers. (scm_i_make_continuation): Use capture_auxiliary_stack. (copy_stack_and_call): Use restore_auxiliary_stack. No need to stash the aux stack on the thread, either. * libguile/continuations.h (scm_t_contregs): Use SCM_HAVE_AUXILIARY_STACK to flag when to have an auxiliary_stack member. * libguile/control.h: * libguile/control.c (reify_partial_continuation, scm_c_abort): (scm_suspendable_continuation_p): Adapt to use setjmp/longjmp directly. * libguile/deprecated.h: Add deprecated scm_i_jmp_buf define. * libguile/dynstack.h: * libguile/dynstack.c (PROMPT_JMPBUF): (scm_dynstack_push_prompt, scm_dynstack_find_prompt): (scm_dynstack_wind_prompt): Adapt to jmp_buf type. * libguile/eval.c (eval): Use jmp_buf and setjmp directly. * libguile/gc-malloc.c: No need for ia64-specific things. * libguile/gc.c: No need for ia64-specific things. * libguile/gc.h: No need to declare scm_ia64_ar_bsp. * libguile/init.c: Remove typedef of setjmp_type for Cray, unused. * libguile/threads.c (guilify_self_1): No more pending_rbs_continuation in scm_i_thread, and register_backing_store_base is handled by libgc. (scm_ia64_ar_bsp): Remove definitions; inlined into continuations.c's capture_auxiliary_stack. * libguile/threads.h (scm_i_thread): jmpbuf member is plain jmp_buf. * libguile/throw.c (catch): Just use jmp_buf and setjmp. * libguile/vm-engine.c (VM_NAME): Adapt prototype to take jmp_buf pointer. * libguile/vm.c (vm_abort): Adapt jmp_buf types. (scm_call_n): Use setjmp.
This commit is contained in:
parent
574f67d1b6
commit
f84ce5442e
19 changed files with 109 additions and 186 deletions
|
@ -414,27 +414,6 @@ typedef void *scm_t_subr;
|
||||||
|
|
||||||
typedef struct scm_dynamic_state scm_t_dynamic_state;
|
typedef struct scm_dynamic_state scm_t_dynamic_state;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* scm_i_jmp_buf
|
|
||||||
*
|
|
||||||
* The corresponding SCM_I_SETJMP and SCM_I_LONGJMP are defined in the
|
|
||||||
* _scm.h private header.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (__ia64__)
|
|
||||||
# include <signal.h>
|
|
||||||
# include <ucontext.h>
|
|
||||||
typedef struct {
|
|
||||||
ucontext_t ctx;
|
|
||||||
int fresh;
|
|
||||||
} scm_i_jmp_buf;
|
|
||||||
|
|
||||||
#else
|
|
||||||
# include <setjmp.h>
|
|
||||||
typedef jmp_buf scm_i_jmp_buf;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -156,24 +156,6 @@
|
||||||
#define scm_from_off64_t scm_from_int64
|
#define scm_from_off64_t scm_from_int64
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined (__ia64__)
|
|
||||||
/* IA64: Implement SCM_I_SETJMP in terms of getcontext. */
|
|
||||||
# define SCM_I_SETJMP(JB) \
|
|
||||||
( (JB).fresh = 1, \
|
|
||||||
getcontext (&((JB).ctx)), \
|
|
||||||
((JB).fresh ? ((JB).fresh = 0, 0) : 1) )
|
|
||||||
# define SCM_I_LONGJMP(JB,VAL) scm_ia64_longjmp (&(JB), VAL)
|
|
||||||
void scm_ia64_longjmp (scm_i_jmp_buf *, int);
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* All other systems just use setjmp and longjmp. */
|
|
||||||
|
|
||||||
#define SCM_I_SETJMP setjmp
|
|
||||||
#define SCM_I_LONGJMP longjmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined __GNUC__)
|
#if (defined __GNUC__)
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if SCM_HAVE_AUXILIARY_STACK
|
||||||
|
#include <ucontext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/async.h"
|
#include "libguile/async.h"
|
||||||
#include "libguile/backtrace.h"
|
#include "libguile/backtrace.h"
|
||||||
|
@ -112,6 +116,49 @@ continuation_print (SCM obj, SCM port, scm_print_state *state SCM_UNUSED)
|
||||||
# define SCM_FLUSH_REGISTER_WINDOWS /* empty */
|
# define SCM_FLUSH_REGISTER_WINDOWS /* empty */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
capture_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation)
|
||||||
|
{
|
||||||
|
#if SCM_HAVE_AUXILIARY_STACK
|
||||||
|
# ifndef __ia64__
|
||||||
|
# error missing auxiliary stack implementation for architecture
|
||||||
|
# endif
|
||||||
|
char *top;
|
||||||
|
ucontext_t ctx;
|
||||||
|
|
||||||
|
if (getcontext (&ctx) != 0)
|
||||||
|
abort ();
|
||||||
|
|
||||||
|
#if defined __hpux
|
||||||
|
__uc_get_ar_bsp (ctx, (uint64_t *) &top);
|
||||||
|
#elif defined linux
|
||||||
|
top = (char *) ctx->uc_mcontext.sc_ar_bsp;
|
||||||
|
#elif defined __FreeBSD__
|
||||||
|
top = (char *)(ctx->uc_mcontext.mc_special.bspstore
|
||||||
|
+ ctx->uc_mcontext.mc_special.ndirty);
|
||||||
|
#else
|
||||||
|
#error missing auxiliary stack implementation for ia64 on this OS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
continuation->auxiliary_stack_size =
|
||||||
|
top - (char *) thread->auxiliary_stack_base;
|
||||||
|
continuation->auxiliary_stack =
|
||||||
|
scm_gc_malloc (continuation->auxiliary_stack_size,
|
||||||
|
"continuation auxiliary stack");
|
||||||
|
memcpy (continuation->auxiliary_stack, thread->auxiliary_stack_base,
|
||||||
|
continuation->auxiliary_stack_size);
|
||||||
|
#endif /* SCM_HAVE_AUXILIARY_STACK */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_auxiliary_stack (scm_i_thread *thread, scm_t_contregs *continuation)
|
||||||
|
{
|
||||||
|
#if SCM_HAVE_AUXILIARY_STACK
|
||||||
|
memcpy (thread->auxiliary_stack_base, continuation->auxiliary_stack,
|
||||||
|
continuation->auxiliary_stack_size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* this may return more than once: the first time with the escape
|
/* this may return more than once: the first time with the escape
|
||||||
procedure, then subsequently with SCM_UNDEFINED (the vals already having been
|
procedure, then subsequently with SCM_UNDEFINED (the vals already having been
|
||||||
placed on the VM stack). */
|
placed on the VM stack). */
|
||||||
|
@ -142,27 +189,13 @@ scm_i_make_continuation (int *first, struct scm_vm *vp, SCM vm_cont)
|
||||||
continuation->vp = vp;
|
continuation->vp = vp;
|
||||||
continuation->vm_cont = vm_cont;
|
continuation->vm_cont = vm_cont;
|
||||||
saved_cookie = vp->resumable_prompt_cookie;
|
saved_cookie = vp->resumable_prompt_cookie;
|
||||||
|
capture_auxiliary_stack (thread, continuation);
|
||||||
|
|
||||||
SCM_NEWSMOB (cont, tc16_continuation, continuation);
|
SCM_NEWSMOB (cont, tc16_continuation, continuation);
|
||||||
|
|
||||||
*first = !SCM_I_SETJMP (continuation->jmpbuf);
|
*first = !setjmp (continuation->jmpbuf);
|
||||||
if (*first)
|
if (*first)
|
||||||
{
|
|
||||||
#ifdef __ia64__
|
|
||||||
continuation->backing_store_size =
|
|
||||||
(char *) scm_ia64_ar_bsp(&continuation->jmpbuf.ctx)
|
|
||||||
-
|
|
||||||
(char *) thread->register_backing_store_base;
|
|
||||||
continuation->backing_store = NULL;
|
|
||||||
continuation->backing_store =
|
|
||||||
scm_gc_malloc (continuation->backing_store_size,
|
|
||||||
"continuation backing store");
|
|
||||||
memcpy (continuation->backing_store,
|
|
||||||
(void *) thread->register_backing_store_base,
|
|
||||||
continuation->backing_store_size);
|
|
||||||
#endif /* __ia64__ */
|
|
||||||
return make_continuation_trampoline (cont);
|
return make_continuation_trampoline (cont);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vp->resumable_prompt_cookie = saved_cookie;
|
vp->resumable_prompt_cookie = saved_cookie;
|
||||||
|
@ -264,32 +297,13 @@ copy_stack_and_call (scm_t_contregs *continuation,
|
||||||
|
|
||||||
memcpy (dst, continuation->stack,
|
memcpy (dst, continuation->stack,
|
||||||
sizeof (SCM_STACKITEM) * continuation->num_stack_items);
|
sizeof (SCM_STACKITEM) * continuation->num_stack_items);
|
||||||
#ifdef __ia64__
|
restore_auxiliary_stack (thread, continuation);
|
||||||
thread->pending_rbs_continuation = continuation;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scm_dynstack_wind (&thread->dynstack, joint);
|
scm_dynstack_wind (&thread->dynstack, joint);
|
||||||
|
|
||||||
SCM_I_LONGJMP (continuation->jmpbuf, 1);
|
longjmp (continuation->jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
void
|
|
||||||
scm_ia64_longjmp (scm_i_jmp_buf *JB, int VAL)
|
|
||||||
{
|
|
||||||
scm_i_thread *t = SCM_I_CURRENT_THREAD;
|
|
||||||
|
|
||||||
if (t->pending_rbs_continuation)
|
|
||||||
{
|
|
||||||
memcpy (t->register_backing_store_base,
|
|
||||||
t->pending_rbs_continuation->backing_store,
|
|
||||||
t->pending_rbs_continuation->backing_store_size);
|
|
||||||
t->pending_rbs_continuation = NULL;
|
|
||||||
}
|
|
||||||
setcontext (&JB->ctx);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Call grow_stack until the stack space is large enough, then, as the current
|
/* Call grow_stack until the stack space is large enough, then, as the current
|
||||||
* stack frame might get overwritten, let copy_stack_and_call perform the
|
* stack frame might get overwritten, let copy_stack_and_call perform the
|
||||||
* actual copying and continuation calling.
|
* actual copying and continuation calling.
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#ifndef SCM_CONTINUATIONS_H
|
#ifndef SCM_CONTINUATIONS_H
|
||||||
#define SCM_CONTINUATIONS_H
|
#define SCM_CONTINUATIONS_H
|
||||||
|
|
||||||
/* Copyright (C) 1995,1996,2000,2001, 2006, 2008, 2009, 2010, 2012, 2013, 2014 Free Software Foundation, Inc.
|
/* Copyright (C) 1995-1996,2000-2001,2006,2008-2010,2012-2014,2018
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -23,12 +24,10 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "libguile/__scm.h"
|
#include "libguile/__scm.h"
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
#include <signal.h>
|
|
||||||
#include <ucontext.h>
|
|
||||||
#endif /* __ia64__ */
|
|
||||||
|
|
||||||
|
|
||||||
#define SCM_CONTINUATIONP(x) \
|
#define SCM_CONTINUATIONP(x) \
|
||||||
|
@ -44,11 +43,11 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
scm_i_jmp_buf jmpbuf;
|
jmp_buf jmpbuf;
|
||||||
#ifdef __ia64__
|
#if SCM_HAVE_AUXILIARY_STACK
|
||||||
void *backing_store;
|
void *auxiliary_stack;
|
||||||
unsigned long backing_store_size;
|
unsigned long auxiliary_stack_size;
|
||||||
#endif /* __ia64__ */
|
#endif
|
||||||
size_t num_stack_items; /* size of the saved stack. */
|
size_t num_stack_items; /* size of the saved stack. */
|
||||||
SCM root; /* continuation root identifier. */
|
SCM root; /* continuation root identifier. */
|
||||||
struct scm_vm *vp; /* vm */
|
struct scm_vm *vp; /* vm */
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Only to be called if the SCM_I_SETJMP returns 1 */
|
/* Only to be called if the setjmp returns 1 */
|
||||||
SCM
|
SCM
|
||||||
scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
|
scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
|
||||||
scm_t_ptrdiff saved_stack_depth)
|
scm_t_ptrdiff saved_stack_depth)
|
||||||
|
@ -86,9 +86,9 @@ reify_partial_continuation (struct scm_vm *vp,
|
||||||
union scm_vm_stack_element *saved_fp,
|
union scm_vm_stack_element *saved_fp,
|
||||||
union scm_vm_stack_element *saved_sp,
|
union scm_vm_stack_element *saved_sp,
|
||||||
scm_t_uint32 *saved_ip,
|
scm_t_uint32 *saved_ip,
|
||||||
scm_i_jmp_buf *saved_registers,
|
jmp_buf *saved_registers,
|
||||||
scm_t_dynstack *dynstack,
|
scm_t_dynstack *dynstack,
|
||||||
scm_i_jmp_buf *current_registers)
|
jmp_buf *current_registers)
|
||||||
{
|
{
|
||||||
SCM vm_cont;
|
SCM vm_cont;
|
||||||
scm_t_uint32 flags;
|
scm_t_uint32 flags;
|
||||||
|
@ -125,7 +125,7 @@ reify_partial_continuation (struct scm_vm *vp,
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
||||||
scm_i_jmp_buf *current_registers)
|
jmp_buf *current_registers)
|
||||||
{
|
{
|
||||||
SCM cont;
|
SCM cont;
|
||||||
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
|
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
|
||||||
|
@ -134,7 +134,7 @@ scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
||||||
scm_t_ptrdiff fp_offset, sp_offset;
|
scm_t_ptrdiff fp_offset, sp_offset;
|
||||||
union scm_vm_stack_element *fp, *sp;
|
union scm_vm_stack_element *fp, *sp;
|
||||||
scm_t_uint32 *ip;
|
scm_t_uint32 *ip;
|
||||||
scm_i_jmp_buf *registers;
|
jmp_buf *registers;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
prompt = scm_dynstack_find_prompt (dynstack, tag,
|
prompt = scm_dynstack_find_prompt (dynstack, tag,
|
||||||
|
@ -177,7 +177,7 @@ scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
||||||
vp->sp[n - i - 1].as_scm = argv[i];
|
vp->sp[n - i - 1].as_scm = argv[i];
|
||||||
|
|
||||||
/* Jump! */
|
/* Jump! */
|
||||||
SCM_I_LONGJMP (*registers, 1);
|
longjmp (*registers, 1);
|
||||||
|
|
||||||
/* Shouldn't get here */
|
/* Shouldn't get here */
|
||||||
abort ();
|
abort ();
|
||||||
|
@ -213,7 +213,7 @@ scm_suspendable_continuation_p (SCM tag)
|
||||||
{
|
{
|
||||||
scm_t_dynstack_prompt_flags flags;
|
scm_t_dynstack_prompt_flags flags;
|
||||||
scm_i_thread *thread = SCM_I_CURRENT_THREAD;
|
scm_i_thread *thread = SCM_I_CURRENT_THREAD;
|
||||||
scm_i_jmp_buf *registers;
|
jmp_buf *registers;
|
||||||
|
|
||||||
if (scm_dynstack_find_prompt (&thread->dynstack, tag, &flags,
|
if (scm_dynstack_find_prompt (&thread->dynstack, tag, &flags,
|
||||||
NULL, NULL, NULL, ®isters))
|
NULL, NULL, NULL, ®isters))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
|
/* Copyright (C) 2010-2013, 2018 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -19,6 +19,8 @@
|
||||||
#ifndef SCM_CONTROL_H
|
#ifndef SCM_CONTROL_H
|
||||||
#define SCM_CONTROL_H
|
#define SCM_CONTROL_H
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "libguile/vm.h"
|
#include "libguile/vm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ SCM_INTERNAL SCM scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
|
||||||
scm_t_ptrdiff saved_stack_depth);
|
scm_t_ptrdiff saved_stack_depth);
|
||||||
|
|
||||||
SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
SCM_INTERNAL void scm_c_abort (struct scm_vm *vp, SCM tag, size_t n, SCM *argv,
|
||||||
scm_i_jmp_buf *registers) SCM_NORETURN;
|
jmp_buf *registers) SCM_NORETURN;
|
||||||
SCM_INTERNAL SCM scm_abort_to_prompt_star (SCM tag, SCM args) SCM_NORETURN;
|
SCM_INTERNAL SCM scm_abort_to_prompt_star (SCM tag, SCM args) SCM_NORETURN;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SCM_DEPRECATED_H
|
#ifndef SCM_DEPRECATED_H
|
||||||
#define SCM_DEPRECATED_H
|
#define SCM_DEPRECATED_H
|
||||||
|
|
||||||
/* Copyright (C) 2003-2007, 2009-2017 Free Software Foundation, Inc.
|
/* Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
/* Deprecated declarations go here. */
|
/* Deprecated declarations go here. */
|
||||||
|
|
||||||
|
#define scm_i_jmp_buf scm_i_jmp_buf_GONE__USE_JMP_BUF_INSTEAD
|
||||||
|
|
||||||
void scm_i_init_deprecated (void);
|
void scm_i_init_deprecated (void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2012, 2013 Free Software Foundation, Inc.
|
/* Copyright (C) 2012-2013,2018 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -24,6 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/control.h"
|
#include "libguile/control.h"
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
#define PROMPT_SP(top) ((scm_t_ptrdiff) ((top)[2]))
|
#define PROMPT_SP(top) ((scm_t_ptrdiff) ((top)[2]))
|
||||||
#define SET_PROMPT_SP(top, sp) do { top[2] = (scm_t_bits)(sp); } while (0)
|
#define SET_PROMPT_SP(top, sp) do { top[2] = (scm_t_bits)(sp); } while (0)
|
||||||
#define PROMPT_IP(top) ((scm_t_uint32 *) ((top)[3]))
|
#define PROMPT_IP(top) ((scm_t_uint32 *) ((top)[3]))
|
||||||
#define PROMPT_JMPBUF(top) ((scm_i_jmp_buf *) ((top)[4]))
|
#define PROMPT_JMPBUF(top) ((jmp_buf *) ((top)[4]))
|
||||||
|
|
||||||
#define WINDER_WORDS 2
|
#define WINDER_WORDS 2
|
||||||
#define WINDER_PROC(top) ((scm_t_guard) ((top)[0]))
|
#define WINDER_PROC(top) ((scm_t_guard) ((top)[0]))
|
||||||
|
@ -193,7 +194,7 @@ scm_dynstack_push_prompt (scm_t_dynstack *dynstack,
|
||||||
scm_t_dynstack_prompt_flags flags,
|
scm_t_dynstack_prompt_flags flags,
|
||||||
SCM key,
|
SCM key,
|
||||||
scm_t_ptrdiff fp_offset, scm_t_ptrdiff sp_offset,
|
scm_t_ptrdiff fp_offset, scm_t_ptrdiff sp_offset,
|
||||||
scm_t_uint32 *ip, scm_i_jmp_buf *registers)
|
scm_t_uint32 *ip, jmp_buf *registers)
|
||||||
{
|
{
|
||||||
scm_t_bits *words;
|
scm_t_bits *words;
|
||||||
|
|
||||||
|
@ -496,7 +497,7 @@ scm_t_bits*
|
||||||
scm_dynstack_find_prompt (scm_t_dynstack *dynstack, SCM key,
|
scm_dynstack_find_prompt (scm_t_dynstack *dynstack, SCM key,
|
||||||
scm_t_dynstack_prompt_flags *flags,
|
scm_t_dynstack_prompt_flags *flags,
|
||||||
scm_t_ptrdiff *fp_offset, scm_t_ptrdiff *sp_offset,
|
scm_t_ptrdiff *fp_offset, scm_t_ptrdiff *sp_offset,
|
||||||
scm_t_uint32 **ip, scm_i_jmp_buf **registers)
|
scm_t_uint32 **ip, jmp_buf **registers)
|
||||||
{
|
{
|
||||||
scm_t_bits *walk;
|
scm_t_bits *walk;
|
||||||
|
|
||||||
|
@ -577,7 +578,7 @@ scm_dynstack_find_old_fluid_value (scm_t_dynstack *dynstack, SCM fluid,
|
||||||
void
|
void
|
||||||
scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item,
|
scm_dynstack_wind_prompt (scm_t_dynstack *dynstack, scm_t_bits *item,
|
||||||
scm_t_ptrdiff base_fp_offset,
|
scm_t_ptrdiff base_fp_offset,
|
||||||
scm_i_jmp_buf *registers)
|
jmp_buf *registers)
|
||||||
{
|
{
|
||||||
scm_t_bits tag = SCM_DYNSTACK_TAG (item);
|
scm_t_bits tag = SCM_DYNSTACK_TAG (item);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifndef SCM_DYNSTACK_H
|
#ifndef SCM_DYNSTACK_H
|
||||||
#define SCM_DYNSTACK_H
|
#define SCM_DYNSTACK_H
|
||||||
|
|
||||||
/* Copyright (C) 2012, 2013 Free Software Foundation, Inc.
|
/* Copyright (C) 2012-2013,2018 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -23,6 +23,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include "libguile/__scm.h"
|
#include "libguile/__scm.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +161,7 @@ SCM_INTERNAL void scm_dynstack_push_prompt (scm_t_dynstack *,
|
||||||
scm_t_ptrdiff fp_offset,
|
scm_t_ptrdiff fp_offset,
|
||||||
scm_t_ptrdiff sp_offset,
|
scm_t_ptrdiff sp_offset,
|
||||||
scm_t_uint32 *ip,
|
scm_t_uint32 *ip,
|
||||||
scm_i_jmp_buf *registers);
|
jmp_buf *registers);
|
||||||
SCM_INTERNAL void scm_dynstack_push_dynwind (scm_t_dynstack *,
|
SCM_INTERNAL void scm_dynstack_push_dynwind (scm_t_dynstack *,
|
||||||
SCM enter, SCM leave);
|
SCM enter, SCM leave);
|
||||||
|
|
||||||
|
@ -199,7 +201,7 @@ SCM_INTERNAL scm_t_bits* scm_dynstack_find_prompt (scm_t_dynstack *, SCM,
|
||||||
scm_t_ptrdiff *,
|
scm_t_ptrdiff *,
|
||||||
scm_t_ptrdiff *,
|
scm_t_ptrdiff *,
|
||||||
scm_t_uint32 **,
|
scm_t_uint32 **,
|
||||||
scm_i_jmp_buf **);
|
jmp_buf **);
|
||||||
|
|
||||||
SCM_INTERNAL SCM scm_dynstack_find_old_fluid_value (scm_t_dynstack *,
|
SCM_INTERNAL SCM scm_dynstack_find_old_fluid_value (scm_t_dynstack *,
|
||||||
SCM, size_t, SCM);
|
SCM, size_t, SCM);
|
||||||
|
@ -208,7 +210,7 @@ SCM_INTERNAL void scm_dynstack_relocate_prompts (scm_t_dynstack *,
|
||||||
scm_t_ptrdiff);
|
scm_t_ptrdiff);
|
||||||
|
|
||||||
SCM_INTERNAL void scm_dynstack_wind_prompt (scm_t_dynstack *, scm_t_bits *,
|
SCM_INTERNAL void scm_dynstack_wind_prompt (scm_t_dynstack *, scm_t_bits *,
|
||||||
scm_t_ptrdiff, scm_i_jmp_buf *);
|
scm_t_ptrdiff, jmp_buf *);
|
||||||
|
|
||||||
|
|
||||||
#endif /* SCM_DYNSTACK_H */
|
#endif /* SCM_DYNSTACK_H */
|
||||||
|
|
|
@ -429,7 +429,7 @@ eval (SCM x, SCM env)
|
||||||
{
|
{
|
||||||
struct scm_vm *vp;
|
struct scm_vm *vp;
|
||||||
SCM k, handler, res;
|
SCM k, handler, res;
|
||||||
scm_i_jmp_buf registers;
|
jmp_buf registers;
|
||||||
const void *prev_cookie;
|
const void *prev_cookie;
|
||||||
scm_t_ptrdiff saved_stack_depth;
|
scm_t_ptrdiff saved_stack_depth;
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ eval (SCM x, SCM env)
|
||||||
®isters);
|
®isters);
|
||||||
|
|
||||||
prev_cookie = vp->resumable_prompt_cookie;
|
prev_cookie = vp->resumable_prompt_cookie;
|
||||||
if (SCM_I_SETJMP (registers))
|
if (setjmp (registers))
|
||||||
{
|
{
|
||||||
/* The prompt exited nonlocally. */
|
/* The prompt exited nonlocally. */
|
||||||
vp->resumable_prompt_cookie = prev_cookie;
|
vp->resumable_prompt_cookie = prev_cookie;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
|
/* Copyright (C) 1995-2004,2006,2008-2014,2018
|
||||||
* 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013,
|
* Free Software Foundation, Inc.
|
||||||
* 2014 Free Software Foundation, Inc.
|
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -29,11 +28,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
#include <ucontext.h>
|
|
||||||
extern unsigned long * __libc_ia64_register_backing_store_base;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/eval.h"
|
#include "libguile/eval.h"
|
||||||
#include "libguile/stime.h"
|
#include "libguile/stime.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006,
|
/* Copyright (C) 1995-2003,2006,2008-2014,2016-2018
|
||||||
* 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Free Software Foundation, Inc.
|
* Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -31,11 +31,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
#include <ucontext.h>
|
|
||||||
extern unsigned long * __libc_ia64_register_backing_store_base;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libguile/_scm.h"
|
#include "libguile/_scm.h"
|
||||||
#include "libguile/eval.h"
|
#include "libguile/eval.h"
|
||||||
#include "libguile/stime.h"
|
#include "libguile/stime.h"
|
||||||
|
|
|
@ -93,10 +93,6 @@ SCM_INTERNAL scm_i_pthread_mutex_t scm_i_gc_admin_mutex;
|
||||||
#define scm_gc_running_p 0
|
#define scm_gc_running_p 0
|
||||||
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_sweep_mutex;
|
SCM_INTERNAL scm_i_pthread_mutex_t scm_i_sweep_mutex;
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
void *scm_ia64_ar_bsp (const void *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SCM_API unsigned long scm_gc_ports_collected;
|
SCM_API unsigned long scm_gc_ports_collected;
|
||||||
|
|
|
@ -263,12 +263,6 @@ scm_load_startup_files ()
|
||||||
|
|
||||||
/* The main init code. */
|
/* The main init code. */
|
||||||
|
|
||||||
#ifdef _UNICOS
|
|
||||||
typedef int setjmp_type;
|
|
||||||
#else
|
|
||||||
typedef long setjmp_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* All the data needed to invoke the main function. */
|
/* All the data needed to invoke the main function. */
|
||||||
struct main_func_closure
|
struct main_func_closure
|
||||||
{
|
{
|
||||||
|
|
|
@ -393,10 +393,6 @@ guilify_self_1 (struct GC_stack_base *base, int needs_unregister)
|
||||||
t.pending_asyncs = SCM_EOL;
|
t.pending_asyncs = SCM_EOL;
|
||||||
t.block_asyncs = 1;
|
t.block_asyncs = 1;
|
||||||
t.base = base->mem_base;
|
t.base = base->mem_base;
|
||||||
#ifdef __ia64__
|
|
||||||
t.register_backing_store_base = base->reg_base;
|
|
||||||
t.pending_rbs_continuation = 0;
|
|
||||||
#endif
|
|
||||||
t.continuation_root = SCM_EOL;
|
t.continuation_root = SCM_EOL;
|
||||||
t.continuation_base = t.base;
|
t.continuation_base = t.base;
|
||||||
scm_i_pthread_cond_init (&t.sleep_cond, NULL);
|
scm_i_pthread_cond_init (&t.sleep_cond, NULL);
|
||||||
|
@ -1850,38 +1846,6 @@ scm_init_threads_default_dynamic_state ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* IA64-specific things. */
|
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
# ifdef __hpux
|
|
||||||
void *
|
|
||||||
scm_ia64_ar_bsp (const void *ctx)
|
|
||||||
{
|
|
||||||
uint64_t bsp;
|
|
||||||
__uc_get_ar_bsp (ctx, &bsp);
|
|
||||||
return (void *) bsp;
|
|
||||||
}
|
|
||||||
# endif /* hpux */
|
|
||||||
# ifdef linux
|
|
||||||
# include <ucontext.h>
|
|
||||||
void *
|
|
||||||
scm_ia64_ar_bsp (const void *opaque)
|
|
||||||
{
|
|
||||||
const ucontext_t *ctx = opaque;
|
|
||||||
return (void *) ctx->uc_mcontext.sc_ar_bsp;
|
|
||||||
}
|
|
||||||
# endif /* linux */
|
|
||||||
# ifdef __FreeBSD__
|
|
||||||
# include <ucontext.h>
|
|
||||||
void *
|
|
||||||
scm_ia64_ar_bsp (const void *opaque)
|
|
||||||
{
|
|
||||||
const ucontext_t *ctx = opaque;
|
|
||||||
return (void *)(ctx->uc_mcontext.mc_special.bspstore
|
|
||||||
+ ctx->uc_mcontext.mc_special.ndirty);
|
|
||||||
}
|
|
||||||
# endif /* __FreeBSD__ */
|
|
||||||
#endif /* __ia64__ */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#ifndef SCM_THREADS_H
|
#ifndef SCM_THREADS_H
|
||||||
#define SCM_THREADS_H
|
#define SCM_THREADS_H
|
||||||
|
|
||||||
/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006,
|
/* Copyright (C) 1996-1998,2000-2004,2006-2009,2011-2014,2018
|
||||||
* 2007, 2008, 2009, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
|
* Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "libguile/__scm.h"
|
#include "libguile/__scm.h"
|
||||||
#include "libguile/procs.h"
|
#include "libguile/procs.h"
|
||||||
#include "libguile/throw.h"
|
#include "libguile/throw.h"
|
||||||
|
@ -104,11 +106,7 @@ typedef struct scm_i_thread {
|
||||||
/* For keeping track of the stack and registers. */
|
/* For keeping track of the stack and registers. */
|
||||||
struct scm_vm *vp;
|
struct scm_vm *vp;
|
||||||
SCM_STACKITEM *base;
|
SCM_STACKITEM *base;
|
||||||
scm_i_jmp_buf regs;
|
jmp_buf regs;
|
||||||
#ifdef __ia64__
|
|
||||||
void *register_backing_store_base;
|
|
||||||
scm_t_contregs *pending_rbs_continuation;
|
|
||||||
#endif
|
|
||||||
} scm_i_thread;
|
} scm_i_thread;
|
||||||
|
|
||||||
#define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x)
|
#define SCM_I_IS_THREAD(x) SCM_SMOB_PREDICATE (scm_tc16_thread, x)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2017 Free Software Foundation, Inc.
|
/* Copyright (C) 1995-1998,2000-2001,2003-2004,2006,2008,2009-2014,2017-2018
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -77,7 +78,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
|
||||||
SCM res;
|
SCM res;
|
||||||
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
|
scm_t_dynstack *dynstack = &SCM_I_CURRENT_THREAD->dynstack;
|
||||||
scm_t_dynamic_state *dynamic_state = SCM_I_CURRENT_THREAD->dynamic_state;
|
scm_t_dynamic_state *dynamic_state = SCM_I_CURRENT_THREAD->dynamic_state;
|
||||||
scm_i_jmp_buf registers;
|
jmp_buf registers;
|
||||||
const void *prev_cookie;
|
const void *prev_cookie;
|
||||||
scm_t_ptrdiff saved_stack_depth;
|
scm_t_ptrdiff saved_stack_depth;
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ catch (SCM tag, SCM thunk, SCM handler, SCM pre_unwind_handler)
|
||||||
scm_dynstack_push_fluid (dynstack, exception_handler_fluid, eh,
|
scm_dynstack_push_fluid (dynstack, exception_handler_fluid, eh,
|
||||||
dynamic_state);
|
dynamic_state);
|
||||||
|
|
||||||
if (SCM_I_SETJMP (registers))
|
if (setjmp (registers))
|
||||||
{
|
{
|
||||||
/* A non-local return. */
|
/* A non-local return. */
|
||||||
SCM args;
|
SCM args;
|
||||||
|
|
|
@ -269,7 +269,7 @@
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
scm_i_jmp_buf *registers, int resume)
|
jmp_buf *registers, int resume)
|
||||||
{
|
{
|
||||||
/* Instruction pointer: A pointer to the opcode that is currently
|
/* Instruction pointer: A pointer to the opcode that is currently
|
||||||
running. */
|
running. */
|
||||||
|
|
|
@ -337,11 +337,11 @@ static void vm_dispatch_abort_hook (struct scm_vm *vp)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_abort (struct scm_vm *vp, SCM tag, size_t nargs,
|
vm_abort (struct scm_vm *vp, SCM tag, size_t nargs,
|
||||||
scm_i_jmp_buf *current_registers) SCM_NORETURN;
|
jmp_buf *current_registers) SCM_NORETURN;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_abort (struct scm_vm *vp, SCM tag, size_t nargs,
|
vm_abort (struct scm_vm *vp, SCM tag, size_t nargs,
|
||||||
scm_i_jmp_buf *current_registers)
|
jmp_buf *current_registers)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
SCM *argv;
|
SCM *argv;
|
||||||
|
@ -381,7 +381,7 @@ vm_reinstate_partial_continuation_inner (void *data_ptr)
|
||||||
static void
|
static void
|
||||||
vm_reinstate_partial_continuation (struct scm_vm *vp, SCM cont, size_t nargs,
|
vm_reinstate_partial_continuation (struct scm_vm *vp, SCM cont, size_t nargs,
|
||||||
scm_t_dynstack *dynstack,
|
scm_t_dynstack *dynstack,
|
||||||
scm_i_jmp_buf *registers)
|
jmp_buf *registers)
|
||||||
{
|
{
|
||||||
struct vm_reinstate_partial_continuation_data data;
|
struct vm_reinstate_partial_continuation_data data;
|
||||||
struct scm_vm_cont *cp;
|
struct scm_vm_cont *cp;
|
||||||
|
@ -721,7 +721,7 @@ scm_i_call_with_current_continuation (SCM proc)
|
||||||
#undef VM_NAME
|
#undef VM_NAME
|
||||||
|
|
||||||
typedef SCM (*scm_t_vm_engine) (scm_i_thread *current_thread, struct scm_vm *vp,
|
typedef SCM (*scm_t_vm_engine) (scm_i_thread *current_thread, struct scm_vm *vp,
|
||||||
scm_i_jmp_buf *registers, int resume);
|
jmp_buf *registers, int resume);
|
||||||
|
|
||||||
static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] =
|
static const scm_t_vm_engine vm_engines[SCM_VM_NUM_ENGINES] =
|
||||||
{ vm_regular_engine, vm_debug_engine };
|
{ vm_regular_engine, vm_debug_engine };
|
||||||
|
@ -1193,12 +1193,12 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
|
||||||
SCM_FRAME_LOCAL (call_fp, i + 1) = argv[i];
|
SCM_FRAME_LOCAL (call_fp, i + 1) = argv[i];
|
||||||
|
|
||||||
{
|
{
|
||||||
scm_i_jmp_buf registers;
|
jmp_buf registers;
|
||||||
int resume;
|
int resume;
|
||||||
const void *prev_cookie = vp->resumable_prompt_cookie;
|
const void *prev_cookie = vp->resumable_prompt_cookie;
|
||||||
SCM ret;
|
SCM ret;
|
||||||
|
|
||||||
resume = SCM_I_SETJMP (registers);
|
resume = setjmp (registers);
|
||||||
if (SCM_UNLIKELY (resume))
|
if (SCM_UNLIKELY (resume))
|
||||||
{
|
{
|
||||||
scm_gc_after_nonlocal_exit ();
|
scm_gc_after_nonlocal_exit ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue