Merge pull request #5198 from BrzVlad/fix-binprot-stats
[mono.git] / mono / mini / interp / interp.c
index c720d786dc1ab69312bac28bb965f1ea4145e060..b9df34db6482d2248bbfb2efe05d8ebbebc84717 100644 (file)
@@ -173,8 +173,8 @@ debug_enter (MonoInvocation *frame, int *tracing)
                g_print  ("%s)\n", args);
                g_free (args);
        }
-       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)
-               mono_profiler_method_enter (frame->runtime_method->method);
+       if (mono_profiler_should_instrument_method (frame->runtime_method->method, TRUE))
+               MONO_PROFILER_RAISE (method_enter, (frame->runtime_method->method));
 }
 
 
@@ -191,8 +191,8 @@ debug_enter (MonoInvocation *frame, int *tracing)
                debug_indent_level--;   \
                if (tracing == 3) global_tracing = 0; \
        }       \
-       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)    \
-               mono_profiler_method_leave (frame->runtime_method->method);
+       if (mono_profiler_should_instrument_method (frame->runtime_method->method, FALSE)) \
+               MONO_PROFILER_RAISE (method_enter, (frame->runtime_method->method));
 
 #else
 
@@ -4427,7 +4427,7 @@ array_constructed:
                                goto main_loop;
                        }
                        if (frame->ex)
-                               goto handle_fault;
+                               goto handle_catch;
                        ves_abort();
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_LEAVE) /* Fall through */
@@ -4502,6 +4502,11 @@ array_constructed:
                        ip += 3;
                        MINT_IN_BREAK;
                }
+               MINT_IN_CASE(MINT_MONO_MEMORY_BARRIER) {
+                       ++ip;
+                       mono_memory_barrier ();
+                       MINT_IN_BREAK;
+               }
                MINT_IN_CASE(MINT_MONO_JIT_ATTACH) {
                        ++ip;
 
@@ -4517,6 +4522,11 @@ array_constructed:
                        ++ip;
                        mono_jit_set_domain (context->original_domain);
                        MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MONO_LDDOMAIN)
+                       sp->data.p = mono_domain_get ();
+                       ++sp;
+                       ++ip;
+                       MINT_IN_BREAK;
                MINT_IN_CASE(MINT_SDB_INTR_LOC)
                        if (G_UNLIKELY (ss_enabled)) {
                                static void (*ss_tramp) (void);
@@ -5057,6 +5067,7 @@ die_on_ex:
                int i;
                guint32 ip_offset;
                MonoExceptionClause *clause;
+               GSList *old_list = finally_ips;
                MonoMethod *method = frame->runtime_method->method;
                MonoMethodHeader *header = mono_method_get_header_checked (method, &error);
                mono_error_cleanup (&error); /* FIXME: don't swallow the error */
@@ -5070,13 +5081,23 @@ die_on_ex:
                        clause = &rtm->clauses [i];
                        if (clause->flags == MONO_EXCEPTION_CLAUSE_FAULT && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
                                ip = rtm->code + clause->handler_offset;
+                               finally_ips = g_slist_prepend (finally_ips, (gpointer) ip);
 #if DEBUG_INTERP
                                if (tracing)
                                        g_print ("* Executing handler at IL_%04x\n", clause->handler_offset);
 #endif
-                               goto main_loop;
                        }
                }
+
+               if (old_list != finally_ips && finally_ips) {
+                       ip = finally_ips->data;
+                       finally_ips = g_slist_remove (finally_ips, ip);
+                       sp = frame->stack; /* spec says stack should be empty at endfinally so it should be at the start too */
+                       goto main_loop;
+               }
+       }
+       handle_catch:
+       {
                /*
                 * If the handler for the exception was found in this method, we jump
                 * to it right away, otherwise we return and let the caller run