mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 17:20:29 +02:00
Remove unboxed case from vm struct accessors
* libguile/vm.c (vm_error_boxed_struct_field): (vm_error_unboxed_struct_field): New helpers. * libguile/vm-engine.c (VM_VALIDATE_BOXED_STRUCT_FIELD): (VM_VALIDATE_UNBOXED_STRUCT_FIELD): New helpers. (struct-ref, struct-set!, struct-ref/immediate) (struct-set!/immediate): Remove unboxed case.
This commit is contained in:
parent
84259f54e3
commit
760662f7f1
2 changed files with 35 additions and 31 deletions
|
@ -441,6 +441,12 @@
|
||||||
|
|
||||||
#define VM_VALIDATE_INDEX(u64, size, proc) \
|
#define VM_VALIDATE_INDEX(u64, size, proc) \
|
||||||
VM_ASSERT (u64 < size, vm_error_out_of_range_uint64 (proc, u64))
|
VM_ASSERT (u64 < size, vm_error_out_of_range_uint64 (proc, u64))
|
||||||
|
#define VM_VALIDATE_BOXED_STRUCT_FIELD(layout, i, proc) \
|
||||||
|
VM_ASSERT (scm_i_symbol_ref (layout, i * 2) == 'p', \
|
||||||
|
vm_error_boxed_struct_field (proc, i))
|
||||||
|
#define VM_VALIDATE_UNBOXED_STRUCT_FIELD(layout, i, proc) \
|
||||||
|
VM_ASSERT (scm_i_symbol_ref (layout, i * 2) == 'u', \
|
||||||
|
vm_error_unboxed_struct_field (proc, i))
|
||||||
|
|
||||||
/* Return true (non-zero) if PTR has suitable alignment for TYPE. */
|
/* Return true (non-zero) if PTR has suitable alignment for TYPE. */
|
||||||
#define ALIGNED_P(ptr, type) \
|
#define ALIGNED_P(ptr, type) \
|
||||||
|
@ -2781,11 +2787,10 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
vtable = SCM_STRUCT_VTABLE (obj);
|
vtable = SCM_STRUCT_VTABLE (obj);
|
||||||
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
||||||
VM_VALIDATE_INDEX (index, nfields, "struct-ref");
|
VM_VALIDATE_INDEX (index, nfields, "struct-ref");
|
||||||
|
VM_VALIDATE_BOXED_STRUCT_FIELD (SCM_VTABLE_LAYOUT (vtable),
|
||||||
|
index, "struct-ref");
|
||||||
|
|
||||||
if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
|
RETURN (SCM_STRUCT_SLOT_REF (obj, index));
|
||||||
RETURN (SCM_STRUCT_SLOT_REF (obj, index));
|
|
||||||
else
|
|
||||||
RETURN (scm_from_uintptr_t (SCM_STRUCT_DATA_REF (obj, index)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* struct-set! dst:8 idx:8 src:8
|
/* struct-set! dst:8 idx:8 src:8
|
||||||
|
@ -2808,18 +2813,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
vtable = SCM_STRUCT_VTABLE (obj);
|
vtable = SCM_STRUCT_VTABLE (obj);
|
||||||
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
||||||
VM_VALIDATE_INDEX (index, nfields, "struct-set!");
|
VM_VALIDATE_INDEX (index, nfields, "struct-set!");
|
||||||
|
VM_VALIDATE_BOXED_STRUCT_FIELD (SCM_VTABLE_LAYOUT (vtable),
|
||||||
|
index, "struct-set!");
|
||||||
|
|
||||||
if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
|
SCM_STRUCT_SLOT_SET (obj, index, val);
|
||||||
{
|
NEXT (1);
|
||||||
SCM_STRUCT_SLOT_SET (obj, index, val);
|
|
||||||
NEXT (1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SYNC_IP ();
|
|
||||||
SCM_STRUCT_DATA_SET (obj, index, scm_to_uintptr_t (val));
|
|
||||||
NEXT (1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate-struct/immediate dst:8 vtable:8 nfields:8
|
/* allocate-struct/immediate dst:8 vtable:8 nfields:8
|
||||||
|
@ -2862,11 +2860,10 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
vtable = SCM_STRUCT_VTABLE (obj);
|
vtable = SCM_STRUCT_VTABLE (obj);
|
||||||
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
||||||
VM_VALIDATE_INDEX (index, nfields, "struct-ref");
|
VM_VALIDATE_INDEX (index, nfields, "struct-ref");
|
||||||
|
VM_VALIDATE_BOXED_STRUCT_FIELD (SCM_VTABLE_LAYOUT (vtable),
|
||||||
|
index, "struct-ref");
|
||||||
|
|
||||||
if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
|
RETURN (SCM_STRUCT_SLOT_REF (obj, index));
|
||||||
RETURN (SCM_STRUCT_SLOT_REF (obj, index));
|
|
||||||
else
|
|
||||||
RETURN (scm_from_uintptr_t (SCM_STRUCT_DATA_REF (obj, index)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* struct-set!/immediate dst:8 idx:8 src:8
|
/* struct-set!/immediate dst:8 idx:8 src:8
|
||||||
|
@ -2890,18 +2887,11 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
||||||
vtable = SCM_STRUCT_VTABLE (obj);
|
vtable = SCM_STRUCT_VTABLE (obj);
|
||||||
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
|
||||||
VM_VALIDATE_INDEX (index, nfields, "struct-set!");
|
VM_VALIDATE_INDEX (index, nfields, "struct-set!");
|
||||||
|
VM_VALIDATE_BOXED_STRUCT_FIELD (SCM_VTABLE_LAYOUT (vtable),
|
||||||
|
index, "struct-set!");
|
||||||
|
|
||||||
if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
|
SCM_STRUCT_SLOT_SET (obj, index, val);
|
||||||
{
|
NEXT (1);
|
||||||
SCM_STRUCT_SLOT_SET (obj, index, val);
|
|
||||||
NEXT (1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SYNC_IP ();
|
|
||||||
SCM_STRUCT_DATA_SET (obj, index, scm_to_uintptr_t (val));
|
|
||||||
NEXT (1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* class-of dst:12 type:12
|
/* class-of dst:12 type:12
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
|
/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017 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
|
||||||
|
@ -439,6 +439,8 @@ static void vm_error_not_a_vector (const char *subr, SCM v) SCM_NORETURN SCM_NOI
|
||||||
static void vm_error_not_a_mutable_vector (const char *subr, SCM v) SCM_NORETURN SCM_NOINLINE;
|
static void vm_error_not_a_mutable_vector (const char *subr, SCM v) SCM_NORETURN SCM_NOINLINE;
|
||||||
static void vm_error_out_of_range_uint64 (const char *subr, scm_t_uint64 idx) SCM_NORETURN SCM_NOINLINE;
|
static void vm_error_out_of_range_uint64 (const char *subr, scm_t_uint64 idx) SCM_NORETURN SCM_NOINLINE;
|
||||||
static void vm_error_out_of_range_int64 (const char *subr, scm_t_int64 idx) SCM_NORETURN SCM_NOINLINE;
|
static void vm_error_out_of_range_int64 (const char *subr, scm_t_int64 idx) SCM_NORETURN SCM_NOINLINE;
|
||||||
|
static void vm_error_boxed_struct_field (const char *subr, scm_t_uint64 idx) SCM_NORETURN SCM_NOINLINE;
|
||||||
|
static void vm_error_unboxed_struct_field (const char *subr, scm_t_uint64 idx) SCM_NORETURN SCM_NOINLINE;
|
||||||
static void vm_error_no_values (void) SCM_NORETURN SCM_NOINLINE;
|
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_not_enough_values (void) SCM_NORETURN SCM_NOINLINE;
|
||||||
static void vm_error_wrong_number_of_values (scm_t_uint32 expected) SCM_NORETURN SCM_NOINLINE;
|
static void vm_error_wrong_number_of_values (scm_t_uint32 expected) SCM_NORETURN SCM_NOINLINE;
|
||||||
|
@ -590,6 +592,18 @@ vm_error_out_of_range_int64 (const char *subr, scm_t_int64 idx)
|
||||||
scm_out_of_range (subr, scm_from_int64 (idx));
|
scm_out_of_range (subr, scm_from_int64 (idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vm_error_boxed_struct_field (const char *subr, scm_t_uint64 idx)
|
||||||
|
{
|
||||||
|
scm_wrong_type_arg_msg (subr, 2, scm_from_uint64 (idx), "boxed field");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vm_error_unboxed_struct_field (const char *subr, scm_t_uint64 idx)
|
||||||
|
{
|
||||||
|
scm_wrong_type_arg_msg (subr, 2, scm_from_uint64 (idx), "unboxed field");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_error_no_values (void)
|
vm_error_no_values (void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue