i386 / x86_64: Align patcher trap instruction.
[cacao.git] / src / vm / jit / x86_64 / emit.c
index 9c777fb54a558b0545c5177ea11a2fdea6107ae3..398d7d05843a96d1fbff1a8a50c7581b302c266d 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/x86_64/emit.c - x86_64 code emitter functions
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008
+   Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 #include <assert.h>
 
 #include "vm/types.h"
+#include "vm/os.hpp"
 
 #include "md-abi.h"
 
 #include "vm/jit/x86_64/codegen.h"
 #include "vm/jit/x86_64/emit.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "threads/lock.hpp"
 
@@ -48,7 +49,7 @@
 #include "vm/jit/patcher-common.hpp"
 #include "vm/jit/replace.hpp"
 #include "vm/jit/trace.hpp"
-#include "vm/jit/trap.h"
+#include "vm/jit/trap.hpp"
 
 
 /* emit_load *******************************************************************
@@ -423,6 +424,19 @@ void emit_trap_compiler(codegendata *cd)
 }
 
 
+/* emit_patcher_alignment ******************************************************
+
+   Emit NOP to ensure placement at an even address.
+
+*******************************************************************************/
+
+void emit_patcher_alignment(codegendata *cd)
+{
+       if ((uintptr_t) cd->mcodeptr & 1)
+               M_NOP;
+}
+
+
 /* emit_trap *******************************************************************
 
    Emit a trap instruction and return the original machine code.