* Merged with c259010fc9d5.
[cacao.git] / src / native / localref.h
1 /* src/native/localref.h - Management of local reference tables
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
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 _LOCALREF_H
27 #define _LOCALREF_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct localref_table localref_table;
32
33 #include "config.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #include "vm/types.h"
40
41 #include "vm/global.h"
42
43 #include "vmcore/method.h"
44
45
46 /* localref_table **************************************************************
47
48    ATTENTION: keep this structure a multiple of 8-bytes!!! This is
49    essential for the native stub on 64-bit architectures.
50
51 *******************************************************************************/
52
53 #define LOCALREFTABLE_CAPACITY    16
54
55 struct localref_table {
56         s4                 capacity;        /* table size                         */
57         s4                 used;            /* currently used references          */
58         s4                 localframes;     /* number of current frames           */
59         s4                 PADDING;         /* 8-byte padding                     */
60         localref_table    *prev;            /* link to prev table (LocalFrame)    */
61         java_object_t     *refs[LOCALREFTABLE_CAPACITY]; /* references            */
62 };
63
64
65 #if defined(ENABLE_THREADS)
66 #define LOCALREFTABLE    (THREADOBJECT->_localref_table)
67 #else
68 extern localref_table *_no_threads_localref_table;
69
70 #define LOCALREFTABLE    (_no_threads_localref_table)
71 #endif
72
73
74 /* function prototypes ********************************************************/
75
76 bool localref_table_init(void);
77 bool localref_table_destroy(void);
78 void localref_table_add(localref_table *lrt);
79 void localref_table_remove();
80
81 bool localref_frame_push(int32_t capacity);
82 void localref_frame_pop_all(void);
83
84 java_handle_t *localref_add(java_object_t *o);
85 void           localref_del(java_handle_t *localref);
86
87 void localref_native_enter(methodinfo *m, uint64_t *argument_regs, uint64_t *argument_stack);
88 void localref_native_exit(methodinfo *m, uint64_t *return_regs);
89
90 #if !defined(NDEBUG)
91 void localref_dump(void);
92 #endif
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* _LOCALREF_H */
99
100
101 /*
102  * These are local overrides for various environment variables in Emacs.
103  * Please do not remove this and leave it at the end of the file, where
104  * Emacs will automagically detect them.
105  * ---------------------------------------------------------------------
106  * Local variables:
107  * mode: c
108  * indent-tabs-mode: t
109  * c-basic-offset: 4
110  * tab-width: 4
111  * End:
112  */