[Pkg-mono-svn-commits] [mono] 03/04: Implement handler block guard trampolines.

Jo Shields directhex at moszumanska.debian.org
Mon Apr 11 18:24:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

directhex pushed a commit to branch master-patches/arm64_port
in repository mono.

commit efc7a578ceaec55554cbdd7a2dbc5ab3bf611deb
Author: Zoltan Varga <vargaz at gmail.com>
Date:   Sat Apr 2 01:27:27 2016 -0400

    Implement handler block guard trampolines.
    
    (cherry picked from commit d93dab827831b94fc65ab9dae5ce531e8ccd7ebe)
---
 mono/mini/mini-arm64.c  | 20 ++++++++++++++++++++
 mono/mini/mini-arm64.h  |  3 +++
 mono/mini/tramp-arm64.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/mono/mini/mini-arm64.c b/mono/mini/mini-arm64.c
index 372cb83..b6fff19 100644
--- a/mono/mini/mini-arm64.c
+++ b/mono/mini/mini-arm64.c
@@ -5200,3 +5200,23 @@ mono_arch_get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, Mono
 {
 	return get_call_info (gsctx, mp, sig);
 }
+
+gpointer
+mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value)
+{
+	gpointer *lr_loc;
+	char *old_value;
+	char *bp;
+
+	/*Load the spvar*/
+	bp = MONO_CONTEXT_GET_BP (ctx);
+	lr_loc = (gpointer*)(bp + clause->exvar_offset);
+
+	old_value = *lr_loc;
+	if ((char*)old_value < (char*)ji->code_start || (char*)old_value > ((char*)ji->code_start + ji->code_size))
+		return old_value;
+
+	*lr_loc = new_value;
+
+	return old_value;
+}
diff --git a/mono/mini/mini-arm64.h b/mono/mini/mini-arm64.h
index 9241cfd..fc9b929 100644
--- a/mono/mini/mini-arm64.h
+++ b/mono/mini/mini-arm64.h
@@ -151,6 +151,9 @@ 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_OPCODE_NEEDS_EMULATION 1
+#define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1
+#define MONO_ARCH_HAVE_HANDLER_BLOCK_GUARD 1
 
 #ifdef TARGET_IOS
 
diff --git a/mono/mini/tramp-arm64.c b/mono/mini/tramp-arm64.c
index 376bb2f..5ce3034 100644
--- a/mono/mini/tramp-arm64.c
+++ b/mono/mini/tramp-arm64.c
@@ -486,6 +486,54 @@ mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboo
 	return buf;
 }
 
+static gpointer
+handler_block_trampoline_helper (gpointer *ptr)
+{
+	MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
+	return jit_tls->handler_block_return_address;
+}
+
+gpointer
+mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+	guint8 *tramp;
+	guint8 *code, *buf;
+	int tramp_size = 64;
+	MonoJumpInfo *ji = NULL;
+	GSList *unwind_ops = NULL;
+
+	g_assert (!aot);
+
+	code = buf = mono_global_codeman_reserve (tramp_size);
+
+	unwind_ops = NULL;
+
+	tramp = mono_arch_create_specific_trampoline (NULL, MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD, NULL, NULL);
+
+	/*
+	This trampoline restore the call chain of the handler block then jumps into the code that deals with it.
+	*/
+
+	/*
+	 * We are in a method frame after the call emitted by OP_CALL_HANDLER.
+	 */
+	code = mono_arm_emit_imm64 (code, ARMREG_IP0, (guint64)handler_block_trampoline_helper);
+	/* Set it as the return address so the trampoline will return to it */
+	arm_movx (code, ARMREG_LR, ARMREG_IP0);
+
+	/* Call the trampoline */
+	code = mono_arm_emit_imm64 (code, ARMREG_IP0, (guint64)tramp);
+	arm_brx (code, ARMREG_IP0);
+
+	mono_arch_flush_icache (buf, code - buf);
+	mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_HELPER, NULL);
+	g_assert (code - buf <= tramp_size);
+
+	*info = mono_tramp_info_create ("handler_block_trampoline", buf, code - buf, ji, unwind_ops);
+
+	return buf;
+}
+
 /*
  * mono_arch_create_sdb_trampoline:
  *

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mono/packages/mono.git



More information about the Pkg-mono-svn-commits mailing list