1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 02:00:26 +02:00

push error handlers out of line in the vm

* libguile/vm.c:
  (vm_error):
  (vm_error_bad_instruction):
  (vm_error_unbound):
  (vm_error_unbound_fluid):
  (vm_error_not_a_variable):
  (vm_error_not_a_thunk):
  (vm_error_apply_to_non_list):
  (vm_error_kwargs_length_not_even):
  (vm_error_kwargs_invalid_keyword):
  (vm_error_kwargs_unrecognized_keyword):
  (vm_error_too_many_args):
  (vm_error_wrong_num_args):
  (vm_error_wrong_type_apply):
  (vm_error_stack_overflow):
  (vm_error_stack_underflow):
  (vm_error_improper_list):
  (vm_error_not_a_pair):
  (vm_error_not_a_bytevector):
  (vm_error_not_a_struct):
  (vm_error_no_values):
  (vm_error_not_enough_values):
  (vm_error_continuation_not_rewindable):
  (vm_error_bad_wide_string_length):
  (vm_error_invalid_address):
  (vm_error_object):
  (vm_error_free_variable): New internal helpers, implementing VM error
  handling.

* libguile/vm-engine.h (VM_ASSERT): New helper macro.
  (ASSERT, CHECK_OBJECT, CHECK_FREE_VARIABLE):
  (PRE_CHECK_UNDERFLOW, PUSH_LIST): Use the new helper.

* libguile/vm-i-loader.c:
* libguile/vm-i-scheme.c:
* libguile/vm-i-system.c: Use VM_ASSERT and the out-of-line error
  handlers.

* libguile/vm-engine.c (vm_engine): Remove inline error handlers, and
  remove a couple of local vars.  Use VM_ASSERT.  Have halt handle the
  return itself.
This commit is contained in:
Andy Wingo 2012-04-30 20:25:53 +02:00
parent 7dbc03498a
commit 53bdfcf034
6 changed files with 332 additions and 320 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@ -124,11 +124,7 @@ VM_DEFINE_FUNCTION (140, cons, "cons", 2)
}
#define VM_VALIDATE_CONS(x, proc) \
if (SCM_UNLIKELY (!scm_is_pair (x))) \
{ func_name = proc; \
finish_args = x; \
goto vm_error_not_a_pair; \
}
VM_ASSERT (scm_is_pair (x), vm_error_not_a_pair (proc, x))
VM_DEFINE_FUNCTION (141, car, "car", 1)
{
@ -503,12 +499,7 @@ VM_DEFINE_INSTRUCTION (165, make_array, "make-array", 3, -1, 1)
* Structs
*/
#define VM_VALIDATE_STRUCT(obj, proc) \
if (SCM_UNLIKELY (!SCM_STRUCTP (obj))) \
{ \
func_name = proc; \
finish_args = (obj); \
goto vm_error_not_a_struct; \
}
VM_ASSERT (SCM_STRUCTP (obj), vm_error_not_a_pair (proc, obj))
VM_DEFINE_FUNCTION (166, struct_p, "struct?", 1)
{
@ -654,16 +645,7 @@ VM_DEFINE_INSTRUCTION (173, slot_set, "slot-set", 0, 3, 0)
* Bytevectors
*/
#define VM_VALIDATE_BYTEVECTOR(x, proc) \
do \
{ \
if (SCM_UNLIKELY (!SCM_BYTEVECTOR_P (x))) \
{ \
func_name = proc; \
finish_args = x; \
goto vm_error_not_a_bytevector; \
} \
} \
while (0)
VM_ASSERT (SCM_BYTEVECTOR_P (x), vm_error_not_a_bytevector (proc, x))
#define BV_REF_WITH_ENDIANNESS(stem, fn_stem) \
{ \