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"
41 * Returns the size (in bytes) of the current stackframe, specified by
42 * the passed codeinfo structure.
44 inline static int32_t md_stacktrace_get_framesize(codeinfo* code)
46 // Check for the asm_vm_call_method special case.
50 // On ARM we use 8-byte stackslots.
51 return code->stackframesize * 8;
55 /* md_stacktrace_get_returnaddress *********************************************
57 Returns the return address of the current stackframe, specified by
58 the passed stack pointer and the stack frame size.
60 *******************************************************************************/
62 inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
66 /* On ARM the return address is located on the top of the
68 /* ATTENTION: This is only true for non-leaf methods!!! */
70 ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
76 /* md_codegen_get_pv_from_pc ***************************************************
80 *******************************************************************************/
82 inline static void* md_codegen_get_pv_from_pc(void* ra)
92 /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
96 /* if this was shifted by 18 bits, we have to load additional instructions */
97 if ((mcode & 0xfff0ff00) == 0xe240c700 /*sub ip,??,#__*/) {
98 pv -= (uintptr_t) ((mcode & 0x000000ff) << 18);
99 mcode = pc[++mcode_idx];
102 /* if this was shifted by 10 bits, we have to load additional instructions */
103 if ((mcode & 0xfff0ff00) == 0xe240cb00 /*sub ip,??,#__*/) {
104 pv -= (uintptr_t) ((mcode & 0x000000ff) << 10);
105 mcode = pc[++mcode_idx];
108 /* this is the default path with just one instruction, shifted by 2 or no bits */
109 if ((mcode & 0xfff0ff00) == 0xe240cf00 /*sub ip,??,#__*/)
110 pv -= (uintptr_t) ((mcode & 0x000000ff) << 2);
111 else if ((mcode & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
112 pv -= (uintptr_t) (mcode & 0x000000ff);
114 /* if this happens, we got an unexpected instruction at (*ra) */
115 vm_abort("Unable to find method: %p (instr=%x)", ra, mcode);
118 /* we used PC-relative adressing; but now it is LR-relative */
121 /* if we found our method the data segment has to be valid */
122 /* we check this by looking up the IsLeaf field, which has to be boolean */
123 /* assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false ); */
129 /* md_cacheflush ***************************************************************
131 Calls the system's function to flush the instruction and data
134 *******************************************************************************/
136 inline static void md_cacheflush(void *addr, int nbytes)
138 asm_cacheflush(addr, nbytes);
142 /* md_icacheflush **************************************************************
144 Calls the system's function to flush the instruction cache.
146 *******************************************************************************/
148 inline static void md_icacheflush(void *addr, int nbytes)
150 asm_cacheflush(addr, nbytes);
154 /* md_dcacheflush **************************************************************
156 Calls the system's function to flush the data cache.
158 *******************************************************************************/
160 inline static void md_dcacheflush(void *addr, int nbytes)
165 #endif /* _VM_JIT_ARM_MD_H */
169 * These are local overrides for various environment variables in Emacs.
170 * Please do not remove this and leave it at the end of the file, where
171 * Emacs will automagically detect them.
172 * ---------------------------------------------------------------------
175 * indent-tabs-mode: t
179 * vim:noexpandtab:sw=4:ts=4: