1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// java-cpool.h - Constant pool parsing header. -*- c++ -*-
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef __JAVA_CPOOL_H__
#define __JAVA_CPOOL_H__
#include <javaprims.h>
// we rename these, to avoid polluting the name space
#define JV_CONSTANT_Undefined (0L)
#define JV_CONSTANT_Utf8 (1L)
#define JV_CONSTANT_Unicode (2L)
#define JV_CONSTANT_Integer (3L)
#define JV_CONSTANT_Float (4L)
#define JV_CONSTANT_Long (5L)
#define JV_CONSTANT_Double (6L)
#define JV_CONSTANT_Class (7L)
#define JV_CONSTANT_String (8L)
#define JV_CONSTANT_Fieldref (9L)
#define JV_CONSTANT_Methodref (10L)
#define JV_CONSTANT_InterfaceMethodref (11L)
#define JV_CONSTANT_NameAndType (12L)
#define JV_CONSTANT_ResolvedFlag (16L)
#define JV_CONSTANT_ResolvedString (16L | 8L)
#define JV_CONSTANT_ResolvedClass (16L | 7L)
/* We use the following two operations uniformly for all put/get operations
* in the runtime system (constant pool & stack), to assure that we keep
* everything in the same format. The idea is, that these should be inlined
* away, into just a simple store (for small data types, and a pair of stores
* if double or long has alignment greater than void *. On an 64-bit
* architecture, all operations should be simple stores; on a 32-bit
* architecture it depends on the alignment requirement for the specific
* type. */
template <class T>
static inline void _Jv_put (void *dst, T value)
{
#if 0
if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*))
{
jint *v_dst = (jint*)(dst);
jint *v_src = (jint*)&value;
v_dst[0] = v_src[0];
v_dst[1] = v_src[1];
}
else
#endif
{
*((T*) (dst)) = value;
}
}
template <class T>
static inline T _Jv_get (void *src)
{
#if 0
if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*))
{
T value;
jint *v_dst = (jint*)&value;
jint *v_src = (jint*)src;
v_dst[0] = v_src[0];
v_dst[1] = v_src[1];
return value;
}
else
#endif
{
return *((T*) (src));
}
}
/** needed to keep the CONSTANT_XXXRef & CONSTANT_NameAndType entries */
extern inline void
_Jv_storeIndexes (void **data,
_Jv_ushort index0,
_Jv_ushort index1)
{
// accomodate 64bit machines...
if (sizeof (void*) == (2 * sizeof (jint)))
{
((jint*)data)[0] = index0;
((jint*)data)[1] = index0;
}
else
{
_Jv_put<jint>(data, ((jint)index0 << 16) | (jint)index1);
}
}
extern inline void
_Jv_loadIndexes (const void **data,
_Jv_ushort& index0,
_Jv_ushort& index1)
{
if (sizeof (void*) == (2*sizeof (jint)))
{
index0 = ((jint*)data)[0];
index0 = ((jint*)data)[1];
}
else
{
jint udata = _Jv_get<jint>(data);
_Jv_uint uindex0 = ((udata >> 16) & 0xffff);
_Jv_uint uindex1 = udata & 0xffff;
index0 = uindex0;
index1 = uindex1;
}
}
extern inline void
_Jv_storeFloat (void **data, jfloat f)
{
_Jv_put<jfloat>(data, f);
}
extern inline jfloat
_Jv_loadFloat (void **data)
{
return _Jv_get<jfloat>(data);
}
extern inline void
_Jv_storeInt (void **data, jint i)
{
_Jv_put<jint>(data, i);
}
extern inline jint
_Jv_loadInt (void **data)
{
return _Jv_get<jint>(data);
}
extern inline void
_Jv_storeLong (void **data, jlong l)
{
return _Jv_put<jlong>(data, l);
}
extern inline jlong
_Jv_loadLong (void **data)
{
return _Jv_get<jlong>(data);
}
extern inline void
_Jv_storeDouble (void **data, jdouble d)
{
_Jv_put<jdouble>(data, d);
}
extern inline jdouble
_Jv_loadDouble (void **data)
{
return _Jv_get<jdouble> (data);
}
#endif /* __JAVA_CPOOL_H__ */
|