/* src/vm/jit/i386/md.c - machine dependent i386 functions
- Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
+ Contact: cacao@cacaojvm.org
Authors: Christian Thalinger
- Changes:
+ Changes: Edwin Steiner
- $Id: md.c 2918 2005-07-05 14:00:17Z twisti $
+ $Id: md.c 4613 2006-03-15 12:04:05Z edwin $
*/
-#include "vm/jit/i386/types.h"
+#include "config.h"
+#include "vm/types.h"
+
+#include <assert.h>
+
#include "vm/global.h"
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.h"
+#include "vm/options.h" /* XXX debug */
+#include "vm/jit/disass.h" /* XXX debug */
/* md_init *********************************************************************
void md_init(void)
{
- /* nothing to do */
+ (void) asm_md_init();
}
*******************************************************************************/
-functionptr md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
+u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
{
- functionptr ra;
+ u1 *ra;
- /* on x86_64 the return address is above the current stack frame */
+ /* on i386 the return address is above the current stack frame */
- ra = (functionptr) *((u1 **) (sp + framesize));
+ ra = *((u1 **) (sp + framesize));
return ra;
}
+/* md_codegen_findmethod *******************************************************
+
+ On this architecture just a wrapper function to codegen_findmethod.
+
+*******************************************************************************/
+
+u1 *md_codegen_findmethod(u1 *ra)
+{
+ u1 *pv;
+
+ /* the the start address of the function which contains this
+ address from the method table */
+
+ pv = codegen_findmethod(ra);
+
+ return pv;
+}
+
+/* md_patch_replacement_point **************************************************
+
+ Patch the given replacement point.
+
+*******************************************************************************/
+
+void md_patch_replacement_point(rplpoint *rp)
+{
+ u8 mcode;
+
+ /* XXX this is probably unsafe! */
+
+ /* save the current machine code */
+ mcode = *(u8*)rp->pc;
+
+ /* write spinning instruction */
+ *(u2*)(rp->pc) = 0xebfe;
+
+ /* write 5th byte */
+ rp->pc[4] = (rp->mcode >> 32);
+
+ /* write first word */
+ *(u4*)(rp->pc) = (u4) rp->mcode;
+
+ /* store saved mcode */
+ rp->mcode = mcode;
+
+ {
+ u1* u1ptr = rp->pc;
+ DISASSINSTR(u1ptr);
+ fflush(stdout);
+ }
+
+ /* XXX if required asm_cacheflush(rp->pc,8); */
+}
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/