1 /* src/vm/jit/arm/md.h - machine dependent Arm functions
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
28 #ifndef _VM_JIT_ARM_MD_H
29 #define _VM_JIT_ARM_MD_H
38 #include "vm/jit/asmpart.h"
39 #include "vm/jit/codegen-common.h"
42 /* md_stacktrace_get_returnaddress *********************************************
44 Returns the return address of the current stackframe, specified by
45 the passed stack pointer and the stack frame size.
47 *******************************************************************************/
49 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
53 /* On ARM the return address is located on the top of the
55 /* ATTENTION: This is only true for non-leaf methods!!! */
57 ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
63 /* md_codegen_get_pv_from_pc ***************************************************
67 *******************************************************************************/
69 inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
72 u4 mcode1, mcode2, mcode3;
76 /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
78 if ((mcode1 & 0xffffff00) == 0xe24fcf00 /*sub ip,pc,#__*/)
79 pv -= (s4) ((mcode1 & 0x000000ff) << 2);
80 else if ((mcode1 & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
81 pv -= (s4) (mcode1 & 0x000000ff);
83 /* if this happens, we got an unexpected instruction at (*ra) */
84 vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
87 /* if we have a RECOMPUTE_IP there can be more than one instruction */
88 mcode2 = *((u4*) (ra + 4));
89 mcode3 = *((u4*) (ra + 8));
90 if ((mcode2 & 0xffffff00) == 0xe24ccb00 /*sub ip,ip,#__*/)
91 pv -= (s4) ((mcode2 & 0x000000ff) << 10);
92 if ((mcode3 & 0xffffff00) == 0xe24cc700 /*sub ip,ip,#__*/)
93 pv -= (s4) ((mcode3 & 0x000000ff) << 18);
95 /* we used PC-relative adressing; but now it is LR-relative */
98 /* if we found our method the data segment has to be valid */
99 /* we check this by looking up the IsLeaf field, which has to be boolean */
100 /* assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false ); */
106 /* md_cacheflush ***************************************************************
108 Calls the system's function to flush the instruction and data
111 *******************************************************************************/
113 inline static void md_cacheflush(void *addr, int nbytes)
115 asm_cacheflush(addr, nbytes);
119 /* md_icacheflush **************************************************************
121 Calls the system's function to flush the instruction cache.
123 *******************************************************************************/
125 inline static void md_icacheflush(void *addr, int nbytes)
127 asm_cacheflush(addr, nbytes);
131 /* md_dcacheflush **************************************************************
133 Calls the system's function to flush the data cache.
135 *******************************************************************************/
137 inline static void md_dcacheflush(void *addr, int nbytes)
142 #endif /* _VM_JIT_ARM_MD_H */
146 * These are local overrides for various environment variables in Emacs.
147 * Please do not remove this and leave it at the end of the file, where
148 * Emacs will automagically detect them.
149 * ---------------------------------------------------------------------
152 * indent-tabs-mode: t
156 * vim:noexpandtab:sw=4:ts=4: