(pcase insn
(`(set ,lval ,rval)
(pcase rval
- (`(,(or 'call 'direct-call) ,f . ,args)
- (setf (comp-mvar-type lval)
- (alist-get f comp-known-ret-types))
- (comp-function-call-maybe-remove insn f args))
- (`(,(or 'callref 'direct-callref) ,f . ,args)
+ (`(,(or 'call 'callref) ,f . ,args)
(setf (comp-mvar-type lval)
(alist-get f comp-known-ret-types))
(comp-function-call-maybe-remove insn f args))
+ (`(,(or 'direct-call 'direct-callref) ,f . ,args)
+ (let ((f (comp-func-name (gethash f (comp-ctxt-funcs-h comp-ctxt)))))
+ (setf (comp-mvar-type lval)
+ (alist-get f comp-known-ret-types))
+ (comp-function-call-maybe-remove insn f args)))
(_
(comp-mvar-propagate lval rval))))
(`(phi ,lval . ,rest)
(not (memq callee comp-never-optimize-functions)))
(let* ((f (symbol-function callee))
(subrp (subrp f))
- (callee-in-unit (gethash (gethash callee
- (comp-ctxt-sym-to-c-name-h comp-ctxt))
- (comp-ctxt-funcs-h comp-ctxt))))
+ (comp-func-callee (gethash (gethash callee
+ (comp-ctxt-sym-to-c-name-h comp-ctxt))
+ (comp-ctxt-funcs-h comp-ctxt))))
(cond
((and subrp (not (subr-native-elisp-p f)))
;; Trampoline removal.
(maxarg (cdr (subr-arity f)))
(call-type (if (if subrp
(not (numberp maxarg))
- (comp-nargs-p callee-in-unit))
+ (comp-nargs-p comp-func-callee))
'callref
'call))
(args (if (eq call-type 'callref)
;; Intra compilation unit procedure call optimization.
;; Attention speed 3 triggers this for non self calls too!!
((and (>= comp-speed 3)
- callee-in-unit)
- (let* ((func-args (comp-func-args callee-in-unit))
+ comp-func-callee)
+ (let* ((func-args (comp-func-args comp-func-callee))
(nargs (comp-nargs-p func-args))
(call-type (if nargs 'direct-callref 'direct-call))
(args (if (eq call-type 'direct-callref)
args
(fill-args args (comp-args-max func-args)))))
- `(,call-type ,callee ,@args)))
+ `(,call-type ,(comp-func-c-name comp-func-callee) ,@args)))
((comp-type-hint-p callee)
`(call ,callee ,@args)))))))
}
/* Emit calls fetching from existing declarations. */
+
static gcc_jit_rvalue *
-emit_call (Lisp_Object subr_sym, gcc_jit_type *ret_type, ptrdiff_t nargs,
+emit_call (Lisp_Object func, gcc_jit_type *ret_type, ptrdiff_t nargs,
gcc_jit_rvalue **args, bool direct)
{
- Lisp_Object func;
- if (direct)
- {
- Lisp_Object c_name =
- Fgethash (subr_sym,
- CALL1I (comp-ctxt-sym-to-c-name-h, Vcomp_ctxt),
- Qnil);
- func = Fgethash (c_name, comp.exported_funcs_h, Qnil);
- }
- else
- func = Fgethash (subr_sym, comp.imported_funcs_h, Qnil);
+ Lisp_Object gcc_func =
+ Fgethash (func,
+ direct ? comp.exported_funcs_h : comp.imported_funcs_h,
+ Qnil);
- if (NILP (func))
+ if (NILP (gcc_func))
xsignal2 (Qnative_ice,
build_string ("missing function declaration"),
- subr_sym);
+ func);
if (direct)
{
- emit_comment (format_string ("direct call to subr: %s",
- SSDATA (SYMBOL_NAME (subr_sym))));
+ emit_comment (format_string ("direct call to: %s",
+ SSDATA (func)));
return gcc_jit_context_new_call (comp.ctxt,
NULL,
- xmint_pointer (func),
+ xmint_pointer (gcc_func),
nargs,
args);
}
gcc_jit_rvalue_dereference_field (
gcc_jit_lvalue_as_rvalue (comp.func_relocs),
NULL,
- (gcc_jit_field *) xmint_pointer (func));
+ (gcc_jit_field *) xmint_pointer (gcc_func));
if (!f_ptr)
xsignal2 (Qnative_ice,
build_string ("missing function relocation"),
- subr_sym);
+ func);
emit_comment (format_string ("calling subr: %s",
- SSDATA (SYMBOL_NAME (subr_sym))));
+ SSDATA (SYMBOL_NAME (func))));
return gcc_jit_context_new_call_through_ptr (comp.ctxt,
NULL,
gcc_jit_lvalue_as_rvalue (f_ptr),
}
static gcc_jit_rvalue *
-emit_call_ref (Lisp_Object subr_sym, ptrdiff_t nargs,
+emit_call_ref (Lisp_Object func, ptrdiff_t nargs,
gcc_jit_lvalue *base_arg, bool direct)
{
gcc_jit_rvalue *args[] =
comp.ptrdiff_type,
nargs),
gcc_jit_lvalue_get_address (base_arg, NULL) };
- return emit_call (subr_sym, comp.lisp_obj_type, 2, args, direct);
+ return emit_call (func, comp.lisp_obj_type, 2, args, direct);
}
/* Close current basic block emitting a conditional. */