From ff3968c22d84529666487c2706d904c96440a33d Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 18 May 2012 12:21:08 +0200 Subject: [PATCH] remove some configurability in vm-engine * libguile/vm-engine.c: Remove the ability for the VM to check object access, free variable access, and the ip. They were off by default. Since they will be different in the RTL VM, their presence is just making things confusing. * libguile/vm.c: Remove corresponding error helpers. --- libguile/vm-engine.c | 38 +++----------------------------------- libguile/vm.c | 32 -------------------------------- 2 files changed, 3 insertions(+), 67 deletions(-) diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 327878335..98e9837a2 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -19,17 +19,11 @@ /* This file is included in vm.c multiple times */ #if (VM_ENGINE == SCM_VM_REGULAR_ENGINE) -#define VM_USE_HOOKS 0 /* Various hooks */ -#define VM_CHECK_OBJECT 0 /* Check object table */ -#define VM_CHECK_FREE_VARIABLES 0 /* Check free variable access */ -#define VM_CHECK_UNDERFLOW 0 /* Check underflow when popping values */ +# define VM_USE_HOOKS 0 /* Various hooks */ #elif (VM_ENGINE == SCM_VM_DEBUG_ENGINE) -#define VM_USE_HOOKS 1 -#define VM_CHECK_OBJECT 0 -#define VM_CHECK_FREE_VARIABLES 0 -#define VM_CHECK_UNDERFLOW 0 /* Check underflow when popping values */ +# define VM_USE_HOOKS 1 #else -#error unknown debug engine VM_ENGINE +# error unknown debug engine VM_ENGINE #endif @@ -163,12 +157,6 @@ #define ASSERT_BOUND(x) #endif -#if VM_CHECK_OBJECT -#define SET_OBJECT_COUNT(n) object_count = n -#else -#define SET_OBJECT_COUNT(n) /* nop */ -#endif - /* Cache the object table and free variables. */ #define CACHE_PROGRAM() \ { \ @@ -177,10 +165,8 @@ ASSERT_ALIGNED_PROCEDURE (); \ if (SCM_I_IS_VECTOR (SCM_PROGRAM_OBJTABLE (program))) { \ objects = SCM_I_VECTOR_WELTS (SCM_PROGRAM_OBJTABLE (program)); \ - SET_OBJECT_COUNT (SCM_I_VECTOR_LENGTH (SCM_PROGRAM_OBJTABLE (program))); \ } else { \ objects = NULL; \ - SET_OBJECT_COUNT (0); \ } \ } \ } @@ -201,20 +187,8 @@ */ /* Accesses to a program's object table. */ -#if VM_CHECK_OBJECT -#define CHECK_OBJECT(_num) \ - VM_ASSERT ((_num) < object_count, vm_error_object ()) -#else #define CHECK_OBJECT(_num) -#endif - -#if VM_CHECK_FREE_VARIABLES -#define CHECK_FREE_VARIABLE(_num) \ - VM_ASSERT ((_num) < SCM_PROGRAM_NUM_FREE_VARIABLES (program), \ - vm_error_free_variable ()) -#else #define CHECK_FREE_VARIABLE(_num) -#endif /* @@ -377,9 +351,6 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs) /* Cache variables */ struct scm_objcode *bp = NULL; /* program base pointer */ SCM *objects = NULL; /* constant objects */ -#if VM_CHECK_OBJECT - size_t object_count = 0; /* length of OBJECTS */ -#endif SCM *stack_limit = vp->stack_limit; /* stack limit address */ scm_i_thread *current_thread = SCM_I_CURRENT_THREAD; @@ -518,9 +489,6 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs) #undef RUN_HOOK #undef RUN_HOOK1 #undef VM_USE_HOOKS -#undef VM_CHECK_OBJECT -#undef VM_CHECK_FREE_VARIABLE -#undef VM_CHECK_UNDERFLOW /* Local Variables: diff --git a/libguile/vm.c b/libguile/vm.c index ccc182afe..0b0650d0f 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -408,15 +408,6 @@ static void vm_error_no_values (void) SCM_NORETURN SCM_NOINLINE; static void vm_error_not_enough_values (void) SCM_NORETURN SCM_NOINLINE; static void vm_error_continuation_not_rewindable (SCM cont) SCM_NORETURN SCM_NOINLINE; static void vm_error_bad_wide_string_length (size_t len) SCM_NORETURN SCM_NOINLINE; -#if VM_CHECK_IP -static void vm_error_invalid_address (void) SCM_NORETURN SCM_NOINLINE; -#endif -#if VM_CHECK_OBJECT -static void vm_error_object (void) SCM_NORETURN SCM_NOINLINE; -#endif -#if VM_CHECK_FREE_VARIABLES -static void vm_error_free_variable (void) SCM_NORETURN SCM_NOINLINE; -#endif static void vm_error (const char *msg, SCM arg) @@ -575,29 +566,6 @@ vm_error_bad_wide_string_length (size_t len) vm_error ("VM: Bad wide string length: ~S", scm_from_size_t (len)); } -#ifdef VM_CHECK_IP -static void -vm_error_invalid_address (void) -{ - vm_error ("VM: Invalid program address", SCM_UNDEFINED); -} -#endif - -#if VM_CHECK_OBJECT -static void -vm_error_object () -{ - vm_error ("VM: Invalid object table access", SCM_UNDEFINED); -} -#endif - -#if VM_CHECK_FREE_VARIABLES -static void -vm_error_free_variable () -{ - vm_error ("VM: Invalid free variable access", SCM_UNDEFINED); -} -#endif