mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Rework foreign-call trampoline
* libguile/foreign.c (scm_i_foreign_call): Rename back from foreign_call. Need a new trampoline that's easier to call from JIT, until we actually rewrite the FFI in terms of the JIT. (scm_register_foreign): Remove foreign_call intrinsic init. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Foreign-call intrinsic sets return directly on stack. * libguile/vm-engine.c (foreign-call): Adapt to new intrinsic behavior. * libguile/vm.c (foreign_call, scm_bootstrap_vm): Add new intrinsic wrapper.
This commit is contained in:
parent
6027027724
commit
939b1ae23f
5 changed files with 24 additions and 12 deletions
|
@ -1016,9 +1016,9 @@ pack (const ffi_type * type, const void *loc, int return_value_p)
|
|||
|
||||
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
|
||||
|
||||
static SCM
|
||||
foreign_call (SCM cif_scm, SCM pointer_scm, SCM *errno_ret,
|
||||
const union scm_vm_stack_element *argv)
|
||||
SCM
|
||||
scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
|
||||
const union scm_vm_stack_element *argv)
|
||||
{
|
||||
/* FOREIGN is the pair that cif_to_procedure set as the 0th element of the
|
||||
objtable. */
|
||||
|
@ -1070,7 +1070,7 @@ foreign_call (SCM cif_scm, SCM pointer_scm, SCM *errno_ret,
|
|||
/* off we go! */
|
||||
errno = 0;
|
||||
ffi_call (cif, func, rvalue, args);
|
||||
*errno_ret = scm_from_int (errno);
|
||||
*errno_ret = errno;
|
||||
|
||||
return pack (cif->rtype, rvalue, 1);
|
||||
}
|
||||
|
@ -1305,6 +1305,5 @@ scm_register_foreign (void)
|
|||
"scm_init_foreign",
|
||||
(scm_t_extension_init_func)scm_init_foreign,
|
||||
NULL);
|
||||
scm_vm_intrinsics.foreign_call = foreign_call;
|
||||
pointer_weak_refs = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue