1 /* src/vm/jit/m68k/md.c
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
39 * As a sanity measuremnt we assert the offset.h values in here as m68k gets
40 * crosscompiled for sure and noone thinks of offset.h wen changing compile flags
41 * and subtile bugs will result...
43 * m68k uses the trap instruction for hardware exceptions, need to register
44 * according signal handler
51 /* md_jit_method_patch_address *************************************************
53 Gets the patch address of the currently compiled method. Has to be
54 extracted from the load instructions which lead to the jump.
56 from asmpart.S (asm_vm_call_method):
57 84: 2879 0000 0000 moveal 0 <asm_vm_call_method-0x34>,%a4
61 from invokestatic / invokespecial
62 0x40290882: 247c 4029 03b4 moveal #1076429748,%a2
63 0x40290888: 4e92 jsr %a2@
66 0x40297eca: 266a 0000 moveal %a2@(0),%a3
67 0x40297ece: 246b 002c moveal %a3@(44),%a2
68 0x40297ed2: 4e92 jsr %a2@
72 *******************************************************************************/
74 void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
82 if (*((u2*)(pc - 2)) == 0x4e94) { /* jsr %a4@ */
83 if (*((u2*)(pc - 6)) == 0x286b) {
84 /* found an invokevirtual */
85 /* get offset of load instruction 246b XXXX */
86 disp = *((s2*)(pc - 4));
88 /* return NULL if no mptr was specified (used for replacement) */
93 pa = ((uint8_t *) mptr) + disp;/* mptr contains the magic we want */
95 /* we had a moveal XXX, %a3 which is a 3 word opcode */
97 assert(*(u2*)(pc - 8) == 0x2879); /* moveal */
98 pa = (void*)*((u4*)(pc - 6)); /* another indirection ! */
100 } else if (*((u2*)(pc - 2)) == 0x4e92) { /* jsr %a2@ */
101 if (*(u2*)(pc - 8) == 0x247c) {
102 /* found a invokestatic/invokespecial */
103 pa = ((u4*)(pc - 6)); /* no indirection ! */
116 * These are local overrides for various environment variables in Emacs.
117 * Please do not remove this and leave it at the end of the file, where
118 * Emacs will automagically detect them.
119 * ---------------------------------------------------------------------
122 * indent-tabs-mode: t
126 * vim:noexpandtab:sw=4:ts=4: