fatal ("Overflowing function relocation table, increase F_RELOC_MAX_SIZE");
}
+int
+filled_freloc (void)
+{
+ return freloc.link_table[0] ? 1 : 0;
+}
+
/******************************************************************************/
/* Helper functions called from the run-time. */
/* These can't be statics till shared mechanism is used to solve relocations. */
return Fread (make_string (res->data, res->len));
}
-static void
+void
load_comp_unit (struct Lisp_Native_Comp_Unit *comp_u)
{
dynlib_handle_ptr handle = comp_u->handle;
if (!freloc.link_table[0])
xsignal2 (Qnative_lisp_load_failed, file,
build_string ("Empty relocation table"));
-
- dynlib_handle_ptr handle = dynlib_open (SSDATA (file));
- load_handle_stack = Fcons (make_mint_ptr (handle), load_handle_stack);
- if (!handle)
- xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ()));
struct Lisp_Native_Comp_Unit *comp_u = allocate_native_comp_unit();
+ comp_u->handle = dynlib_open (SSDATA (file));
+ if (!comp_u->handle)
+ xsignal2 (Qnative_lisp_load_failed, file, build_string (dynlib_error ()));
comp_u->file = file;
- comp_u->fd = fd_out;
- comp_u->handle = handle;
load_comp_unit (comp_u);
return Qt;
COLD_OP_CHARSET,
COLD_OP_BUFFER,
COLD_OP_BIGNUM,
+ COLD_OP_NATIVE_SUBR,
};
/* This structure controls what operations we perform inside
static void *
dump_object_emacs_ptr (Lisp_Object lv)
{
- if (SUBRP (lv))
+ if (SUBRP (lv) && !SUBRP_NATIVE_COMPILEDP (lv))
return XSUBR (lv);
if (dump_builtin_symbol_p (lv))
return XSYMBOL (lv);
#endif
DUMP_FIELD_COPY (&out, subr, min_args);
DUMP_FIELD_COPY (&out, subr, max_args);
- dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
#ifdef HAVE_NATIVE_COMP
if (subr->native_comp_u)
{
+ dump_field_fixup_later (ctx, &out, subr, &subr->symbol_name);
+ dump_remember_cold_op (ctx,
+ COLD_OP_NATIVE_SUBR,
+ make_lisp_ptr ((void *) subr, Lisp_Vectorlike));
dump_field_lv (ctx, &out, subr, &subr->native_intspec, WEIGHT_NORMAL);
dump_field_lv (ctx, &out, subr, &subr->native_doc, WEIGHT_NORMAL);
}
else
{
+ dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
DUMP_FIELD_COPY (&out, subr, doc);
}
dump_field_lv (ctx, &out, subr, &subr->native_comp_u, WEIGHT_NORMAL);
#else
+ dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
DUMP_FIELD_COPY (&out, subr, doc);
#endif
{
START_DUMP_PVEC (ctx, &comp_u->header, struct Lisp_Native_Comp_Unit, out);
dump_pseudovector_lisp_fields (ctx, &out->header, &comp_u->header);
- out->fd = 0;
- out->handle = 0;
- return finish_dump_pvec (ctx, &out->header);
+ out->handle = NULL;
+
+ dump_off comp_u_off = finish_dump_pvec (ctx, &out->header);
+ return comp_u_off;
}
#endif
case PVEC_BIGNUM:
offset = dump_bignum (ctx, lv);
break;
+#ifdef HAVE_NATIVE_COMP
+ case PVEC_NATIVE_COMP_UNIT:
+ offset = dump_native_comp_unit (ctx, XNATIVE_COMP_UNIT (lv));
+ break;
+#endif
case PVEC_WINDOW_CONFIGURATION:
error_unsupported_dump_object (ctx, lv, "window configuration");
case PVEC_OTHER:
error_unsupported_dump_object (ctx, lv, "condvar");
case PVEC_MODULE_FUNCTION:
error_unsupported_dump_object (ctx, lv, "module function");
-#ifdef HAVE_NATIVE_COMP
- case PVEC_NATIVE_COMP_UNIT:
- offset = dump_native_comp_unit (ctx, XNATIVE_COMP_UNIT (lv));
- break;
-#endif
default:
error_unsupported_dump_object(ctx, lv, "weird pseudovector");
}
}
}
+static void
+dump_cold_native_subr (struct dump_context *ctx, Lisp_Object subr)
+{
+ /* Dump subr contents. */
+ dump_off subr_offset = dump_recall_object (ctx, subr);
+ eassert (subr_offset > 0);
+ dump_remember_fixup_ptr_raw
+ (ctx,
+ subr_offset + dump_offsetof (struct Lisp_Subr, symbol_name),
+ ctx->offset);
+ const char *symbol_name = XSUBR (subr)->symbol_name;
+ ALLOW_IMPLICIT_CONVERSION;
+ dump_write (ctx, symbol_name, 1 + strlen (symbol_name));
+ DISALLOW_IMPLICIT_CONVERSION;
+}
+
static void
dump_drain_cold_data (struct dump_context *ctx)
{
case COLD_OP_BIGNUM:
dump_cold_bignum (ctx, data);
break;
+ case COLD_OP_NATIVE_SUBR:
+ dump_cold_native_subr (ctx, data);
+ break;
default:
emacs_abort ();
}
/* Dump wants a pointer to a Lisp object.
If DUMP_FIXUP_LISP_OBJECT_RAW, we should stick a C pointer in
the dump; otherwise, a Lisp_Object. */
- if (SUBRP (arg))
+ if (SUBRP (arg) && !SUBRP_NATIVE_COMPILEDP(arg))
{
dump_value = emacs_offset (XSUBR (arg));
if (type == DUMP_FIXUP_LISP_OBJECT)