1 /* src/vm/jit/argument.c - argument passing from and to JIT methods
3 Copyright (C) 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
33 #include "vm/global.h"
36 #include "vmcore/descriptor.h"
39 /* argument_jitarray_load ******************************************************
41 Returns the argument specified by index from one of the passed arrays
44 *******************************************************************************/
46 imm_union argument_jitarray_load(methoddesc *md, int32_t index,
47 uint64_t *arg_regs, uint64_t *stack)
52 pd = &md->params[index];
54 switch (md->paramtypes[index].type) {
58 #if (SIZEOF_VOID_P == 8)
59 ret.l = (int64_t)stack[pd->index];
61 ret.l = *(int32_t *)(stack + pd->index);
64 #if (SIZEOF_VOID_P == 8)
65 ret.l = arg_regs[index];
67 ret.l = *(int32_t *)(arg_regs + index);
73 ret.l = (int64_t)stack[pd->index];
75 ret.l = (int64_t)arg_regs[index];
80 ret.l = (int64_t)stack[pd->index];
82 ret.l = (int64_t)arg_regs[index];
87 ret.l = (int64_t)stack[pd->index];
89 ret.l = (int64_t)arg_regs[index];
98 /* argument_jitarray_store *****************************************************
100 Stores the argument into one of the passed arrays at a slot specified
103 *******************************************************************************/
105 void argument_jitarray_store(methoddesc *md, int32_t index,
106 uint64_t *arg_regs, uint64_t *stack,
111 pd = &md->params[index];
113 switch (md->paramtypes[index].type) {
116 #if (SIZEOF_VOID_P == 8)
117 stack[pd->index] = param.l;
122 arg_regs[index] = param.l;
126 vm_abort("argument_jitarray_store: type not implemented");
132 /* argument_jitreturn_load *****************************************************
134 Loads the proper return value form the return register and returns it.
136 *******************************************************************************/
138 imm_union argument_jitreturn_load(methoddesc *md, uint64_t *return_regs)
142 switch (md->returntype.type) {
145 #if (SIZEOF_VOID_P == 8)
146 ret.l = return_regs[0];
148 ret.l = *(int32_t *)return_regs;
152 ret.l = *(int64_t *)return_regs;
155 ret.l = *(int64_t *)return_regs;
158 ret.l = *(int64_t *)return_regs;
166 /* argument_jitreturn_store ****************************************************
168 Stores the proper return value into the return registers.
170 *******************************************************************************/
172 void argument_jitreturn_store(methoddesc *md, uint64_t *return_regs, imm_union ret)
174 switch (md->returntype.type) {
176 #if (SIZEOF_VOID_P == 8)
177 return_regs[0] = ret.l;
183 vm_abort("argument_jitreturn_store: type not implemented");
190 * These are local overrides for various environment variables in Emacs.
191 * Please do not remove this and leave it at the end of the file, where
192 * Emacs will automagically detect them.
193 * ---------------------------------------------------------------------
196 * indent-tabs-mode: t
200 * vim:noexpandtab:sw=4:ts=4: