GC Bridge: Make merge_cache more aggressive, less exact, faster
[mono.git] / mono / mini / exceptions-x86.c
index 3db25ca7f810f8ab363fe926b3a75c355c3e10da..d737bc7f7f0768ab51457bf6008fda554de519d0 100644 (file)
@@ -23,7 +23,7 @@
 #include <mono/metadata/threads.h>
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/exception.h>
-#include <mono/metadata/gc-internal.h>
+#include <mono/metadata/gc-internals.h>
 #include <mono/metadata/mono-debug.h>
 #include <mono/utils/mono-mmap.h>
 
@@ -348,8 +348,6 @@ mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot)
        /* jump to the saved IP */
        x86_ret (code);
 
-       nacl_global_codeman_validate(&start, 128, &code);
-
        if (info)
                *info = mono_tramp_info_create ("restore_context", start, code - start, ji, unwind_ops);
        else {
@@ -380,7 +378,7 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
        guint8 *code;
        MonoJumpInfo *ji = NULL;
        GSList *unwind_ops = NULL;
-       guint kMaxCodeSize = NACL_SIZE (64, 128);
+       guint kMaxCodeSize = 64;
 
        /* call_filter (MonoContext *ctx, unsigned long eip) */
        start = code = mono_global_codeman_reserve (kMaxCodeSize);
@@ -428,8 +426,6 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
        x86_leave (code);
        x86_ret (code);
 
-       nacl_global_codeman_validate(&start, kMaxCodeSize, &code);
-
        if (info)
                *info = mono_tramp_info_create ("call_filter", start, code - start, ji, unwind_ops);
        else {
@@ -456,6 +452,7 @@ void
 mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc, 
                                                  mgreg_t eip, gboolean rethrow)
 {
+       MonoError error;
        MonoContext ctx;
 
        ctx.esp = regs [X86_ESP];
@@ -473,13 +470,14 @@ mono_x86_throw_exception (mgreg_t *regs, MonoObject *exc,
        g_assert ((ctx.esp % MONO_ARCH_FRAME_ALIGNMENT) == 0);
 #endif
 
-       if (mono_object_isinst (exc, mono_defaults.exception_class)) {
+       if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
                MonoException *mono_ex = (MonoException*)exc;
                if (!rethrow) {
                        mono_ex->stack_trace = NULL;
                        mono_ex->trace_ips = NULL;
                }
        }
+       mono_error_assert_ok (&error);
 
        /* adjust eip so that it point into the call instruction */
        ctx.eip -= 1;
@@ -542,7 +540,7 @@ get_throw_trampoline (const char *name, gboolean rethrow, gboolean llvm, gboolea
        int i, stack_size, stack_offset, arg_offsets [5], regs_offset;
        MonoJumpInfo *ji = NULL;
        GSList *unwind_ops = NULL;
-       guint kMaxCodeSize = NACL_SIZE (128, 256);
+       guint kMaxCodeSize = 128;
 
        start = code = mono_global_codeman_reserve (kMaxCodeSize);
 
@@ -652,8 +650,6 @@ get_throw_trampoline (const char *name, gboolean rethrow, gboolean llvm, gboolea
        }
        x86_breakpoint (code);
 
-       nacl_global_codeman_validate(&start, kMaxCodeSize, &code);
-
        g_assert ((code - start) < kMaxCodeSize);
 
        if (info)
@@ -893,7 +889,7 @@ mono_arch_unwind_frame (MonoDomain *domain, MonoJitTlsData *jit_tls,
 gpointer
 mono_arch_ip_from_context (void *sigctx)
 {
-#if defined(__native_client__) || defined(HOST_WATCHOS)
+#if defined(HOST_WATCHOS)
        printf("WARNING: mono_arch_ip_from_context() called!\n");
        return (NULL);
 #elif defined(MONO_ARCH_USE_SIGACTION)
@@ -1143,17 +1139,16 @@ mono_tasklets_arch_restore (void)
        static guint8* saved = NULL;
        guint8 *code, *start;
 
-#ifdef __native_client_codegen__
-       g_print("mono_tasklets_arch_restore needs to be aligned for Native Client\n");
-#endif
        if (saved)
                return (MonoContinuationRestore)saved;
        code = start = mono_global_codeman_reserve (48);
        /* the signature is: restore (MonoContinuation *cont, int state, MonoLMF **lmf_addr) */
        /* put cont in edx */
        x86_mov_reg_membase (code, X86_EDX, X86_ESP, 4, 4);
-        /* state in eax, so it's setup as the return value */
-        x86_mov_reg_membase (code, X86_EAX, X86_ESP, 8, 4);
+       /* state in eax, so it's setup as the return value */
+       x86_mov_reg_membase (code, X86_EAX, X86_ESP, 8, 4);
+       /* lmf_addr in ebx */
+       x86_mov_reg_membase(code, X86_EBX, X86_ESP, 0x0C, 4);
 
        /* setup the copy of the stack */
        x86_mov_reg_membase (code, X86_ECX, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, stack_used_size), 4);
@@ -1166,10 +1161,8 @@ mono_tasklets_arch_restore (void)
 
        /* now restore the registers from the LMF */
        x86_mov_reg_membase (code, X86_ECX, X86_EDX, MONO_STRUCT_OFFSET (MonoContinuation, lmf), 4);
-       x86_mov_reg_membase (code, X86_EBX, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, ebx), 4);
        x86_mov_reg_membase (code, X86_EBP, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, ebp), 4);
-       x86_mov_reg_membase (code, X86_ESI, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, esi), 4);
-       x86_mov_reg_membase (code, X86_EDI, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, edi), 4);
+       x86_mov_reg_membase (code, X86_ESP, X86_ECX, MONO_STRUCT_OFFSET (MonoLMF, esp), 4);
 
        /* restore the lmf chain */
        /*x86_mov_reg_membase (code, X86_ECX, X86_ESP, 12, 4);