[go: up one dir, main page]

File: system.h

package info (click to toggle)
sablevm 1.11.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,980 kB
  • ctags: 7,922
  • sloc: ansic: 116,013; sh: 8,679; makefile: 489
file content (330 lines) | stat: -rw-r--r-- 9,087 bytes parent folder | download
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This source file is part of SableVM.                            *
 *                                                                 *
 * See the file "LICENSE" for the copyright information and for    *
 * the terms and conditions for copying, distribution and          *
 * modification of this source file.                               *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef SVM_SYSTEM_H
#define SVM_SYSTEM_H

/*
IMPORTANT: "ALIGNMENT" should be >= sizeof (void *) and a power of 2

This program computes the alignment (assuming a conforming ISO C compiler).

#include "jni_system_specific.h"


union value
{
  void *p;
  _svmt_u8 u8;
  _svmt_s8 s8;
  _svmt_u16 u16;
  _svmt_s16 s16;
  _svmt_u32 u32;
  _svmt_s32 s32;
  _svmt_u64 u64;
  _svmt_s64 s64;
  _svmt_f32 f32;
  _svmt_d64 d64;
};


struct align
{
  char c;
  union value v;
};

int main (int argc, char *argv[])
{
  struct align a;

  printf ("alignment = %u\n", (unsigned int) (((char *) &a.v) - ((char *) &a)));

  return 0;
}

*/

#if (( \
       defined (__sparc__) || defined (__ia64__) || defined (__alpha__) \
    || defined (__i386__) || defined (__powerpc__) || defined (__s390__) \
    || defined (__hppa__) || defined (__arm__) || defined (__m68k__) \
    || defined (__mc68000__) || defined (__mips__) || defined (__mipsel__) \
    || defined (__x86_64__) \
     ) && defined (__GNUC__))

/* "inline" is now an official keyword since the latest C standard (1999).
   So, it is a reasonable assuption to expect a target compiler to
   support it.  If your compiler doesn't, then you should define
   "inline" as nothing.
*/
#define inline __inline__

#define SVM_UNUSED __attribute__((unused))
#define SVM_CAST_EXTENSION __extension__

/* _svmt_word is an unsigned integral type such that:
 *
 *   sizeof (void *) == sizeof(_svmt_word).
 *
 * I guess that on most architectures, an "unsigned int" is a "word".
 */

#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)

#if defined (__alpha__)

typedef _svmt_u64 _svmt_word;
typedef _svmt_d64 _svmt_float_word;

#define SVM_WORD_SIZE 8		/* size in bytes */
#define SVM_WORD_BIT_COUNT 64	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 8192

#include <inlined_alpha.h>

#elif defined (__arm__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 4
#define SVM_ALIGNMENT_POWER 2	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_arm.h>

#elif defined (__hppa__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_hppa.h>

#elif defined (__i386__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 4
#define SVM_ALIGNMENT_POWER 2	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#if   (GCC_VERSION >= 2095) && (GCC_VERSION <3000)
#include <inlined_i386-gcc-2.95.h>
#else
#include <inlined_i386-gcc-3.3.h>
#endif /* (GCC_VERSION >= 2095) && (GCC_VERSION <3000) */

#elif defined (__ia64__)

typedef _svmt_u64 _svmt_word;
typedef _svmt_d64 _svmt_float_word;

#define SVM_WORD_SIZE 8		/* size in bytes */
#define SVM_WORD_BIT_COUNT 64	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 16384

#include <inlined_ia64.h>


#elif defined (__m68k__) || defined (__mc68000__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 2
#define SVM_ALIGNMENT_POWER 1	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_m68k.h>

#elif (defined (__mips__) || defined (__mipsel__))

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#elif defined (__powerpc__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_powerpc-no-reorder.h>

#elif defined (__s390__)
/* yes, that's strange, but s390 is 32bit - apparently at least in the userspace */
typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_s390.h>

#elif defined (__sparc__)

typedef _svmt_u32 _svmt_word;
typedef _svmt_f32 _svmt_float_word;

#define SVM_WORD_SIZE 4		/* size in bytes */
#define SVM_WORD_BIT_COUNT 32	/* size in bits */

/* see comments at the head of this file */
/* http://www.acm.org/crossroads/xrds1-3/free.html says you can have either
 * processor with 4k page size (old sparc) or 8k page size (ultra sparc).
 * We should probably choose the bigger value - shouldn't we? (GBP) */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 8192

#include <inlined_sparc.h>

#elif defined (__x86_64__)

typedef _svmt_u64 _svmt_word;
typedef _svmt_d64 _svmt_float_word;

#define SVM_WORD_SIZE 8		/* size in bytes */
#define SVM_WORD_BIT_COUNT 64	/* size in bits */

/* see comments at the head of this file */
#define SVM_ALIGNMENT 8
#define SVM_ALIGNMENT_POWER 3	/* 2 ^^ SVM_ALIGNMENT_POWER == SVM_ALIGNMENT */
#define SVM_PAGE_SIZE 4096

#include <inlined_x86_64.h>

#else
#error "unknown system"
#endif


/* FFI specific types */
#define ffi_type_float32 ffi_type_float
#define ffi_type_float64 ffi_type_double

/* Does ">>" behaves as a "signed" or "unsigned" shift when
   applied to a signed argument?  I personally think that the C
   standard should have specified this, unstead of leaving the choice
   in the hands of each compiler designer.  But what can I do? */

#define SVM_SIGNED_SHR 1	/* uncomment when: (-1 >> 1) == -1 */

#ifdef COMMENT
#define SVM_UNSIGNED_SHR 1	/* uncomment when: (-1 >> 1) != -1 */
#endif /* COMMENT */

/* Max integer that can be stored in a size_t variable */
#ifndef SIZE_T_MAX
#define SIZE_T_MAX UINT_MAX
#endif /* !SIZE_T_MAX */

#if defined (_SABLEVM_NO_GC)

#define SVM_HEAP_DEFAULT_SIZE 67108864

#elif defined (_SABLEVM_COPY_GC) || (_SABLEVM_GENCOPY_GC)

#define SVM_HEAP_DEFAULT_MIN_SIZE 16777216
#define SVM_HEAP_DEFAULT_MAX_SIZE 0
#define SVM_HEAP_DEFAULT_ALLOCATION_INCREMENT 1048576

#if defined (_SABLEVM_GENCOPY_GC)

#define SVM_HEAP_DEFAULT_NURSERY_SIZE (1<<20)
#define SVM_HEAP_DEFAULT_LARGE_OBJECT_SIZE (1<<11)
#define SVM_HEAP_REMSET_BUCKET_NUM (1<<5)
#define SVM_HEAP_REMSET_BUCKET_SIZE (1<<5)

#endif /* defined (_SABLEVM_GENCOPY_GC) */

#endif /* defined (_SABLEVM_NO_GC) */

#define SVM_STACK_DEFAULT_MIN_SIZE 65536
#define SVM_STACK_DEFAULT_MAX_SIZE 0
#define SVM_STACK_DEFAULT_ALLOCATION_INCREMENT 65536

#define SVM_CLASS_LOADER_DEFAULT_MIN_SIZE 1048576
#define SVM_CLASS_LOADER_DEFAULT_MAX_SIZE 0
#define SVM_CLASS_LOADER_DEFAULT_ALLOCATION_INCREMENT 1048576

#define SVM_THINLOCK_MAX_RECURSIVE_COUNT 0x01f
#define SVM_MAX_FATLOCK_ID 0x07fff
#define SVM_MAX_THREAD_ID 0x03ff

#define SVM_HASH_NONE 0
#define SVM_HASH_NOT_MOVED 1
#define SVM_HASH_MOVED 2

#if defined (_SABLEVM_BIDIRECTIONAL_OBJECT_LAYOUT)

#define SVM_LOCKWORD_START_OVERFLOW 0x03f
#define SVM_LOCKWORD_END_OVERFLOW 0x03f

#define SVM_LOCKWORD_START_OVERFLOW_OFFSET (SVM_LOCKWORD_START_OVERFLOW * SVM_ALIGNMENT)
#define SVM_LOCKWORD_END_OVERFLOW_OFFSET (SVM_LOCKWORD_END_OVERFLOW * SVM_ALIGNMENT + \
                                          _svmf_aligned_size_t (sizeof (_svmt_object_instance)))

#endif

#else

#error "unknown system"

#endif

#endif /* not SVM_SYSTEM_H */