(f (gethash c-name (comp-ctxt-funcs-h comp-ctxt)))
(args (comp-prepare-args-for-top-level f)))
(cl-assert (and name f))
- (comp-emit (comp-call (if for-late-load
- 'comp--late-register-subr
- 'comp--register-subr)
- (make-comp-mvar :constant name)
- (car args)
- (cdr args)
- (make-comp-mvar :constant c-name)
- (make-comp-mvar
- :constant
- (let* ((h (comp-ctxt-function-docs comp-ctxt))
- (i (hash-table-count h)))
- (puthash i (comp-func-doc f) h)
- i))
- (make-comp-mvar :constant
- (comp-func-int-spec f))
- ;; This is the compilation unit it-self passed as
- ;; parameter.
- (make-comp-mvar :slot 0)))))
+ (comp-emit
+ `(set ,(make-comp-mvar :slot 1)
+ ,(comp-call (if for-late-load
+ 'comp--late-register-subr
+ 'comp--register-subr)
+ (make-comp-mvar :constant name)
+ (car args)
+ (cdr args)
+ (make-comp-mvar :constant c-name)
+ (make-comp-mvar
+ :constant
+ (let* ((h (comp-ctxt-function-docs comp-ctxt))
+ (i (hash-table-count h)))
+ (puthash i (comp-func-doc f) h)
+ i))
+ (make-comp-mvar :constant
+ (comp-func-int-spec f))
+ ;; This is the compilation unit it-self passed as
+ ;; parameter.
+ (make-comp-mvar :slot 0))))))
(cl-defmethod comp-emit-for-top-level ((form byte-to-native-top-level)
for-late-load)
"late_top_level_run"
"top_level_run")
:args (make-comp-args :min 1 :max 1)
- :frame-size 1
+ ;; Frame is 2 wide: Slot 0 is the
+ ;; compilation unit being loaded
+ ;; (incoming parameter). Slot 1 is
+ ;; the last function being
+ ;; registered.
+ :frame-size 2
:speed comp-speed))
(comp-func func)
(comp-pass (make-comp-limplify
(comp-ctxt-byte-func-to-func-h comp-ctxt))
(mapc (lambda (x) (comp-emit-for-top-level x for-late-load))
(comp-ctxt-top-level-forms comp-ctxt))
- (comp-emit `(return ,(make-comp-mvar :constant t)))
+ (comp-emit `(return ,(make-comp-mvar :slot 1)))
(puthash 0 (comp-func-frame-size func) (comp-func-array-h func))
(comp-limplify-finalize-function func)))
XNATIVE_COMP_UNIT (comp_u)->load_ongoing = false;
}
-void
+Lisp_Object
load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u, bool loading_dump,
bool late_load)
{
+ Lisp_Object res = Qnil;
dynlib_handle_ptr handle = comp_u->handle;
Lisp_Object comp_u_lisp_obj;
XSETNATIVE_COMP_UNIT (comp_u_lisp_obj, comp_u);
}
/* Executing this will perform all the expected environment
modifications. */
- top_level_run (comp_u_lisp_obj);
+ res = top_level_run (comp_u_lisp_obj);
/* Make sure data_ephemeral_vec still exists after top_level_run has run.
Guard against sibling call optimization (or any other). */
data_ephemeral_vec = data_ephemeral_vec;
register_native_comp_unit (comp_u_lisp_obj);
- return;
+ return res;
}
Lisp_Object
comp_u->data_vec = Qnil;
comp_u->lambda_gc_guard_h = CALLN (Fmake_hash_table, QCtest, Qeq);
comp_u->lambda_c_name_idx_h = CALLN (Fmake_hash_table, QCtest, Qequal);
- load_comp_unit (comp_u, false, !NILP (late_load));
-
- return Qt;
+ return load_comp_unit (comp_u, false, !NILP (late_load));
}
#endif /* HAVE_NATIVE_COMP */
extern void hash_native_abi (void);
-extern void load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
- bool loading_dump, bool late_load);
+extern Lisp_Object load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u,
+ bool loading_dump, bool late_load);
extern Lisp_Object native_function_doc (Lisp_Object function);