From: Zoltan Varga Date: Mon, 21 Oct 2019 03:28:25 +0000 (-0400) Subject: [interp] Small fixes. (mono/mono#17442) X-Git-Tag: submit/tizen/20210909.063632~10331^2~5^2~319 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cc3e16e89bb99e8d8ae1877266984f39b1bc4978;p=platform%2Fupstream%2Fdotnet%2Fruntime.git [interp] Small fixes. (mono/mono#17442) * [interp] Really abort in ves_real_abort (). * [interp] Fix stack usage in TRACE_EXIT. * [interp] Add a callback to free ThreadContext. * Fix warnings. * Remove an empty statement. * Fix a double free. Commit migrated from https://github.com/mono/mono/commit/4b9226619c9caef3d45778380198c70a43e3570c --- diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index bebb92b..200b1d3 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -9540,11 +9540,13 @@ ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void) return mono_gc_get_allocated_bytes_for_current_thread (); } +#ifdef ENABLE_NETCORE guint64 ves_icall_System_GC_GetTotalAllocatedBytes (MonoBoolean precise, MonoError* error) { return mono_gc_get_total_allocated_bytes (precise); } +#endif void ves_icall_System_GC_RecordPressure (gint64 value) diff --git a/src/mono/mono/metadata/threadpool-io.c b/src/mono/mono/metadata/threadpool-io.c index abaf8a6..ae3f2bd 100644 --- a/src/mono/mono/metadata/threadpool-io.c +++ b/src/mono/mono/metadata/threadpool-io.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/src/mono/mono/mini/ee.h b/src/mono/mono/mini/ee.h index 2bd5da5..5a0090d 100644 --- a/src/mono/mono/mini/ee.h +++ b/src/mono/mono/mini/ee.h @@ -57,6 +57,7 @@ typedef gpointer MonoInterpFrameHandle; MONO_EE_CALLBACK (MonoInterpFrameHandle, frame_get_parent, (MonoInterpFrameHandle frame)) \ MONO_EE_CALLBACK (void, start_single_stepping, (void)) \ MONO_EE_CALLBACK (void, stop_single_stepping, (void)) \ + MONO_EE_CALLBACK (void, free_context, (gpointer)) \ MONO_EE_CALLBACK (void, cleanup, (void)) \ typedef struct _MonoEECallbacks { diff --git a/src/mono/mono/mini/interp-stubs.c b/src/mono/mono/mini/interp-stubs.c index a77e85c..28c4ed1 100644 --- a/src/mono/mono/mini/interp-stubs.c +++ b/src/mono/mono/mini/interp-stubs.c @@ -201,6 +201,12 @@ stub_frame_arg_set_storage (MonoInterpFrameHandle frame, MonoMethodSignature *si g_assert_not_reached (); } +static void +stub_free_context (gpointer context) +{ + g_assert_not_reached (); +} + #undef MONO_EE_CALLBACK #define MONO_EE_CALLBACK(ret, name, sig) stub_ ## name, diff --git a/src/mono/mono/mini/interp/interp.c b/src/mono/mono/mini/interp/interp.c index 46fba70..4d894c2 100644 --- a/src/mono/mono/mini/interp/interp.c +++ b/src/mono/mono/mini/interp/interp.c @@ -281,6 +281,14 @@ get_context (void) } static void +interp_free_context (gpointer ctx) +{ + ThreadContext *context = (ThreadContext*)ctx; + + g_free (context); +} + +static void mono_interp_error_cleanup (MonoError* error) { mono_error_cleanup (error); /* FIXME: don't swallow the error */ @@ -298,6 +306,7 @@ ves_real_abort (int line, MonoMethod *mh, g_printerr ("Line=%d IP=0x%04lx, Aborted execution\n", line, ip-(const unsigned short *) header->code); g_printerr ("0x%04x %02x\n", ip-(const unsigned short *) header->code, *ip); mono_metadata_free_mh (header); + g_assert_not_reached (); } #define ves_abort() \ @@ -6306,16 +6315,18 @@ common_vcall: MINT_IN_BREAK; } - MINT_IN_CASE(MINT_TRACE_EXIT) { + MINT_IN_CASE(MINT_TRACE_EXIT) + MINT_IN_CASE(MINT_TRACE_EXIT_VOID) { // Set retval int const i32 = READ32 (ip + 1); - --sp; - if (i32 == -1) - ; - else if (i32) + if (i32 == -1) { + } else if (i32) { + sp--; memcpy(frame->retval->data.p, sp->data.p, i32); - else + } else { + sp--; *frame->retval = *sp; + } MonoProfilerCallContext *prof_ctx = g_alloca (sizeof (MonoProfilerCallContext)); prof_ctx->interp_frame = frame; diff --git a/src/mono/mono/mini/interp/mintops.def b/src/mono/mono/mini/interp/mintops.def index 47788c0..f96aa2d 100644 --- a/src/mono/mono/mini/interp/mintops.def +++ b/src/mono/mono/mini/interp/mintops.def @@ -723,7 +723,8 @@ OPDEF(MINT_TANH, "tanh", 1, Pop1, Push1, MintOpNoArgs) */ OPDEF(MINT_PROF_ENTER, "prof_enter", 1, Pop0, Push0, MintOpNoArgs) OPDEF(MINT_TRACE_ENTER, "trace_enter", 1, Pop0, Push0, MintOpNoArgs) -OPDEF(MINT_TRACE_EXIT, "trace_exit", 3, Pop0, Push0, MintOpInt) +OPDEF(MINT_TRACE_EXIT, "trace_exit", 3, Pop1, Push0, MintOpInt) +OPDEF(MINT_TRACE_EXIT_VOID, "trace_exit_void", 3, Pop0, Push0, MintOpInt) OPDEF(MINT_INTRINS_ENUM_HASFLAG, "intrins_enum_hasflag", 2, Pop2, Push1, MintOpClassToken) OPDEF(MINT_INTRINS_GET_HASHCODE, "intrins_get_hashcode", 1, Pop1, Push1, MintOpNoArgs) diff --git a/src/mono/mono/mini/interp/transform.c b/src/mono/mono/mini/interp/transform.c index 857ccac..a05d4f095 100644 --- a/src/mono/mono/mini/interp/transform.c +++ b/src/mono/mono/mini/interp/transform.c @@ -3627,9 +3627,12 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, if (mono_jit_trace_calls != NULL && mono_trace_eval (method)) { /* This does the return as well */ - interp_add_ins (td, MINT_TRACE_EXIT); - if (ult->type == MONO_TYPE_VOID) + if (ult->type == MONO_TYPE_VOID) { + interp_add_ins (td, MINT_TRACE_EXIT_VOID); vt_size = -1; + } else { + interp_add_ins (td, MINT_TRACE_EXIT); + } WRITE32_INS (td->last_ins, 0, &vt_size); ++td->ip; } else { diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index 8ffa188..0f86b29 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -951,10 +951,10 @@ dump_native_stacktrace (const char *signal, MonoContext *mctx) pid_t pid; int status; pid_t crashed_pid = getpid (); - gchar *output = NULL; - MonoStackHash hashes; #ifndef DISABLE_CRASH_REPORTING + gchar *output = NULL; + MonoStackHash hashes; MonoStateMem merp_mem; memset (&merp_mem, 0, sizeof (merp_mem)); diff --git a/src/mono/mono/mini/mini-runtime.c b/src/mono/mono/mini/mini-runtime.c index 36e851c..0089cfb 100644 --- a/src/mono/mono/mini/mini-runtime.c +++ b/src/mono/mono/mini/mini-runtime.c @@ -952,8 +952,10 @@ free_jit_tls_data (MonoJitTlsData *jit_tls) return; mono_free_altstack (jit_tls); + if (jit_tls->interp_context) + mini_get_interp_callbacks ()->free_context (jit_tls->interp_context); + g_free (jit_tls->first_lmf); - g_free (jit_tls->interp_context); g_free (jit_tls); }