/* src/vm/jit/x86_64/emit.c - x86_64 code emitter functions
- Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
+ Copyright (C) 1996-2011
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
}
+/**
+ * Generates fast-path code for the below builtin.
+ * Function: LOCK_monitor_enter
+ * Signature: (Ljava/lang/Object;)V
+ * Slow-path: bool lock_monitor_enter(java_handle_t*);
+ */
+void emit_fastpath_monitor_enter(jitdata* jd, instruction* iptr, int d)
+{
+ // Get required compiler data.
+ codegendata* cd = jd->cd;
+
+ // XXX Currently the fast-path always fails. Implement me!
+ M_CLR(d);
+}
+
+
+/**
+ * Generates fast-path code for the below builtin.
+ * Function: LOCK_monitor_exit
+ * Signature: (Ljava/lang/Object;)V
+ * Slow-path: bool lock_monitor_exit(java_handle_t*);
+ */
+void emit_fastpath_monitor_exit(jitdata* jd, instruction* iptr, int d)
+{
+ // Get required compiler data.
+ codegendata* cd = jd->cd;
+
+ // XXX Currently the fast-path always fails. Implement me!
+ M_CLR(d);
+}
+
+
/**
* Generates synchronization code to enter a monitor.
*/
/* low-level code emitter functions *******************************************/
+void emit_nop(codegendata *cd, int length)
+{
+ assert(length >= 1 && length <= 9);
+ switch (length) {
+ case 1:
+ *(cd->mcodeptr++) = 0x90;
+ break;
+ case 2:
+ *(cd->mcodeptr++) = 0x66;
+ *(cd->mcodeptr++) = 0x90;
+ break;
+ case 3:
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 4:
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x40;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 5:
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x44;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 6:
+ *(cd->mcodeptr++) = 0x66;
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x44;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 7:
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x80;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 8:
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x84;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ case 9:
+ *(cd->mcodeptr++) = 0x66;
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0x1f;
+ *(cd->mcodeptr++) = 0x84;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ *(cd->mcodeptr++) = 0x00;
+ break;
+ }
+}
+
+void emit_arbitrary_nop(codegendata *cd, int disp)
+{
+ while (disp) {
+ int x = disp < 9 ? disp : 9;
+ emit_nop(cd, x);
+ disp -= x;
+ }
+}
+
void emit_mov_reg_reg(codegendata *cd, s8 reg, s8 dreg)
{
emit_rex(1,(reg),0,(dreg));
*(cd->mcodeptr++) = 0x31;
}
+void emit_mfence(codegendata *cd)
+{
+ *(cd->mcodeptr++) = 0x0f;
+ *(cd->mcodeptr++) = 0xae;
+ *(cd->mcodeptr++) = 0xf0;
+}
+
/*
* These are local overrides for various environment variables in Emacs.
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/