Blame SOURCES/runtime-77308-ppc64le-delegate.patch

c51fa4
diff --git a/src/runtime/src/mono/mono/mini/mini-ppc.c b/src/runtime/src/mono/mono/mini/mini-ppc.c
c51fa4
index db669f8b5da0f..73a26c02b18aa 100644
c51fa4
--- a/src/runtime/src/mono/mono/mini/mini-ppc.c
c51fa4
+++ b/src/runtime/src/mono/mono/mini/mini-ppc.c
c51fa4
@@ -470,10 +470,54 @@ mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_targe
c51fa4
 	return start;
c51fa4
 }
c51fa4
 
c51fa4
+/**
c51fa4
+ *
c51fa4
+ * @brief Architecture-specific delegation virtual trampoline processing
c51fa4
+ *
c51fa4
+ * @param[in] @sig - Method signature
c51fa4
+ * @param[in] @method - Method
c51fa4
+ * @param[in] @offset - Offset into vtable
c51fa4
+ * @param[in] @load_imt_reg - Whether to load the LMT register
c51fa4
+ * @returns Trampoline
c51fa4
+ *
c51fa4
+ * Return a pointer to a delegation virtual trampoline
c51fa4
+ */
c51fa4
+
c51fa4
 gpointer
c51fa4
 mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method, int offset, gboolean load_imt_reg)
c51fa4
 {
c51fa4
-	return NULL;
c51fa4
+	guint8 *code, *start;
c51fa4
+	int size = 32;
c51fa4
+
c51fa4
+	start = code = (guint8 *) mono_global_codeman_reserve (size);
c51fa4
+
c51fa4
+	/*
c51fa4
+	 * Replace the "this" argument with the target
c51fa4
+	 */
c51fa4
+	ppc_mr  (code, ppc_r12, ppc_r3);
c51fa4
+	ppc_ldptr (code, ppc_r3, MONO_STRUCT_OFFSET(MonoDelegate, target), ppc_r12);
c51fa4
+
c51fa4
+	/*
c51fa4
+	 * Load the IMT register, if needed
c51fa4
+	 */
c51fa4
+	if (load_imt_reg) {
c51fa4
+		ppc_ldptr  (code, MONO_ARCH_IMT_REG, MONO_STRUCT_OFFSET(MonoDelegate, method), ppc_r12);
c51fa4
+	}
c51fa4
+
c51fa4
+	/*
c51fa4
+	 * Load the vTable
c51fa4
+	 */
c51fa4
+	ppc_ldptr  (code, ppc_r12, MONO_STRUCT_OFFSET(MonoObject, vtable), ppc_r3);
c51fa4
+	if (!ppc_is_imm16(offset))
c51fa4
+		ppc_addis (code, ppc_r12, ppc_r12, ppc_ha(offset));
c51fa4
+	ppc_ldptr  (code, ppc_r12, offset, ppc_r12);
c51fa4
+	ppc_mtctr (code, ppc_r12);
c51fa4
+	ppc_bcctr (code, PPC_BR_ALWAYS, 0);
c51fa4
+
c51fa4
+	mono_arch_flush_icache (start, code - start);
c51fa4
+	MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE, NULL));
c51fa4
+
c51fa4
+	return(start);
c51fa4
 }
c51fa4
 
c51fa4
 gpointer