/* Main thread */
static MonoThread *main_thread;
+/* Functions supplied by the runtime */
+static MonoRuntimeCallbacks callbacks;
+
/**
* mono_thread_set_main:
* @thread: thread to set as the main thread
static MonoJumpTrampoline arch_create_jump_trampoline = default_jump_trampoline;
static MonoRemotingTrampoline arch_create_remoting_trampoline = default_remoting_trampoline;
static MonoDelegateTrampoline arch_create_delegate_trampoline = default_delegate_trampoline;
-static MonoVTableTrampoline arch_create_vtable_trampoline;
static MonoImtThunkBuilder imt_thunk_builder = NULL;
#define ARCH_USE_IMT (imt_thunk_builder != NULL)
#if (MONO_IMT_SIZE > 32)
#error "MONO_IMT_SIZE cannot be larger than 32"
#endif
+void
+mono_install_callbacks (MonoRuntimeCallbacks *cbs)
+{
+ memcpy (&callbacks, cbs, sizeof (*cbs));
+}
+
void
mono_install_trampoline (MonoTrampoline func)
{
arch_create_delegate_trampoline = func? func: default_delegate_trampoline;
}
-void
-mono_install_vtable_trampoline (MonoVTableTrampoline func)
-{
- arch_create_vtable_trampoline = func;
-}
-
void
mono_install_imt_thunk_builder (MonoImtThunkBuilder func) {
imt_thunk_builder = func;
imt_trampoline = tramp_code;
}
+static gpointer vtable_trampoline = NULL;
+
+void
+mono_install_vtable_trampoline (gpointer tramp_code)
+{
+ vtable_trampoline = tramp_code;
+}
+
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a,b,c) { \
a -= c; a ^= rot(c, 4); c += b; \
MonoImtBuilderEntry *entries;
int i;
GPtrArray *sorted;
- gpointer vtable_trampoline = NULL;
mono_domain_lock (domain);
if (!domain->generic_virtual_cases)
if (++gvc->count == THUNK_THRESHOLD) {
gpointer *old_thunk = *vtable_slot;
- if (arch_create_vtable_trampoline)
- vtable_trampoline = arch_create_vtable_trampoline (vtable);
-
if ((gpointer)vtable_slot < (gpointer)vtable)
/* Force the rebuild of the thunk at the next call */
*vtable_slot = imt_trampoline;
}
/* Initialize vtable */
- if (arch_create_vtable_trampoline) {
- gpointer vtable_trampoline = arch_create_vtable_trampoline (vt);
+ if (vtable_trampoline) {
// This also covers the AOT case
for (i = 0; i < class->vtable_size; ++i) {
vt->vtable [i] = vtable_trampoline;
MonoMethod *cm;
if ((cm = class->vtable [i]))
- vt->vtable [i] = arch_create_jit_trampoline (cm);
+ vt->vtable [i] = vtable_trampoline? vtable_trampoline: arch_create_jit_trampoline (cm);
}
}
* mono_create_ftnptr:
*
* Given a function address, create a function descriptor for it.
- * This is only needed on IA64 and PPC64.
+ * This is only needed on some platforms.
*/
gpointer
mono_create_ftnptr (MonoDomain *domain, gpointer addr)
{
-#ifdef __ia64__
- gpointer *desc;
-
- desc = mono_domain_code_reserve (domain, 2 * sizeof (gpointer));
-
- desc [0] = addr;
- desc [1] = NULL;
-
- return desc;
-#elif defined(__ppc64__) || defined(__powerpc64__)
- gpointer *desc;
-
- desc = mono_domain_code_reserve (domain, 3 * sizeof (gpointer));
-
- desc [0] = addr;
- desc [1] = NULL;
- desc [2] = NULL;
-
- return desc;
-#else
- return addr;
-#endif
+ return callbacks.create_ftnptr (domain, addr);
}
/*
* mono_get_addr_from_ftnptr:
*
* Given a pointer to a function descriptor, return the function address.
- * This is only needed on IA64 and PPC64.
+ * This is only needed on some platforms.
*/
gpointer
mono_get_addr_from_ftnptr (gpointer descr)
{
-#if defined(__ia64__) || defined(__ppc64__) || defined(__powerpc64__)
- return *(gpointer*)descr;
-#else
- return descr;
-#endif
+ return callbacks.get_addr_from_ftnptr (descr);
}
#if 0