1 /* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include <libguile/programs.h>
27 SCM_VM_PUSH_CONTINUATION_HOOK
,
28 SCM_VM_POP_CONTINUATION_HOOK
,
30 SCM_VM_ABORT_CONTINUATION_HOOK
,
34 #define SCM_VM_REGULAR_ENGINE 0
35 #define SCM_VM_DEBUG_ENGINE 1
36 #define SCM_VM_NUM_ENGINES 2
39 scm_t_uint32
*ip
; /* instruction pointer */
40 SCM
*sp
; /* stack pointer */
41 SCM
*fp
; /* frame pointer */
42 SCM
*stack_limit
; /* stack limit address */
43 int trace_level
; /* traces enabled if trace_level > 0 */
44 SCM
*sp_max_since_gc
; /* highest sp since last gc */
45 size_t stack_size
; /* stack size */
46 SCM
*stack_base
; /* stack base address */
47 SCM overflow_handler_stack
; /* alist of max-stack-size -> thunk */
48 SCM hooks
[SCM_VM_NUM_HOOKS
]; /* hooks */
49 int engine
; /* which vm engine we're using */
52 SCM_INTERNAL
struct scm_vm
*scm_the_vm (void);
53 SCM_API SCM
scm_call_with_vm (SCM proc
, SCM args
);
55 SCM_API SCM
scm_call_with_stack_overflow_handler (SCM limit
, SCM thunk
,
58 SCM_API SCM
scm_vm_apply_hook (void);
59 SCM_API SCM
scm_vm_push_continuation_hook (void);
60 SCM_API SCM
scm_vm_pop_continuation_hook (void);
61 SCM_API SCM
scm_vm_abort_continuation_hook (void);
62 SCM_API SCM
scm_vm_next_hook (void);
63 SCM_API SCM
scm_vm_trace_level (void);
64 SCM_API SCM
scm_set_vm_trace_level_x (SCM level
);
65 SCM_API SCM
scm_vm_engine (void);
66 SCM_API SCM
scm_set_vm_engine_x (SCM engine
);
67 SCM_API SCM
scm_set_default_vm_engine_x (SCM engine
);
68 SCM_API
void scm_c_set_vm_engine_x (int engine
);
69 SCM_API
void scm_c_set_default_vm_engine_x (int engine
);
72 SCM_INTERNAL
struct GC_ms_entry
* scm_i_vm_mark_stack (struct scm_vm
*,
74 struct GC_ms_entry
*);
75 SCM_INTERNAL
void scm_i_vm_free_stack (struct scm_vm
*vp
);
77 #define SCM_F_VM_CONT_PARTIAL 0x1
78 #define SCM_F_VM_CONT_REWINDABLE 0x2
84 scm_t_ptrdiff stack_size
;
87 scm_t_dynstack
*dynstack
;
91 #define SCM_VM_CONT_P(OBJ) (SCM_HAS_TYP7 (OBJ, scm_tc7_vm_cont))
92 #define SCM_VM_CONT_DATA(CONT) ((struct scm_vm_cont *) SCM_CELL_WORD_1 (CONT))
93 #define SCM_VM_CONT_PARTIAL_P(CONT) (SCM_VM_CONT_DATA (CONT)->flags & SCM_F_VM_CONT_PARTIAL)
94 #define SCM_VM_CONT_REWINDABLE_P(CONT) (SCM_VM_CONT_DATA (CONT)->flags & SCM_F_VM_CONT_REWINDABLE)
96 SCM_API SCM
scm_load_compiled_with_vm (SCM file
);
98 SCM_INTERNAL SCM
scm_i_call_with_current_continuation (SCM proc
);
99 SCM_INTERNAL SCM
scm_i_capture_current_stack (void);
100 SCM_INTERNAL SCM
scm_i_vm_capture_stack (SCM
*stack_base
, SCM
*fp
, SCM
*sp
,
102 scm_t_dynstack
*dynstack
,
104 SCM_INTERNAL
int scm_i_vm_cont_to_frame (SCM cont
, struct scm_frame
*frame
);
105 SCM_INTERNAL
void scm_i_vm_cont_print (SCM x
, SCM port
,
106 scm_print_state
*pstate
);
107 SCM_INTERNAL
void scm_bootstrap_vm (void);
108 SCM_INTERNAL
void scm_init_vm (void);
110 #endif /* _SCM_VM_H_ */