These functions can be used on x86-64 as well, so we move them into
the generic section and ensure they do what they're supposed to.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munte...@linux360.ro>
---
 arch/x86/emit-code.c |   94 +++++++++++++++++++++++++-------------------------
 1 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/arch/x86/emit-code.c b/arch/x86/emit-code.c
index a93eac2..0fe7f20 100644
--- a/arch/x86/emit-code.c
+++ b/arch/x86/emit-code.c
@@ -354,6 +354,53 @@ void emit_unwind(struct buffer *buf)
        __emit_jmp(buf, (unsigned long)&unwind);
 }
 
+/*
+ * This fixes relative calls generated by EXPR_INVOKE.
+ *
+ * Please note, that this code does not care about icache flushing in
+ * MP environment. This may lead to a GPF when one CPU modifies code
+ * already prefetched by another CPU on some bogus Intel CPUs (see
+ * section 7.1.3 of "Intel 64 and IA-32 Architectures Software
+ * Developers Manual Volume 3A"). It is required for other CPUs to
+ * execute a serializing instruction (to flush instruction cache)
+ * between modification and execution of new instruction. To achieve
+ * this, we could suspend all threads before patching, and force them
+ * to execute flush_icache() on resume.
+ */
+void fixup_direct_calls(struct jit_trampoline *t, unsigned long target)
+{
+       struct fixup_site *this, *next;
+
+       pthread_mutex_lock(&t->mutex);
+
+       list_for_each_entry_safe(this, next, &t->fixup_site_list,
+                                fixup_list_node) {
+               unsigned char *site_addr;
+               uint32_t new_target;
+
+               site_addr = fixup_site_addr(this);
+               new_target = target - ((uint32_t)site_addr + CALL_INSN_SIZE);
+               cpu_write_u32(site_addr+1, new_target);
+
+               list_del(&this->fixup_list_node);
+               free_fixup_site(this);
+       }
+
+       pthread_mutex_unlock(&t->mutex);
+}
+
+/*
+ * This function replaces pointers in vtable so that they point
+ * directly to compiled code instead of trampoline code.
+ */
+static void fixup_vtable(struct compilation_unit *cu,
+       struct vm_object *objref, void *target)
+{
+       struct vm_class *vmc = objref->class;
+
+       vmc->vtable.native_ptr[cu->method->method_index] = target;
+}
+
 #ifdef CONFIG_X86_32
 
 /************************
@@ -1077,53 +1124,6 @@ struct emitter emitters[] = {
        DECL_EMITTER(INSN_XOR_REG_REG, emit_xor_reg_reg, TWO_OPERANDS),
 };
 
-/*
- * This fixes relative calls generated by EXPR_INVOKE.
- *
- * Please note, that this code does not care about icache flushing in
- * MP environment. This may lead to a GPF when one CPU modifies code
- * already prefetched by another CPU on some bogus Intel CPUs (see
- * section 7.1.3 of "Intel 64 and IA-32 Architectures Software
- * Developers Manual Volume 3A"). It is required for other CPUs to
- * execute a serializing instruction (to flush instruction cache)
- * between modification and execution of new instruction. To achieve
- * this, we could suspend all threads before patching, and force them
- * to execute flush_icache() on resume.
- */
-void fixup_direct_calls(struct jit_trampoline *t, unsigned long target)
-{
-       struct fixup_site *this, *next;
-
-       pthread_mutex_lock(&t->mutex);
-
-       list_for_each_entry_safe(this, next, &t->fixup_site_list,
-                                fixup_list_node) {
-               unsigned char *site_addr;
-               uint32_t new_target;
-
-               site_addr = fixup_site_addr(this);
-               new_target = target - ((uint32_t)site_addr + CALL_INSN_SIZE);
-               cpu_write_u32(site_addr+1, new_target);
-
-               list_del(&this->fixup_list_node);
-               free_fixup_site(this);
-       }
-
-       pthread_mutex_unlock(&t->mutex);
-}
-
-/*
- * This function replaces pointers in vtable so that they point
- * directly to compiled code instead of trampoline code.
- */
-static void fixup_vtable(struct compilation_unit *cu,
-       struct vm_object *objref, void *target)
-{
-       struct vm_class *vmc = objref->class;
-
-       vmc->vtable.native_ptr[cu->method->method_index] = target;
-}
-
 void emit_trampoline(struct compilation_unit *cu,
                     void *call_target,
                     struct jit_trampoline *trampoline)
-- 
1.6.0.6


------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
Jatovm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to