1 /* src/vm/jit/arm/md.h - machine dependent Arm functions
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #ifndef _VM_JIT_ARM_MD_H
27 #define _VM_JIT_ARM_MD_H
36 #include "vm/jit/asmpart.h"
37 #include "vm/jit/codegen-common.hpp"
40 /* md_stacktrace_get_returnaddress *********************************************
42 Returns the return address of the current stackframe, specified by
43 the passed stack pointer and the stack frame size.
45 *******************************************************************************/
47 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
51 /* On ARM the return address is located on the top of the
53 /* ATTENTION: This is only true for non-leaf methods!!! */
55 ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
61 /* md_codegen_get_pv_from_pc ***************************************************
65 *******************************************************************************/
67 inline static void* md_codegen_get_pv_from_pc(void* ra)
77 /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
81 /* if this was shifted by 18 bits, we have to load additional instructions */
82 if ((mcode & 0xfff0ff00) == 0xe240c700 /*sub ip,??,#__*/) {
83 pv -= (uintptr_t) ((mcode & 0x000000ff) << 18);
84 mcode = pc[++mcode_idx];
87 /* if this was shifted by 10 bits, we have to load additional instructions */
88 if ((mcode & 0xfff0ff00) == 0xe240cb00 /*sub ip,??,#__*/) {
89 pv -= (uintptr_t) ((mcode & 0x000000ff) << 10);
90 mcode = pc[++mcode_idx];
93 /* this is the default path with just one instruction, shifted by 2 or no bits */
94 if ((mcode & 0xfff0ff00) == 0xe240cf00 /*sub ip,??,#__*/)
95 pv -= (uintptr_t) ((mcode & 0x000000ff) << 2);
96 else if ((mcode & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
97 pv -= (uintptr_t) (mcode & 0x000000ff);
99 /* if this happens, we got an unexpected instruction at (*ra) */
100 vm_abort("Unable to find method: %p (instr=%x)", ra, mcode);
103 /* we used PC-relative adressing; but now it is LR-relative */
106 /* if we found our method the data segment has to be valid */
107 /* we check this by looking up the IsLeaf field, which has to be boolean */
108 /* assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false ); */
114 /* md_cacheflush ***************************************************************
116 Calls the system's function to flush the instruction and data
119 *******************************************************************************/
121 inline static void md_cacheflush(void *addr, int nbytes)
123 asm_cacheflush(addr, nbytes);
127 /* md_icacheflush **************************************************************
129 Calls the system's function to flush the instruction cache.
131 *******************************************************************************/
133 inline static void md_icacheflush(void *addr, int nbytes)
135 asm_cacheflush(addr, nbytes);
139 /* md_dcacheflush **************************************************************
141 Calls the system's function to flush the data cache.
143 *******************************************************************************/
145 inline static void md_dcacheflush(void *addr, int nbytes)
150 #endif /* _VM_JIT_ARM_MD_H */
154 * These are local overrides for various environment variables in Emacs.
155 * Please do not remove this and leave it at the end of the file, where
156 * Emacs will automagically detect them.
157 * ---------------------------------------------------------------------
160 * indent-tabs-mode: t
164 * vim:noexpandtab:sw=4:ts=4: