]>
Commit | Line | Data |
---|---|---|
e301621d | 1 | // nogc.cc - Implement null garbage collector. |
ee9dd372 | 2 | |
73068e36 | 3 | /* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation |
ee9dd372 TT |
4 | |
5 | This file is part of libgcj. | |
6 | ||
7 | This software is copyrighted work licensed under the terms of the | |
8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for | |
9 | details. */ | |
10 | ||
11 | #include <config.h> | |
12 | ||
13 | #include <stdio.h> | |
14 | #include <stdlib.h> | |
15 | ||
27e934d8 | 16 | #include <gcj/cni.h> |
ee9dd372 TT |
17 | #include <jvm.h> |
18 | ||
19 | // Total amount of memory allocated. | |
20 | static long total = 0; | |
21 | ||
22 | void * | |
73068e36 | 23 | _Jv_BuildGCDescr(jclass) |
bf3b8e42 HB |
24 | { |
25 | return 0; | |
26 | } | |
bf3b8e42 HB |
27 | |
28 | void * | |
29 | _Jv_AllocObj (jsize size, jclass klass) | |
ee9dd372 TT |
30 | { |
31 | total += size; | |
e301621d | 32 | void *obj = calloc (size, 1); |
3610e0d5 TT |
33 | if (!obj) _Jv_ThrowNoMemory(); |
34 | *((_Jv_VTable **) obj) = klass->vtable; | |
35 | return obj; | |
36 | } | |
37 | ||
38 | void * | |
39 | _Jv_AllocPtrFreeObj (jsize size, jclass klass) | |
40 | { | |
41 | total += size; | |
73068e36 | 42 | void *obj = calloc (size, 1); |
3610e0d5 | 43 | if (!obj) _Jv_ThrowNoMemory(); |
bf3b8e42 HB |
44 | *((_Jv_VTable **) obj) = klass->vtable; |
45 | return obj; | |
ee9dd372 TT |
46 | } |
47 | ||
48 | void * | |
bf3b8e42 | 49 | _Jv_AllocArray (jsize size, jclass klass) |
ee9dd372 TT |
50 | { |
51 | total += size; | |
e301621d | 52 | void *obj = calloc (size, 1); |
3610e0d5 | 53 | if (!obj) _Jv_ThrowNoMemory(); |
bf3b8e42 HB |
54 | *((_Jv_VTable **) obj) = klass->vtable; |
55 | return obj; | |
ee9dd372 TT |
56 | } |
57 | ||
58 | void * | |
59 | _Jv_AllocBytes (jsize size) | |
60 | { | |
61 | total += size; | |
73068e36 | 62 | void *obj = calloc (size, 1); |
3610e0d5 TT |
63 | if (!obj) _Jv_ThrowNoMemory(); |
64 | return obj; | |
ee9dd372 TT |
65 | } |
66 | ||
7866a458 BM |
67 | void * |
68 | _Jv_AllocRawObj (jsize size) | |
69 | { | |
70 | total += size; | |
71 | return calloc (size, 1); | |
72 | } | |
73 | ||
ee9dd372 TT |
74 | void |
75 | _Jv_RegisterFinalizer (void *, _Jv_FinalizerFunc *) | |
76 | { | |
77 | // FIXME: should actually register so that finalizers can be run on | |
78 | // exit. | |
79 | } | |
80 | ||
81 | void | |
82 | _Jv_RunFinalizers (void) | |
83 | { | |
84 | } | |
85 | ||
86 | void | |
87 | _Jv_RunAllFinalizers (void) | |
88 | { | |
89 | // FIXME: should still run all finalizers. | |
90 | } | |
91 | ||
eeedeb5a TT |
92 | void |
93 | _Jv_GCInitializeFinalizers (void (*) (void)) | |
94 | { | |
95 | } | |
96 | ||
ee9dd372 TT |
97 | void |
98 | _Jv_RunGC (void) | |
99 | { | |
100 | } | |
101 | ||
102 | long | |
103 | _Jv_GCTotalMemory (void) | |
104 | { | |
105 | return total; | |
106 | } | |
107 | ||
108 | long | |
109 | _Jv_GCFreeMemory (void) | |
110 | { | |
111 | return 0; | |
112 | } | |
113 | ||
b8c3c4f0 | 114 | void |
73068e36 | 115 | _Jv_GCSetInitialHeapSize (size_t) |
b8c3c4f0 TT |
116 | { |
117 | } | |
118 | ||
119 | void | |
73068e36 | 120 | _Jv_GCSetMaximumHeapSize (size_t) |
b8c3c4f0 TT |
121 | { |
122 | } | |
123 | ||
54c2f04b AG |
124 | void |
125 | _Jv_DisableGC (void) | |
126 | { | |
127 | } | |
128 | ||
129 | void | |
130 | _Jv_EnableGC (void) | |
131 | { | |
132 | } | |
133 | ||
ee9dd372 TT |
134 | void |
135 | _Jv_InitGC (void) | |
136 | { | |
137 | } | |
3610e0d5 | 138 | |
73068e36 AT |
139 | void |
140 | _Jv_GCRegisterDisappearingLink (jobject *) | |
141 | { | |
142 | } | |
143 | ||
144 | jboolean | |
145 | _Jv_GCCanReclaimSoftReference (jobject) | |
146 | { | |
147 | // For now, always reclaim soft references. FIXME. | |
148 | return true; | |
149 | } | |
150 | ||
3610e0d5 TT |
151 | #ifdef JV_HASH_SYNCHRONIZATION |
152 | void * | |
153 | _Jv_AllocTraceOne (jsize size /* includes vtable slot */) | |
154 | { | |
73068e36 | 155 | void *obj = calloc(size, 1); |
3610e0d5 TT |
156 | if (!obj) _Jv_ThrowNoMemory(); |
157 | return result; | |
158 | } | |
3a8da024 HB |
159 | |
160 | void * | |
161 | _Jv_AllocTraceTwo (jsize size /* includes vtable slot */) | |
162 | { | |
73068e36 | 163 | void *obj = calloc(size, 1); |
3a8da024 HB |
164 | if (!obj) _Jv_ThrowNoMemory(); |
165 | return result; | |
166 | } | |
3610e0d5 | 167 | #endif /* JV_HASH_SYNCHRONIZATION */ |