1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 14:21:10 +02:00

Inline struct-ref etc definitions in the VM.

* libguile/vm-engine.c (struct-ref, struct-set!, struct-ref/immediate)
  (struct-set!/immediate): Inline definitions.  Still a ways to go
  before no function calls though.
This commit is contained in:
Andy Wingo 2017-09-23 15:51:50 +02:00
parent 5870188eb4
commit 9211981524

View file

@ -1,5 +1,5 @@
/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013, /* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013,
* 2014, 2015 Free Software Foundation, Inc. * 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
@ -2769,23 +2769,23 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
VM_DEFINE_OP (108, struct_ref, "struct-ref", OP1 (X8_S8_S8_S8) | OP_DST) VM_DEFINE_OP (108, struct_ref, "struct-ref", OP1 (X8_S8_S8_S8) | OP_DST)
{ {
scm_t_uint8 dst, src, idx; scm_t_uint8 dst, src, idx;
SCM obj; SCM obj, vtable;
scm_t_uint64 index; scm_t_uint64 index, nfields;
UNPACK_8_8_8 (op, dst, src, idx); UNPACK_8_8_8 (op, dst, src, idx);
obj = SP_REF (src); obj = SP_REF (src);
index = SP_REF_U64 (idx); index = SP_REF_U64 (idx);
if (SCM_LIKELY (SCM_STRUCTP (obj) VM_VALIDATE_STRUCT (obj, "struct-ref");
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, vtable = SCM_STRUCT_VTABLE (obj);
SCM_VTABLE_FLAG_SIMPLE) nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
&& index < (SCM_STRUCT_DATA_REF (SCM_STRUCT_VTABLE (obj), VM_VALIDATE_INDEX (index, nfields, "struct-ref");
scm_vtable_index_size))))
RETURN (SCM_STRUCT_SLOT_REF (obj, index));
SYNC_IP (); if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
RETURN (scm_struct_ref (obj, scm_from_uint64 (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
@ -2795,8 +2795,8 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
VM_DEFINE_OP (109, struct_set, "struct-set!", OP1 (X8_S8_S8_S8)) VM_DEFINE_OP (109, struct_set, "struct-set!", OP1 (X8_S8_S8_S8))
{ {
scm_t_uint8 dst, idx, src; scm_t_uint8 dst, idx, src;
SCM obj, val; SCM obj, vtable, val;
scm_t_uint64 index; scm_t_uint64 index, nfields;
UNPACK_8_8_8 (op, dst, idx, src); UNPACK_8_8_8 (op, dst, idx, src);
@ -2804,21 +2804,22 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
val = SP_REF (src); val = SP_REF (src);
index = SP_REF_U64 (idx); index = SP_REF_U64 (idx);
if (SCM_LIKELY (SCM_STRUCTP (obj) VM_VALIDATE_STRUCT (obj, "struct-set!");
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, vtable = SCM_STRUCT_VTABLE (obj);
SCM_VTABLE_FLAG_SIMPLE) nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, VM_VALIDATE_INDEX (index, nfields, "struct-set!");
SCM_VTABLE_FLAG_SIMPLE_RW)
&& index < (SCM_STRUCT_DATA_REF (SCM_STRUCT_VTABLE (obj), if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
scm_vtable_index_size))))
{ {
SCM_STRUCT_SLOT_SET (obj, index, val); SCM_STRUCT_SLOT_SET (obj, index, val);
NEXT (1); NEXT (1);
} }
else
SYNC_IP (); {
scm_struct_set_x (obj, scm_from_uint64 (index), val); SYNC_IP ();
NEXT (1); 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
@ -2849,21 +2850,23 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
VM_DEFINE_OP (111, struct_ref_immediate, "struct-ref/immediate", OP1 (X8_S8_S8_C8) | OP_DST) VM_DEFINE_OP (111, struct_ref_immediate, "struct-ref/immediate", OP1 (X8_S8_S8_C8) | OP_DST)
{ {
scm_t_uint8 dst, src, idx; scm_t_uint8 dst, src, idx;
SCM obj; SCM obj, vtable;
scm_t_uint64 index, nfields;
UNPACK_8_8_8 (op, dst, src, idx); UNPACK_8_8_8 (op, dst, src, idx);
obj = SP_REF (src); obj = SP_REF (src);
index = idx;
if (SCM_LIKELY (SCM_STRUCTP (obj) VM_VALIDATE_STRUCT (obj, "struct-ref");
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, vtable = SCM_STRUCT_VTABLE (obj);
SCM_VTABLE_FLAG_SIMPLE) nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
&& idx < SCM_STRUCT_DATA_REF (SCM_STRUCT_VTABLE (obj), VM_VALIDATE_INDEX (index, nfields, "struct-ref");
scm_vtable_index_size)))
RETURN (SCM_STRUCT_SLOT_REF (obj, idx));
SYNC_IP (); if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
RETURN (scm_struct_ref (obj, SCM_I_MAKINUM (idx))); 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
@ -2874,28 +2877,31 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
VM_DEFINE_OP (112, struct_set_immediate, "struct-set!/immediate", OP1 (X8_S8_C8_S8)) VM_DEFINE_OP (112, struct_set_immediate, "struct-set!/immediate", OP1 (X8_S8_C8_S8))
{ {
scm_t_uint8 dst, idx, src; scm_t_uint8 dst, idx, src;
SCM obj, val; SCM obj, vtable, val;
scm_t_uint64 index, nfields;
UNPACK_8_8_8 (op, dst, idx, src); UNPACK_8_8_8 (op, dst, idx, src);
obj = SP_REF (dst); obj = SP_REF (dst);
val = SP_REF (src); val = SP_REF (src);
index = idx;
if (SCM_LIKELY (SCM_STRUCTP (obj) VM_VALIDATE_STRUCT (obj, "struct-set!");
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, vtable = SCM_STRUCT_VTABLE (obj);
SCM_VTABLE_FLAG_SIMPLE) nfields = SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size);
&& SCM_STRUCT_VTABLE_FLAG_IS_SET (obj, VM_VALIDATE_INDEX (index, nfields, "struct-set!");
SCM_VTABLE_FLAG_SIMPLE_RW)
&& idx < SCM_STRUCT_DATA_REF (SCM_STRUCT_VTABLE (obj), if (scm_i_symbol_ref (SCM_VTABLE_LAYOUT (vtable), index * 2) == 'p')
scm_vtable_index_size)))
{ {
SCM_STRUCT_SLOT_SET (obj, idx, val); 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); NEXT (1);
} }
SYNC_IP ();
scm_struct_set_x (obj, SCM_I_MAKINUM (idx), val);
NEXT (1);
} }
/* class-of dst:12 type:12 /* class-of dst:12 type:12