From: Andrea Corallo Date: Mon, 8 Jul 2019 16:33:56 +0000 (+0200) Subject: first functional function X-Git-Tag: emacs-28.0.90~2727^2~1378 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cd55772c8c4fea27b344633dec7ad893cf799036;p=emacs.git first functional function --- diff --git a/src/comp.c b/src/comp.c index 4f6382304a6..e524e28b143 100644 --- a/src/comp.c +++ b/src/comp.c @@ -121,6 +121,7 @@ typedef struct { gcc_jit_function *check_impure; Lisp_Object func_blocks; /* blk_name -> gcc_block. */ Lisp_Object func_hash; /* f_name -> gcc_func. */ + Lisp_Object funcs; /* List of functions defined. */ } comp_t; static comp_t comp; @@ -1686,6 +1687,7 @@ DEFUN ("comp-init-ctxt", Fcomp_init_ctxt, Scomp_init_ctxt, return Qnil; } comp.ctxt = gcc_jit_context_acquire(); + comp.funcs = Qnil; if (COMP_DEBUG) { @@ -1907,6 +1909,8 @@ DEFUN ("comp-add-func-to-ctxt", Fcomp_add_func_to_ctxt, Scomp_add_func_to_ctxt, limple = XCDR (limple); } + comp.funcs = Fcons (func, comp.funcs); + return Qt; } @@ -1933,15 +1937,26 @@ DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt, GCC_JIT_OUTPUT_KIND_ASSEMBLER, "gcc-ctxt-dump.s"); - /* FIXME: must iterate all function names. */ - union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); - x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; - x->s.function.a0 = gcc_jit_result_get_code(gcc_res, "F666f6f_foo"); - eassert (x->s.function.a0); - x->s.min_args = 0; - x->s.max_args = 0; - x->s.symbol_name = "foo"; - defsubr(x); + while (CONSP (comp.funcs)) + { + union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); + Lisp_Object func = XCAR (comp.funcs); + Lisp_Object args = (CALLN (Ffuncall, intern ("comp-func-args"), func)); + char *c_name = + (char *) SDATA (CALLN (Ffuncall, + intern ("comp-func-c-func-name"), + func)); + + x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; + x->s.function.a0 = gcc_jit_result_get_code(gcc_res, c_name); + eassert (x->s.function.a0); + x->s.min_args = XFIXNUM (CALLN (Ffuncall, intern ("comp-args-min"), args)); + x->s.max_args = XFIXNUM (CALLN (Ffuncall, intern ("comp-args-min"), args)); + x->s.symbol_name = "foo"; + defsubr(x); + + comp.funcs = XCDR (comp.funcs); + } unblock_atimers (&oldset);