CACAO
stack.hpp
Go to the documentation of this file.
1 /* src/vm/jit/stack.hpp - stack analysis header
2 
3  Copyright (C) 1996-2014
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
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.
12 
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.
17 
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
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef STACK_HPP_
27 #define STACK_HPP_ 1
28 
29 #include "config.h" // for ENABLE_VERIFIER
30 #include <stdint.h>
31 #include "vm/global.hpp" // for Type
32 
33 struct instruction;
34 struct jitdata;
35 
36 /* stack element structure ****************************************************/
37 
39  SAVEDVAR = 1, // variable has to survive method invocations
40  INMEMORY = 2, // variable stored in memory
41  SAVREG = 4, // allocated to a saved register
42  ARGREG = 8, // allocated to an arg register
43  PASSTHROUGH = 32, // stackslot was passed-through by an ICMD
44  PREALLOC = 64, // preallocated var like for ARGVARS.
45  // Used with the new var system
46  INOUT = 128 // variable is an invar or/and an outvar
47 };
48 
49 // check flags
50 static inline bool IS_SAVEDVAR(s4 flags) { return flags & SAVEDVAR; }
51 static inline bool IS_INMEMORY(s4 flags) { return flags & INMEMORY; }
52 
53 
55  UNDEFVAR = 0, // stack slot will become temp during regalloc
56  TEMPVAR = 1, // stack slot is temp register
57  STACKVAR = 2, // stack slot is numbered stack slot
58  LOCALVAR = 3, // stack slot is local variable
59  ARGVAR = 4 // stack slot is argument variable
60 };
61 
62 /* variable kinds */
64  stackelement_t *prev; /* pointer to next element towards bottom */
65  instruction *creator; /* instruction that created this element */
66  Type type; /* slot type of stack element */
67  int32_t flags; /* flags (SAVED, INMEMORY) */
68  VariableKind varkind; /* kind of variable or register */
69  int32_t varnum; /* number of variable */
70 };
71 
72 
73 /* function prototypes ********************************************************/
74 
75 bool stack_init(void);
76 
77 bool stack_analyse(jitdata *jd);
78 
79 void stack_javalocals_store(instruction *iptr, int32_t *javalocals);
80 
81 #endif // STACK_HPP_
82 
83 
84 /*
85  * These are local overrides for various environment variables in Emacs.
86  * Please do not remove this and leave it at the end of the file, where
87  * Emacs will automagically detect them.
88  * ---------------------------------------------------------------------
89  * Local variables:
90  * mode: c++
91  * indent-tabs-mode: t
92  * c-basic-offset: 4
93  * tab-width: 4
94  * End:
95  * vim:noexpandtab:sw=4:ts=4:
96  */
Definition: stack.hpp:41
Definition: jit.hpp:126
Definition: stack.hpp:46
VariableKind
Definition: stack.hpp:54
VariableFlag
Definition: stack.hpp:38
Definition: stack.hpp:42
bool stack_init(void)
Definition: stack.cpp:666
u4 flags
Definition: jit.hpp:138
int32_t flags
Definition: stack.hpp:67
Definition: stack.hpp:59
stackelement_t * prev
Definition: stack.hpp:64
instruction * creator
Definition: stack.hpp:65
bool stack_analyse(jitdata *jd)
Definition: stack.cpp:2144
static bool IS_SAVEDVAR(s4 flags)
Definition: stack.hpp:50
Type
Types used internally by JITTED code.
Definition: global.hpp:117
int32_t s4
Definition: types.hpp:45
VariableKind varkind
Definition: stack.hpp:68
void stack_javalocals_store(instruction *iptr, s4 *javalocals)
Definition: stack.cpp:4692
static bool IS_INMEMORY(s4 flags)
Definition: stack.hpp:51
int32_t varnum
Definition: stack.hpp:69