:documentation "Optimization level (see `comp-speed').")
(pure nil :type boolean
:documentation "t if pure nil otherwise.")
- (type nil :type list
- :documentation "Derived return type."))
+ (type nil :type (or null comp-mvar)
+ :documentation "Mvar holding the derived return type."))
(cl-defstruct (comp-func-l (:include comp-func))
"Lexically-scoped function."
(make-comp-mvar :constant c-name)
(car args)
(cdr args)
+ (setf (comp-func-type f)
+ (make-comp-mvar :constant nil))
(make-comp-mvar
:constant
(list
(make-comp-mvar :constant (comp-func-c-name func))
(car args)
(cdr args)
+ (setf (comp-func-type func)
+ (make-comp-mvar :constant nil))
(make-comp-mvar
:constant
(list
(defun comp-compute-function-type (_ func)
"Compute type specifier for `comp-func' FUNC.
Set it into the `type' slot."
- (when (comp-func-l-p func)
+ (when (and (comp-func-l-p func)
+ (comp-mvar-p (comp-func-type func)))
(let* ((comp-func (make-comp-func))
(res-mvar (apply #'comp-cstr-union
(make-comp-cstr)
do (pcase insn
(`(return ,mvar)
(push mvar res))))
- finally return res))))
- (setf (comp-func-type func)
- `(function ,(comp-args-to-lambda-list (comp-func-l-args func))
- ,(comp-cstr-to-type-spec res-mvar))))))
+ finally return res)))
+ (type `(function ,(comp-args-to-lambda-list (comp-func-l-args func))
+ ,(comp-cstr-to-type-spec res-mvar))))
+ (comp-add-const-to-relocs type)
+ ;; Fix it up.
+ (setf (comp-mvar-value (comp-func-type func)) type))))
(defun comp-finalize-container (cont)
"Finalize data container CONT."
\f
/* Increase this number to force a new Vcomp_abi_hash to be generated. */
-#define ABI_VERSION "0"
+#define ABI_VERSION "1"
/* C symbols emitted for the load relocation mechanism. */
#define CURRENT_THREAD_RELOC_SYM "current_thread_reloc"
static Lisp_Object
make_subr (Lisp_Object symbol_name, Lisp_Object minarg, Lisp_Object maxarg,
- Lisp_Object c_name, Lisp_Object doc_idx, Lisp_Object intspec,
- Lisp_Object comp_u)
+ Lisp_Object c_name, Lisp_Object type, Lisp_Object doc_idx,
+ Lisp_Object intspec, Lisp_Object comp_u)
{
struct Lisp_Native_Comp_Unit *cu = XNATIVE_COMP_UNIT (comp_u);
dynlib_handle_ptr handle = cu->handle;
x->s.doc = XFIXNUM (doc_idx);
x->s.native_comp_u[0] = comp_u;
x->s.native_c_name[0] = xstrdup (SSDATA (c_name));
+ x->s.type[0] = type;
Lisp_Object tem;
XSETSUBR (tem, &x->s);
}
DEFUN ("comp--register-lambda", Fcomp__register_lambda, Scomp__register_lambda,
- 6, 6, 0,
+ 7, 7, 0,
doc: /* Register anonymous lambda.
This gets called by top_level_run during the load phase. */)
(Lisp_Object reloc_idx, Lisp_Object c_name, Lisp_Object minarg,
- Lisp_Object maxarg, Lisp_Object rest, Lisp_Object comp_u)
+ Lisp_Object maxarg, Lisp_Object type, Lisp_Object rest,
+ Lisp_Object comp_u)
{
Lisp_Object doc_idx = FIRST (rest);
Lisp_Object intspec = SECOND (rest);
return Qnil;
Lisp_Object tem =
- make_subr (c_name, minarg, maxarg, c_name, doc_idx, intspec, comp_u);
+ make_subr (c_name, minarg, maxarg, c_name, type, doc_idx, intspec, comp_u);
/* We must protect it against GC because the function is not
reachable through symbols. */
}
DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
- 6, 6, 0,
+ 7, 7, 0,
doc: /* Register exported subr.
This gets called by top_level_run during the load phase. */)
(Lisp_Object name, Lisp_Object c_name, Lisp_Object minarg,
- Lisp_Object maxarg, Lisp_Object rest, Lisp_Object comp_u)
+ Lisp_Object maxarg, Lisp_Object type, Lisp_Object rest,
+ Lisp_Object comp_u)
{
Lisp_Object doc_idx = FIRST (rest);
Lisp_Object intspec = SECOND (rest);
Lisp_Object tem =
- make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, doc_idx, intspec,
- comp_u);
+ make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, type, doc_idx,
+ intspec, comp_u);
if (AUTOLOADP (XSYMBOL (name)->u.s.function))
/* Remember that the function was already an autoload. */
}
DEFUN ("comp--late-register-subr", Fcomp__late_register_subr,
- Scomp__late_register_subr, 6, 6, 0,
+ Scomp__late_register_subr, 7, 7, 0,
doc: /* Register exported subr.
This gets called by late_top_level_run during the load phase. */)
(Lisp_Object name, Lisp_Object c_name, Lisp_Object minarg,
- Lisp_Object maxarg, Lisp_Object rest, Lisp_Object comp_u)
+ Lisp_Object maxarg, Lisp_Object type, Lisp_Object rest,
+ Lisp_Object comp_u)
{
if (!NILP (Fequal (Fsymbol_function (name),
Fgethash (name, Vcomp_deferred_pending_h, Qnil))))