1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Alloc foreign procedures using primitive mechanism

* libguile/foreign.c (get_foreign_stub_code): Use
  scm_i_alloc_primitive_code_with_instrumentation.  This will allow FFI
  procedures to be JITted, and allow us to move the apply hook to
  instrument-entry.
This commit is contained in:
Andy Wingo 2018-08-06 13:35:41 +02:00
parent d145b57baf
commit 14539d3986

View file

@ -830,15 +830,14 @@ get_foreign_stub_code (unsigned int nargs, int with_errno)
{ {
size_t i; size_t i;
size_t code_len = with_errno ? 4 : 5; size_t code_len = with_errno ? 4 : 5;
uint32_t *code; uint32_t *ret, *code;
code = scm_gc_malloc_pointerless (code_len * sizeof (uint32_t),
"foreign code");
if (nargs >= (1 << 24) + 1) if (nargs >= (1 << 24) + 1)
scm_misc_error ("make-foreign-function", "too many arguments: ~a", scm_misc_error ("make-foreign-function", "too many arguments: ~a",
scm_list_1 (scm_from_uint (nargs))); scm_list_1 (scm_from_uint (nargs)));
ret = scm_i_alloc_primitive_code_with_instrumentation (code_len, &code);
i = 0; i = 0;
code[i++] = SCM_PACK_OP_24 (assert_nargs_ee, nargs + 1); code[i++] = SCM_PACK_OP_24 (assert_nargs_ee, nargs + 1);
code[i++] = SCM_PACK_OP_12_12 (foreign_call, 0, 1); code[i++] = SCM_PACK_OP_12_12 (foreign_call, 0, 1);
@ -847,7 +846,7 @@ get_foreign_stub_code (unsigned int nargs, int with_errno)
code[i++] = SCM_PACK_OP_24 (reset_frame, 1); code[i++] = SCM_PACK_OP_24 (reset_frame, 1);
code[i++] = SCM_PACK_OP_24 (return_values, 0); code[i++] = SCM_PACK_OP_24 (return_values, 0);
return code; return ret;
} }
static SCM static SCM