extern void initialize_svm1 (void);
extern insn_t * read_uuo_target (SCHEME_OBJECT *);
extern unsigned int read_u16 (insn_t *);
+extern unsigned long svm_export_instruction_pointer (unsigned long pc);
#endif /* !SCM_CMPINTMD_H_INCLUDED */
SET_VAL ((SCHEME_OBJECT) (WREG_REF (SVM1_REG_VALUE))); \
} while (0)
+/* Only true when the virtual machine is running, e.g. while Free is
+ cached in word_registers[]. In a signal handler, the virtual
+ instruction that trapped is at instruction_pointer. */
+static bool running_p = false;
+static insn_t * instruction_pointer;
+
long
C_to_interface (void * address)
{
- insn_t * PC = (insn_t *)address;
+ instruction_pointer = (insn_t *)address;
IMPORT_REGS ();
- while (predict_true (PC))
+ running_p = true;
+ while (predict_true (instruction_pointer))
{
- byte_t opcode = *PC++;
- PC = (* (inst_defns[opcode])) (PC);
+ byte_t opcode = *instruction_pointer;
+ instruction_pointer = (* (inst_defns[opcode])) (instruction_pointer+1);
}
EXPORT_REGS ();
+ running_p = false;
return (svm1_result);
}
+/* For signal/trap handlers. */
+unsigned long
+svm_export_instruction_pointer (unsigned long pc)
+{
+ if (running_p)
+ {
+ EXPORT_REGS ();
+ return ((unsigned long)instruction_pointer);
+ }
+ else
+ {
+ return (pc);
+ }
+}
+
static byte_t *
illegal_instruction (byte_t * PC)
{
#define TRAP_PREFIX(result) \
utility_result_t result; \
- EXPORT_REGS ()
+ EXPORT_REGS (); \
+ running_p = false
#define TRAP_SUFFIX(result) \
IMPORT_REGS (); \
+ running_p = true; \
if ((result).scheme_p) \
{ \
NEW_PC ((result).arg.new_pc); \
#ifdef PC_VALUE_MASK
pc &= PC_VALUE_MASK;
#endif
+#ifdef CC_IS_SVM
+ pc = svm_export_instruction_pointer (pc);
+#endif
/* Choose new SP and encode location data. */
switch (classify_pc (pc, (&block_addr), (&index)))
case pcl_heap:
case pcl_constant:
#ifdef CC_SUPPORT_P
+
+# ifdef CC_IS_SVM
+ new_sp = stack_pointer;
+ /* Free already set by svm_export_instruction_pointer. */
+# else
new_sp = ((SCHEME_OBJECT *) (SIGCONTEXT_SCHSP (scp)));
Free = ((SCHEME_OBJECT *) (SIGCONTEXT_RFREE (scp)));
+# endif
+
SET_RECOVERY_INFO
(STATE_COMPILED_CODE,
(MAKE_CC_BLOCK (block_addr)),