From 0ce5f9c721cf426bc3d7c3254642cdc3f03819bf Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 24 May 2016 16:37:58 -0400 Subject: [PATCH] [amd64] Implement the general rgctx fetch trampoline. --- mono/mini/Makefile.am.in | 2 +- mono/mini/mini-amd64.h | 1 + mono/mini/tramp-amd64.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index 7099579a80c..a2fe4561018 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -49,7 +49,7 @@ MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE) RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE) CSC = $(mcs_topdir)/class/lib/build/mcs.exe -MCS = CSC_SDK_PATH_DISABLED= $(MINI_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll +MCS = CSC_SDK_PATH_DISABLED= $(MINI_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll ILASM = $(MINI_RUNTIME) $(CLASS)/ilasm.exe AM_CFLAGS = \ diff --git a/mono/mini/mini-amd64.h b/mono/mini/mini-amd64.h index 33c815d7576..753c091a3b7 100644 --- a/mono/mini/mini-amd64.h +++ b/mono/mini/mini-amd64.h @@ -402,6 +402,7 @@ typedef struct { #define MONO_ARCH_HAVE_SDB_TRAMPOLINES 1 #define MONO_ARCH_HAVE_PATCH_CODE_NEW 1 #define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1 +#define MONO_ARCH_HAVE_GENERAL_RGCTX_LAZY_FETCH_TRAMPOLINE 1 #if defined(TARGET_OSX) || defined(__linux__) #define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1 diff --git a/mono/mini/tramp-amd64.c b/mono/mini/tramp-amd64.c index a8df3065dd8..d9737fb8c52 100644 --- a/mono/mini/tramp-amd64.c +++ b/mono/mini/tramp-amd64.c @@ -709,6 +709,41 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info return buf; } +gpointer +mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot) +{ + guint8 *code, *buf; + int tramp_size; + MonoJumpInfo *ji = NULL; + GSList *unwind_ops; + + g_assert (aot); + tramp_size = 64; + + code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size); + + unwind_ops = mono_arch_get_cie_program (); + + // FIXME: Currently, we always go to the slow path. + /* This receives a in the rgctx arg reg. */ + /* Load trampoline addr */ + amd64_mov_reg_membase (code, AMD64_R11, MONO_ARCH_RGCTX_REG, 8, 8); + /* move the rgctx pointer to the VTABLE register */ + amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer)); + /* Jump to the trampoline */ + amd64_jump_reg (code, AMD64_R11); + + mono_arch_flush_icache (buf, code - buf); + mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL); + + g_assert (code - buf <= tramp_size); + + if (info) + *info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, ji, unwind_ops); + + return buf; +} + void mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg) { -- 2.25.1