author | Stefan Vogel <sv@exept.de> |
Tue, 11 May 2010 12:31:43 +0200 | |
changeset 12924 | 1e165b38598b |
parent 12923 | c2bfe4a0c2ce |
child 13302 | 24c3c50a0750 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5441 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1 | 14 |
Object subclass:#ObjectMemory |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
15 |
instanceVariableNames:'' |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
16 |
classVariableNames:'InternalErrorHandler UserInterruptHandler TimerInterruptHandler |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
17 |
SpyInterruptHandler StepInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
18 |
ExceptionInterruptHandler ErrorInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
19 |
MemoryInterruptHandler SignalInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
20 |
ChildSignalInterruptHandler DisposeInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
21 |
RecursionInterruptHandler IOInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
22 |
CustomInterruptHandler RegisteredErrorInterruptHandlers |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
23 |
InterruptLatencyMonitor AllocationFailureSignal |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
24 |
MallocFailureSignal LowSpaceSemaphore IncrementalGCLimit |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
25 |
FreeSpaceGCLimit FreeSpaceGCAmount BackgroundCollectProcess |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
26 |
BackgroundFinalizationProcess FinalizationSemaphore Dependents |
1108 | 27 |
ImageName ImageSaveTime ChangeFileName MaxInterruptLatency |
1767 | 28 |
InterruptLatencyGoal VMSelectors DynamicCodeGCTrigger |
3733 | 29 |
DynamicCodeLimit JustInTimeCompilationEnabled |
3912 | 30 |
JavaJustInTimeCompilationEnabled JavaNativeCodeOptimization |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
31 |
BackgroundCollectMaximumInterval SavedGarbageCollectorSettings' |
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
32 |
poolDictionaries:'' |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
33 |
category:'System-Support' |
1 | 34 |
! |
35 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
36 |
Object subclass:#BinaryModuleDescriptor |
12922 | 37 |
instanceVariableNames:'name type id dynamic classNames handle pathName libraryName |
38 |
timeStamp' |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
39 |
classVariableNames:'' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
40 |
poolDictionaries:'' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
41 |
privateIn:ObjectMemory |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
42 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
43 |
|
1767 | 44 |
!ObjectMemory class methodsFor:'documentation'! |
2 | 45 |
|
615 | 46 |
caching |
47 |
" |
|
48 |
The system uses various caches to speed up method-lookup. |
|
49 |
Currently, there is a three-level cache hierarchy: |
|
50 |
||
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
51 |
inline-cache keeps the target of the last send at the caller- |
10226 | 52 |
side (i.e. every send goes through its private |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
53 |
1-slot inline-cache, where the address of the last |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
54 |
called function at this call location is kept.) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
55 |
|
10226 | 56 |
polymorph-inline-cache keeps a limited list of all targets ever reached |
57 |
at this call location. The list is automatically |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
58 |
flushed if it grows too large, or the overall number |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
59 |
of poly-chache entries exceeds a limit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
60 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
61 |
method-lookup-cache a global cache. Hashes on class-selector pairs, |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
62 |
returning the target method. |
615 | 63 |
|
10226 | 64 |
Whenever methods are added or removed from the system, or the inheritance |
615 | 65 |
hierarchy changes, some or all caches have to be flushed. |
66 |
The flushXXX methods perform the task of flushing various caches. |
|
67 |
All standard methods in Behavior call for cache flushing, when things change; |
|
68 |
however, if you use the low level access methods in Behavior |
|
69 |
(for example: #setSuperclass:) special care has to be taken. |
|
70 |
||
71 |
In some situations, not all caches need flushing, for example a change |
|
72 |
in an interpreted method (currently) needs no flushing of the inline caches. |
|
73 |
Also, flushing can be limited to entries for a specific class for most changes. |
|
74 |
||
75 |
To be 'on the brigth side of live', use ObjectMemory>>flushCaches (which |
|
10226 | 76 |
flushes all of them), when in doubt of which caches should be flushed. |
77 |
It is better flush too much - otherwise you may end up in a wrong method after |
|
1152 | 78 |
a send (you wont really see a difference in speed after the flush, anyway). |
615 | 79 |
" |
80 |
! |
|
81 |
||
88 | 82 |
copyright |
83 |
" |
|
84 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
159 | 85 |
All Rights Reserved |
88 | 86 |
|
87 |
This software is furnished under a license and may be used |
|
88 |
only in accordance with the terms of that license and with the |
|
89 |
inclusion of the above copyright notice. This software may not |
|
90 |
be provided or otherwise made available to, or used by, any |
|
91 |
other person. No title to or ownership of the software is |
|
92 |
hereby transferred. |
|
93 |
" |
|
94 |
! |
|
95 |
||
2 | 96 |
documentation |
97 |
" |
|
403 | 98 |
This class contains access methods to the system memory and the VM. |
99 |
||
100 |
In previous ST/X versions, this stuff used to be in the Smalltalk class. |
|
101 |
It has been separated for better overall class structure and modularisation. |
|
229 | 102 |
There are no instances of ObjectMemory - all is done in class methods. |
403 | 103 |
(this is a functional interface). |
104 |
||
105 |
Many methods here are for debuging purposes, for developers |
|
106 |
or experimental, and therefore not standard. |
|
68 | 107 |
Do not depend on them being there - some may vanish ... |
108 |
(especially those, that depend on a specific GC implementation) |
|
403 | 109 |
Most of the stuff found here is not available, or different or called |
110 |
different in other smalltalk implementations. Be aware, that using these |
|
111 |
interfaces (especially: depending on them) may make your application |
|
112 |
non portable. |
|
113 |
||
114 |
See more documentation in -> caching |
|
10226 | 115 |
-> interrupts |
116 |
-> garbageCollection |
|
2 | 117 |
|
1300 | 118 |
[Class variables:] |
2 | 119 |
|
10226 | 120 |
InternalErrorHandler gets informed (by VM), when some runtime |
121 |
error occurs (usually fatal) |
|
122 |
||
123 |
UserInterruptHandler gets informed (by VM) when CNTL-C is pressed |
|
124 |
TimerInterruptHandler gets alarm timer interrupts (from VM) |
|
125 |
SpyInterruptHandler another alarm timer (from VM) |
|
126 |
StepInterruptHandler gets single step interrupts (from VM) |
|
127 |
ExceptionInterruptHandler gets floating point exceptions (from VM) |
|
128 |
ErrorInterruptHandler gets primitive errors (from VM) |
|
129 |
MemoryInterruptHandler gets soon-out-of-memory conditions (from VM) |
|
130 |
SignalInterruptHandler gets unix signals (from VM) |
|
131 |
ChildSignalInterruptHandler gets child death signals (from VM) |
|
132 |
DisposeInterruptHandler gets informed, when an object is disposed from |
|
133 |
a shadowArray (from VM) |
|
134 |
RecursionInterruptHandler gets recursion limit violations (from VM) |
|
135 |
IOInterruptHandler gets SIGIO unix signals (from VM) |
|
136 |
CustomInterruptHandler gets custom interrupts (from VM) |
|
137 |
||
138 |
InterruptLatencyMonitor if nonNil, that one will be notified (by the VM) |
|
139 |
with an interruptLatency:millis message for every |
|
140 |
interrupt and gets the delay time |
|
141 |
(between the time when the signal arrived and |
|
142 |
when it was really delivered) as argument. |
|
143 |
This can be used to create a statistic for |
|
144 |
realtime systems. |
|
145 |
||
146 |
RegisteredErrorInterruptHandlers |
|
147 |
associates errorID (as passed from primitive |
|
148 |
to the __errorInterruptWithID() function) |
|
149 |
with handlers. |
|
150 |
||
151 |
IncrementalGCLimit number of bytes, that must be allocated since |
|
152 |
last full garbage collect to turn the incremental |
|
153 |
collector on (at idle time). |
|
154 |
||
155 |
FreeSpaceGCLimit low limit on freeSpace, at which incremental |
|
156 |
gc starts to run at idle time. |
|
157 |
||
158 |
FreeSpaceGCAmount amount to allocate, once freeSpace drops |
|
159 |
below FreeSpaceGCLimit |
|
160 |
||
161 |
DynamicCodeGCTrigger amount of generated dynamically compiled code |
|
162 |
to trigger the incremental garbage collector |
|
163 |
nil means: no trigger |
|
164 |
||
165 |
DynamicCodeLimit max. amount of space allocated for dynamically compiled code |
|
166 |
nil means: unlimited. |
|
167 |
||
168 |
JustInTimeCompilationEnabled boolean - enables/disables JIT-compilation of |
|
169 |
bytecode to machine code. |
|
170 |
(this has nothing to do with stc-compilation) |
|
171 |
||
172 |
Dependents keep my dependents locally (its faster) for |
|
173 |
all those registries |
|
174 |
||
175 |
LowSpaceSemaphore a semaphore signalled whenever the system is |
|
176 |
running in low memory (i.e. the memory manager |
|
177 |
ran into memory shortage and feels that it |
|
178 |
may soon no longer be able to grant allocation requests). |
|
179 |
You can have a process waiting on this semaphore |
|
180 |
which starts to remove (i.e. nil-out) objects |
|
181 |
or preform other cleanup actions. |
|
182 |
||
183 |
AllocationFailureSignal signal raised when a new fails (see Behavior) |
|
184 |
When this signal is raised, the memory manager |
|
185 |
is really in trouble (i.e. above low-mem feelings |
|
186 |
were correct) |
|
187 |
||
188 |
MallocFailureSignal signal raised when a malloc fails |
|
189 |
mallocs are used internally in the VM and/or |
|
190 |
by some classes (ExternalBytes) |
|
191 |
||
192 |
BackgroundCollectProcess created by startBackgroundCollectorAt: |
|
193 |
||
194 |
BackgroundFinalizationProcess created by startBackgroundFinalizationAt: |
|
195 |
||
196 |
BackgroundCollectMaximumInterval |
|
197 |
number of seconds after which an incremental background |
|
198 |
collection is started - regardless of the allocation |
|
199 |
rate or freeSpace situation. If nil, IGC is only done |
|
200 |
when the space situation makes it feasable. |
|
201 |
Can be set to (say) 3600, to have the memory cleaned |
|
202 |
at least once an hour. |
|
203 |
||
204 |
FinalizationSemaphore triggered by the VM, when any weak pointer is |
|
205 |
lost. Been waited upon by the backgroundFinalizer. |
|
206 |
||
207 |
ImageName name of the current image (or nil) |
|
208 |
||
209 |
ImageSaveTime <Timestamp> timestamp when this image was saved |
|
1096 | 210 |
|
211 |
||
403 | 212 |
Warning: |
213 |
The InterruptHandler variables are known by the runtime system - |
|
214 |
they are the objects that get an interrupt message when the event |
|
215 |
occurs. You may not remove any of them. |
|
1300 | 216 |
|
217 |
[author:] |
|
10226 | 218 |
Claus Gittinger |
2 | 219 |
" |
93 | 220 |
! |
221 |
||
222 |
garbageCollection |
|
223 |
" |
|
403 | 224 |
Currently, Smalltalk/X uses a two-level memory hierachy (actually, there |
225 |
are more memory regions used for stack, permanent objects, symbols etc. |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
226 |
but for the following discussion, these are not of interest). |
403 | 227 |
|
228 |
newSpace: |
|
229 |
||
93 | 230 |
Objects are created in a so-called newSpace, which is relatively small. |
10226 | 231 |
This newSpace is cleaned by a so called ``scavenge''-operation, whenever |
403 | 232 |
becoming full. Scavenging means, that all still-live objects (i.e. referenced |
233 |
by some other) are copied over to another memory area, leaving all unreachable |
|
234 |
objects as garbage behind. Thus, the newSpace actually consists of two semispaces, |
|
235 |
of whih only one is active - the other being used only while objects are |
|
236 |
copied. |
|
237 |
After this copying, these two semispaces exchange their roles - i.e. reachable |
|
238 |
objects are copied ping-pong like between these semispaces. |
|
10226 | 239 |
Once an object survives enough of these copying operations, the next scavenge |
216 | 240 |
will move it into the so called oldSpace, which is much larger, and not |
10226 | 241 |
processed by the scavenger. |
403 | 242 |
This movement of an object from newSpace to oldSpace is called ``tenure''. |
243 |
(this avoids objects being copied around forever). |
|
244 |
Once tenured, an object is no longer contained in the newSpace, and |
|
245 |
thus ceases to create any scavenging overhead after that. |
|
133 | 246 |
|
10226 | 247 |
Scavenging occurs automatically, and is usually done fast enough to go |
248 |
unnoticed (typically, it takes some 5 to 40ms to perform a scavenge, |
|
93 | 249 |
depending on how many live objects are in the newspace). |
403 | 250 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
251 |
Interestingly, the scavenger performs better, if many garbage objects |
93 | 252 |
are to be reclaimed, since less object-copying has to be done. Therefore, |
216 | 253 |
the best-case scavenge time is almost zero, if there is only garbage in |
254 |
the newSpace. In contrast, the worst-case is when all newSpace objects are still |
|
403 | 255 |
living. Thus, from a newSpace collectors viewPoint, it makes sense to get |
256 |
objects out of the way as fast as possible. However the oldSpace is |
|
257 |
collected much less frequently and the cost to reclaim an oldspace object |
|
258 |
is much higher (actually, the cost to reclaim a newspace object is zero - |
|
259 |
its the survival of objects which we have to pay for). |
|
260 |
Therefore, from an oldSpace collectors point of view, its preferable to |
|
261 |
keep objects in the newSpace as long as possible. |
|
262 |
||
263 |
To honor this conflicting situation, the system uses an adaptive tenure-count, |
|
10226 | 264 |
which adjusts the number of scavenges required for tenure (the so called |
207 | 265 |
'tenureAge') according to the fill-grade of the newSpace. |
403 | 266 |
If the newSpace is relatively empty, it tries to keep objects longer there. |
267 |
The controlling parameters of the tenure age can be changed dynamically, |
|
268 |
detailed information is available upon request. |
|
269 |
||
270 |
The exact speed of the scavenger depends mostly on the speed of your memory |
|
271 |
interface (and, since most of todays memories have access times in the order |
|
272 |
of 50-100ns, the raw CPU speed does not correlate linear with the GC speed). |
|
10226 | 273 |
Measurements give roughly 40ms for a full 400k newSpace |
1152 | 274 |
(i.e. all objects survive) on a 486/50 - this only drops to some 20-30ms on a P5. |
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
275 |
Big caches help - i.e. a 1Mb cache machine performs better than a 256k cache machine. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
276 |
Also, a good memory interface (small number of wait cycles and burst modes) |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
277 |
help a lot. |
1152 | 278 |
|
403 | 279 |
The upper bounds of the scavenge blocking time can be controlled by changing |
1152 | 280 |
the size of the newSpace - either via a command line argument, or even dynamically |
403 | 281 |
by Objectmemory>>newSpaceSize:. Smaller sizes lead to shorter blocking periods, |
282 |
but greater absolute GC overhead. The default (400k) seems to be a good compromise. |
|
283 |
(if you are not happy with it, try playing around with the settings) |
|
284 |
||
285 |
oldSpace: |
|
93 | 286 |
|
287 |
To reclaim oldspace, the system uses three algorithms: mark&sweep, a copying |
|
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
288 |
(and compressing) baker-type collector and an incremental mark&sweep, augmented |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
289 |
by an inplace compress algorithm. |
93 | 290 |
|
291 |
The mark&sweep runs whenever the oldspace becomes full, putting dead objects |
|
292 |
onto a free list. If a memory request cannot be served from this freelist, |
|
293 |
and the total size of objects on the freelist exceeds a threshold, the system |
|
294 |
will compress the oldspace to make the free-space into one big area. |
|
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
295 |
This compress is either done by a 1-pass semispace copy algorithm, or |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
296 |
a 2pass inplace compress - depending on the setting of the compress limit. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
297 |
|
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
298 |
The 1pass algorithm copies all live objects into a newly allocated |
3733 | 299 |
area, and frees the previous memory afterwards (a baker style copying collector). |
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
300 |
The 2pass algorithm moves objects inPlace, and adjusts the pointers in |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
301 |
a second pass. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
302 |
The 1pass algorithm requires twice the amount of memory (virtually) and is |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
303 |
slightly faster, if enough real memory is available. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
304 |
In memory limited systems, the 2pass algorithm generally performs better, |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
305 |
since it is less affected by paging. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
306 |
To honor this situation, the compressLimit should be set to enforce the |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
307 |
2-pass algorithm if the oldSpace size exceeds a certain threshold. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
308 |
|
3733 | 309 |
We recommend setting the compressLimit to roughly 1/4th of the physical |
310 |
memory size of the machine, if other programs are to run beside ST/X |
|
311 |
(i.e. an XServer, some xterms etc.). |
|
312 |
If ST/X is running almost alone (i.e. using an XTerminal), the compressLimit |
|
313 |
can be set to 1/3rd of the physical memory. |
|
314 |
This is only a rough estimate - you may want to play around with this |
|
315 |
parameter, to find a value which avoids paging due to a 1pass compress. |
|
316 |
||
93 | 317 |
Since a compressing oldspace collect leads to a noticable pause of the system, |
318 |
the memory manager tries hard to avoid oldspace compression. |
|
1152 | 319 |
(well, if enough real memory is available to hold both spaces in physical |
3733 | 320 |
memory, the compress algorithms are actually pretty fast). |
202 | 321 |
|
93 | 322 |
The incremental mark&sweep runs in the background, whenever the system is idle |
403 | 323 |
(see ProcessorSceduler>>waitForEventOrTimeout), or alternatively as a low or high |
10226 | 324 |
priority background process (see ObjectMemory>>startBackgroundCollector). |
325 |
Like the normal mark&sweep, this incremental collector follows object references |
|
362 | 326 |
and marks reachable objects on its way. However, this is done 'a few objects-at-a-time', |
10226 | 327 |
to not disrupt the system noticably. |
3733 | 328 |
Currently, there are some (theoretical) and in practice never occurring situations, |
329 |
in which the incremental GC still creates noticable delays. |
|
330 |
A current project is involved with this and a future version of ST/X (ST/X-RT) |
|
10226 | 331 |
will be available which shows deterministic worst case behavior in its GC pauses |
403 | 332 |
(this will be provided as an additional add-on option - certainly not for free ;-). |
1152 | 333 |
|
403 | 334 |
Currently, incremental GC blockings are in the order of 10-70ms. |
335 |
There is one catch with low priority background IGC: if there is never any idle |
|
336 |
time available (i.e. all processes run all the time), it would never get a chance |
|
10226 | 337 |
to do any collection work. |
3733 | 338 |
To handle this case, a background IGC can either be started as a high priority |
339 |
process, which gives up the cpu (by delaying on the time) after every IGC step, |
|
340 |
or it can be gicen a dynamic priority, where the max-prio is above UserSchedulingPriority. |
|
341 |
A high priority background collector will always make progress and eventually finish |
|
342 |
a GC cycle. However, it may have more of an influence on the other processes. |
|
343 |
So, its up to you, to decide ... |
|
362 | 344 |
|
1152 | 345 |
|
10226 | 346 |
Incremental garbage collection is controlled by the variables |
362 | 347 |
'IncrementalGCLimit', 'FreeSpaceGCLimit' and 'FreeSpaceGCAmount': |
310 | 348 |
|
10226 | 349 |
the ProcessorScheduler will perform incremental GC steps at idle time, |
350 |
if the total space allocated since the last full collect exceeds |
|
362 | 351 |
'IncrementalGCLimit', |
290 | 352 |
or if there are less than 'FreeSpaceGCLimit' bytes available in free store. |
362 | 353 |
If after the incrementalGC, less than 'FreeSpaceGCLimi't bytes are available, |
310 | 354 |
'FreeSpaceGCAmount' more bytes are requested from the memory manager. |
290 | 355 |
|
10226 | 356 |
The defaults are set in ObjectMemory>>initialize and can be changed in your |
403 | 357 |
startup 'smalltalk.rc'-file. Setting them to nil turns incremental GC off. |
270 | 358 |
|
1152 | 359 |
|
362 | 360 |
For example, setting 'IncrementalGCLimit' to 500000 will start the background collector |
207 | 361 |
whenever 500k bytes have been allocated - usually very seldom. Setting it to some |
362 |
small number (say 10000) will have it run very often. |
|
290 | 363 |
|
362 | 364 |
Setting 'FreeSpaceGCAmount' to (say) 1meg lets the system try to always keep |
403 | 365 |
1meg of freeSpace. If less memory is available, more oldSpace will be allocated. |
366 |
Keeping some memory in the pocket may prevent the system from running into a blocking |
|
10226 | 367 |
GC if memory is allocated in peaks (but only, if the incremental GC can keep up with |
403 | 368 |
allocation rate). The trigger level 'FreeSpaceGCLimit' should be below that amount; |
310 | 369 |
to avoid excessive incremental GC activity (say 1/4 if the amount). |
290 | 370 |
|
10226 | 371 |
Having the background GC running often should not hurt the performance of your |
372 |
smalltalk processes, since the IGC only runs at times when no ST processes are runnable. |
|
373 |
(there are some short delays in event processing, since the IGC's steps may take |
|
374 |
some XX ms.) |
|
375 |
However, if you are not alone on your machine (i.e. a timesharing system) or |
|
376 |
you have other Unix processes to run, you should not run the IGC too often, |
|
362 | 377 |
since it may hurt OTHER users/unix processes. |
93 | 378 |
|
10226 | 379 |
Since this collector only runs at idle times, even a low priority background |
216 | 380 |
process will prevent it from doing its work. You may want to start a somewhat |
207 | 381 |
higher priority background collect (say at prio 4), which also preempts these |
382 |
background processes. (see ObjectMemory>>startBackgroundCollectorAt:). |
|
202 | 383 |
|
325 | 384 |
Beginning with 2.10.4, a third space, called symSpace has been added. |
216 | 385 |
Objects in this space are never moved or garbage collected. |
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
386 |
This space is (currently) used for symbols only. |
325 | 387 |
|
388 |
Beginning with 2.10.5, a fourth space, called fixSpace has been added. |
|
389 |
Objects in this space are never moved or garbage collected. |
|
390 |
This space is used for constant objects (true, false, some basic classes etc.). |
|
229 | 391 |
|
392 |
A plan for 2.11 is to offer an arbitrary number of spaces, which can be |
|
393 |
attached and detached at runtime. This will allow easy share of object |
|
394 |
with remote systems and separating objects into a per application/package |
|
395 |
space. (be prepared for changes in the future and make your application |
|
396 |
independ of the VM internals) |
|
216 | 397 |
|
403 | 398 |
default setup: |
399 |
||
3733 | 400 |
The following table lists some default settings and means for changing them; |
401 |
Notice, that the defaults below are those of the VM and or ObjectMemory class. |
|
402 |
These may already be changed by a smalltalk.rc or private.rc startup file. |
|
403 | 403 |
|
10226 | 404 |
what default change by |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
405 |
command line arg dynamically |
403 | 406 |
----------------------------------------------------------------------- |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
407 |
newSpace size 400k -Mnew nnn newSpaceSize:nnn |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
408 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
409 |
oldSpace size 3000k -Mold nnn moreOldSpace: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
410 |
announceSpaceNeed: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
411 |
collectGarbage |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
412 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
413 |
max tenure age 29 lockTenure: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
414 |
avoidTenure: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
415 |
(sets it to infinity) |
10226 | 416 |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
417 |
adaptive tenure - - tenureParameters |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
418 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
419 |
2pass oldSpace |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
420 |
compressor enabled -Msingle - |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
421 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
422 |
limit for 1pass |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
423 |
old-compress 8000k - oldSpaceCompressLimit: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
424 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
425 |
chunk size |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
426 |
to increase |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
427 |
oldSpace 256k - oldSpaceIncrement: |
10226 | 428 |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
429 |
prefer moreOld |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
430 |
to doing GC false - fastMoreOldSpaceAllocation: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
431 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
432 |
limit for |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
433 |
above - - fastMoreOldSpaceLimit: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
434 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
435 |
keep size for - - freeSpaceGCAmount: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
436 |
IGC |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
437 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
438 |
low water |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
439 |
trigger for IGC - - freeSpaceGCLimit: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
440 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
441 |
allocated |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
442 |
trigger for IGC 500k - incrementalGCLimit |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
443 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
444 |
maximum time |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
445 |
interval between |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
446 |
IGC's - - BackgroundCollectMaximumInterval |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
447 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
448 |
JIT codeCache |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
449 |
size unlimited - dynamicCodeLimit: |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
450 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
451 |
new JIT code |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
452 |
trigger for IGC none - dynamicCodeGCTrigger: |
3652 | 453 |
|
454 |
||
1152 | 455 |
By default, no incremental GC is started by the system; however, |
456 |
the standard startup script starts a low prio background incremental GC process. |
|
10226 | 457 |
You have to edit your startup files to change this. |
1152 | 458 |
A suggested configuration (used by the author and the default) is: |
459 |
||
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
460 |
' keep 1meg in the pocket ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
461 |
|
10226 | 462 |
ObjectMemory freeSpaceGCAmount:1000000. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
463 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
464 |
' start incrementalGC when freespace drops below 250k ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
465 |
' or 500k of oldSpace has been allocated ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
466 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
467 |
ObjectMemory freeSpaceGCLimit:250000. ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
468 |
ObjectMemory incrementalGCLimit:500000. ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
469 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
470 |
' collect as a background process (the default is: at idle times) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
471 |
' this means that running cubes or other demo processes are suspended |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
472 |
' for the collect; change the prio to below 4 if you want them to continue |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
473 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
474 |
ObjectMemory startBackgroundCollectorAt:5. ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
475 |
ObjectMemory startBackgroundFinalizationAt:5. ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
476 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
477 |
' quickly allocate more space (i.e. avoid blocking collects) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
478 |
' up to 8meg - then start to collect if more memory is needed. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
479 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
480 |
ObjectMemory fastMoreOldSpaceLimit:8*1024*1024. ' |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
481 |
ObjectMemory fastMoreOldSpaceAllocation:true. ' |
403 | 482 |
|
202 | 483 |
hints & tricks: |
484 |
||
213 | 485 |
normally, there is no need to call for an explicit garbage collection, or |
216 | 486 |
modify the default parameters. |
10226 | 487 |
The memory system should adapt reasonable and provide good performance |
202 | 488 |
for a wide range of allocation patterns (see Example3 below for an exception). |
489 |
||
207 | 490 |
However, there may be situations, in which hints and/or explicit |
202 | 491 |
control over allocation can speedup your programs; but please: |
93 | 492 |
|
207 | 493 |
- if you think you have to play around with the memory policies, |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
494 |
first check your program - you may find useless allocations |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
495 |
or bad uses of collections. A typical error that is made is to |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
496 |
create large collections using the #, (comma) concatenation method, |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
497 |
which shows square behavior, since it allocates many, many temporary |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
498 |
collections. Also, watch out for #copyWith:, #add: etc. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
499 |
All of these create a new collection. Remember, that most collections |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
500 |
offer methods to preallocate some space; for example, 'Set new:' creates |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
501 |
an empty set, but preallocates space to avoid resizing over and over. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
502 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
503 |
An especially bad performace dog is to use #add: on fix-size collection |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
504 |
objects (such as Strings or Arrays), since in addition to allocating |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
505 |
lots of garbage, a #become: operation is required for EACH element |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
506 |
added. NEVER use Arrays for growing/shrinking data - use OrderedCollection |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
507 |
instead. (if you really need an array, use asArray afterwards) |
202 | 508 |
|
207 | 509 |
- if you are going to allocate huge data structures, think about |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
510 |
optimizing space. For example, if you allocate a million instances of |
10226 | 511 |
some object, each added instance variable makes up 4Mb of additional |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
512 |
memory need. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
513 |
Also, for Byte-valued, Integer-valued and Float like objects, special |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
514 |
collections are provided, which store their values directly inside (instead |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
515 |
of a reference to the object). A FloatArray consisting of 1 million floats |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
516 |
requires about 4mb of memory, while an Array of Floats requires 4mb for the |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
517 |
references to the floats, PLUS 20Mb for the floats themself. |
93 | 518 |
|
207 | 519 |
- check if you really need fast access to all of these objects; you may |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
520 |
try to only keep some subset in memory, and use binary storage or |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
521 |
(if this is too slow) optimized store/retrieve methods and keep the bigger |
10226 | 522 |
part in a file. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
523 |
(How about a DiskArray class, which does this transparently ? |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
524 |
See the FileText class for some ideas and something to start with ...) |
207 | 525 |
|
526 |
||
10226 | 527 |
Hint / Example 1: |
93 | 528 |
you are about to allocate a huge data structure, which is known to |
529 |
survive long. In this case, it is better to have these objects move into the |
|
530 |
oldspace sooner, to avoid the copying overhead during scavenges. |
|
531 |
||
532 |
To do this, you can call ObjectMemory>>tenure after allocation, which |
|
10226 | 533 |
forces all new-objects immediately into the oldspace. |
93 | 534 |
Make certain, that not to many (ideally no) short-living objects are in the |
535 |
newspace when doing this. |
|
536 |
||
537 |
Another alternative is to tell the system that all allocation should be |
|
538 |
done directly in the oldspace. This completely avoids the scavenging overhead |
|
539 |
for these objects. To do so, use ObjectMemory>>turnGarbageCollectorOff |
|
540 |
before the allocation, and ObjectMemory>>turnGarbageCollectorOn afterwards. |
|
202 | 541 |
Keep in mind, that do-loops may allocate block-objects and other temporaries, |
178 | 542 |
so there is a danger of making things worse due to having all those temporaries |
93 | 543 |
in the oldspace afterwards. (which is not a fatal situation, but will |
178 | 544 |
force the system to do an oldspace collect earlier, which may not be your |
545 |
intention). |
|
93 | 546 |
|
202 | 547 |
|
207 | 548 |
Hint / Example 2: |
93 | 549 |
you know in advance, that a certain (big) amount of memory will be needed. |
550 |
For example, the fileBrowser wants to show a huge file in its text-view. |
|
133 | 551 |
In this case, it is better to tell the memory system in advance, how much |
93 | 552 |
memory will be needed, since otherwise many compresses and reallocations will |
133 | 553 |
occur (the memory system will allocate additional memory in chunks of smaller |
10226 | 554 |
256k pieces, if a compress failes. Thus, if you are going to allocate (say) 1Mb of |
133 | 555 |
strings, it will perform 5 compressing GC's). |
556 |
||
202 | 557 |
This is done using ObjectMemory>>moreOldSpace: or ObjectMemory announceSpaceNeed:. |
10226 | 558 |
In the above example, you would do 'ObjectMemory announceSpaceNeed:500000', which |
133 | 559 |
avoids those annoying 5 compressing GC's. |
207 | 560 |
BTW: if you have other smalltalk processes (threads) running which should not be |
10226 | 561 |
paused if possible, it is better to use #announceSpaceNeed. This tries to avoid |
562 |
pausing in other processes and sometimes succeeds, while moreOldSpace will always |
|
207 | 563 |
block the whole system for a while. However, there is no 'no-pause' guarantee. |
133 | 564 |
|
565 |
The amount of automatic increase (in case the oldSpace becomes full) is 256k by |
|
566 |
default. This number can be changed with ObjectMemory>>oldSpaceIncrement:. |
|
567 |
||
207 | 568 |
|
569 |
Hint / Example3: |
|
178 | 570 |
There are rare cases, when an explicit GC makes a difference: since |
571 |
object finalization is done at GC time, objects which keep operatingSystem |
|
572 |
resources may be finalized late. This is normally no problem, except if |
|
573 |
the system is running out of resources. For example, allocating new colors |
|
574 |
may fail if many colors have already been allocated in the past - even |
|
575 |
though these colors are actually free. The Depth8Image calls for an |
|
576 |
explicit GC, whenever it fails to allocate a color for a bitmap, to force |
|
577 |
finalization of free, but not yet finalized colors. |
|
1152 | 578 |
The same is true for things like file descriptors, if fileStreams are not closed |
579 |
correctly. |
|
207 | 580 |
|
581 |
Hint 4: |
|
582 |
If you run in too small of physical memory, the incremental GC may have a |
|
583 |
bad effect on your working set: since it touches pages (which may otherwise |
|
584 |
not be needed at the moment, the operating system is forced to steal other |
|
585 |
(possibly more useful) pages from your set of incore pages. |
|
1152 | 586 |
Although ST/X would be willing to fix this behavior (by telling the OS about |
587 |
its page requirements, many OS's do not listen. The SGI-Iris, For example ignores |
|
588 |
the madvice system calls - other systems do not implement it. |
|
589 |
The trouble is that the standard LRU paging strategy is exactly the worst for |
|
590 |
a program which sequentially scans its memory once in a single direction ... |
|
207 | 591 |
You may get better performance, if you turn off the incremental GC while |
592 |
processing a big data structure. |
|
593 |
||
594 |
||
229 | 595 |
Warning: many of the methods found here are not standard and may not even be available in |
133 | 596 |
future versions of ST/X. Use them only in very special situations or experiments. |
229 | 597 |
|
207 | 598 |
Let me know about additional special features you think are useful, and about |
599 |
special features you are using - this provides the feedback required to decide |
|
403 | 600 |
which methods are to be removed, kept or enhanced in future versions. |
93 | 601 |
" |
615 | 602 |
! |
603 |
||
604 |
interrupts |
|
605 |
" |
|
606 |
Handling of interrupts (i.e. unix-signals) is done via handler objects, which |
|
607 |
get a #XXXInterrupt-message sent. This is more flexible than (say) signalling |
|
608 |
a semaphore, since the handler-object may do anything to react on the signal |
|
609 |
(of course, it can also signal a semaphore to emulate the above behavior). |
|
610 |
||
611 |
Another reason for having handler objects is that they allow interrupt handling |
|
612 |
without any context switch, for high speed interrupt response. |
|
10226 | 613 |
However, if you do this, special care is needed, since it is not defined, |
614 |
which (smalltalk-)process gets the interrupt and will do the processing |
|
615 |
(therefore, the default setup installs handlers which simply signal a semaphore |
|
1152 | 616 |
and continue the current process). |
615 | 617 |
|
618 |
Typically, the handlers are set during early initialization of the system |
|
619 |
by sending 'ObjectMemory XXXInterruptHandler:aHandler' and not changed later. |
|
620 |
(see Smalltalk>>initialize or ProcessorScheduler>>initialize). |
|
621 |
To setup your own handler, create some object which responds to #xxxInterrupt, |
|
622 |
and make it the handler using the above method. |
|
623 |
||
624 |
Interrupt messages sent to handlers are: |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
625 |
internalError:<someString> - internal interpreter/GC errors |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
626 |
userInterrupt - ^C interrupt |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
627 |
customInterrupt - custom interrupt |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
628 |
ioInterrupt - SIGIO interrupt |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
629 |
timerInterrupt - alarm timer (SIGALRM) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
630 |
errorInterrupt:<id> - errors from other primitives/subsystems |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
631 |
(DisplayError) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
632 |
spyInterrupt - spy timer interrupt (SIGVTALARM) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
633 |
stepInterrupt - single step interrupt |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
634 |
disposeInterrupt - finalization required |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
635 |
recursionInterrupt - recursion (stack) overflow |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
636 |
memoryInterrupt - soon running out of memory |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
637 |
fpExceptionInterrupt - floating point exception (SIGFPE) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
638 |
childSignalInterrupt - death of a child process (SIGCHILD) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
639 |
signalInterrupt:<number> - unix signal (if other than above signals) |
615 | 640 |
|
641 |
To avoid frustration in case of badly set handlers, these messages |
|
642 |
are also implemented in the Object class - thus anything can be defined |
|
643 |
as interrupt handler. However, the VM will not send any |
|
644 |
interrupt message, if the corresonding handler object is nil |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
645 |
(which means that nil is a bad choice, if you are interested in the event). |
615 | 646 |
|
10226 | 647 |
Interrupt processing is not done immediately after the event arrives: |
1152 | 648 |
there are certain ``save-places'' at which this handling is performed |
615 | 649 |
(message send, method return and loop-heads). |
650 |
If not explicitely enabled, primitive code is never interrupted. |
|
1152 | 651 |
However, if you do enable interrupts in your primitive (see ExternalStream as example), |
652 |
be prepared for your objects to move around ... therefore, these have to |
|
653 |
be coded very carefully. |
|
654 |
||
10226 | 655 |
Interrupts may be disabled completely (OperatingSystem blockInterrupts) and |
1152 | 656 |
reenabled (unblockInterrupts) to allow for critical data to be manipulated. |
657 |
The above are low-level primitive entries - you better use #valueUninterruptably, |
|
658 |
which cares for unwinds, long returns and restores the blocking state. |
|
659 |
||
615 | 660 |
Every process has its own interrupt-enable state which is switched |
661 |
when processes switch control (i.e. you cannot block interrupts across |
|
10226 | 662 |
a suspend, delay etc.). |
1152 | 663 |
However, the state will be restored after a resume. |
615 | 664 |
" |
2 | 665 |
! ! |
666 |
||
1767 | 667 |
!ObjectMemory class methodsFor:'initialization'! |
2 | 668 |
|
669 |
initialize |
|
178 | 670 |
"initialize the class" |
671 |
||
2 | 672 |
AllocationFailureSignal isNil ifTrue:[ |
10226 | 673 |
AllocationFailureSignal := AllocationFailure. |
674 |
AllocationFailureSignal notifierString:'allocation failure'. |
|
675 |
||
676 |
MallocFailureSignal := MallocFailure. |
|
677 |
MallocFailureSignal notifierString:'(malloc) allocation failure'. |
|
678 |
||
679 |
LowSpaceSemaphore := Semaphore new name:'LowSpaceSemaphore' |
|
2 | 680 |
]. |
290 | 681 |
DisposeInterruptHandler := self. |
3733 | 682 |
|
683 |
"/ BackgroundCollectMaximumInterval := 3600. "/ run it at least once an hour |
|
684 |
BackgroundCollectMaximumInterval := nil. "/ only run when space situation makes it feasable |
|
685 |
IncrementalGCLimit := 500000. "/ run it whenever 500k have been allocated |
|
686 |
FreeSpaceGCLimit := FreeSpaceGCAmount := nil. "/ no minumum-freeSpace trigger. |
|
1729
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
687 |
MemoryInterruptHandler := self. |
1926 | 688 |
ExceptionInterruptHandler := self. |
1729
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
689 |
|
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
690 |
VMSelectors := #( #noByteCode #invalidCodeObject #invalidByteCode #invalidInstruction |
10226 | 691 |
#tooManyArguments #badLiteralTable #receiverNotBoolean: #typeCheckError |
692 |
#integerCheckError #wrongNumberOfArguments: #privateMethodCalled |
|
693 |
#doesNotUnderstand: #invalidReturn: #invalidReturnOrRestart: |
|
694 |
#userInterrupt #internalError: #spyInterrupt #timerInterrupt #stepInterrupt |
|
695 |
#errorInterrupt:with: #disposeInterrupt #recursionInterrupt |
|
696 |
#memoryInterrupt #fpExceptionInterrupt #signalInterrupt: #childSignalInterrupt |
|
697 |
#ioInterrupt #customInterrupt #schedulerInterrupt #contextInterrupt |
|
698 |
#interruptLatency:receiver:class:selector:vmActivity:id:). |
|
1926 | 699 |
|
3733 | 700 |
"Modified: / 5.8.1998 / 15:30:12 / cg" |
2 | 701 |
! ! |
702 |
||
7295 | 703 |
!ObjectMemory class methodsFor:'Compatibility-ST80'! |
615 | 704 |
|
705 |
availableFreeBytes |
|
2320 | 706 |
"return the amount of free memory |
707 |
(both in the compact free area and in the free lists)" |
|
708 |
||
615 | 709 |
^ self freeSpace + self freeListSpace |
710 |
||
711 |
" |
|
10226 | 712 |
ObjectMemory availableFreeBytes |
615 | 713 |
" |
2320 | 714 |
|
715 |
"Modified: 29.1.1997 / 23:43:05 / cg" |
|
615 | 716 |
! |
717 |
||
718 |
bytesPerOOP |
|
719 |
"return the number of bytes an object reference (for example: an instvar) |
|
720 |
takes" |
|
721 |
||
722 |
%{ /* NOCONTEXT */ |
|
8913 | 723 |
RETURN(__mkSmallInteger(sizeof(OBJ))); |
615 | 724 |
%} |
725 |
||
726 |
" |
|
10226 | 727 |
ObjectMemory bytesPerOOP |
615 | 728 |
" |
729 |
! |
|
730 |
||
731 |
bytesPerOTE |
|
732 |
"return the number of overhead bytes of an object. |
|
733 |
i.e. the number of bytes in every objects header." |
|
734 |
||
735 |
%{ /* NOCONTEXT */ |
|
8913 | 736 |
RETURN(__mkSmallInteger(OHDR_SIZE)); |
615 | 737 |
%} |
738 |
||
739 |
" |
|
10226 | 740 |
ObjectMemory bytesPerOTE |
615 | 741 |
" |
742 |
! |
|
743 |
||
9451 | 744 |
collectGarbage |
745 |
self garbageCollect |
|
746 |
||
747 |
" |
|
748 |
ObjectMemory garbageCollect |
|
749 |
" |
|
750 |
||
751 |
"Created: / 19-07-2006 / 09:11:37 / cg" |
|
752 |
! |
|
753 |
||
615 | 754 |
compactingGC |
2320 | 755 |
"perform a compacting garbage collect" |
756 |
||
615 | 757 |
self garbageCollect |
2320 | 758 |
|
759 |
"Modified: 29.1.1997 / 23:43:25 / cg" |
|
615 | 760 |
! |
761 |
||
762 |
current |
|
2320 | 763 |
"the 'current' ObjectMemory - thats myself" |
764 |
||
615 | 765 |
^ self |
2320 | 766 |
|
767 |
"Modified: 29.1.1997 / 23:43:39 / cg" |
|
615 | 768 |
! |
769 |
||
770 |
globalCompactingGC |
|
2320 | 771 |
"perform a compacting garbage collect" |
772 |
||
3605
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
773 |
self reclaimSymbols. |
615 | 774 |
self garbageCollect |
2320 | 775 |
|
3605
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
776 |
"Modified: / 18.6.1998 / 15:00:52 / cg" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
777 |
! |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
778 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
779 |
globalGarbageCollect |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
780 |
"perform a compacting garbage collect" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
781 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
782 |
self reclaimSymbols. |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
783 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
784 |
"Created: / 18.6.1998 / 15:00:05 / cg" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
785 |
"Modified: / 18.6.1998 / 15:00:47 / cg" |
615 | 786 |
! |
787 |
||
788 |
growMemoryBy:numberOfBytes |
|
2320 | 789 |
"allocate more memory" |
790 |
||
615 | 791 |
^ self moreOldSpace:numberOfBytes |
2320 | 792 |
|
793 |
"Modified: 29.1.1997 / 23:44:01 / cg" |
|
615 | 794 |
! |
795 |
||
796 |
numOopsNumBytes |
|
2320 | 797 |
"return an array filled with the number of objects |
798 |
and the number of used bytes." |
|
799 |
||
615 | 800 |
^ Array with:(self numberOfObjects) |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
801 |
with:(self bytesUsed) |
615 | 802 |
|
803 |
" |
|
10226 | 804 |
ObjectMemory numOopsNumBytes |
615 | 805 |
" |
2320 | 806 |
|
807 |
"Modified: 29.1.1997 / 23:44:24 / cg" |
|
3057
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
808 |
! |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
809 |
|
8304 | 810 |
verboseCompactingGC |
811 |
"ST80 compatibility; same as verboseGarbageCollect" |
|
812 |
||
813 |
self verboseGarbageCollect |
|
814 |
! |
|
815 |
||
816 |
verboseGlobalCompactingGC |
|
817 |
"ST80 compatibility; same as verboseGarbageCollect" |
|
818 |
||
819 |
self verboseGarbageCollect |
|
820 |
! |
|
821 |
||
3057
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
822 |
versionId |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
823 |
"return this systems version. |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
824 |
For ST80 compatibility." |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
825 |
|
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
826 |
^ Smalltalk versionString |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
827 |
|
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
828 |
"Created: / 27.10.1997 / 13:51:59 / cg" |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
829 |
"Modified: / 28.10.1997 / 20:06:14 / cg" |
615 | 830 |
! ! |
831 |
||
1767 | 832 |
!ObjectMemory class methodsFor:'Signal constants'! |
2 | 833 |
|
834 |
allocationFailureSignal |
|
13 | 835 |
"return the signal raised when an object allocation failed" |
836 |
||
2 | 837 |
^ AllocationFailureSignal |
464
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
838 |
! |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
839 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
840 |
mallocFailureSignal |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
841 |
"return the signal raised when malloc memory allocation failed. |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
842 |
(usually, this kind of memory is used with I/O buffers or other temporary |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
843 |
non-Object storage)" |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
844 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
845 |
^ MallocFailureSignal |
2 | 846 |
! ! |
1 | 847 |
|
1767 | 848 |
!ObjectMemory class methodsFor:'VM messages'! |
375 | 849 |
|
615 | 850 |
debugPrinting |
851 |
"return true, if various debug printouts in the VM |
|
375 | 852 |
are turned on, false of off." |
853 |
||
854 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
855 |
extern int __getDebugPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
856 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
857 |
RETURN (__getDebugPrinting() ? true : false); |
10226 | 858 |
%}. |
859 |
" |
|
860 |
ObjectMemory debugPrinting |
|
861 |
" |
|
375 | 862 |
! |
863 |
||
864 |
debugPrinting:aBoolean |
|
865 |
"turn on/off various debug printouts in the VM |
|
866 |
in case of an error. For example, a double-notUnderstood |
|
867 |
leads to a VM context dump if debugPrinting is on. |
|
868 |
If off, those messages are suppressed. |
|
10226 | 869 |
The default is on, since these messages are only printed for severe errors. |
870 |
Returns the previous setting." |
|
375 | 871 |
|
872 |
%{ /* NOCONTEXT */ |
|
10226 | 873 |
extern int __setDebugPrinting(); |
874 |
||
875 |
RETURN ( __setDebugPrinting( (aBoolean == true) ) ? true : false); |
|
375 | 876 |
%} |
877 |
! |
|
878 |
||
615 | 879 |
infoPrinting |
880 |
"return true, if various informational printouts in the VM |
|
375 | 881 |
are turned on, false of off." |
882 |
||
883 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
884 |
extern int __getInfoPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
885 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
886 |
RETURN (__getInfoPrinting() ? true : false); |
615 | 887 |
%} |
10226 | 888 |
" |
889 |
ObjectMemory infoPrinting |
|
890 |
" |
|
615 | 891 |
! |
892 |
||
893 |
infoPrinting:aBoolean |
|
894 |
"turn on/off various informational printouts in the VM. |
|
895 |
For example, the GC activity messages are controlled by |
|
896 |
this flags setting. |
|
10226 | 897 |
The default is true, since (currently) those messages are useful for ST/X developers. |
898 |
Returns the previous setting." |
|
615 | 899 |
|
900 |
%{ /* NOCONTEXT */ |
|
10226 | 901 |
extern int __setInfoPrinting(); |
902 |
||
903 |
RETURN ( __setInfoPrinting( (aBoolean == true) ) ? true : false); |
|
904 |
%} |
|
905 |
! |
|
906 |
||
907 |
initTrace:aBoolean |
|
908 |
"turn on/off various init-trace printouts in the VM. |
|
909 |
The default is false. |
|
910 |
Returns the previous setting." |
|
911 |
||
912 |
%{ /* NOCONTEXT */ |
|
913 |
extern int __setInitTrace(); |
|
914 |
||
915 |
RETURN ( __setInitTrace( (aBoolean == true) ) ? true : false); |
|
615 | 916 |
%} |
917 |
! ! |
|
918 |
||
1767 | 919 |
!ObjectMemory class methodsFor:'access debugging'! |
703 | 920 |
|
921 |
setTrapOnAccessFor:anObject |
|
922 |
"install an access trap for anObject; |
|
923 |
An accessSignal will be raised, whenever any instvar of anObject is either read or written. |
|
924 |
This is not supported on all architectures, therefore the return value |
|
925 |
(true of trap was installed ok, false if failed) should be checked." |
|
926 |
||
927 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
928 |
RETURN (__addTrapOnAccess(anObject, 2) ? true : false); |
703 | 929 |
%} |
930 |
! |
|
931 |
||
932 |
setTrapOnReadFor:anObject |
|
933 |
"install a read trap for anObject; |
|
934 |
An accessSignal will be raised, whenever any access into anObject occurrs. |
|
935 |
This is not supported on all architectures, therefore the return value |
|
936 |
(true of trap was installed ok, false if failed) should be checked." |
|
937 |
||
938 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
939 |
RETURN (__addTrapOnAccess(anObject, 0) ? true : false); |
703 | 940 |
%} |
941 |
! |
|
942 |
||
943 |
setTrapOnWriteFor:anObject |
|
944 |
"install a write trap for anObject; |
|
945 |
An accessSignal will be raised, whenever any instvar of anObject is written to. |
|
946 |
This is not supported on all architectures, therefore the return value |
|
947 |
(true of trap was installed ok, false if failed) should be checked." |
|
948 |
||
949 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
950 |
RETURN (__addTrapOnAccess(anObject, 1) ? true : false); |
703 | 951 |
%} |
952 |
! |
|
953 |
||
954 |
unsetAllTraps |
|
955 |
"remove all access traps" |
|
956 |
||
957 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
958 |
__removeAllAccessTraps(); |
10226 | 959 |
%} |
703 | 960 |
! |
961 |
||
962 |
unsetTrapFor:anObject |
|
963 |
"remove any access trap for anObject." |
|
964 |
||
965 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
966 |
__removeTrapOnAccess(anObject); |
703 | 967 |
%} |
968 |
! ! |
|
969 |
||
1767 | 970 |
!ObjectMemory class methodsFor:'cache management'! |
615 | 971 |
|
972 |
flushCaches |
|
973 |
"flush method and inline caches for all classes" |
|
974 |
||
975 |
%{ /* NOCONTEXT */ |
|
976 |
__flushMethodCache(); |
|
977 |
__flushAllInlineCaches(); |
|
978 |
%} |
|
979 |
! |
|
980 |
||
981 |
flushCachesFor:aClass |
|
982 |
"flush method and inline caches for aClass" |
|
983 |
||
984 |
%{ /* NOCONTEXT */ |
|
985 |
__flushMethodCacheFor(aClass); |
|
986 |
__flushInlineCachesFor(aClass); |
|
987 |
%} |
|
988 |
! |
|
989 |
||
990 |
flushCachesForSelector:aSelector |
|
991 |
"flush method and inline caches for aSelector" |
|
992 |
||
8527 | 993 |
self flushMethodCacheForSelector:aSelector. |
994 |
||
995 |
"/ self flushInlineCachesForSelector:aSelector. |
|
996 |
self flushInlineCachesWithArgs:(aSelector numArgs). |
|
615 | 997 |
! |
998 |
||
999 |
flushInlineCaches |
|
1000 |
"flush all inlinecaches" |
|
1001 |
||
1002 |
%{ /* NOCONTEXT */ |
|
1003 |
__flushAllInlineCaches(); |
|
1004 |
%} |
|
1005 |
! |
|
1006 |
||
1007 |
flushInlineCachesFor:aClass withArgs:nargs |
|
1008 |
"flush inlinecaches for calls to aClass with nargs arguments" |
|
1009 |
||
1010 |
%{ /* NOCONTEXT */ |
|
1133 | 1011 |
__flushInlineCachesForAndNargs(aClass, __intVal(nargs)); |
615 | 1012 |
%} |
8528 | 1013 |
! |
615 | 1014 |
|
1015 |
flushInlineCachesForClass:aClass |
|
1016 |
"flush inlinecaches for calls to aClass." |
|
1017 |
||
1018 |
%{ /* NOCONTEXT */ |
|
1019 |
__flushInlineCachesFor(aClass); |
|
1020 |
%} |
|
8528 | 1021 |
! |
615 | 1022 |
|
1023 |
flushInlineCachesForSelector:aSelector |
|
1024 |
"flush inlinecaches for sends of aSelector" |
|
1025 |
||
1026 |
%{ /* NOCONTEXT */ |
|
1027 |
__flushInlineCachesForSelector(aSelector); |
|
1028 |
%} |
|
1029 |
! |
|
1030 |
||
1031 |
flushInlineCachesWithArgs:nargs |
|
1032 |
"flush inlinecaches for calls with nargs arguments" |
|
1033 |
||
1034 |
%{ /* NOCONTEXT */ |
|
1133 | 1035 |
__flushInlineCaches(__intVal(nargs)); |
615 | 1036 |
%} |
1037 |
! |
|
1038 |
||
1039 |
flushMethodCache |
|
1040 |
"flush the method cache" |
|
1041 |
||
1042 |
%{ /* NOCONTEXT */ |
|
1043 |
__flushMethodCache(); |
|
1044 |
%} |
|
1045 |
! |
|
1046 |
||
1047 |
flushMethodCacheFor:aClass |
|
1048 |
"flush the method cache for sends to aClass" |
|
1049 |
||
1050 |
%{ /* NOCONTEXT */ |
|
1051 |
__flushMethodCacheFor(aClass); |
|
1052 |
%} |
|
1053 |
! |
|
1054 |
||
1055 |
flushMethodCacheForSelector:aSelector |
|
1056 |
"flush the method cache for sends of aSelector" |
|
1057 |
||
1058 |
%{ /* NOCONTEXT */ |
|
1059 |
__flushMethodCacheForSelector(aSelector); |
|
1060 |
%} |
|
1061 |
! |
|
1062 |
||
1108 | 1063 |
incrementSnapshotID |
2526 | 1064 |
"obsolete - do not use" |
1065 |
||
1108 | 1066 |
%{ /* NOCONTEXT */ |
1067 |
__bumpSnapshotID(); |
|
1068 |
%} |
|
1069 |
! |
|
1070 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1071 |
snapshotID |
918 | 1072 |
"return the internal snapshotID number. |
1073 |
This is incremented when an image is restarted, and |
|
1074 |
stored with the image. |
|
1075 |
Not for normal users, this is used by the VM to invalidate |
|
1076 |
caches which are stored with the image" |
|
1077 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1078 |
%{ /* NOCONTEXT */ |
8913 | 1079 |
RETURN ( __mkSmallInteger( __snapshotID() )); |
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1080 |
%} |
918 | 1081 |
" |
10226 | 1082 |
ObjectMemory snapshotID |
918 | 1083 |
" |
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1084 |
! |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1085 |
|
615 | 1086 |
trapRestrictedMethods:trap |
1087 |
"Allow/Deny execution of restricted Methods (see Method>>>restricted:) |
|
1088 |
||
1089 |
Notice: method restriction is a nonstandard feature, not supported |
|
1090 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1091 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1092 |
It may change or even vanish (if it shows to be not useful)." |
|
1093 |
||
1094 |
|oldTrap| |
|
1095 |
||
10226 | 1096 |
%{ |
615 | 1097 |
if (__setTrapRestrictedMethods(trap == true)) |
1098 |
oldTrap = true; |
|
1099 |
else |
|
1100 |
oldTrap = false; |
|
1101 |
%}. |
|
1102 |
||
1103 |
(trap and:[oldTrap not]) ifTrue:[ |
|
1104 |
self flushCaches |
|
1105 |
]. |
|
1106 |
^ oldTrap |
|
1107 |
||
1108 |
" |
|
1109 |
ObjectMemory trapRestrictedMethods:true |
|
1110 |
ObjectMemory trapRestrictedMethods:false |
|
1111 |
" |
|
1112 |
! ! |
|
1113 |
||
1767 | 1114 |
!ObjectMemory class methodsFor:'debug queries'! |
615 | 1115 |
|
1116 |
addressOf:anObject |
|
1117 |
"return the core address of anObject as an integer |
|
1118 |
- since objects may move around, the returned value is invalid after the |
|
1119 |
next scavenge/collect. |
|
10226 | 1120 |
WARNING: this method is for ST/X debugging only |
1121 |
it will be removed without notice" |
|
615 | 1122 |
|
1123 |
%{ /* NOCONTEXT */ |
|
1124 |
||
5783 | 1125 |
if (anObject != nil) { |
10226 | 1126 |
if (! __isNonNilObject(anObject)) { |
1127 |
RETURN ( nil ); |
|
1128 |
} |
|
615 | 1129 |
} |
2783 | 1130 |
if ((unsigned INT)anObject <= _MAX_INT) { |
10226 | 1131 |
RETURN ( __mkSmallInteger((INT)anObject) ); |
615 | 1132 |
} |
2769 | 1133 |
RETURN ( __MKUINT((INT)anObject) ); |
615 | 1134 |
%} |
1135 |
" |
|
1136 |
|p| |
|
1137 |
p := Point new. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1138 |
((ObjectMemory addressOf:p) printStringRadix:16) printCR. |
615 | 1139 |
ObjectMemory scavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1140 |
((ObjectMemory addressOf:p) printStringRadix:16) printCR. |
615 | 1141 |
" |
1142 |
! |
|
1143 |
||
1144 |
ageOf:anObject |
|
1145 |
"return the number of scavenges, an object has survived |
|
10226 | 1146 |
in new space. |
615 | 1147 |
For old objects and living contexts, the returned number is invalid. |
10226 | 1148 |
WARNING: this method is for ST/X debugging only |
1149 |
it will be removed without notice" |
|
615 | 1150 |
|
1151 |
%{ /* NOCONTEXT */ |
|
1152 |
||
1153 |
if (! __isNonNilObject(anObject)) { |
|
10226 | 1154 |
RETURN ( 0 ); |
615 | 1155 |
} |
8913 | 1156 |
RETURN ( __mkSmallInteger( _GET_AGE(anObject) ) ); |
615 | 1157 |
%} |
1158 |
" |
|
1159 |
|p| |
|
1160 |
p := Point new. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1161 |
(ObjectMemory ageOf:p) printCR. |
615 | 1162 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1163 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1164 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1165 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1166 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1167 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1168 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1169 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1170 |
" |
1171 |
! |
|
1172 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1173 |
displayRefChainTo:anObject |
3266 | 1174 |
self displayRefChainToAny:(Array with:anObject). |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1175 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1176 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1177 |
self displayRefChainTo:Point new |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1178 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1179 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1180 |
Smalltalk at:#foo put:Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1181 |
self displayRefChainTo:(Smalltalk at:#foo) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1182 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1183 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1184 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1185 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1186 |
Smalltalk at:#foo put:(#x -> p). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1187 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1188 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1189 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1190 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1191 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1192 |
Smalltalk at:#foo put:(#x -> a). |
10226 | 1193 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1194 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1195 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1196 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1197 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1198 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
10226 | 1199 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1200 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1201 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1202 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1203 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1204 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
10226 | 1205 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1206 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1207 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1208 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1209 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1210 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1211 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1212 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1213 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1214 |
self displayRefChainTo:Transcript topView |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1215 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1216 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1217 |
"Created: / 2.2.1998 / 19:23:55 / cg" |
3266 | 1218 |
"Modified: / 3.2.1998 / 00:30:14 / cg" |
1219 |
! |
|
1220 |
||
1221 |
displayRefChainToAny:aCollection |
|
10855 | 1222 |
self displayRefChainToAny:aCollection limitNumberOfSearchedReferences:nil |
1223 |
! |
|
1224 |
||
1225 |
displayRefChainToAny:aCollection limitNumberOfSearchedReferences:limitOrNil |
|
3266 | 1226 |
|levels objects done showMore stop userStop chain |
10226 | 1227 |
top progress lbl h nDone nAll panel listV |
3266 | 1228 |
moreButton owners objectArray numObjects numObjectsDone |
4739 | 1229 |
found moreChainsOnThisLevel temporaryRemoved chains |
3643 | 1230 |
anyShown anyShownInAnyLevel list tLevels firstRound| |
3266 | 1231 |
|
1232 |
top := StandardSystemView new. |
|
1233 |
top extent:350@250. |
|
1234 |
top label:'Object reference finder'. |
|
1235 |
||
1236 |
lbl := Label label:'compressing garbage ...' in:top. |
|
1237 |
lbl adjust:#left. |
|
1238 |
lbl origin:(0.0@0.0) corner:(1.0@0.0). |
|
11030
d23ae30a947a
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
10921
diff
changeset
|
1239 |
h := lbl preferredHeight. |
3266 | 1240 |
lbl |
10855 | 1241 |
topInset:5; |
1242 |
bottomInset:(h+5) negated; |
|
1243 |
leftInset:5; |
|
1244 |
rightInset:5. |
|
3266 | 1245 |
|
1246 |
progress := ProgressIndicator in:top. |
|
1247 |
progress origin:(0.0@45) corner:(1.0@45). |
|
1248 |
progress level:-1. |
|
11030
d23ae30a947a
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
10921
diff
changeset
|
1249 |
h := progress preferredHeight. |
10226 | 1250 |
progress |
10855 | 1251 |
topInset:(h // 2) negated; |
1252 |
bottomInset:(h // 2) negated; |
|
1253 |
leftInset:5; |
|
1254 |
rightInset:5. |
|
3266 | 1255 |
progress beInvisible. |
1256 |
||
1257 |
listV := HVScrollableView for:SelectionInListView in:top. |
|
1258 |
listV origin:(0.0@55) corner:(1.0@1.0). |
|
10226 | 1259 |
listV |
10855 | 1260 |
topInset:(h // 2); |
1261 |
bottomInset:40; |
|
1262 |
leftInset:5; |
|
1263 |
rightInset:5. |
|
3266 | 1264 |
listV beInvisible. |
10226 | 1265 |
|
3266 | 1266 |
panel := HorizontalPanelView in:top. |
1267 |
panel origin:(0.0@1.0) corner:(1.0@1.0). |
|
1268 |
panel topInset:-40. |
|
1269 |
panel horizontalLayout:#left. |
|
1270 |
||
1271 |
panel add:(Button label:'stop' action:[stop := userStop := true]). |
|
1272 |
panel add:(moreButton := Button label:'more' action:[showMore := true]). |
|
1273 |
panel ignoreInvisibleComponents:false. |
|
1274 |
moreButton beInvisible. |
|
1275 |
||
1276 |
top openWithPriority:(Processor activePriority + 1). |
|
1277 |
top waitUntilVisible. |
|
1278 |
||
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1279 |
lbl label:'compressing garbage ...'. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1280 |
self compressingGarbageCollect. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1281 |
|
3266 | 1282 |
progress beVisible. |
1283 |
||
1284 |
levels := OrderedCollection new. |
|
1285 |
objects := WeakIdentitySet withAll:aCollection. |
|
1286 |
||
1287 |
done := (objects includesIdentical:Smalltalk). |
|
1288 |
stop := userStop := false. |
|
3643 | 1289 |
anyShown := anyShownInAnyLevel := false. |
3266 | 1290 |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1291 |
"/ consider this a kludge: |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1292 |
"/ the processes are not held in any global; they are (currently) |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1293 |
"/ only known to the VM. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1294 |
"/ In order to find a global ref, temporarily create one here. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1295 |
"/ These are released later. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1296 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1297 |
Smalltalk at:#'__VMProcesses__' put:(self processesKnownInVM). |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1298 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1299 |
firstRound := true. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1300 |
|
3266 | 1301 |
[done] whileFalse:[ |
10855 | 1302 |
anyShown := false. |
1303 |
||
1304 |
progress percentage:0. |
|
1305 |
firstRound ifTrue:[ |
|
1306 |
firstRound := false. |
|
1307 |
] ifFalse:[ |
|
1308 |
lbl label:'compressing garbage ...'. |
|
1309 |
self garbageCollect. |
|
1310 |
]. |
|
1311 |
||
1312 |
lbl label:('searching level ' |
|
1313 |
, levels size printString |
|
1314 |
, ' (' , objects size printString , ' refs) ...'). |
|
1315 |
nAll := objects size. |
|
1316 |
nDone := 0. |
|
1317 |
||
1318 |
objectArray := objects asArray. |
|
1319 |
||
1320 |
owners := "Weak"IdentitySet new. |
|
1321 |
||
1322 |
numObjectsDone := 0. |
|
1323 |
found := false. |
|
1324 |
||
1325 |
AbortSignal handle:[] |
|
1326 |
do:[ |
|
1327 |
[self allObjectsDo:[:o | |
|
1328 |
|inPrevLevel isOwner| |
|
1329 |
||
1330 |
stop ifTrue:[AbortSignal raise]. |
|
1331 |
stop ifFalse:[ |
|
1332 |
isOwner := false. |
|
1333 |
(o referencesAny:objectArray) ifTrue:[ |
|
1334 |
o isBehavior ifTrue:[ |
|
1335 |
o == Smalltalk ifTrue:[ |
|
1336 |
found := true. |
|
1337 |
] ifFalse:[ |
|
1338 |
"/ only add it if it has classInstVars |
|
1339 |
o instSize ~~ Class instSize ifTrue:[ |
|
1340 |
isOwner := true. |
|
1341 |
] |
|
1342 |
] |
|
1343 |
] ifFalse:[ |
|
1344 |
o class ~~ WeakArray ifTrue:[ |
|
1345 |
isOwner := true. |
|
1346 |
] |
|
1347 |
]. |
|
1348 |
]. |
|
1349 |
||
1350 |
isOwner ifTrue:[ |
|
1351 |
(objects includesIdentical:o) ifFalse:[ |
|
1352 |
inPrevLevel := false. |
|
1353 |
levels do:[:lColl | |
|
1354 |
lColl == o ifTrue:[ |
|
1355 |
inPrevLevel := true |
|
1356 |
] ifFalse:[ |
|
1357 |
(lColl includesIdentical:o) ifTrue:[inPrevLevel := true]. |
|
1358 |
] |
|
1359 |
]. |
|
1360 |
inPrevLevel ifFalse:[ |
|
1361 |
owners add:o. |
|
1362 |
(limitOrNil notNil and:[owners size >= limitOrNil]) ifTrue:[ |
|
1363 |
AbortSignal raise |
|
1364 |
]. |
|
1365 |
] |
|
1366 |
] |
|
1367 |
]. |
|
1368 |
||
1369 |
numObjectsDone := numObjectsDone + 1. |
|
1370 |
numObjects notNil ifTrue:[ |
|
1371 |
numObjectsDone \\ 1000 == 0 ifTrue:[ |
|
1372 |
progress percentage:(numObjectsDone / numObjects * 100). |
|
1373 |
Processor yield. |
|
1374 |
] |
|
1375 |
] |
|
1376 |
] |
|
1377 |
]] whileFalse. |
|
1378 |
]. |
|
1379 |
progress percentage:100. |
|
1380 |
||
1381 |
numObjects isNil ifTrue:[ |
|
1382 |
numObjects := numObjectsDone. |
|
1383 |
]. |
|
1384 |
||
1385 |
owners remove:aCollection ifAbsent:nil. |
|
1386 |
owners remove:thisContext ifAbsent:nil. |
|
1387 |
owners remove:objectArray ifAbsent:nil. |
|
1388 |
owners remove:objects keyArray ifAbsent:nil. |
|
1389 |
owners remove:owners keyArray ifAbsent:nil. |
|
3266 | 1390 |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1391 |
"/ 'done with level: ' print. levels size print. ' found ' print. owners size print. ' refs' printCR. |
3266 | 1392 |
|
10855 | 1393 |
owners isEmpty ifTrue:[ |
1394 |
found ifFalse:[ |
|
1395 |
stop := true. |
|
1396 |
] |
|
1397 |
]. |
|
1398 |
||
1399 |
stop ifFalse:[ |
|
1400 |
done := found or:[(owners includesIdentical:Smalltalk)]. |
|
1401 |
done ifTrue:[ |
|
1402 |
moreChainsOnThisLevel := true. |
|
1403 |
temporaryRemoved := IdentitySet new. |
|
1404 |
||
1405 |
levels size > 0 ifTrue:[ |
|
1406 |
"/ show what we found so far. |
|
1407 |
levels last add:Smalltalk. |
|
1408 |
levels reverse. |
|
1409 |
]. |
|
1410 |
||
1411 |
chains := OrderedCollection new. |
|
1412 |
||
1413 |
tLevels := levels collect:[:lColl | lColl copy]. |
|
1414 |
||
1415 |
lbl label:('building refchains ...'). |
|
1416 |
||
1417 |
nAll := aCollection size. |
|
1418 |
nDone := 0. |
|
1419 |
aCollection do:[:anObject | |theseChains| |
|
1420 |
stop ifFalse:[ |
|
1421 |
theseChains := self |
|
1422 |
refChainsFrom:Smalltalk |
|
1423 |
to:anObject |
|
1424 |
inRefSets:tLevels |
|
1425 |
startingAt:1. |
|
1426 |
||
1427 |
theseChains size > 0 ifTrue:[ |
|
1428 |
chains addAll:theseChains |
|
1429 |
]. |
|
1430 |
nDone := nDone + 1. |
|
1431 |
progress percentage:(nDone / nAll * 100). |
|
1432 |
] |
|
1433 |
]. |
|
1434 |
||
1435 |
tLevels := nil. |
|
1436 |
||
1437 |
levels size > 0 ifTrue:[ |
|
1438 |
levels reverse. |
|
1439 |
levels last remove:Smalltalk. |
|
1440 |
]. |
|
1441 |
||
1442 |
[stop not |
|
1443 |
and:[chains size > 0]] whileTrue:[ |
|
1444 |
chain := chains first. |
|
1445 |
chains removeFirst. |
|
1446 |
||
1447 |
lbl label:('found a reference chain.'). |
|
1448 |
progress beInvisible. |
|
1449 |
||
1450 |
chain addFirst:Smalltalk. |
|
1451 |
list := OrderedCollection withSize:chain size. |
|
1452 |
1 to:chain size-1 do:[:i | |
|
1453 |
list |
|
1454 |
at:i |
|
1455 |
put:(self refNameFor:(chain at:i+1) in:(chain at:i)) |
|
1456 |
]. |
|
1457 |
list at:list size put:(chain last classNameWithArticle). |
|
1458 |
||
1459 |
"/ hide the VMProcesses stuff from the user ... |
|
1460 |
(list at:1) string = 'Smalltalk:__VMProcesses__' ifTrue:[ |
|
1461 |
list at:1 put:'__VMProcesses__ (a hidden VM reference)'. |
|
1462 |
list removeIndex:2. |
|
1463 |
chain at:1 put:nil. |
|
1464 |
chain removeIndex:2. |
|
1465 |
]. |
|
1466 |
||
1467 |
listV list:list. |
|
1468 |
||
1469 |
listV beVisible. |
|
1470 |
listV doubleClickAction:[:idx | |o| |
|
1471 |
(o := chain at:idx) notNil ifTrue:[ |
|
1472 |
o inspect. |
|
1473 |
] |
|
1474 |
]. |
|
1475 |
moreButton beVisible. |
|
1476 |
anyShown := anyShownInAnyLevel := true. |
|
1477 |
showMore := false. |
|
1478 |
||
1479 |
"/ kludge - wait for some user action |
|
1480 |
||
1481 |
[showMore or:[stop or:[top realized not]]] whileFalse:[ |
|
1482 |
Delay waitForSeconds:0.1 |
|
1483 |
]. |
|
1484 |
||
1485 |
chain := nil. |
|
1486 |
||
1487 |
top realized ifFalse:[ |
|
1488 |
stop := true |
|
1489 |
] ifTrue:[ |
|
1490 |
listV doubleClickAction:nil. |
|
1491 |
showMore ifFalse:[ |
|
1492 |
stop := true. |
|
1493 |
]. |
|
1494 |
]. |
|
1495 |
done := false. |
|
1496 |
||
1497 |
stop ifFalse:[ |
|
1498 |
progress beVisible. |
|
1499 |
listV beInvisible. |
|
1500 |
moreButton beInvisible. |
|
1501 |
||
1502 |
chain := nil. |
|
1503 |
] |
|
1504 |
]. |
|
1505 |
levels size > 0 ifTrue:[ |
|
1506 |
levels last addAll:temporaryRemoved. |
|
1507 |
] |
|
1508 |
]. |
|
1509 |
]. |
|
1510 |
||
1511 |
owners remove:Smalltalk ifAbsent:nil. |
|
1512 |
owners remove:(owners keyArray) ifAbsent:nil. |
|
1513 |
owners remove:objectArray ifAbsent:nil. |
|
1514 |
levels do:[:lColl | |
|
1515 |
owners remove:lColl ifAbsent:nil |
|
1516 |
]. |
|
1517 |
||
1518 |
levels add:owners. |
|
1519 |
||
1520 |
objects := owners. |
|
1521 |
||
1522 |
objects size == 0 ifTrue:[ |
|
1523 |
stop := true |
|
1524 |
]. |
|
1525 |
||
1526 |
stop ifTrue:[ |
|
1527 |
Smalltalk at:#'__VMProcesses__' put:nil. |
|
1528 |
top destroy. |
|
1529 |
anyShown ifFalse:[ |
|
1530 |
userStop ifFalse:[ |
|
1531 |
self information:(anyShownInAnyLevel ifTrue:['no more references'] ifFalse:['no references']). |
|
1532 |
] |
|
1533 |
]. |
|
1534 |
^ self. |
|
1535 |
]. |
|
3266 | 1536 |
|
1537 |
]. |
|
1538 |
||
1539 |
anyShown ifTrue:[ |
|
10855 | 1540 |
userStop ifFalse:[ |
1541 |
self information:'no more references'. |
|
1542 |
] |
|
3266 | 1543 |
]. |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1544 |
Smalltalk at:#'__VMProcesses__' put:nil. |
3266 | 1545 |
^ self |
1546 |
||
1547 |
" |
|
1548 |
self displayRefChainTo:Point new |
|
1549 |
" |
|
1550 |
" |
|
1551 |
Smalltalk at:#foo put:Point new. |
|
1552 |
self displayRefChainTo:(Smalltalk at:#foo) |
|
1553 |
" |
|
1554 |
" |
|
1555 |
|p| |
|
1556 |
p := Point new. |
|
1557 |
Smalltalk at:#foo put:(#x -> p). |
|
1558 |
self displayRefChainTo:p |
|
1559 |
" |
|
1560 |
" |
|
1561 |
|a| |
|
1562 |
a := Array new:1. a at:1 put:a. |
|
1563 |
Smalltalk at:#foo put:(#x -> a). |
|
1564 |
Smalltalk at:#bar put:(Array with:(#y -> a)). |
|
10226 | 1565 |
self displayRefChainTo:a |
3266 | 1566 |
" |
1567 |
" |
|
1568 |
|a| |
|
1569 |
a := Array new:1. a at:1 put:a. |
|
1570 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
|
10226 | 1571 |
self displayRefChainTo:a |
3266 | 1572 |
" |
1573 |
" |
|
1574 |
|a| |
|
1575 |
a := Array new:1. a at:1 put:a. |
|
1576 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
|
10226 | 1577 |
self displayRefChainTo:a |
3266 | 1578 |
" |
1579 |
" |
|
1580 |
|p| |
|
1581 |
p := Point new. |
|
1582 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
|
1583 |
self displayRefChainTo:p |
|
1584 |
" |
|
1585 |
" |
|
1586 |
self displayRefChainTo:Transcript topView |
|
1587 |
" |
|
1588 |
||
1589 |
"Created: / 2.2.1998 / 23:58:04 / cg" |
|
3643 | 1590 |
"Modified: / 10.7.1998 / 17:22:06 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1591 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1592 |
|
615 | 1593 |
dumpObject:someObject |
1594 |
"low level dump an object. |
|
10226 | 1595 |
WARNING: this method is for ST/X debugging only |
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1596 |
it may be removed (or replaced by a noop) without notice" |
615 | 1597 |
|
1598 |
%{ |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1599 |
__dumpObject__(someObject); |
615 | 1600 |
%} |
1601 |
" |
|
1602 |
ObjectMemory dumpObject:true |
|
10226 | 1603 |
ObjectMemory dumpObject:(Array new:10) |
1604 |
ObjectMemory dumpObject:(10@20 corner:30@40) |
|
615 | 1605 |
" |
1606 |
! |
|
1607 |
||
7326 | 1608 |
dumpSender |
1609 |
"dump my senders context" |
|
1610 |
||
1611 |
%{ |
|
1612 |
__PATCHUPCONTEXT(__thisContext); |
|
1613 |
__dumpContext__(__ContextInstPtr(__thisContext)->c_sender); |
|
1614 |
%} |
|
1615 |
" |
|
1616 |
ObjectMemory dumpSender |
|
1617 |
" |
|
1618 |
! |
|
1619 |
||
615 | 1620 |
flagsOf:anObject |
1621 |
"For debugging only. |
|
10226 | 1622 |
WARNING: this method is for ST/X debugging only |
1623 |
it will be removed without notice" |
|
615 | 1624 |
|
1625 |
%{ /* NOCONTEXT */ |
|
1626 |
||
1627 |
if (! __isNonNilObject(anObject)) { |
|
10226 | 1628 |
RETURN ( nil ); |
615 | 1629 |
} |
8913 | 1630 |
RETURN ( __mkSmallInteger( anObject->o_flags ) ); |
615 | 1631 |
%} |
1632 |
" |
|
1633 |
F_ISREMEMBERED 1 /* a new-space thing being refd by some oldSpace thing */ |
|
1634 |
F_ISFORWARDED 2 /* a forwarded object (you will never see this here) */ |
|
1635 |
F_DEREFERENCED 4 /* a collection after grow (not currently used) */ |
|
1636 |
F_ISONLIFOLIST 8 /* a non-lifo-context-referencing-obj already on list */ |
|
1637 |
F_MARK 16 /* mark bit for background collector */ |
|
1638 |
" |
|
1639 |
||
1640 |
" |
|
1641 |
|arr| |
|
1642 |
||
1643 |
arr := Array new. |
|
1644 |
arr at:1 put:([thisContext] value). |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1645 |
(ObjectMemory flagsOf:anObject) printCR |
615 | 1646 |
" |
1647 |
! |
|
1648 |
||
1649 |
objectAt:anAddress |
|
1650 |
"return whatever anAddress points to as object. |
|
10226 | 1651 |
BIG BIG DANGER ALERT: |
1652 |
this method is only to be used for debugging ST/X itself |
|
615 | 1653 |
- you can easily (and badly) crash the system. |
10226 | 1654 |
WARNING: this method is for ST/X debugging only |
615 | 1655 |
it will be removed without notice" |
1656 |
||
1288 | 1657 |
%{ /* NOCONTEXT */ |
4104 | 1658 |
INT addr = __longIntVal(anAddress); |
1288 | 1659 |
|
1660 |
if (addr) { |
|
1661 |
RETURN ((OBJ)(addr)); |
|
615 | 1662 |
} |
1288 | 1663 |
RETURN (nil); |
615 | 1664 |
%} |
1665 |
! |
|
1666 |
||
1288 | 1667 |
printReferences:anObject |
1668 |
"for debugging: print referents to anObject. |
|
10226 | 1669 |
WARNING: this method is for ST/X debugging only |
1288 | 1670 |
it will be removed without notice |
1671 |
use ObjectMemory>>whoReferences: or anObject>>allOwners." |
|
615 | 1672 |
|
1673 |
%{ |
|
1674 |
__printRefChain(__context, anObject); |
|
1675 |
%} |
|
1676 |
! |
|
1677 |
||
1288 | 1678 |
refChainFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1679 |
|chain| |
1288 | 1680 |
|
1681 |
index > levels size ifTrue:[ |
|
10226 | 1682 |
(start referencesObject:anObject) ifTrue:[ |
1683 |
^ OrderedCollection with:anObject. "/ (self refNameFor:anObject in:start) |
|
1684 |
]. |
|
1685 |
^ nil. |
|
1288 | 1686 |
]. |
1687 |
||
1688 |
(levels at:index) do:[:el | |
|
3266 | 1689 |
el ~~ start ifTrue:[ |
10226 | 1690 |
(start referencesObject:el) ifTrue:[ |
1691 |
chain := self |
|
1692 |
refChainFrom:el |
|
1693 |
to:anObject |
|
1694 |
inRefSets:levels |
|
1695 |
startingAt:(index+1). |
|
1696 |
||
1697 |
chain notNil ifTrue:[ |
|
1698 |
(levels at:index) saveRemove:el. |
|
1699 |
chain addFirst:el. "/ (self refNameFor:el in:start). |
|
1700 |
^ chain. |
|
1701 |
] |
|
1702 |
]. |
|
3266 | 1703 |
]. |
1288 | 1704 |
]. |
1705 |
^ nil |
|
1706 |
||
1707 |
||
1708 |
" |
|
1709 |
|o a1 a2| |
|
1710 |
||
1711 |
o := Object new. |
|
1712 |
a1 := Array with:o with:nil with:nil. |
|
1713 |
a2 := Array with:a1 with:nil with:nil. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1714 |
a2 referencesObject:a1 |
1288 | 1715 |
" |
1716 |
||
1717 |
" |
|
1718 |
|o a1 a2 a3 a4 levels| |
|
1719 |
||
1720 |
o := Object new. |
|
1721 |
a1 := Array with:o. |
|
1722 |
a2 := Array with:a1. |
|
1723 |
a3 := Array with:a2. |
|
1724 |
a4 := Array with:a3. |
|
1725 |
levels := Array with:(Array with:a3) |
|
10226 | 1726 |
with:(Array with:a2) |
1727 |
with:(Array with:a1). |
|
1728 |
||
1729 |
self refChainFrom:a4 to:o inRefSets:levels startingAt:1. |
|
1108 | 1730 |
" |
1731 |
||
3266 | 1732 |
"Modified: / 3.2.1998 / 02:38:27 / cg" |
1108 | 1733 |
! |
1734 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1735 |
refChainsFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1736 |
|chains chain c| |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1737 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1738 |
chains := OrderedCollection new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1739 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1740 |
index > levels size ifTrue:[ |
10226 | 1741 |
(start referencesObject:anObject) ifTrue:[ |
1742 |
chains add:(OrderedCollection with:anObject "(self refNameFor:anObject in:start)"). |
|
1743 |
]. |
|
1744 |
^ chains |
|
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1745 |
]. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1746 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1747 |
(levels at:index) do:[:el | |
3266 | 1748 |
el ~~ start ifTrue:[ |
10226 | 1749 |
(start referencesObject:el) ifTrue:[ |
1750 |
chain := self |
|
1751 |
refChainFrom:el |
|
1752 |
to:anObject |
|
1753 |
inRefSets:levels |
|
1754 |
startingAt:(index+1). |
|
1755 |
||
1756 |
chain size > 0 ifTrue:[ |
|
1757 |
(levels at:index) saveRemove:el. |
|
1758 |
||
1759 |
c := chain copy. |
|
1760 |
c addFirst:el "(self refNameFor:el in:start)". |
|
1761 |
chains add:c. |
|
1762 |
] |
|
3266 | 1763 |
]. |
10226 | 1764 |
]. |
3266 | 1765 |
]. |
1766 |
^ chains |
|
1767 |
||
1768 |
"Created: / 2.2.1998 / 19:09:22 / cg" |
|
1769 |
"Modified: / 3.2.1998 / 02:38:17 / cg" |
|
1770 |
! |
|
1771 |
||
1772 |
refNameFor:anObject in:referent |
|
1773 |
|names oClass| |
|
1774 |
||
1775 |
referent == Smalltalk ifTrue:[ |
|
10833 | 1776 |
referent keysAndValuesDo:[:key :val | |
1777 |
|idx| |
|
1778 |
||
1779 |
(anObject == val) ifTrue:[ |
|
1780 |
"/ for our convenience - if its a nameSpace, cut off Smalltalk. |
|
1781 |
idx := key string indexOf:$:. |
|
1782 |
(idx ~~ 0 |
|
1783 |
and:[idx < key string size |
|
1784 |
and:[(key string at:(idx+1)) == $:]]) ifTrue:[ |
|
1785 |
^ key allBold "/ (key copyFrom:(idx+2)) allBold |
|
1786 |
]. |
|
1787 |
^ 'Smalltalk:' , (key allBold). |
|
1788 |
] |
|
1789 |
]. |
|
3266 | 1790 |
] ifFalse:[ |
10833 | 1791 |
names := referent class allInstVarNames. |
1792 |
oClass := referent class. |
|
1793 |
1 to:oClass instSize do:[:i | |
|
1794 |
((referent instVarAt:i) == anObject) ifTrue:[ |
|
12650 | 1795 |
^ '%1 [%2]' bindWith:referent classNameWithArticle with:(names at:i) allBold. |
10833 | 1796 |
]. |
1797 |
]. |
|
1798 |
oClass isVariable ifTrue:[ |
|
1799 |
oClass isPointers ifTrue:[ |
|
1800 |
1 to:referent basicSize do:[:i | |
|
1801 |
((referent basicAt:i) == anObject) ifTrue:[ |
|
12650 | 1802 |
^ '%1 [%2] (sz=%2)' bindWith:referent classNameWithArticle with:i printString allBold with:referent basicSize printString |
10833 | 1803 |
] |
1804 |
] |
|
1805 |
] |
|
1806 |
]. |
|
3266 | 1807 |
]. |
10833 | 1808 |
self error:'no reference' mayProceed:true. |
6568 | 1809 |
^ nil. |
3266 | 1810 |
|
1811 |
"Created: / 2.2.1998 / 23:46:12 / cg" |
|
3275
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1812 |
"Modified: / 4.2.1998 / 22:03:36 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1813 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1814 |
|
1288 | 1815 |
sizeOf:anObject |
1816 |
"return the size of anObject in bytes. |
|
1817 |
(this is not the same as 'anObject size'). |
|
10226 | 1818 |
WARNING: this method is for ST/X debugging only |
1819 |
it will be removed without notice" |
|
1288 | 1820 |
|
1821 |
%{ /* NOCONTEXT */ |
|
1822 |
||
8913 | 1823 |
RETURN ( __isNonNilObject(anObject) ? __mkSmallInteger(__qSize(anObject)) : __mkSmallInteger(0) ) |
1288 | 1824 |
%} |
1825 |
" |
|
1826 |
|hist big nw| |
|
1827 |
||
1828 |
hist := Array new:100 withAll:0. |
|
1829 |
big := 0. |
|
1830 |
ObjectMemory allObjectsDo:[:o | |
|
10226 | 1831 |
nw := (ObjectMemory sizeOf:o) // 4 + 1. |
1832 |
nw > 100 ifTrue:[ |
|
1833 |
big := big + 1 |
|
1834 |
] ifFalse:[ |
|
1835 |
hist at:nw put:(hist at:nw) + 1 |
|
1836 |
]. |
|
615 | 1837 |
]. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1838 |
hist printCR. |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1839 |
big printCR |
615 | 1840 |
" |
1288 | 1841 |
! |
1842 |
||
1843 |
spaceOf:anObject |
|
1844 |
"return the memory space, in which anObject is. |
|
10226 | 1845 |
- since objects may move between spaces, |
1288 | 1846 |
the returned value may be invalid after the next scavenge/collect. |
10226 | 1847 |
WARNING: this method is for ST/X debugging only |
1288 | 1848 |
it will be removed without notice" |
1849 |
||
1850 |
%{ /* NOCONTEXT */ |
|
1851 |
||
1852 |
if (! __isNonNilObject(anObject)) { |
|
1853 |
RETURN ( nil ); |
|
1854 |
} |
|
8913 | 1855 |
RETURN ( __mkSmallInteger( __qSpace(anObject) ) ); |
1288 | 1856 |
%} |
375 | 1857 |
! ! |
1858 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1859 |
!ObjectMemory class methodsFor:'debugging ST/X'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1860 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1861 |
printPolyCaches |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1862 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1863 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1864 |
"dump poly caches. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1865 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1866 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1867 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1868 |
__dumpILCCaches(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1869 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1870 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1871 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1872 |
ObjectMemory printPolyCaches |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1873 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1874 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1875 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1876 |
printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1877 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1878 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1879 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1880 |
(You may turn off the stack print with debugPrinting:false) |
10226 | 1881 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1882 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1883 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1884 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1885 |
__printStack(__context); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1886 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1887 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1888 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1889 |
ObjectMemory printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1890 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1891 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1892 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1893 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1894 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1895 |
printStackBacktraceFrom:aContext |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1896 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1897 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1898 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1899 |
(You may turn off the stack print with debugPrinting:false) |
10226 | 1900 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1901 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1902 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1903 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1904 |
__printStack(aContext); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1905 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1906 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1907 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1908 |
ObjectMemory printStackBacktraceFrom:thisContext sender sender |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1909 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1910 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1911 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1912 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1913 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1914 |
printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1915 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1916 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1917 |
"dump the internal symbol table. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1918 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1919 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1920 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1921 |
#ifdef DEBUG |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1922 |
__dumpSymbols(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1923 |
#endif |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1924 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1925 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1926 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1927 |
ObjectMemory printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1928 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1929 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1930 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1931 |
sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1932 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1933 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1934 |
"turns tracing of message sends off. |
10226 | 1935 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1936 |
it may be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1937 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1938 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1939 |
__setMessageTrace__(0); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1940 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1941 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1942 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1943 |
ObjectMemory sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1944 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1945 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1946 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1947 |
sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1948 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1949 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1950 |
"turns tracing of message sends on. |
10226 | 1951 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1952 |
it may be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1953 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1954 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1955 |
__setMessageTrace__(1); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1956 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1957 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1958 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1959 |
ObjectMemory sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1960 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1961 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1962 |
|
1767 | 1963 |
!ObjectMemory class methodsFor:'dependents access'! |
10 | 1964 |
|
1288 | 1965 |
dependents |
3223 | 1966 |
"return the collection of my dependents" |
1288 | 1967 |
|
3057
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
1968 |
^ Dependents ? #() |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
1969 |
|
3223 | 1970 |
"Modified: / 26.1.1998 / 11:17:59 / cg" |
10 | 1971 |
! |
1972 |
||
1288 | 1973 |
dependents:aCollection |
10 | 1974 |
"set the dependents collection" |
1975 |
||
1976 |
Dependents := aCollection |
|
1288 | 1977 |
! |
1978 |
||
1979 |
dependentsDo:aBlock |
|
1980 |
"evaluate aBlock for all of my dependents. |
|
1981 |
Since this is performed at startup time (under the scheduler), |
|
1982 |
this is redefined here to catch abort signals. |
|
1983 |
Thus, if any error occurs in a #returnFromSnapshot, |
|
1984 |
the user can press abort to continue." |
|
1985 |
||
1986 |
|deps| |
|
1987 |
||
1988 |
deps := Dependents. |
|
1989 |
deps notNil ifTrue:[ |
|
10226 | 1990 |
deps do:[:each | |
1991 |
AbortOperationRequest handle:[:ex | |
|
1992 |
ex return |
|
1993 |
] do:[ |
|
1994 |
aBlock value:each |
|
1995 |
] |
|
1996 |
] |
|
282 | 1997 |
] |
1288 | 1998 |
! ! |
1999 |
||
1767 | 2000 |
!ObjectMemory class methodsFor:'enumerating'! |
1288 | 2001 |
|
2002 |
allInstancesOf:aClass do:aBlock |
|
2003 |
"evaluate the argument, aBlock for all instances of aClass in the system. |
|
2004 |
There is one caveat: if a compressing oldSpace collect |
|
2005 |
occurs while looping over the objects, the loop cannot be |
|
2006 |
continued (for some internal reasons). In this case, false |
|
2007 |
is returned." |
|
2008 |
||
2009 |
|work| |
|
2010 |
||
2011 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
2012 |
__nonTenuringScavenge(__context); |
|
2013 |
/* |
|
2014 |
* allInstancesDo needs a temporary to hold newSpace objects |
|
2015 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2016 |
if (__allInstancesOfDo(&aClass, &aBlock, &work) < 0) { |
159 | 2017 |
RETURN (false); |
85 | 2018 |
} |
2019 |
%}. |
|
2020 |
^ true |
|
2 | 2021 |
! |
2022 |
||
1288 | 2023 |
allObjectsDo:aBlock |
2024 |
"evaluate the argument, aBlock for all objects in the system. |
|
2025 |
There is one caveat: if a compressing oldSpace collect |
|
2026 |
occurs while looping over the objects, the loop cannot be |
|
2027 |
continued (for some internal reasons). In this case, false |
|
2028 |
is returned." |
|
2029 |
||
2030 |
|work| |
|
2031 |
||
2032 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
2033 |
__nonTenuringScavenge(__context); |
|
2034 |
/* |
|
2035 |
* allObjectsDo needs a temporary to hold newSpace objects |
|
2036 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2037 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, &work) < 0) { |
615 | 2038 |
RETURN (false); |
2039 |
} |
|
2040 |
%}. |
|
2041 |
^ true |
|
1288 | 2042 |
! |
2043 |
||
3266 | 2044 |
allObjectsIncludingContextsDo:aBlock |
2045 |
"like allObjectsDo, but also walks over all contexts |
|
2046 |
of living processes" |
|
2047 |
||
2048 |
self allObjectsDo:aBlock. |
|
2049 |
ProcessorScheduler knownProcesses do:[:p | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2050 |
|con| |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2051 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2052 |
con := p suspendedContext. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2053 |
[con notNil] whileTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2054 |
aBlock value:con. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2055 |
con := con sender. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2056 |
]. |
3266 | 2057 |
]. |
2058 |
||
2059 |
"Created: / 3.2.1998 / 11:32:08 / cg" |
|
2060 |
! |
|
2061 |
||
1288 | 2062 |
allOldObjectsDo:aBlock |
2063 |
"evaluate the argument, aBlock for all old objects in the system. |
|
2064 |
For debugging and tests only - do not use" |
|
2065 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2066 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, (OBJ *)0) < 0) { |
1288 | 2067 |
RETURN (false); |
2068 |
} |
|
10226 | 2069 |
%}. |
1288 | 2070 |
^ true |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2071 |
! |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2072 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2073 |
processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2074 |
"debug query: return a collection of processObjects as known |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2075 |
in the VM. For ST/X internal use only." |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2076 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2077 |
%{ |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2078 |
extern OBJ __processesKnownInVM(); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2079 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2080 |
RETURN (__processesKnownInVM()); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2081 |
%} |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2082 |
" |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2083 |
ObjectMemory processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2084 |
" |
1 | 2085 |
! ! |
2086 |
||
1767 | 2087 |
!ObjectMemory class methodsFor:'garbage collection'! |
615 | 2088 |
|
3725
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2089 |
backgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2090 |
"return the backgroundCollectProcess (or nil, if noone is running)" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2091 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2092 |
^ BackgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2093 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2094 |
"Created: / 4.8.1998 / 01:54:16 / cg" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2095 |
! |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2096 |
|
1288 | 2097 |
backgroundCollectorRunning |
2098 |
"return true, if a backgroundCollector is running" |
|
2099 |
||
2100 |
^ BackgroundCollectProcess notNil |
|
500 | 2101 |
|
2102 |
" |
|
615 | 2103 |
ObjectMemory backgroundCollectorRunning |
375 | 2104 |
" |
2105 |
! |
|
2106 |
||
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2107 |
compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2108 |
"COMPRESS the oldSpace memory area. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2109 |
This uses an inplace 2-pass compress algorithm, which may |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2110 |
be slightly slower than the semispace compress if lots of real memory |
10226 | 2111 |
is available. |
2112 |
In memory limited systems, this inplace compress is usually preferable. |
|
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2113 |
Inplace compression can be enforced by setting the compress-limit to a |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2114 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2115 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2116 |
This can take a long time." |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2117 |
%{ |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2118 |
__compressOldSpace(__context); |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2119 |
%} |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2120 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2121 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2122 |
ObjectMemory compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2123 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2124 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2125 |
Transcript showCR:(Time millisecondsToRun:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2126 |
ObjectMemory markAndSweep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2127 |
ObjectMemory compressOldSpace. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2128 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2129 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2130 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2131 |
Transcript showCR:(Time millisecondsToRun:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2132 |
ObjectMemory compressingGarbageCollect. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2133 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2134 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2135 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2136 |
! |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2137 |
|
1288 | 2138 |
compressingGarbageCollect |
10226 | 2139 |
"search for and free garbage in the oldSpace (newSpace is cleaned automatically) |
1288 | 2140 |
performing a COMPRESSING garbage collect. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2141 |
This uses a 1-pass copying semispace algorithm, which may |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2142 |
be slightly faster than the 2-pass in-place compress if enough real memory |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2143 |
is available. In memory limited systems, an inplace compress is |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2144 |
preferable, which is enforced by setting the compress-limit to a |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2145 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2146 |
|
1288 | 2147 |
This can take a long time - especially, if paging is involved |
2148 |
(when no paging is involved, its faster than I thought :-). |
|
2149 |
If no memory is available for the compress, or the system has been started with |
|
2150 |
the -Msingle option, this does a non-COMPRESSING collect." |
|
2151 |
%{ |
|
2152 |
if (! __garbageCollect(__context)) { |
|
10226 | 2153 |
__markAndSweep(); |
2154 |
RETURN (false); |
|
178 | 2155 |
} |
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2156 |
RETURN (true); |
1 | 2157 |
%} |
2158 |
||
93 | 2159 |
" |
375 | 2160 |
ObjectMemory compressingGarbageCollect |
93 | 2161 |
" |
2162 |
! |
|
2163 |
||
1288 | 2164 |
garbageCollect |
2165 |
"search for and free garbage in the oldSpace. |
|
2166 |
This can take a long time - especially, if paging is involved." |
|
2167 |
||
10226 | 2168 |
"/ used to be |
2169 |
"/ self compressingGarbageCollect |
|
1288 | 2170 |
"/ here; changed to default to markAndSweep |
615 | 2171 |
|
2172 |
self markAndSweep |
|
1 | 2173 |
|
93 | 2174 |
" |
615 | 2175 |
ObjectMemory garbageCollect |
375 | 2176 |
" |
2177 |
! |
|
2178 |
||
1288 | 2179 |
gcStep |
2180 |
"one incremental garbage collect step. |
|
2181 |
Mark or sweep some small number of objects. This |
|
2182 |
method will return after a reasonable (short) time. |
|
2183 |
This is used by the ProcessorScheduler at idle times. |
|
2184 |
Returns true, if an incremental GC cycle has finished." |
|
2185 |
%{ |
|
2186 |
extern int __incrGCstep(); |
|
133 | 2187 |
|
5461 | 2188 |
RETURN (__incrGCstep() ? true : false); |
1 | 2189 |
%} |
2190 |
! |
|
2191 |
||
1288 | 2192 |
gcStepIfUseful |
2193 |
"If either the IncrementalGCLimit or the FreeSpaceGCLimits have been |
|
2194 |
reached, perform one incremental garbage collect step. |
|
2195 |
Return true, if more gcSteps are required to finish the cycle, |
|
2196 |
false if done with a gc round. |
|
2197 |
If no limit has been reached yet, do nothing and return false. |
|
10226 | 2198 |
This is called by the ProcessorScheduler at idle times or by the |
1288 | 2199 |
backgroundCollector." |
2200 |
||
2201 |
|done limit| |
|
2202 |
||
2203 |
AbortSignal handle:[:ex | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2204 |
"/ in case of abort (from the debugger), |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2205 |
"/ disable gcSteps. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2206 |
done := true. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2207 |
IncrementalGCLimit := FreeSpaceGCLimit := nil. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2208 |
'ObjectMemory [error]: IGC aborted; turning off incremental GC' errorPrintCR |
1288 | 2209 |
] do:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2210 |
limit := IncrementalGCLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2211 |
(limit notNil and:[self oldSpaceAllocatedSinceLastGC > limit]) ifTrue:[ |
3761 | 2212 |
"/ 'IGC [info]: start since allocatedSinceLastGC > IncrementalGCLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2213 |
done := ObjectMemory gcStep |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2214 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2215 |
limit := FreeSpaceGCLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2216 |
(limit notNil and:[(self freeSpace + self freeListSpace) < limit]) ifTrue:[ |
3761 | 2217 |
"/ 'IGC [info]: start since freeSpace < FreeSpaceGCLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2218 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2219 |
done ifTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2220 |
self moreOldSpaceIfUseful |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2221 |
]. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2222 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2223 |
limit := DynamicCodeGCTrigger. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2224 |
(limit notNil and:[self compiledCodeCounter > limit]) ifTrue:[ |
3761 | 2225 |
"/ 'IGC [info]: start since compiledCodeCounter > DynamicCodeGCTrigger' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2226 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2227 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2228 |
limit := DynamicCodeLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2229 |
(limit notNil and:[self compiledCodeSpaceUsed > limit]) ifTrue:[ |
3761 | 2230 |
"/ 'IGC [info]: start since compiledCodeSpaceUsed > DynamicCodeLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2231 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2232 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2233 |
done := true |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2234 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2235 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2236 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2237 |
]. |
615 | 2238 |
]. |
2239 |
^ done not |
|
1768 | 2240 |
|
3761 | 2241 |
"Modified: / 14.8.1998 / 13:08:15 / cg" |
615 | 2242 |
! |
2243 |
||
1288 | 2244 |
incrementalGC |
2245 |
"perform one round of incremental GC steps. |
|
10226 | 2246 |
The overall effect of this method is (almost) the same as calling |
1288 | 2247 |
markAndSweep. However, #incrementalGC is interruptable while #markAndSweep |
2248 |
is atomic and blocks for a while. The code here performs incremental |
|
2249 |
GC steps, until one complete gc-cycle is completed. If running at a higher |
|
2250 |
than userBackground priority, it will give up the CPU after every such |
|
2251 |
step for a while. |
|
10226 | 2252 |
Thus this method can be called either from a low prio (background) process |
1288 | 2253 |
or from a high prio process. |
2254 |
(however, if you have nothing else to do, its better to call for markAndSweep, |
|
2255 |
since it is faster) |
|
2256 |
For example, someone allocating huge amounts of memory could |
|
2257 |
ask for the possibility of a quick allocation using |
|
2258 |
#checkForFastNew: and try a #incrementalGC if not. In many |
|
10226 | 2259 |
cases, this can avoid a pause (in the higher prio processes) due to |
1288 | 2260 |
a blocking GC." |
2261 |
||
1669 | 2262 |
|delay| |
1288 | 2263 |
|
2264 |
Processor activeProcess priority > Processor userBackgroundPriority ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2265 |
delay := Delay forMilliseconds:1 |
1288 | 2266 |
]. |
2267 |
||
3742 | 2268 |
((self incrementalGCPhaseSymbolic ~~ #idle) |
2269 |
or:[self gcStepIfUseful]) ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2270 |
[self gcStep] whileFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2271 |
delay notNil ifTrue:[delay wait] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2272 |
] |
1288 | 2273 |
]. |
2274 |
self moreOldSpaceIfUseful |
|
2275 |
||
2276 |
" |
|
2277 |
ObjectMemory incrementalGC |
|
2278 |
[ObjectMemory incrementalGC] forkAt:3 |
|
10226 | 2279 |
[ObjectMemory incrementalGC] forkAt:9 |
133 | 2280 |
" |
3108 | 2281 |
|
3742 | 2282 |
"Modified: / 10.8.1998 / 15:03:07 / cg" |
194 | 2283 |
! |
2284 |
||
1288 | 2285 |
markAndSweep |
2286 |
"mark/sweep garbage collector. |
|
2287 |
perform a full mark&sweep collect. |
|
2288 |
Warning: this may take some time and it is NOT interruptable. |
|
2289 |
If you want to do a collect from a background process, or have |
|
2290 |
other things to do, better use #incrementalGC which is interruptable." |
|
615 | 2291 |
%{ |
5461 | 2292 |
__markAndSweep(); |
615 | 2293 |
%} |
194 | 2294 |
|
2295 |
" |
|
615 | 2296 |
ObjectMemory markAndSweep |
2297 |
" |
|
2298 |
! |
|
2299 |
||
8304 | 2300 |
nonVerboseGarbageCollect |
2301 |
"perform a compressing garbage collect or fallback to non-compressing collect, |
|
2302 |
if required." |
|
2303 |
||
2304 |
"/ try 1pass baker collect first. |
|
2305 |
"/ this will fail if oldSpace size is above compressLimit |
|
2306 |
(self compressingGarbageCollect) ifFalse:[ |
|
10226 | 2307 |
"/ fallBack - use 2pass inplace compress |
2308 |
self compressOldSpace |
|
8304 | 2309 |
]. |
2310 |
||
2311 |
" |
|
2312 |
ObjectMemory nonVerboseGarbageCollect |
|
2313 |
" |
|
2314 |
! |
|
2315 |
||
1288 | 2316 |
reclaimSymbols |
2317 |
"reclaim unused symbols; |
|
2318 |
Unused symbols are (currently) not reclaimed automatically, |
|
10226 | 2319 |
but only upon request with this method. |
1288 | 2320 |
It takes some time to do this ... and it is NOT interruptable. |
2321 |
Future versions may do this automatically, while garbage collecting." |
|
615 | 2322 |
%{ |
5461 | 2323 |
__reclaimSymbols(); |
615 | 2324 |
%} |
2325 |
" |
|
2326 |
ObjectMemory reclaimSymbols |
|
2327 |
" |
|
2328 |
! |
|
2329 |
||
8455 | 2330 |
resumeBackgroundCollector |
10743 | 2331 |
"resume the background collector process" |
8455 | 2332 |
|
2333 |
BackgroundCollectProcess notNil ifTrue:[ |
|
10743 | 2334 |
BackgroundCollectProcess resume. |
8455 | 2335 |
] |
2336 |
||
2337 |
" |
|
2338 |
ObjectMemory resumeBackgroundCollector |
|
2339 |
" |
|
2340 |
||
2341 |
"Created: / 03-08-2004 / 18:12:30 / stefan" |
|
10743 | 2342 |
"Modified: / 17-10-2007 / 13:14:46 / cg" |
8455 | 2343 |
! |
2344 |
||
1288 | 2345 |
scavenge |
2346 |
"collect young objects, without aging (i.e. no tenure). |
|
2347 |
Can be used to quickly get rid of shortly before allocated |
|
2348 |
stuff. This is relatively fast (compared to oldspace collect). |
|
2349 |
||
2350 |
An example where a non-tenuring scavenge makes sense is when |
|
10226 | 2351 |
allocating some OperatingSystem resource (a Color, File or View) |
1288 | 2352 |
and the OS runs out of resources. In this case, the scavenge may |
2353 |
free some ST-objects and therefore (by signalling the WeakArrays |
|
2354 |
or Registries) free the OS resources too. |
|
2355 |
Of course, only recently allocated resources will be freed this |
|
2356 |
way. If none was freed, a full collect will be needed." |
|
615 | 2357 |
%{ |
5461 | 2358 |
__nonTenuringScavenge(); |
615 | 2359 |
%} |
2360 |
||
2361 |
" |
|
2362 |
ObjectMemory scavenge |
|
194 | 2363 |
" |
207 | 2364 |
! |
2365 |
||
1288 | 2366 |
startBackgroundCollectorAt:aPriority |
2367 |
"start a process doing incremental GC in the background. |
|
2368 |
Use this, if you have suspendable background processes which |
|
2369 |
run all the time, and therefore would prevent the idle-collector |
|
2370 |
from running. See documentation in this class for more details." |
|
2371 |
||
2372 |
|p| |
|
2373 |
||
2374 |
"/ |
|
2375 |
"/ its not useful, to run it more than once |
|
2376 |
"/ |
|
2377 |
BackgroundCollectProcess notNil ifTrue:[ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2378 |
BackgroundCollectProcess priority:aPriority. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2379 |
^ self |
1288 | 2380 |
]. |
2381 |
||
2382 |
p := |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2383 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2384 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2385 |
|myDelay timeOfLastGC doGC| |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2386 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2387 |
myDelay := Delay forSeconds:5. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2388 |
timeOfLastGC := Timestamp now. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2389 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2390 |
[true] whileTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2391 |
doGC := self gcStepIfUseful. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2392 |
doGC ifFalse:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2393 |
(BackgroundCollectMaximumInterval notNil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2394 |
and:[(Timestamp now getSeconds - timeOfLastGC getSeconds) > BackgroundCollectMaximumInterval]) |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2395 |
ifTrue:[ |
3743 | 2396 |
"/ 'ObjectMemory [info]: start time-triggered background collect.' infoPrintCR. |
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2397 |
doGC := true. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2398 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2399 |
]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2400 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2401 |
doGC ifTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2402 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2403 |
"/ perform a full cycle (finish cycle) |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2404 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2405 |
[self gcStep] whileFalse:[]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2406 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2407 |
"/ increase oldSpace, if freeSpace is below limits. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2408 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2409 |
self moreOldSpaceIfUseful. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2410 |
timeOfLastGC := Timestamp now. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2411 |
]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2412 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2413 |
"/ wait a bit |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2414 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2415 |
myDelay wait. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2416 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2417 |
] ifCurtailed:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2418 |
BackgroundCollectProcess := nil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2419 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2420 |
] newProcess. |
1288 | 2421 |
p name:'background collector'. |
2422 |
p priority:aPriority. |
|
2423 |
p restartable:true. |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
2424 |
p beSystemProcess. |
1288 | 2425 |
p resume. |
2426 |
BackgroundCollectProcess := p |
|
2427 |
||
2428 |
" |
|
2429 |
the following lets the backgroundCollector run at prio 5 |
|
2430 |
whenever 100000 bytes have been allocated, OR freeSpace drops |
|
2431 |
below 1meg. Having the system keep 1meg as reserve for peak allocation. |
|
2432 |
||
2433 |
Doing this may reduce pauses due to inevitable collects when running |
|
2434 |
out of freeSpace, if the collector can keep up with allocation rate. |
|
2435 |
" |
|
2436 |
||
2437 |
" |
|
2258 | 2438 |
ObjectMemory stopBackgroundCollector. |
2439 |
||
1288 | 2440 |
ObjectMemory incrementalGCLimit:100000. |
2441 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
2258 | 2442 |
ObjectMemory startBackgroundCollectorAt:5. |
211 | 2443 |
" |
2258 | 2444 |
|
3761 | 2445 |
"Modified: / 14.8.1998 / 13:09:19 / cg" |
207 | 2446 |
! |
2447 |
||
1288 | 2448 |
stopBackgroundCollector |
2449 |
"stop the background collector" |
|
2450 |
||
2451 |
BackgroundCollectProcess notNil ifTrue:[ |
|
2452 |
BackgroundCollectProcess terminate. |
|
2453 |
BackgroundCollectProcess := nil |
|
207 | 2454 |
] |
293 | 2455 |
|
211 | 2456 |
" |
2457 |
ObjectMemory stopBackgroundCollector |
|
2458 |
" |
|
362 | 2459 |
! |
2460 |
||
8455 | 2461 |
suspendBackgroundCollector |
10743 | 2462 |
"suspend the background collector process. |
2463 |
Answer true, if the background collector was running before" |
|
8455 | 2464 |
|
2465 |
|backgroundCollectorWasRunning| |
|
2466 |
||
2467 |
backgroundCollectorWasRunning := false. |
|
2468 |
||
2469 |
BackgroundCollectProcess notNil ifTrue:[ |
|
10743 | 2470 |
"suspend doesn't work due to interrupt processing" |
2471 |
backgroundCollectorWasRunning := BackgroundCollectProcess isStopped not. |
|
2472 |
BackgroundCollectProcess stop. |
|
8455 | 2473 |
]. |
2474 |
||
2475 |
^ backgroundCollectorWasRunning |
|
10226 | 2476 |
|
8455 | 2477 |
|
2478 |
" |
|
2479 |
ObjectMemory suspendBackgroundCollector. |
|
2480 |
ObjectMemory resumeBackgroundCollector |
|
2481 |
" |
|
2482 |
||
2483 |
"Created: / 03-08-2004 / 18:11:41 / stefan" |
|
10743 | 2484 |
"Modified: / 17-10-2007 / 13:15:01 / cg" |
8455 | 2485 |
! |
2486 |
||
1288 | 2487 |
tenure |
2488 |
"force all living new stuff into old-space - effectively making |
|
2489 |
all living young objects become old objects immediately. |
|
2490 |
This is relatively fast (compared to oldspace collect). |
|
2491 |
||
2492 |
This method should only be used in very special situations: |
|
2493 |
for example, when building up some long-living data structure |
|
2494 |
in a time critical application. |
|
2495 |
To do so, you have to do a scavenge followed by a tenure after the |
|
2496 |
objects are created. Be careful, to not reference any other chunk- |
|
2497 |
data when calling for a tenure (this will lead to lots of garbage in |
|
2498 |
the oldspace). |
|
2499 |
In normal situations, explicit tenures are not needed." |
|
2500 |
%{ |
|
5461 | 2501 |
__tenure(); |
1288 | 2502 |
%} |
2503 |
||
2504 |
" |
|
2505 |
ObjectMemory tenure |
|
2506 |
" |
|
2507 |
" |
|
2508 |
... build up long living objects ... |
|
2509 |
ObjectMemory scavenge. |
|
2510 |
ObjectMemory tenure |
|
615 | 2511 |
... continue - objects created above are now in oldSpace ... |
2512 |
" |
|
2513 |
! |
|
2514 |
||
1288 | 2515 |
tenuringScavenge |
2516 |
"collect newspace stuff, with aging (i.e. objects old enough |
|
2517 |
will be moved into the oldSpace). |
|
2518 |
Use this for debugging and testing only - the system performs |
|
2519 |
this automatically when the newspace fills up. |
|
2520 |
This is relatively fast (compared to oldspace collect)" |
|
615 | 2521 |
%{ |
5461 | 2522 |
__scavenge(); |
615 | 2523 |
%} |
2524 |
||
2525 |
" |
|
2526 |
ObjectMemory tenuringScavenge |
|
2527 |
" |
|
1288 | 2528 |
! |
2529 |
||
2530 |
verboseGarbageCollect |
|
2531 |
"perform a compressing garbage collect and show some informational |
|
2532 |
output on the Transcript" |
|
2533 |
||
2534 |
|nBytesBefore nReclaimed value unit| |
|
2535 |
||
2536 |
nBytesBefore := self oldSpaceUsed. |
|
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2537 |
|
8304 | 2538 |
self nonVerboseGarbageCollect. |
3649 | 2539 |
|
2540 |
"/ show what we reclaimed |
|
1288 | 2541 |
nReclaimed := nBytesBefore - self oldSpaceUsed. |
2542 |
nReclaimed > 0 ifTrue:[ |
|
10226 | 2543 |
nReclaimed > 1024 ifTrue:[ |
2544 |
nReclaimed > (1024 * 1024) ifTrue:[ |
|
2545 |
value := nReclaimed * 10 // (1024 * 1024) / 10.0. |
|
2546 |
unit := ' Mb.' |
|
2547 |
] ifFalse:[ |
|
2548 |
value := nReclaimed // 1024. |
|
2549 |
unit := ' Kb.' |
|
2550 |
] |
|
2551 |
] ifFalse:[ |
|
2552 |
value := nReclaimed. |
|
2553 |
unit := ' bytes.' |
|
2554 |
]. |
|
2555 |
Transcript show:'reclaimed '; show:value. |
|
2556 |
Transcript showCR:unit |
|
1288 | 2557 |
] |
2558 |
||
2559 |
" |
|
2560 |
ObjectMemory verboseGarbageCollect |
|
2561 |
" |
|
1418 | 2562 |
|
3649 | 2563 |
"Modified: / 15.7.1998 / 13:28:05 / cg" |
178 | 2564 |
! ! |
2565 |
||
1767 | 2566 |
!ObjectMemory class methodsFor:'garbage collector control'! |
133 | 2567 |
|
1288 | 2568 |
announceOldSpaceNeed:howMuch |
2569 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
10226 | 2570 |
soon, which is going to live longer (whatever that means). |
1288 | 2571 |
It first checks if the memory can be allocated without forcing a compressing |
2572 |
GC. If not, the oldSpace is increased. This may also lead to a slow compressing |
|
2573 |
collect. However, many smaller increases are avoided afterwards. Calling this |
|
2574 |
method before allocating huge chunks of data may provide better overall performance. |
|
2575 |
Notice: this is a nonstandard interface - use only in special situations." |
|
2576 |
||
2577 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2578 |
self incrementalGC. |
|
2579 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2580 |
self moreOldSpace:howMuch |
|
615 | 2581 |
] |
2582 |
] |
|
310 | 2583 |
|
2584 |
" |
|
615 | 2585 |
ObjectMemory announceOldSpaceNeed:1000000 |
133 | 2586 |
" |
2587 |
! |
|
2588 |
||
1288 | 2589 |
announceSpaceNeed:howMuch |
2590 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
2591 |
soon. The VM tries to prepare itself for this allocation to be performed |
|
2592 |
with less overhead. For example, it could preallocate some memory in one |
|
2593 |
big chunk (instead of doing many smaller reallocations later). |
|
2594 |
Notice: this is a nonstandard interface - use only in special situations. |
|
2595 |
Also, this does a background collect before the big chunk of memory is |
|
2596 |
allocated, not locking other processes while doing so." |
|
2597 |
||
2598 |
(howMuch < (self newSpaceSize // 2)) ifTrue:[ |
|
2599 |
self scavenge. |
|
2600 |
]. |
|
2601 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2602 |
(howMuch > (self newSpaceSize // 2)) ifFalse:[ |
|
2603 |
self scavenge. |
|
2604 |
]. |
|
2605 |
self incrementalGC. |
|
2606 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2607 |
self moreOldSpace:howMuch |
|
202 | 2608 |
] |
2609 |
] |
|
2610 |
||
2611 |
" |
|
2612 |
ObjectMemory announceSpaceNeed:100000 |
|
2613 |
" |
|
2614 |
! |
|
2615 |
||
1288 | 2616 |
avoidTenure:flag |
2617 |
"set/clear the avoidTenure flag. If set, aging of newSpace is turned off |
|
2618 |
as long as the newSpace fill-grade stays below some magic high-water mark. |
|
2619 |
If off (the default), aging is done as usual. |
|
2620 |
If the flag is turned on, scavenge may be a bit slower, due to more |
|
2621 |
objects being copied around. However, chances are high that in an idle |
|
2622 |
or (almost idle) system, less objects are moved into oldSpace. |
|
2623 |
Therefore, this helps to avoid oldSpace colelcts, in systems which go into |
|
2624 |
some standby mode and are reactivated by some external event. |
|
2625 |
(the avoid-flag should be turned off there, and set again once the idle loop |
|
2626 |
is reentered). |
|
2627 |
||
2628 |
This is an EXPERIMENTAL interface." |
|
178 | 2629 |
|
2630 |
%{ /* NOCONTEXT */ |
|
615 | 2631 |
__avoidTenure(flag == true ? 1 : 0); |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2632 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2633 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2634 |
self saveGarbageCollectorSetting:#avoidTenure: value:flag. |
133 | 2635 |
! |
2636 |
||
1288 | 2637 |
checkForFastNew:amount |
2638 |
"this method returns true, if amount bytes could be allocated |
|
2639 |
quickly (i.e. without forcing a full GC or compress). |
|
2640 |
This can be used for smart background processes, which want to |
|
2641 |
allocate big chunks of data without disturbing foreground processes |
|
2642 |
too much. Such a process would check for fast-allocation, and perform |
|
10226 | 2643 |
incremental GC-steps if required. Thus, avoiding the long blocking pause |
2644 |
due to a forced (non-incremental) GC. |
|
1288 | 2645 |
Especially: doing so will not block higher priority foreground processes. |
2646 |
See an example use in Behavior>>niceBasicNew:. |
|
2647 |
This is experimental and not guaranteed to be in future versions." |
|
2648 |
||
2649 |
%{ /* NOCONTEXT */ |
|
2650 |
extern int __checkForFastNew(); |
|
2651 |
||
2652 |
if (__isSmallInteger(amount)) { |
|
2653 |
if (! __checkForFastNew(__intVal(amount))) { |
|
2654 |
RETURN (false); |
|
2655 |
} |
|
2656 |
} |
|
2657 |
||
2658 |
%}. |
|
2659 |
^ true |
|
178 | 2660 |
! |
2661 |
||
1768 | 2662 |
dynamicCodeGCTrigger |
2663 |
"return the dynamic code trigger limit for incremental GC activation. |
|
2664 |
The system will start doing incremental background GC, whenever this amount |
|
10226 | 2665 |
of code was dynamically generated. |
1768 | 2666 |
The default is nil; which disables this trigger" |
2667 |
||
2668 |
^ DynamicCodeGCTrigger |
|
2669 |
||
2670 |
" |
|
2671 |
ObjectMemory dynamicCodeGCTrigger |
|
2672 |
" |
|
2673 |
||
2674 |
"Created: 16.10.1996 / 17:42:01 / cg" |
|
2675 |
! |
|
2676 |
||
2677 |
dynamicCodeGCTrigger:numberOfBytesOrNil |
|
2678 |
"set the dynamic code trigger limit for incremental GC activation. |
|
2679 |
The system will start doing incremental background GC, whenever this amount |
|
10226 | 2680 |
of code was dynamically generated. |
1768 | 2681 |
The default is nil; which disables this trigger" |
2682 |
||
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2683 |
(numberOfBytesOrNil notNil and:[numberOfBytesOrNil > 0]) ifTrue:[ |
10226 | 2684 |
DynamicCodeGCTrigger := numberOfBytesOrNil. |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2685 |
] ifFalse:[ |
10226 | 2686 |
DynamicCodeGCTrigger := nil |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2687 |
] |
1768 | 2688 |
|
2689 |
" |
|
2690 |
ObjectMemory dynamicCodeGCTrigger:50000 |
|
2691 |
" |
|
2692 |
||
2693 |
"Created: 16.10.1996 / 17:42:29 / cg" |
|
2694 |
! |
|
2695 |
||
2696 |
dynamicCodeLimit |
|
2697 |
"return the dynamic code limit. |
|
2698 |
The system will start doing incremental background GC, whenever this amount |
|
2699 |
of code has been generated (overall), and start to flush the code cache, |
|
10226 | 2700 |
if (after the GC), more code is still allocated. |
1768 | 2701 |
The default is nil; which disables this trigger" |
2702 |
||
1781 | 2703 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 2704 |
^ DynamicCodeLimit |
2705 |
||
2706 |
" |
|
2707 |
ObjectMemory dynamicCodeLimit |
|
2708 |
" |
|
2709 |
||
2710 |
"Created: 16.10.1996 / 17:43:37 / cg" |
|
2711 |
! |
|
2712 |
||
2713 |
dynamicCodeLimit:nBytesOrNil |
|
2714 |
"set the dynamic code limit. |
|
2715 |
The system will start doing incremental background GC, whenever this amount |
|
2716 |
of code has been generated (overall), and start to flush the code cache, |
|
10226 | 2717 |
if (after the GC), more code is still allocated. |
1768 | 2718 |
The default is nil; which disables this trigger" |
2719 |
||
1770 | 2720 |
self setCompiledCodeLimit:nBytesOrNil. |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2721 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 2722 |
|
2723 |
" |
|
2724 |
ObjectMemory dynamicCodeLimit:100000 |
|
2725 |
" |
|
2726 |
||
2727 |
"Created: 16.10.1996 / 17:43:58 / cg" |
|
1770 | 2728 |
"Modified: 16.10.1996 / 19:30:46 / cg" |
1768 | 2729 |
! |
2730 |
||
1288 | 2731 |
fastMoreOldSpaceAllocation:aBoolean |
2732 |
"this method turns on/off fastMoreOldSpace allocation. |
|
2733 |
By default, this is turned off (false), which means that in case of |
|
10226 | 2734 |
a filled-up oldSpace, a GC is tried first before more oldSpace is allocated. |
1288 | 2735 |
This strategy is ok for the normal operation of the system, |
2736 |
but behaves badly, if the program allocates huge data structures (say a |
|
2737 |
game tree of 30Mb in size) which survives and therefore will not be reclaimed |
|
2738 |
by a GC. |
|
10226 | 2739 |
Of course while building this tree, and the memory becomes full, the system |
1288 | 2740 |
would not know in advance, that the GC will not reclaim anything. |
2741 |
||
8455 | 2742 |
Setting fastMoreOldSpaceAllocation to true will avoid this, by forcing the |
1288 | 2743 |
memory system to allocate more memory right away, without doing a GC first. |
2744 |
||
2745 |
WARNING: make certain that this flag is turned off, after your huge data |
|
2746 |
is allocated, since otherwise the system may continue to increase its |
|
2747 |
virtual memory without ever checking for garbage. |
|
2748 |
This method returns the previous value of the flag; typically this return |
|
2749 |
value should be used to switch back." |
|
2750 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2751 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2752 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2753 |
%{ |
1288 | 2754 |
extern int __fastMoreOldSpaceAllocation(); |
2755 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2756 |
result = __fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false; |
5441 | 2757 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2758 |
self saveGarbageCollectorSetting:#fastMoreOldSpaceAllocation: value:aBoolean. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2759 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2760 |
^ result |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2761 |
|
1288 | 2762 |
" |
2763 |
|previousSetting| |
|
2764 |
||
2765 |
previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
2766 |
[ |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2767 |
... |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2768 |
allocate your huge data |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2769 |
... |
8455 | 2770 |
] ensure:[ |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2771 |
ObjectMemory fastMoreOldSpaceAllocation:previousSetting |
1288 | 2772 |
] |
2773 |
" |
|
2774 |
||
2775 |
" |
|
2776 |
|prev this| |
|
2777 |
||
2778 |
prev := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
370 | 2779 |
ObjectMemory fastMoreOldSpaceAllocation:prev. |
2780 |
^ prev |
|
2781 |
" |
|
8455 | 2782 |
|
2783 |
"Modified: / 03-08-2004 / 18:05:31 / stefan" |
|
370 | 2784 |
! |
2785 |
||
1288 | 2786 |
fastMoreOldSpaceLimit:aNumber |
2787 |
"this method sets and returns the fastMoreOldSpace limit. |
|
2788 |
If fastMoreOldSpaceAllocation is true, and the current oldSpace size is |
|
2789 |
below this limit, the memory manager will NOT do a GC when running out of |
|
2790 |
oldSpace, but instead quickly go ahead increasing the size of the oldSpace. |
|
2791 |
Setting the limit to 0 turns off any limit (i.e. it will continue to |
|
2792 |
increase the oldSpace forwever - actually, until the OS refuses to give us |
|
2793 |
more memory). The returned value is the previous setting of the limit." |
|
2794 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2795 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2796 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2797 |
%{ |
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2798 |
extern unsigned int __fastMoreOldSpaceLimit(); |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2799 |
|
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2800 |
if (__isInteger(aNumber)) { |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2801 |
result = __MKUINT( __fastMoreOldSpaceLimit(__unsignedLongIntVal(aNumber))); |
1288 | 2802 |
} |
2803 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2804 |
result isNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2805 |
^ 0. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2806 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2807 |
self saveGarbageCollectorSetting:#fastMoreOldSpaceLimit: value:aNumber. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2808 |
^ result. |
10226 | 2809 |
|
1288 | 2810 |
" |
2811 |
|prev this| |
|
2812 |
||
2813 |
prev := ObjectMemory fastMoreOldSpaceLimit:10*1024*1024. |
|
370 | 2814 |
ObjectMemory fastMoreOldSpaceLimit:prev. |
2815 |
^ prev |
|
2816 |
" |
|
133 | 2817 |
! |
2818 |
||
1288 | 2819 |
freeSpaceGCAmount |
2820 |
"return the amount to be allocated if, after an incrementalGC, |
|
2821 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2822 |
The default is nil, which lets the system compute an abbpropriate value" |
|
615 | 2823 |
|
2824 |
^ FreeSpaceGCAmount |
|
2825 |
||
2826 |
" |
|
2827 |
ObjectMemory freeSpaceGCAmount |
|
2828 |
" |
|
2829 |
! |
|
2830 |
||
1288 | 2831 |
freeSpaceGCAmount:aNumber |
2832 |
"set the amount to be allocated if, after an incrementalGC, |
|
2833 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2834 |
The amount should be greater than the limit, otherwise the incremental |
|
2835 |
GC may try over and over to get the memory (actually waisting time)." |
|
2836 |
||
2837 |
FreeSpaceGCAmount := aNumber |
|
2838 |
||
2839 |
" |
|
2840 |
the following will try to always keep at least 1meg of free space |
|
2841 |
(in the background) and start to do so, whenever the freeSpace drops |
|
2842 |
below 250k. |
|
2843 |
" |
|
2844 |
" |
|
10226 | 2845 |
ObjectMemory freeSpaceGCLimit:250000. |
2846 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
1288 | 2847 |
" |
2848 |
||
2849 |
" |
|
2850 |
turn it off (i.e. let the system compute an appropriate amount ...) |
|
615 | 2851 |
" |
2852 |
" |
|
10226 | 2853 |
ObjectMemory freeSpaceGCAmount:nil. |
615 | 2854 |
" |
2855 |
! |
|
2856 |
||
1288 | 2857 |
freeSpaceGCLimit |
2858 |
"return the freeSpace limit for incremental GC activation. |
|
10226 | 2859 |
The system will start doing incremental background GC, once less than this number |
1288 | 2860 |
of bytes are available in the compact free space. |
2861 |
The default is 100000; setting it to nil will turn this trigger off." |
|
615 | 2862 |
|
2863 |
^ FreeSpaceGCLimit |
|
2864 |
||
2865 |
" |
|
2866 |
ObjectMemory freeSpaceGCLimit |
|
2867 |
" |
|
133 | 2868 |
! |
2869 |
||
1288 | 2870 |
freeSpaceGCLimit:aNumber |
2871 |
"set the freeSpace limit for incremental GC activation. |
|
10226 | 2872 |
The system will start doing incremental background GC, once less than this number |
1288 | 2873 |
of bytes are available for allocation. |
2874 |
The default is nil; setting it to nil will turn this trigger off." |
|
2875 |
||
2876 |
FreeSpaceGCLimit := aNumber |
|
2877 |
||
2878 |
" |
|
2879 |
the following will start the incrementalGC (in the background) |
|
2880 |
whenever the freeSpace drops below 1meg of free space |
|
2881 |
" |
|
2882 |
" |
|
10226 | 2883 |
ObjectMemory freeSpaceGCLimit:1000000. |
1288 | 2884 |
" |
2885 |
||
2886 |
" |
|
2887 |
turn it off (i.e. let the system hit the wall ...) |
|
615 | 2888 |
" |
2889 |
" |
|
10226 | 2890 |
ObjectMemory freeSpaceGCLimit:nil. |
615 | 2891 |
" |
1 | 2892 |
! |
2893 |
||
1288 | 2894 |
incrementalGCLimit |
2895 |
"return the allocatedSinceLastGC limit for incremental GC activation. |
|
10226 | 2896 |
The system will start doing incremental background GC, once more than this number |
2897 |
of bytes have been allocated since the last GC. |
|
1288 | 2898 |
The default is 500000; setting it to nil will turn this trigger off." |
615 | 2899 |
|
2900 |
^ IncrementalGCLimit |
|
2901 |
||
2902 |
" |
|
2903 |
ObjectMemory incrementalGCLimit |
|
2904 |
" |
|
178 | 2905 |
! |
85 | 2906 |
|
1288 | 2907 |
incrementalGCLimit:aNumber |
2908 |
"set the allocatedSinceLastGC limit for incremental GC activation. |
|
10226 | 2909 |
The system will start doing incremental background GC, once more than this number |
2910 |
of bytes have been allocated since the last GC. |
|
1288 | 2911 |
The default is 500000; setting it to nil will turn this trigger off." |
2912 |
||
2913 |
IncrementalGCLimit := aNumber |
|
2914 |
||
2915 |
" |
|
2916 |
ObjectMemory incrementalGCLimit:500000. 'do incr. GC very seldom' |
|
2917 |
ObjectMemory incrementalGCLimit:100000. 'medium' |
|
2918 |
ObjectMemory incrementalGCLimit:10000. 'do incr. GC very often' |
|
615 | 2919 |
ObjectMemory incrementalGCLimit:nil. 'never' |
2920 |
" |
|
370 | 2921 |
! |
2922 |
||
3859 | 2923 |
incrementalSweep:aBoolean |
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2924 |
"ineable/disable incremental sweeps during background GC. |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2925 |
This entry is provided as a test interface and should not be |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2926 |
used by applications - it may vanish without notice" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2927 |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2928 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2929 |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2930 |
%{ |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2931 |
result = __incrementalSweep((aBoolean == true) ? 1 : 0) ? true : false; |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2932 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2933 |
self saveGarbageCollectorSetting:#incrementalSweep: value:aBoolean. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2934 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2935 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2936 |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2937 |
" |
3859 | 2938 |
ObjectMemory incrementalSweep:false. |
2939 |
ObjectMemory incrementalSweep:true |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2940 |
" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2941 |
! |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2942 |
|
1288 | 2943 |
lockTenure:flag |
2944 |
"set/clear the tenureLock. If the lock is set, the system |
|
2945 |
completely turns off tenuring, and objects remain in newSpace (forever). |
|
10226 | 2946 |
Once this lock is set, the system operates only in the newSpace and no memory |
2947 |
allocations from oldSpace are allowed (except for explicit tenure calls). |
|
1288 | 2948 |
If any allocation request cannot be resoved, the VM raises a memory interrupt, |
2949 |
clears the lockTenure-flag and returns nil. Thus, it automatically falls back into |
|
10226 | 2950 |
the normal mode of operation, to avoid big trouble |
1288 | 2951 |
(fail to allocate memory when handling the exception). |
2952 |
||
2953 |
This interface can be used in applications, which are guaranteed to have their |
|
2954 |
working set completely in the newSpace AND want to limit the worst case |
|
10226 | 2955 |
pause times to the worst case scavenge time |
2956 |
(which itself is limitd by the size of the newSpace). |
|
1288 | 2957 |
I.e. systems which go into some event loop after initial startup, |
10226 | 2958 |
may turn on the tenureLock to make certain that no oldSpace memory is |
1288 | 2959 |
allocated in the future; thereby limiting any GC activity to newSpace scavenges only. |
2960 |
||
2961 |
This is an EXPERIMENTAL interface. |
|
2962 |
" |
|
2963 |
||
2964 |
%{ |
|
2965 |
if (flag == true) { |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2966 |
__tenure(__context); |
370 | 2967 |
} |
379 | 2968 |
__lockTenure(flag == true ? 1 : 0); |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2969 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2970 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2971 |
self saveGarbageCollectorSetting:#lockTenure: value:flag. |
379 | 2972 |
! |
2973 |
||
1288 | 2974 |
makeOld:anObject |
2975 |
"move anObject into oldSpace. |
|
2976 |
This method is for internal & debugging purposes only - |
|
2977 |
it may vanish. Dont use it." |
|
2978 |
%{ |
|
2979 |
if (__moveToOldSpace(anObject, __context) < 0) { |
|
615 | 2980 |
RETURN (false); |
2981 |
} |
|
2982 |
%}. |
|
2983 |
^ true |
|
2984 |
! |
|
2985 |
||
2337 | 2986 |
maxOldSpace |
2339 | 2987 |
"return the maxOldSpace value. If non-zero, thats the limit for which the |
2988 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 2989 |
If zero, it will allocate forever (until the OS wont hand out more). |
2990 |
The default is zero." |
|
2991 |
||
2992 |
%{ /* NOCONTEXT */ |
|
2993 |
extern unsigned __maxOldSpace(); |
|
2994 |
||
10226 | 2995 |
RETURN (__MKUINT( __maxOldSpace((unsigned int)-1) )); |
5441 | 2996 |
%}. |
2997 |
^ 0 |
|
2337 | 2998 |
" |
2999 |
ObjectMemory maxOldSpace |
|
3000 |
" |
|
3001 |
! |
|
3002 |
||
3003 |
maxOldSpace:amount |
|
2339 | 3004 |
"set the maxOldSpace value. If non-zero, thats the limit for which the |
3005 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 3006 |
If zero, it will allocate forever (until the OS wont hand out more). |
2338 | 3007 |
The default is zero. |
10226 | 3008 |
WARNING: |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3009 |
an oldSpace limit may lead to trashing due to exorbitant GC activity; |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3010 |
its usually better to let it allocate more and page in/page out. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3011 |
Usually, the background GC will catch up sooner or later and reclaim |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3012 |
the memory without blocking the system" |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3013 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3014 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3015 |
%{ |
2337 | 3016 |
extern unsigned __maxOldSpace(); |
3017 |
||
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3018 |
if (__isInteger(amount)) { |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3019 |
result = __MKUINT( __maxOldSpace(__unsignedLongIntVal(amount))); |
2337 | 3020 |
} |
5441 | 3021 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3022 |
result notNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3023 |
self saveGarbageCollectorSetting:#maxOldSpace: value:amount. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3024 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3025 |
]. |
5441 | 3026 |
^ 0 |
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3027 |
|
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3028 |
" |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3029 |
to change maximum to 1GByte: |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3030 |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3031 |
ObjectMemory maxOldSpace:1024*1024*1024 |
2337 | 3032 |
" |
3033 |
! |
|
3034 |
||
1288 | 3035 |
moreOldSpace:howMuch |
3036 |
"allocate howMuch bytes more for old objects; return true if this worked, |
|
3037 |
false if that failed. |
|
3038 |
This is done automatically, when running out of space, but makes |
|
3039 |
sense, if its known in advance that a lot of memory is needed to |
|
3040 |
avoid multiple reallocations and compresses. |
|
3041 |
On systems which do not support the mmap (or equivalent) system call, |
|
3042 |
this (currently) implies a compressing garbage collect - so its slow. |
|
3043 |
Notice: this is a nonstandard interface - use only in special situations." |
|
3044 |
||
10226 | 3045 |
%{ |
1288 | 3046 |
if (__isSmallInteger(howMuch)) { |
3047 |
RETURN( __moreOldSpace(__context, __intVal(howMuch)) ? true : false ); |
|
615 | 3048 |
} |
3049 |
RETURN (false); |
|
379 | 3050 |
%} |
615 | 3051 |
" |
3052 |
ObjectMemory moreOldSpace:1000000 |
|
3053 |
" |
|
379 | 3054 |
! |
3055 |
||
1288 | 3056 |
moreOldSpaceIfUseful |
3057 |
"to be called after an incremental GC cycle; |
|
3058 |
if freeSpace is still below limit, allocate more oldSpace" |
|
3059 |
||
3060 |
|limit free amount| |
|
3061 |
||
3062 |
limit := FreeSpaceGCLimit. |
|
3063 |
limit notNil ifTrue:[ |
|
10226 | 3064 |
"/ if reclaimed space is below limit, we have to allocate more |
3065 |
"/ oldSpace, to avoid excessive gcSteps (due to freeSpaceLimit |
|
3066 |
"/ still not reached) |
|
3067 |
"/ |
|
3068 |
free := self freeSpace + self freeListSpace. |
|
3069 |
free < (limit * 3 // 2) ifTrue:[ |
|
3070 |
amount := FreeSpaceGCAmount. |
|
3071 |
amount isNil ifTrue:[ |
|
3072 |
amount := limit * 3 // 2. |
|
3073 |
]. |
|
3074 |
"/ 'ObjectMemory [info]: moreOldSpace to satisfy free-limit' infoPrintCR. |
|
3075 |
(self moreOldSpace:(amount - free + (64*1024))) ifFalse:[ |
|
3076 |
"/ |
|
3077 |
"/ could not increase oldspace; reset FreeSpaceGCLimit to avoid |
|
3078 |
"/ useless retries |
|
3079 |
'ObjectMemory [warning]: could not increase oldSpace - reset limit' errorPrintCR. |
|
3080 |
FreeSpaceGCLimit := nil |
|
3081 |
] |
|
3082 |
]. |
|
615 | 3083 |
]. |
2122 | 3084 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3085 |
"Modified: 10.1.1997 / 17:59:48 / cg" |
370 | 3086 |
! |
3087 |
||
1288 | 3088 |
newSpaceSize:newSize |
3089 |
"change the size of the newSpace. To do this, the current contents |
|
3090 |
of the newSpace may have to be tenured (if size is smaller). |
|
3091 |
Returns false, if it failed for any reason. |
|
3092 |
Experimental: this interface may valish without notice. |
|
3093 |
||
3094 |
DANGER ALERT: |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3095 |
be careful too big of a size may lead to longer scavenge pauses. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3096 |
Too small of a newSpace may lead to more CPU overhead, due to |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3097 |
excessive scavenges. You have been warned." |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3098 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3099 |
|result| |
10226 | 3100 |
|
3101 |
%{ |
|
1288 | 3102 |
extern int __setNewSpaceSize(); |
3103 |
||
3104 |
if (__isSmallInteger(newSize)) { |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3105 |
result = __setNewSpaceSize(__intVal(newSize)) ? true : false; |
1288 | 3106 |
} |
3107 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3108 |
result isNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3109 |
self primitiveFailed. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3110 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3111 |
result ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3112 |
self saveGarbageCollectorSetting:#newSpaceSize: value:newSize. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3113 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3114 |
^ result. |
1288 | 3115 |
|
3116 |
" less absolute CPU overhead (but longer pauses): |
|
3117 |
||
8423 | 3118 |
ObjectMemory newSpaceSize:1600*1024 |
1288 | 3119 |
" |
3120 |
||
3121 |
" smaller pauses, but more overall CPU overhead: |
|
3122 |
||
3123 |
ObjectMemory newSpaceSize:200*1024 |
|
370 | 3124 |
" |
3125 |
||
3126 |
" the default: |
|
3127 |
||
8423 | 3128 |
ObjectMemory newSpaceSize:800*1024 |
370 | 3129 |
" |
615 | 3130 |
! |
3131 |
||
1288 | 3132 |
oldSpaceCompressLimit |
3133 |
"return the limit for oldSpace compression. If more memory than this |
|
3134 |
limit is in use, the system will not perform compresses on the oldspace, |
|
3135 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
3136 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
3137 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
3138 |
you may want to increase this limit." |
|
3139 |
||
3140 |
%{ /* NOCONTEXT */ |
|
3141 |
extern unsigned __compressingGCLimit(); |
|
3142 |
||
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3143 |
RETURN (__MKUINT( __compressingGCLimit((unsigned int)-1) )); |
5441 | 3144 |
%}. |
3145 |
^ 0 |
|
1105
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3146 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3147 |
ObjectMemory oldSpaceCompressLimit |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3148 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3149 |
! |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3150 |
|
1288 | 3151 |
oldSpaceCompressLimit:amount |
3152 |
"set the limit for oldSpace compression. If more memory than this |
|
3153 |
limit is in use, the system will not perform compresses on the oldspace, |
|
3154 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
3155 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
3156 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
3157 |
you may want to increase this limit. |
|
3158 |
This method returns the previous increment value." |
|
3159 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3160 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3161 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3162 |
%{ |
1288 | 3163 |
extern unsigned __compressingGCLimit(); |
3164 |
||
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3165 |
if (__isInteger(amount)) { |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3166 |
result = __MKUINT( __compressingGCLimit(__unsignedLongIntVal(amount)) ); |
1288 | 3167 |
} |
5441 | 3168 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3169 |
result isNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3170 |
^ 0. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3171 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3172 |
self saveGarbageCollectorSetting:#oldSpaceCompressLimit: value:amount. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3173 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3174 |
|
1288 | 3175 |
"to change the limit to 12Mb:" |
615 | 3176 |
" |
3177 |
ObjectMemory oldSpaceCompressLimit:12*1024*1024 |
|
3178 |
" |
|
3179 |
! |
|
3180 |
||
1288 | 3181 |
oldSpaceIncrement |
3182 |
"return the oldSpaceIncrement value. Thats the amount by which |
|
3183 |
more memory is allocated in case the oldSpace gets filled up. |
|
3184 |
In normal situations, the default value used in the VM is fine |
|
3185 |
and there is no need to change it." |
|
3186 |
||
3187 |
%{ /* NOCONTEXT */ |
|
3188 |
extern unsigned __oldSpaceIncrement(); |
|
3189 |
||
10226 | 3190 |
RETURN (__MKUINT( __oldSpaceIncrement((unsigned int)-1) )); |
5441 | 3191 |
%}. |
3192 |
^ 0 |
|
615 | 3193 |
" |
3194 |
ObjectMemory oldSpaceIncrement |
|
3195 |
" |
|
3196 |
! |
|
3197 |
||
1288 | 3198 |
oldSpaceIncrement:amount |
3199 |
"set the oldSpaceIncrement value. Thats the amount by which |
|
3200 |
more memory is allocated in case the oldSpace gets filled up. |
|
3201 |
In normal situations, the default value used in the VM is fine |
|
10226 | 3202 |
and there is no need to change it. This method returns the |
1288 | 3203 |
previous increment value." |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3204 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3205 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3206 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3207 |
%{ |
1288 | 3208 |
extern unsigned __oldSpaceIncrement(); |
3209 |
||
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3210 |
if (__isInteger(amount)) { |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3211 |
result = __MKUINT( __oldSpaceIncrement(__unsignedLongIntVal(amount)) ); |
1288 | 3212 |
} |
5441 | 3213 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3214 |
result isNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3215 |
^ 0. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3216 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3217 |
self saveGarbageCollectorSetting:#oldSpaceIncrement: value:amount. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3218 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3219 |
|
1288 | 3220 |
"to change increment to 1Meg:" |
615 | 3221 |
" |
3222 |
ObjectMemory oldSpaceIncrement:1024*1024 |
|
3223 |
" |
|
3224 |
! |
|
3225 |
||
1288 | 3226 |
tenureParameters:magic |
3227 |
"this is pure magic and not for public eyes ... |
|
3228 |
This method allows fine tuning the scavenger internals, |
|
3229 |
in cooperation to some statistic & test programs. |
|
10226 | 3230 |
It is undocumented, secret and may vanish. |
1288 | 3231 |
If you play around here, the system may behave very strange." |
615 | 3232 |
|
3233 |
%{ /* NOCONTEXT */ |
|
3234 |
__tenureParams(magic); |
|
3235 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3236 |
self saveGarbageCollectorSetting:#tenureParameters: value:magic. |
615 | 3237 |
! |
3238 |
||
1288 | 3239 |
turnGarbageCollectorOff |
3240 |
"turn off the generational garbage collector by forcing new objects to be |
|
3241 |
allocated directly in oldSpace (instead of newSpace) |
|
3242 |
WARNING: |
|
3243 |
This is somewhat dangerous: if collector is turned off, |
|
3244 |
and too many objects are created, the system may run into trouble |
|
3245 |
(i.e. oldSpace becomes full) and be forced to perform a full mark&sweep |
|
3246 |
or even a compressing collect - making the overall realtime behavior worse. |
|
3247 |
Use this only for special purposes or when realtime behavior |
|
3248 |
is required for a limited time period. |
|
3249 |
||
10226 | 3250 |
OBSOLETE: this is no longer supported |
1288 | 3251 |
- it may be a no-operation by the time you read this." |
615 | 3252 |
|
3253 |
%{ /* NOCONTEXT */ |
|
3254 |
__allocForceSpace(OLDSPACE); |
|
3255 |
%} |
|
3256 |
! |
|
3257 |
||
1288 | 3258 |
turnGarbageCollectorOn |
3259 |
"turn garbage collector on again (see ObjectMemory>>turnGarbageCollectorOff)" |
|
615 | 3260 |
|
3261 |
%{ /* NOCONTEXT */ |
|
3262 |
__allocForceSpace(9999); |
|
3263 |
%} |
|
1288 | 3264 |
! |
3265 |
||
3266 |
watchTenure:flag |
|
3267 |
"set/clear the tenureWatch. If set, an internalError exception will be raised, |
|
3268 |
whenever objects are tenured from newSpace into oldSpace |
|
10226 | 3269 |
(except for an explicit tenure request). |
1288 | 3270 |
This can be used to validate that no oldSpace objects are created |
10226 | 3271 |
(i.e. the system operates fully in newSpace). |
3272 |
Be careful, if the avoidTenure flag is not set, |
|
1288 | 3273 |
there will almost always be a tenure sooner or later. |
3274 |
||
3275 |
EXPERIMENTAL - no warranty" |
|
3276 |
||
3277 |
%{ /* NOCONTEXT */ |
|
3278 |
__watchTenure(flag == true ? 1 : 0); |
|
3279 |
%} |
|
178 | 3280 |
! ! |
3281 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3282 |
!ObjectMemory class methodsFor:'garbage collector settings'! |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3283 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3284 |
restoreGarbageCollectorSettings |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3285 |
"restore the saved garbage collector settings" |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3286 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3287 |
SavedGarbageCollectorSettings isEmptyOrNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3288 |
^ self. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3289 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3290 |
SavedGarbageCollectorSettings keysAndValuesDo:[:eachKey :eachValue| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3291 |
eachKey numArgs == 1 ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3292 |
self perform:eachKey with:eachValue. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3293 |
] ifFalse:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3294 |
self perform:eachKey. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3295 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3296 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3297 |
! |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3298 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3299 |
saveGarbageCollectorSetting:aSymbol value:something |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3300 |
"save some garbage collector setting, which is stored only in the VM, |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3301 |
to be restored on snapshot return" |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3302 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3303 |
SavedGarbageCollectorSettings isNil ifTrue:[ |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3304 |
SavedGarbageCollectorSettings := IdentityDictionary new. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3305 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3306 |
SavedGarbageCollectorSettings at:aSymbol put:something. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3307 |
! ! |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3308 |
|
1767 | 3309 |
!ObjectMemory class methodsFor:'interrupt handler access'! |
615 | 3310 |
|
1288 | 3311 |
childSignalInterruptHandler |
3312 |
"return the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
615 | 3313 |
|
3314 |
^ ChildSignalInterruptHandler |
|
3315 |
! |
|
3316 |
||
1288 | 3317 |
childSignalInterruptHandler:aHandler |
3318 |
"set the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
3319 |
||
3320 |
ChildSignalInterruptHandler := aHandler |
|
3321 |
||
3322 |
"Created: 22.12.1995 / 14:14:52 / stefan" |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
3323 |
"Modified: 22.12.1995 / 14:15:16 / stefan" |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
3324 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
3325 |
|
1288 | 3326 |
customInterruptHandler |
615 | 3327 |
"return the handler for custom interrupts" |
3328 |
||
3329 |
^ CustomInterruptHandler |
|
3330 |
! |
|
3331 |
||
1288 | 3332 |
customInterruptHandler:aHandler |
615 | 3333 |
"set the handler for custom interrupts" |
3334 |
||
3335 |
CustomInterruptHandler := aHandler |
|
3336 |
! |
|
3337 |
||
1288 | 3338 |
disposeInterruptHandler |
3339 |
"return the handler for object disposal interrupts" |
|
615 | 3340 |
|
3341 |
^ DisposeInterruptHandler |
|
3342 |
! |
|
3343 |
||
1288 | 3344 |
disposeInterruptHandler:aHandler |
3345 |
"set the handler for object disposal interrupts" |
|
615 | 3346 |
|
3347 |
DisposeInterruptHandler := aHandler |
|
3348 |
! |
|
3349 |
||
1288 | 3350 |
errorInterruptHandler |
615 | 3351 |
"return the handler for display error interrupts" |
3352 |
||
3353 |
^ ErrorInterruptHandler |
|
3354 |
! |
|
3355 |
||
1288 | 3356 |
errorInterruptHandler:aHandler |
3357 |
"set the handler for display error interrupts" |
|
615 | 3358 |
|
3359 |
ErrorInterruptHandler := aHandler |
|
3360 |
! |
|
3361 |
||
1288 | 3362 |
exceptionInterruptHandler |
3363 |
"return the handler for floating point exception interrupts" |
|
615 | 3364 |
|
3365 |
^ ExceptionInterruptHandler |
|
3366 |
! |
|
3367 |
||
1288 | 3368 |
internalErrorHandler |
3369 |
"return the handler for ST/X internal errors. |
|
3370 |
An internal error is reported for example when a methods |
|
3371 |
bytecode is not a ByteArray, the selector table is not an Array |
|
10226 | 3372 |
etc. |
615 | 3373 |
Those should not occur in normal circumstances." |
3374 |
||
3375 |
^ InternalErrorHandler |
|
3376 |
! |
|
3377 |
||
1288 | 3378 |
ioInterruptHandler |
3379 |
"return the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3380 |
|
3381 |
^ IOInterruptHandler |
|
3382 |
! |
|
3383 |
||
1288 | 3384 |
ioInterruptHandler:aHandler |
3385 |
"set the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3386 |
|
3387 |
IOInterruptHandler := aHandler |
|
3388 |
! |
|
3389 |
||
1288 | 3390 |
recursionInterruptHandler |
3391 |
"return the handler for recursion/stack overflow interrupts" |
|
615 | 3392 |
|
3393 |
^ RecursionInterruptHandler |
|
3394 |
! |
|
3395 |
||
1288 | 3396 |
recursionInterruptHandler:aHandler |
3397 |
"set the handler for recursion/stack overflow interrupts" |
|
615 | 3398 |
|
3399 |
RecursionInterruptHandler := aHandler |
|
3400 |
! |
|
3401 |
||
1288 | 3402 |
registerErrorInterruptHandler:aHandler forID:errorIDSymbol |
3403 |
"register a handler" |
|
3404 |
||
3405 |
RegisteredErrorInterruptHandlers isNil ifTrue:[ |
|
3406 |
RegisteredErrorInterruptHandlers := IdentityDictionary new |
|
615 | 3407 |
]. |
3408 |
RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler |
|
3409 |
! |
|
3410 |
||
1288 | 3411 |
registeredErrorInterruptHandlers |
615 | 3412 |
"return registered handlers" |
3413 |
||
3414 |
^ RegisteredErrorInterruptHandlers |
|
3415 |
! |
|
3416 |
||
1288 | 3417 |
signalInterruptHandler |
615 | 3418 |
"return the handler for UNIX-signal interrupts" |
3419 |
||
3420 |
^ SignalInterruptHandler |
|
3421 |
! |
|
3422 |
||
1288 | 3423 |
signalInterruptHandler:aHandler |
3424 |
"set the handler for UNIX-signal interrupts" |
|
615 | 3425 |
|
3426 |
SignalInterruptHandler := aHandler |
|
3427 |
! |
|
3428 |
||
1288 | 3429 |
spyInterruptHandler |
615 | 3430 |
"return the handler for spy-timer interrupts" |
3431 |
||
3432 |
^ SpyInterruptHandler |
|
3433 |
! |
|
3434 |
||
1288 | 3435 |
spyInterruptHandler:aHandler |
615 | 3436 |
"set the handler for spy-timer interrupts" |
3437 |
||
3438 |
SpyInterruptHandler := aHandler |
|
3439 |
! |
|
3440 |
||
1288 | 3441 |
stepInterruptHandler |
615 | 3442 |
"return the handler for single step interrupts" |
3443 |
||
3444 |
^ StepInterruptHandler |
|
3445 |
! |
|
3446 |
||
1288 | 3447 |
stepInterruptHandler:aHandler |
3448 |
"set the handler for single step interrupts" |
|
615 | 3449 |
|
3450 |
StepInterruptHandler := aHandler |
|
3451 |
! |
|
3452 |
||
1288 | 3453 |
timerInterruptHandler |
615 | 3454 |
"return the handler for timer interrupts" |
3455 |
||
3456 |
^ TimerInterruptHandler |
|
3457 |
! |
|
3458 |
||
1288 | 3459 |
timerInterruptHandler:aHandler |
615 | 3460 |
"set the handler for timer interrupts" |
3461 |
||
3462 |
TimerInterruptHandler := aHandler |
|
3463 |
! |
|
3464 |
||
1288 | 3465 |
userInterruptHandler |
615 | 3466 |
"return the handler for CNTL-C interrupt handling" |
3467 |
||
3468 |
^ UserInterruptHandler |
|
1288 | 3469 |
! |
3470 |
||
3471 |
userInterruptHandler:aHandler |
|
3472 |
"set the handler for CNTL-C interrupt handling" |
|
3473 |
||
3474 |
UserInterruptHandler := aHandler |
|
615 | 3475 |
! ! |
3476 |
||
1767 | 3477 |
!ObjectMemory class methodsFor:'interrupt statistics'! |
615 | 3478 |
|
1288 | 3479 |
interruptLatency:ms receiver:rec class:cls selector:sel vmActivity:vmActivity id:pid |
3480 |
"example implementation of latencyTime monitoring: |
|
3481 |
This method simply measures the max-latency time. |
|
3482 |
You may want to use some other handler (see #interruptLatencyMonitor:) |
|
3483 |
and extract more information (blocking context). |
|
3484 |
DEMO Example." |
|
3485 |
||
3486 |
ms > MaxInterruptLatency ifTrue:[ |
|
10226 | 3487 |
MaxInterruptLatency := ms. |
3488 |
'IRQ-LATENCY: ' infoPrint. cls infoPrint. ' ' infoPrint. sel infoPrint. '(' infoPrint. vmActivity infoPrint . ') ---> ' infoPrint. ms infoPrintCR. |
|
1288 | 3489 |
]. |
3490 |
(InterruptLatencyGoal notNil and:[ms > InterruptLatencyGoal]) ifTrue:[ |
|
10226 | 3491 |
'*** IRQ REALTIME-DEADLINE MISSED: ' errorPrint. |
3492 |
cls errorPrint. |
|
3493 |
' ' errorPrint. sel errorPrint. '(' errorPrint. vmActivity errorPrint . ') ---> ' errorPrint. |
|
3494 |
ms errorPrintCR. |
|
1288 | 3495 |
]. |
3496 |
||
3497 |
"to enable the demo handler: |
|
3498 |
||
3499 |
ObjectMemory resetMaxInterruptLatency. |
|
3500 |
ObjectMemory interruptLatencyMonitor:ObjectMemory. |
|
3501 |
" |
|
3502 |
"to disable timing statistics: |
|
3503 |
||
3504 |
ObjectMemory interruptLatencyMonitor:nil. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
3505 |
ObjectMemory maxInterruptLatency printCR. |
1288 | 3506 |
" |
615 | 3507 |
|
3508 |
"Created: 7.11.1995 / 21:05:50 / cg" |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
3509 |
"Modified: 18.6.1996 / 14:15:52 / stefan" |
2138 | 3510 |
"Modified: 10.1.1997 / 19:09:53 / cg" |
615 | 3511 |
! |
3512 |
||
1288 | 3513 |
interruptLatencyGoal:millis |
3514 |
"setup to report an error message, whenever a realtime goal could not be |
|
3515 |
met due to blocked interrupts or long primitives or GC activity. |
|
3516 |
An argument of nil clears the check. |
|
3517 |
DEMO Example." |
|
3518 |
||
3519 |
InterruptLatencyGoal := millis. |
|
3520 |
millis isNil ifTrue:[ |
|
3521 |
InterruptLatencyMonitor := nil. |
|
3522 |
] ifFalse:[ |
|
3523 |
MaxInterruptLatency := 0. |
|
3524 |
InterruptLatencyMonitor := self. |
|
615 | 3525 |
] |
3526 |
||
3527 |
" |
|
3528 |
ObjectMemory interruptLatencyGoal:50 |
|
3529 |
" |
|
3530 |
! |
|
3531 |
||
1288 | 3532 |
interruptLatencyMonitor |
10226 | 3533 |
"return the interrupt-latency-monitor if any. |
1288 | 3534 |
See comment in #interruptLatencyMonitor:. |
3535 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3536 |
|
3537 |
^ InterruptLatencyMonitor |
|
3538 |
! |
|
3539 |
||
1288 | 3540 |
interruptLatencyMonitor:aHandler |
3541 |
"set the interrupt latency monitor. If non-nil, this one will be sent |
|
3542 |
an interruptLatency: message with the millisecond delay between |
|
3543 |
the interrupt and its handling. |
|
3544 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3545 |
|
3546 |
InterruptLatencyMonitor := aHandler |
|
3547 |
! |
|
3548 |
||
1288 | 3549 |
maxInterruptLatency |
3550 |
"return the maximum accumulated interrupt latency in millis. |
|
615 | 3551 |
DEMO Example." |
3552 |
||
3553 |
^ MaxInterruptLatency |
|
1288 | 3554 |
! |
3555 |
||
3556 |
resetMaxInterruptLatency |
|
3557 |
"reset the maximum accumulated interrupt latency probe time. |
|
3558 |
DEMO Example." |
|
3559 |
||
3560 |
MaxInterruptLatency := 0 |
|
615 | 3561 |
! ! |
3562 |
||
1767 | 3563 |
!ObjectMemory class methodsFor:'just in time compilation'! |
3564 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3565 |
byteCodeSizeLimitForDynamicCompilation:aNumber |
2526 | 3566 |
"set a limit on a methods number of byteCodes. |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3567 |
Compilation of a method into machine code is aborted, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3568 |
if its bytecode size is larger than the given number. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3569 |
This is only useful, if large methods have a smaller |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3570 |
chance of being evaluated often (which may not be true). |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3571 |
The predefined limit is some 4k (which seems to be ok)." |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3572 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3573 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3574 |
extern int __byteCodeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3575 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3576 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3577 |
prev = __byteCodeSizeLimitForDynamicCompilation( |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3578 |
__isSmallInteger(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3579 |
? __intVal(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3580 |
: -1); |
8913 | 3581 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3582 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3583 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3584 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3585 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3586 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3587 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3588 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3589 |
|
2638 | 3590 |
codeForCPU:aCPUSymbol |
3591 |
"instruct the just in time compiler that some specific CPU |
|
3592 |
is present (forcing it to generate code for that). |
|
3593 |
The default is set correct for the architecture, and the |
|
3594 |
runTime system tries to figure out the cpu - but who knows ... |
|
3595 |
The valid symbols depend on the architecture: |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3596 |
i386: #i486 / #i586 (affects code ordering) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3597 |
sparc: #sparcV8 / #sparcV8 (affects instruction set) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3598 |
mips: #rs2000 / #rs4000 (affects delay slot generation) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3599 |
This method returns the current setting; a nil arg will not change |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3600 |
the setting (but only return the current). |
2638 | 3601 |
|
10226 | 3602 |
This is a nonstandard entry and may be removed without notice - |
2638 | 3603 |
not for the general user." |
3604 |
||
3605 |
%{ /* NOCONTEXT */ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3606 |
extern OBJ __codeForCPU(); |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3607 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3608 |
RETURN (__codeForCPU(aCPUSymbol)); |
2638 | 3609 |
%}. |
3610 |
||
3611 |
" |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3612 |
ObjectMemory codeForCPU:nil |
2638 | 3613 |
ObjectMemory codeForCPU:#i486 |
3614 |
ObjectMemory codeForCPU:#i586 |
|
3615 |
" |
|
3616 |
! |
|
3617 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3618 |
codeSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3619 |
"set a limit on the resulting dynamic generates code |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3620 |
size. Compilation of a method into machine code is aborted, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3621 |
if the resulting code is larger than the given number of |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3622 |
bytes. This is only useful, if large methods have a smaller |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3623 |
chance of being evaluated often (which may not be true). |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3624 |
The predefined limit is some 4k (which seems to be ok)." |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3625 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3626 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3627 |
extern int __codeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3628 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3629 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3630 |
prev = __codeSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3631 |
? __intVal(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3632 |
: -1); |
8913 | 3633 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3634 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3635 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3636 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3637 |
ObjectMemory codeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3638 |
ObjectMemory codeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3639 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3640 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3641 |
|
1767 | 3642 |
compiledCodeCounter |
3643 |
"return the number of additional code-bytes which |
|
3644 |
were generated since the counter was last reset" |
|
3645 |
||
3646 |
%{ /* NOCONTEXT */ |
|
3647 |
||
3648 |
extern __compiledCodeCounter(); |
|
3649 |
int nBytes; |
|
3650 |
||
3651 |
nBytes = __compiledCodeCounter(); |
|
8913 | 3652 |
RETURN (__mkSmallInteger(nBytes)); |
1767 | 3653 |
%} |
3654 |
" |
|
3655 |
ObjectMemory compiledCodeCounter |
|
3656 |
" |
|
3657 |
! |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3658 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3659 |
compiledCodeSpaceUsed |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3660 |
"return the actual number of bytes used for compiled code" |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3661 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3662 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3663 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3664 |
extern __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3665 |
int nBytes; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3666 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3667 |
nBytes = __compiledCodeSpaceUsed(); |
8913 | 3668 |
RETURN (__mkSmallInteger(nBytes)); |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3669 |
%} |
1767 | 3670 |
" |
3671 |
ObjectMemory compiledCodeSpaceUsed |
|
3672 |
" |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3673 |
! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3674 |
|
1948
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3675 |
fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3676 |
"return the setting of the full single step support flag" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3677 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3678 |
%{ /* NOCONTEXT */ |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3679 |
extern int __fullSingleStep(); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3680 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3681 |
RETURN (__fullSingleStep(-1) ? true : false); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3682 |
%} |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3683 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3684 |
ObjectMemory fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3685 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3686 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3687 |
! |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3688 |
|
1795 | 3689 |
fullSingleStepSupport:aBoolean |
10226 | 3690 |
"enable/disable full single step support for the just-in-time-compiled code. |
1795 | 3691 |
If off, things like simple increment/decrement, additions and variable- |
3692 |
stores are not steppable, but treated like atomar invisible operations. |
|
10226 | 3693 |
If on, single step halts at those operations. |
1795 | 3694 |
Execution is a bit slower if enabled." |
3695 |
||
3696 |
%{ /* NOCONTEXT */ |
|
3697 |
extern int __fullSingleStep(); |
|
3698 |
int prev; |
|
3699 |
||
3700 |
prev = __fullSingleStep(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3701 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3702 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3703 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3704 |
: -1); |
1795 | 3705 |
RETURN (prev ? true : false); |
3706 |
%} |
|
3707 |
" |
|
3708 |
ObjectMemory fullSingleStepSupport:true |
|
3709 |
ObjectMemory fullSingleStepSupport:false |
|
3710 |
" |
|
3711 |
||
3712 |
! |
|
3713 |
||
3714 |
getCompiledCodeLimit |
|
3715 |
"get the codeLimit from the VM" |
|
3716 |
||
3717 |
%{ /* NOCONTEXT */ |
|
3718 |
extern int __dynamicCodeLimit(); |
|
3719 |
int limit; |
|
3720 |
||
3721 |
limit = __dynamicCodeLimit(); |
|
3722 |
if (limit) { |
|
8913 | 3723 |
RETURN (__mkSmallInteger(limit)); |
1795 | 3724 |
} |
3725 |
RETURN (nil); |
|
3726 |
%} |
|
3727 |
! |
|
3728 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3729 |
insnSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3730 |
"set a limit on a methods number of internal insns. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3731 |
Compilation of a method into machine code is aborted, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3732 |
if during compilation, more than the given number of |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3733 |
internal insns are generated. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3734 |
The limit controls the amount of dynamic memory allocated |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3735 |
during compilation and may be changed for small-memory |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3736 |
systems. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3737 |
The predefined limit is some 4k (which seems to be ok)." |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3738 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3739 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3740 |
extern int __insnSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3741 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3742 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3743 |
prev = __insnSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3744 |
? __intVal(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3745 |
: -1); |
8913 | 3746 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3747 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3748 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3749 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3750 |
ObjectMemory insnSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3751 |
ObjectMemory insnSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3752 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3753 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3754 |
|
3912 | 3755 |
javaJustInTimeCompilation |
3756 |
"return the value of the java-just-in-time-compilation flag" |
|
3757 |
||
3758 |
%{ /* NOCONTEXT */ |
|
3759 |
extern int __javaJustInTimeCompilation(); |
|
3760 |
||
3761 |
RETURN (__javaJustInTimeCompilation(-1) ? true : false); |
|
3762 |
%} |
|
3763 |
" |
|
3764 |
ObjectMemory javaJustInTimeCompilation |
|
3765 |
" |
|
3766 |
||
3767 |
! |
|
3768 |
||
3769 |
javaJustInTimeCompilation:aBoolean |
|
3770 |
"enable/disable java just-in-time-compilation." |
|
3771 |
||
3772 |
aBoolean notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3773 |
JavaJustInTimeCompilationEnabled := aBoolean. |
3912 | 3774 |
]. |
3775 |
||
3776 |
%{ /* NOCONTEXT */ |
|
3777 |
extern int __javaJustInTimeCompilation(); |
|
3778 |
int prev; |
|
3779 |
||
3780 |
prev = __javaJustInTimeCompilation(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3781 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3782 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3783 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3784 |
: -1); |
3912 | 3785 |
RETURN (prev ? true : false); |
3786 |
%}. |
|
3787 |
" |
|
3788 |
ObjectMemory javaJustInTimeCompilation:true |
|
3789 |
ObjectMemory javaJustInTimeCompilation:false |
|
3790 |
" |
|
3791 |
! |
|
3792 |
||
3793 |
javaNativeCodeOptimization |
|
3794 |
"return the value of the java-native-code-optimization flag" |
|
3795 |
||
3796 |
%{ /* NOCONTEXT */ |
|
3797 |
extern int __javaNativeCodeOptimization(); |
|
3798 |
||
3799 |
RETURN (__javaNativeCodeOptimization(-1) ? true : false); |
|
3800 |
%} |
|
3801 |
" |
|
3802 |
ObjectMemory javaNativeCodeOptimization |
|
3803 |
" |
|
3804 |
||
3805 |
! |
|
3806 |
||
3807 |
javaNativeCodeOptimization:aBoolean |
|
3808 |
"enable/disable java native code-optimization." |
|
3809 |
||
3810 |
aBoolean notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3811 |
JavaNativeCodeOptimization := aBoolean. |
3912 | 3812 |
]. |
3813 |
||
3814 |
%{ /* NOCONTEXT */ |
|
3815 |
extern int __javaNativeCodeOptimization(); |
|
3816 |
int prev; |
|
3817 |
||
3818 |
prev = __javaNativeCodeOptimization(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3819 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3820 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3821 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3822 |
: -1); |
3912 | 3823 |
RETURN (prev ? true : false); |
3824 |
%}. |
|
3825 |
" |
|
3826 |
ObjectMemory javaNativeCodeOptimization:true |
|
3827 |
ObjectMemory javaNativeCodeOptimization:false |
|
3828 |
" |
|
3829 |
! |
|
3830 |
||
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3831 |
justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3832 |
"return the value of the just-in-time-compilation flag" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3833 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3834 |
%{ /* NOCONTEXT */ |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3835 |
extern int __justInTimeCompilation(); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3836 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3837 |
RETURN (__justInTimeCompilation(-1) ? true : false); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3838 |
%} |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3839 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3840 |
ObjectMemory justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3841 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3842 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3843 |
! |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3844 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3845 |
justInTimeCompilation:aBoolean |
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3846 |
"enable/disable just-in-time-compilation." |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3847 |
|
1939
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3848 |
aBoolean notNil ifTrue:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3849 |
JustInTimeCompilationEnabled := aBoolean. |
1939
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3850 |
]. |
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3851 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3852 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3853 |
extern int __justInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3854 |
int prev; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3855 |
|
1657 | 3856 |
prev = __justInTimeCompilation(aBoolean == true |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3857 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3858 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3859 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3860 |
: -1); |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3861 |
RETURN (prev ? true : false); |
2017 | 3862 |
%}. |
1767 | 3863 |
" |
3864 |
ObjectMemory justInTimeCompilation:true |
|
3865 |
ObjectMemory justInTimeCompilation:false |
|
3866 |
" |
|
2017 | 3867 |
! |
3868 |
||
1940 | 3869 |
reEnableJustInTimeCompilation |
3870 |
"to be called after a snapshot restart; if justInTimeCompiler |
|
10226 | 3871 |
was enabled before, do it again. |
1940 | 3872 |
For now, this is not done automatically, to allow restarting |
3873 |
a system with the dynamic compiler turned off (its still experimental). |
|
3874 |
Therefore, this reenabling is done in the smalltalk_r.rc file." |
|
3875 |
||
3876 |
JustInTimeCompilationEnabled == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3877 |
self justInTimeCompilation:true |
3913 | 3878 |
]. |
3879 |
JavaJustInTimeCompilationEnabled == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3880 |
self javaJustInTimeCompilation:true |
3913 | 3881 |
]. |
3882 |
JavaNativeCodeOptimization == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3883 |
self javaNativeCodeOptimization:true |
3913 | 3884 |
]. |
3885 |
||
3886 |
"Modified: / 5.11.1998 / 15:00:00 / cg" |
|
1940 | 3887 |
! |
3888 |
||
1770 | 3889 |
resetCompiledCodeCounter |
3890 |
"reset the counter of additional code-bytes" |
|
3891 |
||
3892 |
%{ /* NOCONTEXT */ |
|
3893 |
||
3894 |
extern void __resetDynamicCodeGeneratedCounter(); |
|
3895 |
||
3896 |
__resetDynamicCodeGeneratedCounter(); |
|
3897 |
%} |
|
3898 |
" |
|
3899 |
ObjectMemory resetCompiledCodeCounter |
|
3900 |
" |
|
3901 |
||
3902 |
! |
|
3903 |
||
1769 | 3904 |
setCompiledCodeLimit:newLimit |
3905 |
"set the VM's limit" |
|
3906 |
||
3907 |
%{ /* NOCONTEXT */ |
|
3908 |
extern __setDynamicCodeLimit(); |
|
3909 |
||
3910 |
if (__isSmallInteger(newLimit)) { |
|
3911 |
__setDynamicCodeLimit(__intVal(newLimit)); |
|
3912 |
} else if (newLimit == nil) { |
|
3913 |
__setDynamicCodeLimit(0); |
|
3914 |
} |
|
3915 |
%} |
|
3916 |
! |
|
3917 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3918 |
supportsJustInTimeCompilation |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3919 |
"return true, if this system supports just-in-time-compilation of |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3920 |
bytecode to machine code. Dont confuse this with stc-compilation." |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3921 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3922 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3923 |
extern int __canDoJustInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3924 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3925 |
RETURN (__canDoJustInTimeCompilation() ? true : false); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3926 |
%} |
1767 | 3927 |
" |
3928 |
ObjectMemory supportsJustInTimeCompilation |
|
3929 |
" |
|
3930 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3931 |
! ! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3932 |
|
1767 | 3933 |
!ObjectMemory class methodsFor:'low memory handling'! |
615 | 3934 |
|
3781 | 3935 |
allocationFailed |
3936 |
"memory allocation has failed in the VM |
|
3937 |
This is triggered by the runtime system (or possibly by |
|
3938 |
a user primitive)" |
|
3939 |
||
8963
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3940 |
^ AllocationFailure raiseRequest |
3781 | 3941 |
! |
3942 |
||
1288 | 3943 |
memoryInterrupt |
3944 |
"when a low-memory condition arises, ask all classes to |
|
3945 |
remove possibly cached data. You may help the system a bit, |
|
3946 |
in providing a lowSpaceCleanup method in your classes which have |
|
3947 |
lots of data kept somewhere (usually, cached data). |
|
3948 |
- this may or may not help." |
|
3949 |
||
11747 | 3950 |
self changed:#memoryLow. |
1288 | 3951 |
self performLowSpaceCleanup. |
3952 |
"/ self error:'almost out of memory' |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3953 |
'ObjectMemory [warning]: almost out of memory' errorPrintCR. |
615 | 3954 |
|
3955 |
LowSpaceSemaphore signalIf. |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
3956 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3957 |
"Modified: 10.1.1997 / 17:59:31 / cg" |
1288 | 3958 |
! |
3959 |
||
3960 |
performLowSpaceCleanup |
|
10226 | 3961 |
"ask all classes to remove possibly cached data. |
3962 |
You may help the system a bit, in providing a lowSpaceCleanup method |
|
1288 | 3963 |
in your classes which have lots of data kept somewhere (usually, cached data)." |
3964 |
||
8963
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3965 |
"avoid to allocate memory here - so don't send Smalltalk>>allClassesDo:, |
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3966 |
which allocates an IdentitySet" |
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3967 |
|
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3968 |
Smalltalk do:[:eachGlobal| |
10226 | 3969 |
eachGlobal isBehavior ifTrue:[ |
3970 |
eachGlobal lowSpaceCleanup |
|
3971 |
]. |
|
1288 | 3972 |
]. |
3973 |
||
10226 | 3974 |
" |
8963
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3975 |
ObjectMemory performLowSpaceCleanup |
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3976 |
" |
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
3977 |
|
1288 | 3978 |
"Created: 12.4.1996 / 14:57:28 / cg" |
362 | 3979 |
! ! |
3980 |
||
1767 | 3981 |
!ObjectMemory class methodsFor:'object finalization'! |
290 | 3982 |
|
1288 | 3983 |
allChangedShadowObjectsDo:aBlock |
3984 |
"evaluate the argument, aBlock for all known shadow objects which have |
|
3985 |
lost a pointer recently." |
|
290 | 3986 |
%{ |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
3987 |
__allChangedShadowObjectsDo(&aBlock); |
290 | 3988 |
%} |
3989 |
! |
|
3990 |
||
3733 | 3991 |
backgroundFinalizationProcess |
3992 |
"return the backgroundFinalizationProcess (or nil, if noone is running)" |
|
3993 |
||
3994 |
^ BackgroundFinalizationProcess |
|
3995 |
||
3996 |
"Created: / 4.8.1998 / 02:00:13 / cg" |
|
3997 |
! |
|
3998 |
||
1288 | 3999 |
disposeInterrupt |
4000 |
"this is triggered by the garbage collector, |
|
4001 |
whenever any shadowArray looses a pointer." |
|
4002 |
||
4003 |
FinalizationSemaphore notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4004 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4005 |
"/ background finalizer is waiting ... |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4006 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4007 |
FinalizationSemaphore signalOnce |
290 | 4008 |
] ifFalse:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4009 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4010 |
"/ do it right here |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4011 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4012 |
self finalize |
290 | 4013 |
] |
2160
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
4014 |
|
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
4015 |
"Modified: 13.1.1997 / 17:26:16 / cg" |
290 | 4016 |
! |
4017 |
||
1288 | 4018 |
finalize |
4019 |
"tell all weak objects that something happened." |
|
4020 |
||
10226 | 4021 |
self allChangedShadowObjectsDo:[:aShadowArray | |
4022 |
Error handle:[:ex | |
|
4023 |
'ObjectMemory [warning]: cought error in weakArray processing: ' errorPrint. |
|
4024 |
ex description errorPrintCR. |
|
4025 |
ex suspendedContext fullPrintAllLevels:10. |
|
4026 |
"Restart the do block to clean up the rest of the shadow array. |
|
4027 |
This is safe here, because the old executor that triggered the error |
|
4028 |
has already been removed from the Registry" |
|
4029 |
ex restart. |
|
4030 |
] do:[ |
|
4031 |
aShadowArray lostPointer. |
|
4032 |
]. |
|
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4033 |
]. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4034 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4035 |
"/ we should change the setup, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4036 |
"/ to make the Dependencies collection a dependent |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4037 |
"/ of all the WeakArrays and WeakIDSets there, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4038 |
"/ and send a changed message when any of them looses |
10226 | 4039 |
"/ a pointer. |
2100 | 4040 |
"/ This would automize the send below. |
4041 |
"/ |
|
4042 |
"/ WARNING: |
|
4043 |
"/ this can only be done, if the WeakIDSet holds its |
|
10226 | 4044 |
"/ dependends itself (like a WeakArray), |
2100 | 4045 |
"/ otherwise we might get trouble. |
4046 |
"/ Therefore, things are as they are now ;-) |
|
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4047 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4048 |
Dependencies removeEmptyDependencyValues |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4049 |
|
3885
b699abd9476f
catch errors while finalizing
Claus Gittinger <cg@exept.de>
parents:
3859
diff
changeset
|
4050 |
"Modified: / 19.10.1998 / 22:03:12 / cg" |
4675 | 4051 |
"Modified: / 3.9.1999 / 14:03:05 / ps" |
615 | 4052 |
! |
4053 |
||
1288 | 4054 |
startBackgroundFinalizationAt:aPriority |
4055 |
"start a process doing finalization work in the background. |
|
4056 |
Can be used to reduce the pauses created by finalization. |
|
4057 |
Normally, these pauses are not noticed; however if you have (say) |
|
4058 |
ten thousands of weak objects, these could become long enough to |
|
4059 |
make background finalization usefull. |
|
4060 |
WARNING: background finalization may lead to much delayed freeing of |
|
4061 |
system resources. Especially, you may temporarily run out of free |
|
4062 |
color table entries or fileDescriptors etc. Use at your own risk (if at all)" |
|
4063 |
||
4064 |
|p| |
|
4065 |
||
4066 |
"/ |
|
4067 |
"/ its not useful, to run it more than once |
|
4068 |
"/ |
|
4069 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4070 |
BackgroundFinalizationProcess priority:aPriority. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4071 |
^ self |
1288 | 4072 |
]. |
4073 |
||
2262 | 4074 |
FinalizationSemaphore := Semaphore new name:'FinalizationSemaphore'. |
1288 | 4075 |
|
4076 |
p := |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4077 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4078 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4079 |
[true] whileTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4080 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4081 |
wait till something to do ... |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4082 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4083 |
FinalizationSemaphore wait. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4084 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4085 |
... and do it |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4086 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4087 |
self finalize |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4088 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4089 |
] ifCurtailed:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4090 |
BackgroundFinalizationProcess := nil. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4091 |
FinalizationSemaphore := nil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4092 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4093 |
] newProcess. |
1288 | 4094 |
p name:'background finalizer'. |
4095 |
p priority:aPriority. |
|
4096 |
p restartable:true. |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
4097 |
p beSystemProcess. |
1288 | 4098 |
p resume. |
4099 |
BackgroundFinalizationProcess := p |
|
290 | 4100 |
|
4101 |
" |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
4102 |
ObjectMemory stopBackgroundFinalization. |
290 | 4103 |
ObjectMemory startBackgroundFinalizationAt:5 |
4104 |
" |
|
3733 | 4105 |
|
4106 |
"Modified: / 5.8.1998 / 14:53:27 / cg" |
|
1288 | 4107 |
! |
4108 |
||
4109 |
stopBackgroundFinalization |
|
4110 |
"stop the background finalizer" |
|
4111 |
||
4112 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
4113 |
BackgroundFinalizationProcess terminate. |
|
4114 |
BackgroundFinalizationProcess := nil |
|
4115 |
]. |
|
4116 |
||
4117 |
" |
|
4118 |
ObjectMemory stopBackgroundFinalization |
|
4119 |
" |
|
290 | 4120 |
! ! |
4121 |
||
1767 | 4122 |
!ObjectMemory class methodsFor:'physical memory access'! |
93 | 4123 |
|
1288 | 4124 |
collectedOldSpacePagesDo:aBlock |
4125 |
"evaluates aBlock for all pages in the prev. oldSpace, passing |
|
10226 | 4126 |
the pages address as argument. |
1288 | 4127 |
For internal & debugging use only." |
4128 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4129 |
if (__collectedOldSpacePagesDo(&aBlock) < 0) { |
615 | 4130 |
RETURN (false); |
4131 |
} |
|
4132 |
%}. |
|
4133 |
^ true |
|
4134 |
! |
|
4135 |
||
1288 | 4136 |
newSpacePagesDo:aBlock |
4137 |
"evaluates aBlock for all pages in the newSpace, passing |
|
4138 |
the pages address as argument. |
|
4139 |
For internal & debugging use only." |
|
4140 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4141 |
if (__newSpacePagesDo(&aBlock) < 0) { |
159 | 4142 |
RETURN (false); |
85 | 4143 |
} |
4144 |
%}. |
|
4145 |
^ true |
|
4146 |
! |
|
4147 |
||
1288 | 4148 |
oldSpacePagesDo:aBlock |
4149 |
"evaluates aBlock for all pages in the oldSpace, passing |
|
10226 | 4150 |
the pages address as argument. |
1288 | 4151 |
For internal & debugging use only." |
4152 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4153 |
if (__oldSpacePagesDo(&aBlock) < 0) { |
1286 | 4154 |
RETURN (false); |
85 | 4155 |
} |
4156 |
%}. |
|
4157 |
^ true |
|
1288 | 4158 |
! |
4159 |
||
4160 |
pageIsInCore:aPageNumber |
|
4161 |
"return true, if the page (as enumerated via oldSpacePagesDo:) |
|
4162 |
is in memory; false, if currently paged out. For internal |
|
4163 |
use / monitors only; may vanish. |
|
4164 |
NOTICE: not all systems provide this information; on those that |
|
4165 |
do not, true is returned for all pages." |
|
4166 |
%{ |
|
4167 |
#ifdef HAS_MINCORE |
|
4168 |
int pageSize = getpagesize(); |
|
4169 |
char result[10]; |
|
4170 |
INT addr; |
|
4171 |
||
4172 |
if (__isSmallInteger(aPageNumber)) { |
|
4173 |
addr = __intVal(aPageNumber) & ~(pageSize - 1); |
|
4174 |
} else { |
|
4175 |
addr = ((INT)aPageNumber) & ~(pageSize - 1); |
|
4176 |
} |
|
4177 |
if (mincore(addr, pageSize-1, result) < 0) { |
|
4178 |
RETURN (true); |
|
4179 |
} |
|
4180 |
RETURN ((result[0] & 1) ? true : false); |
|
4181 |
#endif |
|
4182 |
%}. |
|
4183 |
"OS does not supply this info - assume yes" |
|
4184 |
^ true |
|
85 | 4185 |
! ! |
4186 |
||
1767 | 4187 |
!ObjectMemory class methodsFor:'queries'! |
615 | 4188 |
|
1288 | 4189 |
bytesUsed |
4190 |
"return the number of bytes allocated for objects - |
|
4191 |
this number is not exact, since some objects may already be dead |
|
4192 |
(i.e. not yet reclaimed by the garbage collector). |
|
4193 |
If you need the exact number, you have to loop over all |
|
4194 |
objects and ask for the bytesize using ObjectMemory>>sizeOf:." |
|
4195 |
||
4196 |
%{ /* NOCONTEXT */ |
|
4197 |
extern unsigned __oldSpaceUsed(), __newSpaceUsed(), __freeListSpace(); |
|
4198 |
||
8913 | 4199 |
RETURN ( __mkSmallInteger(__oldSpaceUsed() + __newSpaceUsed() - __freeListSpace()) ); |
615 | 4200 |
%} |
4201 |
" |
|
10226 | 4202 |
ObjectMemory bytesUsed |
615 | 4203 |
" |
4204 |
! |
|
4205 |
||
1288 | 4206 |
collectObjectsWhich:aBlock |
4207 |
"helper for the whoReferences queries. Returns a collection |
|
4208 |
of objects for which aBlock returns true." |
|
4209 |
||
4210 |
|aCollection| |
|
4211 |
||
4212 |
aCollection := IdentitySet new. |
|
4213 |
self allObjectsDo:[:o | |
|
4214 |
(aBlock value:o) ifTrue:[ |
|
4215 |
aCollection add:o |
|
4216 |
] |
|
4217 |
]. |
|
4218 |
(aCollection size == 0) ifTrue:[ |
|
615 | 4219 |
"actually this cannot happen - there is always one" |
4220 |
^ nil |
|
4221 |
]. |
|
4222 |
^ aCollection |
|
4223 |
! |
|
4224 |
||
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4225 |
collectedOldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4226 |
%{ |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4227 |
RETURN(__MKUINT(COLLECTEDOLD_ADDRESS)); |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4228 |
%} |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4229 |
|
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4230 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4231 |
self collectedOldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4232 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4233 |
! |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4234 |
|
1288 | 4235 |
fixSpaceSize |
4236 |
"return the total size of the fix space." |
|
4237 |
||
4238 |
%{ /* NOCONTEXT */ |
|
4239 |
extern unsigned __fixSpaceSize(); |
|
4240 |
||
8913 | 4241 |
RETURN ( __mkSmallInteger(__fixSpaceSize()) ); |
615 | 4242 |
%} |
4243 |
" |
|
4244 |
ObjectMemory fixSpaceSize |
|
4245 |
" |
|
4246 |
! |
|
4247 |
||
1288 | 4248 |
fixSpaceUsed |
4249 |
"return the number of bytes allocated for old objects in fix space." |
|
4250 |
||
4251 |
%{ /* NOCONTEXT */ |
|
4252 |
extern unsigned __fixSpaceUsed(); |
|
4253 |
||
8913 | 4254 |
RETURN ( __mkSmallInteger(__fixSpaceUsed()) ); |
615 | 4255 |
%} |
4256 |
" |
|
4257 |
ObjectMemory fixSpaceUsed |
|
4258 |
" |
|
4259 |
! |
|
4260 |
||
1288 | 4261 |
freeListSpace |
4262 |
"return the number of bytes in the free lists. |
|
4263 |
(which is included in oldSpaceUsed)" |
|
4264 |
||
4265 |
%{ /* NOCONTEXT */ |
|
4266 |
extern unsigned __freeListSpace(); |
|
4267 |
||
8913 | 4268 |
RETURN ( __mkSmallInteger(__freeListSpace()) ); |
615 | 4269 |
%} |
4270 |
" |
|
4271 |
ObjectMemory freeListSpace |
|
4272 |
" |
|
4273 |
! |
|
4274 |
||
1288 | 4275 |
freeSpace |
4276 |
"return the number of bytes in the compact free area. |
|
4277 |
(oldSpaceUsed + freeSpaceSize = oldSpaceSize)" |
|
4278 |
||
4279 |
%{ /* NOCONTEXT */ |
|
4280 |
extern unsigned __oldSpaceSize(), __oldSpaceUsed(); |
|
4281 |
||
8913 | 4282 |
RETURN ( __mkSmallInteger(__oldSpaceSize() - __oldSpaceUsed()) ); |
615 | 4283 |
%} |
4284 |
" |
|
4285 |
ObjectMemory freeSpace |
|
4286 |
" |
|
4287 |
! |
|
4288 |
||
1288 | 4289 |
garbageCollectCount |
4290 |
"return the number of compressing collects that occurred since startup" |
|
4291 |
||
4292 |
%{ /* NOCONTEXT */ |
|
4293 |
extern int __garbageCollectCount(); |
|
4294 |
||
8913 | 4295 |
RETURN (__mkSmallInteger(__garbageCollectCount())); |
615 | 4296 |
%} |
4297 |
" |
|
10226 | 4298 |
ObjectMemory garbageCollectCount |
615 | 4299 |
" |
4300 |
! |
|
4301 |
||
1288 | 4302 |
incrementalGCCount |
4303 |
"return the number of incremental collects that occurred since startup" |
|
4304 |
||
4305 |
%{ /* NOCONTEXT */ |
|
4306 |
extern int __incrementalGCCount(); |
|
4307 |
||
8913 | 4308 |
RETURN (__mkSmallInteger(__incrementalGCCount())); |
615 | 4309 |
%} |
4310 |
" |
|
4311 |
ObjectMemory incrementalGCCount |
|
4312 |
" |
|
4313 |
! |
|
4314 |
||
1288 | 4315 |
incrementalGCPhase |
4316 |
"returns the internal state of the incremental GC. |
|
4317 |
The meaning of those numbers is a secret :-). |
|
4318 |
(for the curious: (currently) |
|
4319 |
2 is idle, 3..11 are various mark phases, |
|
4320 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4321 |
incr. GC gets interrupted by a full GC). |
|
4322 |
Do not depend on the values - there may be additional phases in |
|
4323 |
future versions (incremental compact ;-). |
|
4324 |
This is for debugging and monitoring only - and may change or vanish" |
|
4325 |
||
4326 |
%{ /* NOCONTEXT */ |
|
615 | 4327 |
extern int __incrGCphase(); |
4328 |
||
8913 | 4329 |
RETURN (__mkSmallInteger(__incrGCphase())); |
615 | 4330 |
%} |
4331 |
! |
|
4332 |
||
3742 | 4333 |
incrementalGCPhaseSymbolic |
4334 |
"returns the internal state of the incremental GC |
|
4335 |
in a symbolic form. |
|
4336 |
(for the curious: (currently) |
|
4337 |
2 is idle, 3..11 are various mark phases, |
|
4338 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4339 |
incr. GC gets interrupted by a full GC). |
|
4340 |
Do not depend on the values - there may be additional phases in |
|
4341 |
future versions (incremental compact ;-). |
|
4342 |
This is for debugging and monitoring only - and may change or vanish" |
|
4343 |
||
4344 |
|phase| |
|
4345 |
||
4346 |
phase := self incrementalGCPhase. |
|
4347 |
phase < 2 ifTrue:[^ #cleanup]. |
|
4348 |
phase == 2 ifTrue:[^ #idle]. |
|
4349 |
phase < 12 ifTrue:[^ #marking]. |
|
4350 |
^ #sweeping |
|
4351 |
||
4352 |
"Created: / 10.8.1998 / 15:02:52 / cg" |
|
4353 |
! |
|
4354 |
||
1288 | 4355 |
lastScavengeReclamation |
4356 |
"returns the number of bytes replacimed by the last scavenge. |
|
4357 |
For statistic only - this may vanish." |
|
4358 |
||
4359 |
%{ /* NOCONTEXT */ |
|
4360 |
extern int __newSpaceReclaimed(); |
|
4361 |
||
8913 | 4362 |
RETURN ( __mkSmallInteger(__newSpaceReclaimed()) ); |
1288 | 4363 |
%} |
4364 |
"percentage of reclaimed objects is returned by: |
|
4365 |
||
4366 |
((ObjectMemory lastScavengeReclamation) |
|
10226 | 4367 |
/ (ObjectMemory newSpaceSize)) * 100.0 |
615 | 4368 |
" |
4369 |
! |
|
4370 |
||
1288 | 4371 |
lifoRememberedSet |
4372 |
"return the lifoRemSet. |
|
4373 |
This is pure VM debugging and will vanish without notice." |
|
4374 |
||
4375 |
%{ /* NOCONTEXT */ |
|
4376 |
extern OBJ __lifoRememberedSet(); |
|
4377 |
||
4378 |
RETURN ( __lifoRememberedSet() ); |
|
615 | 4379 |
%} |
4380 |
" |
|
4381 |
ObjectMemory lifoRememberedSet |
|
4382 |
" |
|
4383 |
! |
|
4384 |
||
1288 | 4385 |
lifoRememberedSetSize |
4386 |
"return the size of the lifoRemSet. |
|
4387 |
This is a VM debugging interface and may vanish without notice." |
|
4388 |
||
4389 |
%{ /* NOCONTEXT */ |
|
4390 |
extern int __lifoRememberedSetSize(); |
|
4391 |
||
8913 | 4392 |
RETURN (__mkSmallInteger(__lifoRememberedSetSize())); |
615 | 4393 |
%} |
4394 |
" |
|
4395 |
ObjectMemory lifoRememberedSetSize |
|
4396 |
" |
|
4397 |
! |
|
4398 |
||
1288 | 4399 |
markAndSweepCount |
4400 |
"return the number of mark&sweep collects that occurred since startup" |
|
4401 |
||
4402 |
%{ /* NOCONTEXT */ |
|
4403 |
extern int __markAndSweepCount(); |
|
4404 |
||
8913 | 4405 |
RETURN (__mkSmallInteger(__markAndSweepCount())); |
615 | 4406 |
%} |
4407 |
" |
|
10226 | 4408 |
ObjectMemory markAndSweepCount |
615 | 4409 |
" |
4410 |
! |
|
4411 |
||
1288 | 4412 |
maximumIdentityHashValue |
4413 |
"for ST-80 compatibility: return the maximum value |
|
4414 |
a hashKey as returned by identityHash can get. |
|
4415 |
Since ST/X uses direct pointers, a field in the objectHeader |
|
4416 |
is used, which is currently 11 bits in size." |
|
4417 |
||
4418 |
%{ /* NOCONTEXT */ |
|
8913 | 4419 |
RETURN ( __mkSmallInteger( __MAX_HASH__ << __HASH_SHIFT__) ); |
615 | 4420 |
%} |
4421 |
" |
|
4422 |
ObjectMemory maximumIdentityHashValue |
|
4423 |
" |
|
4424 |
! |
|
4425 |
||
1288 | 4426 |
minScavengeReclamation |
4427 |
"returns the number of bytes replacimed by the least effective scavenge. |
|
4428 |
For statistic only - this may vanish." |
|
4429 |
||
4430 |
%{ /* NOCONTEXT */ |
|
4431 |
extern int __newSpaceReclaimedMin(); |
|
4432 |
||
8913 | 4433 |
RETURN ( __mkSmallInteger(__newSpaceReclaimedMin()) ); |
615 | 4434 |
%} |
4435 |
" |
|
4436 |
ObjectMemory minScavengeReclamation |
|
4437 |
" |
|
4438 |
! |
|
4439 |
||
1288 | 4440 |
newSpaceSize |
4441 |
"return the total size of the new space - this is usually fix" |
|
4442 |
||
4443 |
%{ /* NOCONTEXT */ |
|
4444 |
extern unsigned __newSpaceSize(); |
|
4445 |
||
8913 | 4446 |
RETURN ( __mkSmallInteger(__newSpaceSize()) ); |
615 | 4447 |
%} |
4448 |
" |
|
4449 |
ObjectMemory newSpaceSize |
|
4450 |
" |
|
4451 |
! |
|
4452 |
||
1288 | 4453 |
newSpaceUsed |
4454 |
"return the number of bytes allocated for new objects. |
|
4455 |
The returned value is usually obsolete as soon as you do |
|
4456 |
something with it ..." |
|
4457 |
||
4458 |
%{ /* NOCONTEXT */ |
|
4459 |
extern unsigned __newSpaceUsed(); |
|
4460 |
||
8913 | 4461 |
RETURN ( __mkSmallInteger(__newSpaceUsed()) ); |
615 | 4462 |
%} |
4463 |
" |
|
10226 | 4464 |
ObjectMemory newSpaceUsed |
615 | 4465 |
" |
4466 |
! |
|
4467 |
||
1288 | 4468 |
numberOfObjects |
4469 |
"return the number of objects in the system." |
|
4470 |
||
4471 |
|tally "{ Class: SmallInteger }"| |
|
4472 |
||
4473 |
tally := 0. |
|
4474 |
self allObjectsDo:[:obj | tally := tally + 1]. |
|
615 | 4475 |
^ tally |
4476 |
||
4477 |
" |
|
10226 | 4478 |
ObjectMemory numberOfObjects |
615 | 4479 |
" |
4480 |
! |
|
4481 |
||
1288 | 4482 |
numberOfWeakObjects |
4483 |
"return the number of weak objects in the system" |
|
4484 |
||
4485 |
%{ /* NOCONTEXT */ |
|
4486 |
extern int __weakListSize(); |
|
4487 |
||
8913 | 4488 |
RETURN ( __mkSmallInteger(__weakListSize()) ); |
615 | 4489 |
%} |
4490 |
" |
|
4491 |
ObjectMemory numberOfWeakObjects |
|
4492 |
" |
|
4493 |
! |
|
4494 |
||
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4495 |
oldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4496 |
%{ |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4497 |
RETURN(__MKUINT(OLDSPACE_ADDRESS)); |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4498 |
%} |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4499 |
|
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4500 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4501 |
self oldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4502 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4503 |
! |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4504 |
|
1288 | 4505 |
oldSpaceAllocatedSinceLastGC |
4506 |
"return the number of bytes allocated for old objects since the |
|
4507 |
last oldspace garbage collect occured. This information is used |
|
4508 |
by ProcessorScheduler to decide when to start the incremental |
|
4509 |
background GC." |
|
4510 |
||
4511 |
%{ /* NOCONTEXT */ |
|
4512 |
extern unsigned __oldSpaceAllocatedSinceLastGC(); |
|
4513 |
||
8913 | 4514 |
RETURN ( __mkSmallInteger(__oldSpaceAllocatedSinceLastGC()) ); |
615 | 4515 |
%} |
4516 |
" |
|
10226 | 4517 |
ObjectMemory oldSpaceAllocatedSinceLastGC |
615 | 4518 |
" |
4519 |
! |
|
4520 |
||
1288 | 4521 |
oldSpaceSize |
4522 |
"return the total size of the old space. - may grow slowly" |
|
4523 |
||
4524 |
%{ /* NOCONTEXT */ |
|
4525 |
extern unsigned __oldSpaceSize(); |
|
4526 |
||
8913 | 4527 |
RETURN ( __mkSmallInteger(__oldSpaceSize()) ); |
615 | 4528 |
%} |
4529 |
" |
|
4530 |
ObjectMemory oldSpaceSize |
|
4531 |
" |
|
4532 |
! |
|
4533 |
||
1288 | 4534 |
oldSpaceUsed |
4535 |
"return the number of bytes allocated for old objects. |
|
4536 |
(This includes the free lists)" |
|
4537 |
||
4538 |
%{ /* NOCONTEXT */ |
|
4539 |
extern unsigned __oldSpaceUsed(); |
|
4540 |
||
8913 | 4541 |
RETURN ( __mkSmallInteger(__oldSpaceUsed()) ); |
615 | 4542 |
%} |
4543 |
" |
|
10226 | 4544 |
ObjectMemory oldSpaceUsed |
615 | 4545 |
" |
4546 |
! |
|
4547 |
||
1288 | 4548 |
rememberedSetSize |
4549 |
"return the number of old objects referencing new ones. |
|
4550 |
This is a VM debugging interface and may vanish without notice." |
|
4551 |
||
4552 |
%{ /* NOCONTEXT */ |
|
4553 |
extern int __rememberedSetSize(); |
|
4554 |
||
8913 | 4555 |
RETURN (__mkSmallInteger(__rememberedSetSize())); |
615 | 4556 |
%} |
4557 |
" |
|
4558 |
ObjectMemory rememberedSetSize |
|
4559 |
" |
|
4560 |
! |
|
4561 |
||
1288 | 4562 |
resetMinScavengeReclamation |
4563 |
"resets the number of bytes replacimed by the least effective scavenge. |
|
4564 |
For statistic only - this may vanish." |
|
4565 |
||
4566 |
%{ /* NOCONTEXT */ |
|
4567 |
extern int __resetNewSpaceReclaimedMin(); |
|
4568 |
||
4569 |
__resetNewSpaceReclaimedMin(); |
|
4570 |
%}. |
|
4571 |
^ self |
|
4572 |
" |
|
4573 |
ObjectMemory resetMinScavengeReclamation. |
|
615 | 4574 |
ObjectMemory minScavengeReclamation |
4575 |
" |
|
4576 |
! |
|
4577 |
||
1288 | 4578 |
runsSingleOldSpace |
4579 |
"return true, if the system runs in a single oldSpace or |
|
4580 |
false if not. |
|
10226 | 4581 |
The memory system will always drop the second semispace when |
1288 | 4582 |
running out of virtual memory, or the baker-limit is reached. |
10226 | 4583 |
OBSOLETE: |
4584 |
the system may now decide at any time to switch between |
|
4585 |
single and double-space algorithms, depending on the overall memory |
|
4586 |
size. You will now almost always get true as result, since the |
|
4587 |
second semispace is only allocated when needed, and released |
|
4588 |
immediately afterwards. |
|
1288 | 4589 |
" |
4590 |
||
4591 |
%{ /* NOCONTEXT */ |
|
4592 |
extern int __runsSingleOldSpace(); |
|
4593 |
||
4594 |
RETURN ( (__runsSingleOldSpace() ? true : false) ); |
|
615 | 4595 |
%} |
4596 |
" |
|
10226 | 4597 |
ObjectMemory runsSingleOldSpace |
615 | 4598 |
" |
4599 |
! |
|
4600 |
||
1288 | 4601 |
scavengeCount |
4602 |
"return the number of scavenges that occurred since startup" |
|
4603 |
||
4604 |
%{ /* NOCONTEXT */ |
|
4605 |
extern int __scavengeCount(); |
|
4606 |
||
8913 | 4607 |
RETURN (__mkSmallInteger(__scavengeCount())); |
615 | 4608 |
%} |
4609 |
" |
|
10226 | 4610 |
ObjectMemory scavengeCount |
615 | 4611 |
" |
4612 |
! |
|
4613 |
||
1288 | 4614 |
symSpaceSize |
4615 |
"return the total size of the sym space." |
|
4616 |
||
4617 |
%{ /* NOCONTEXT */ |
|
4618 |
extern unsigned __symSpaceSize(); |
|
4619 |
||
8913 | 4620 |
RETURN ( __mkSmallInteger(__symSpaceSize()) ); |
615 | 4621 |
%} |
4622 |
" |
|
4623 |
ObjectMemory symSpaceSize |
|
4624 |
" |
|
4625 |
! |
|
4626 |
||
1288 | 4627 |
symSpaceUsed |
4628 |
"return the number of bytes allocated for old objects in sym space." |
|
4629 |
||
4630 |
%{ /* NOCONTEXT */ |
|
4631 |
extern unsigned __symSpaceUsed(); |
|
4632 |
||
8913 | 4633 |
RETURN ( __mkSmallInteger(__symSpaceUsed()) ); |
615 | 4634 |
%} |
4635 |
" |
|
4636 |
ObjectMemory symSpaceUsed |
|
4637 |
" |
|
4638 |
! |
|
4639 |
||
1288 | 4640 |
tenureAge |
4641 |
"return the current tenure age - thats the number of times |
|
4642 |
an object has to survive scavenges to be moved into oldSpace. |
|
4643 |
For statistic/debugging only - this method may vanish" |
|
4644 |
||
4645 |
%{ /* NOCONTEXT */ |
|
615 | 4646 |
extern unsigned __tenureAge(); |
4647 |
||
8913 | 4648 |
RETURN ( __mkSmallInteger(__tenureAge()) ); |
615 | 4649 |
%} |
4650 |
! |
|
4651 |
||
3181
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4652 |
vmSymbols |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4653 |
"return a collection of symbols used by the VM" |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4654 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4655 |
"/ DO NOT REMOVE THIS METHOD. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4656 |
"/ It is required to force the compiler to create those symbols |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4657 |
"/ in fixed (non-moving) memory. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4658 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4659 |
^ #( |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4660 |
"/ interpreter stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4661 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4662 |
"/ JavaVM stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4663 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4664 |
nativeMethodInvokation |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4665 |
newCleared |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4666 |
monitorEnter: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4667 |
monitorExit: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4668 |
classInit |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4669 |
javaClass |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4670 |
resolve |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4671 |
resolveStatic |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4672 |
) |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4673 |
! |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4674 |
|
1288 | 4675 |
whoReferences:anObject |
4676 |
"return a collection of objects referencing the argument, anObject" |
|
4677 |
||
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4678 |
^ self collectObjectsWhich:[:o | o referencesObject:anObject] |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4679 |
|
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4680 |
" |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4681 |
(ObjectMemory whoReferences:Transcript) printCR |
615 | 4682 |
" |
4683 |
! |
|
4684 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4685 |
whoReferencesAny:aCollection |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4686 |
"return a collection of objects referencing any object from |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4687 |
the argument, aCollection" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4688 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4689 |
^ self collectObjectsWhich:[:o | o referencesAny:aCollection] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4690 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4691 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4692 |
ObjectMemory whoReferencesAny:(Array with:Transcript with:Smalltalk) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4693 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4694 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4695 |
"Modified: / 2.2.1998 / 16:08:18 / cg" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4696 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4697 |
|
1288 | 4698 |
whoReferencesDerivedInstancesOf:aClass |
4699 |
"return a collection of objects refering to instances |
|
4700 |
of the argument, aClass or a subclass of it." |
|
4701 |
||
4702 |
^ self collectObjectsWhich:[:o | o referencesDerivedInstanceOf:aClass] |
|
615 | 4703 |
|
4704 |
" |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4705 |
(ObjectMemory whoReferencesDerivedInstancesOf:View) printCR |
615 | 4706 |
" |
1288 | 4707 |
! |
4708 |
||
4709 |
whoReferencesInstancesOf:aClass |
|
4710 |
"return a collection of objects refering to instances |
|
4711 |
of the argument, aClass" |
|
4712 |
||
4713 |
^ self collectObjectsWhich:[:o | o referencesInstanceOf:aClass] |
|
4714 |
||
4715 |
" |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4716 |
(ObjectMemory whoReferencesInstancesOf:SystemBrowser) printCR |
1288 | 4717 |
" |
615 | 4718 |
! ! |
4719 |
||
1767 | 4720 |
!ObjectMemory class methodsFor:'semaphore access'! |
615 | 4721 |
|
1288 | 4722 |
lowSpaceSemaphore |
4723 |
"return the semaphore that is signalled when the system detects a |
|
4724 |
low space condition. Usually, some time after this, an allocationFailure |
|
4725 |
will happen. You can have a cleanup process sitting in that semaphore and |
|
4726 |
start to release object." |
|
379 | 4727 |
|
1286 | 4728 |
^ LowSpaceSemaphore |
379 | 4729 |
! ! |
4730 |
||
1767 | 4731 |
!ObjectMemory class methodsFor:'statistics'! |
1288 | 4732 |
|
4733 |
ageStatistic |
|
2524 | 4734 |
"for ST/X developers only: |
4735 |
dump contents of newSpace with objects age information. |
|
4736 |
This method may be removed without notice" |
|
4737 |
||
1288 | 4738 |
%{ /* NOCONTEXT */ |
1286 | 4739 |
|
4740 |
__ageStatistics(); |
|
4741 |
%} |
|
2524 | 4742 |
" |
4743 |
ObjectMemory ageStatistic |
|
4744 |
" |
|
4745 |
! |
|
4746 |
||
4747 |
codeCacheInfo |
|
4748 |
"for ST/X developers only: |
|
4749 |
dump contents of dynamic code cache LRU lists. |
|
4750 |
This method may be removed without notice" |
|
4751 |
||
4752 |
%{ /* NOCONTEXT */ |
|
2525 | 4753 |
OBJ __codeCacheInfo(); |
2524 | 4754 |
|
4755 |
RETURN (__codeCacheInfo()); |
|
4756 |
%} |
|
4757 |
" |
|
4758 |
ObjectMemory codeCacheInfo do:[:item | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4759 |
|n nMethods nBytes| |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4760 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4761 |
n := item at:1. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4762 |
nMethods := item at:2. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4763 |
nBytes := item at:3. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4764 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4765 |
n isNil ifTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4766 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4767 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4768 |
(n printStringLeftPaddedTo:2) print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4769 |
]. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4770 |
' ' print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4771 |
(nMethods printStringLeftPaddedTo:4) print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4772 |
' ' print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4773 |
(nBytes printStringLeftPaddedTo:6) printCR. |
2524 | 4774 |
] |
4775 |
" |
|
4776 |
||
1288 | 4777 |
! ! |
4778 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4779 |
!ObjectMemory class methodsFor:'system configuration queries'! |
1288 | 4780 |
|
4781 |
allBinaryModulesDo:aBlock |
|
4782 |
"internal private method - walk over all known binary |
|
4783 |
modules and evaluate aBlock for each entry. |
|
4784 |
Do not depend on the information returned for each - this may |
|
418 | 4785 |
change without notice." |
4786 |
||
4787 |
%{ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4788 |
__REGISTRATION_DO_BLOCK5__(&aBlock COMMA_SND); |
418 | 4789 |
%} |
4790 |
! |
|
4791 |
||
1288 | 4792 |
binaryModuleInfo |
4793 |
"return a collection of moduleInfo entries. |
|
4794 |
This returns a dictionary (keys are internal moduleIDs) |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4795 |
with one entry for each binary package (module)." |
1288 | 4796 |
|
4797 |
|modules| |
|
4798 |
||
4799 |
modules := IdentityDictionary new. |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4800 |
self allBinaryModulesDo:[:idArg :nameArg :flagsArg :libName :timeStamp | |
12922 | 4801 |
|type subModuleName module dynamic infoRec handle pathName |
4802 |
typeName name nameString| |
|
4803 |
||
4804 |
nameArg class == String ifFalse:[ |
|
4805 |
'Error in binaryModuleInfo - skip entry' errorPrintCR. |
|
4806 |
] ifTrue:[ |
|
4807 |
name := nameArg. |
|
4808 |
subModuleName := name asSymbol. |
|
4809 |
||
4810 |
idArg > 0 ifTrue:[ |
|
4811 |
dynamic := true. |
|
4812 |
typeName := 'dynamic '. |
|
4813 |
handle := ObjectFileLoader handleFromID:idArg. |
|
4814 |
(handle isNil or:[(pathName := handle pathName) isNil]) ifTrue:[ |
|
4815 |
name := '?' |
|
4816 |
] ifFalse:[ |
|
4817 |
name := pathName asFilename baseName |
|
4818 |
] |
|
4819 |
] ifFalse:[ |
|
4820 |
dynamic := false. |
|
4821 |
typeName := 'builtIn '. |
|
4822 |
pathName := nil. |
|
4823 |
libName isNil ifTrue:[ |
|
4824 |
name := subModuleName |
|
4825 |
] ifFalse:[ |
|
4826 |
name := libName |
|
4827 |
]. |
|
4828 |
]. |
|
4829 |
nameString := typeName. |
|
4830 |
libName isNil ifTrue:[ |
|
4831 |
nameString := nameString, 'module ' |
|
4832 |
] ifFalse:[ |
|
4833 |
nameString := nameString, 'classLib ' |
|
4834 |
]. |
|
4835 |
nameString := nameString , name. |
|
4836 |
||
4837 |
libName isNil ifTrue:[ |
|
4838 |
type := #classObject |
|
4839 |
] ifFalse:[ |
|
4840 |
type := #classLibrary |
|
4841 |
]. |
|
4842 |
||
4843 |
infoRec := modules at:idArg ifAbsent:nil. |
|
4844 |
infoRec notNil ifTrue:[ |
|
4845 |
infoRec classNames add:subModuleName. |
|
4846 |
] ifFalse:[ |
|
4847 |
infoRec := BinaryModuleDescriptor |
|
4848 |
name:nameString |
|
4849 |
type:type |
|
4850 |
id:idArg |
|
4851 |
dynamic:dynamic |
|
4852 |
classNames:( (OrderedSet ? Set) with:subModuleName) |
|
4853 |
handle:handle |
|
4854 |
pathName:pathName |
|
4855 |
libraryName:libName |
|
4856 |
timeStamp:nil. |
|
4857 |
||
4858 |
modules at:idArg put:infoRec. |
|
4859 |
]. |
|
4860 |
]. |
|
1288 | 4861 |
]. |
4862 |
^ modules |
|
4863 |
||
4864 |
" |
|
4865 |
ObjectMemory binaryModuleInfo |
|
418 | 4866 |
" |
4867 |
||
438 | 4868 |
"Modified: 17.9.1995 / 16:33:02 / claus" |
2580
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4869 |
"Modified: 22.4.1997 / 23:42:59 / cg" |
418 | 4870 |
! |
4871 |
||
1288 | 4872 |
fullBinaryModuleInfo |
4873 |
"return a full collection of moduleInfo entries. |
|
4874 |
This returns a dictionary (keys are component names) |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4875 |
with one entry for each sub-component in all binary packages." |
1288 | 4876 |
|
4877 |
|modules| |
|
4878 |
||
4879 |
modules := IdentityDictionary new. |
|
10226 | 4880 |
self allBinaryModulesDo:[:entry | |
4881 |
|infoEntry |
|
4882 |
id name type libName subModuleName module dynamic pathName t| |
|
4883 |
||
4884 |
id := entry at:1. |
|
4885 |
subModuleName := (entry at:2) asSymbol. |
|
4886 |
libName := (entry at:4). |
|
4887 |
t := Timestamp fromOSTime:((entry at:5) * 1000). |
|
4888 |
||
4889 |
id > 0 ifTrue:[ |
|
4890 |
dynamic := true. |
|
4891 |
] ifFalse:[ |
|
4892 |
dynamic := false. |
|
4893 |
]. |
|
4894 |
libName isNil ifTrue:[ |
|
4895 |
type := #classObject |
|
4896 |
] ifFalse:[ |
|
4897 |
type := #classLibrary |
|
4898 |
]. |
|
4899 |
||
4900 |
"/ ... new: |
|
4901 |
infoEntry := BinaryModuleDescriptor |
|
4902 |
name:nil |
|
4903 |
type:type |
|
4904 |
id:id |
|
4905 |
dynamic:dynamic |
|
4906 |
classNames:(Array with:subModuleName) |
|
4907 |
pathName:nil |
|
4908 |
libraryName:libName |
|
4909 |
timeStamp:t. |
|
4910 |
||
4911 |
modules at:subModuleName put:infoEntry. |
|
1288 | 4912 |
]. |
4913 |
^ modules |
|
4914 |
||
4915 |
" |
|
4916 |
ObjectMemory fullBinaryModuleInfo |
|
418 | 4917 |
" |
4918 |
||
4919 |
"Modified: 30.8.1995 / 17:29:30 / claus" |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4920 |
"Modified: 31.10.1996 / 13:58:44 / cg" |
615 | 4921 |
! |
4922 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4923 |
getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4924 |
"return a collection of release strings giving information |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4925 |
about the running VM. This is for configuration management only. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4926 |
Do not depend on the information returned - this may |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4927 |
change or vanish without notice." |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4928 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4929 |
%{ |
3729
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
4930 |
extern OBJ __getVMReleaseStrings(); |
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
4931 |
|
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4932 |
RETURN (__getVMReleaseStrings()); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4933 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4934 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4935 |
ObjectMemory getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4936 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4937 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4938 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4939 |
!ObjectMemory class methodsFor:'system management'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4940 |
|
1288 | 4941 |
imageBaseName |
4942 |
"return a reasonable filename to use as baseName (i.e. without extension). |
|
4943 |
This is the filename of the current image (without '.img') or, |
|
4944 |
if not running from an image, the default name 'st'" |
|
4945 |
||
12648 | 4946 |
|nm filename suffix| |
1288 | 4947 |
|
4948 |
nm := ImageName. |
|
12648 | 4949 |
(nm isEmptyOrNil or:[nm isBlank]) ifTrue:[ |
4950 |
^ 'st' |
|
1288 | 4951 |
]. |
12648 | 4952 |
|
4953 |
filename := nm asFilename. |
|
4954 |
suffix := filename suffix. |
|
4955 |
(suffix = 'sav' or:[suffix = self suffixForSnapshot]) ifTrue:[ |
|
4956 |
^ filename nameWithoutSuffix. |
|
615 | 4957 |
]. |
12648 | 4958 |
|
615 | 4959 |
^ nm |
4960 |
||
4961 |
" |
|
10226 | 4962 |
ObjectMemory imageBaseName |
615 | 4963 |
" |
4964 |
! |
|
4965 |
||
1288 | 4966 |
imageName |
4967 |
"return the filename of the current image, or nil |
|
4968 |
if not running from an image." |
|
615 | 4969 |
|
4970 |
^ ImageName |
|
335 | 4971 |
|
4972 |
" |
|
10226 | 4973 |
ObjectMemory imageName |
335 | 4974 |
" |
1 | 4975 |
! |
4976 |
||
1288 | 4977 |
imageSaveTime |
4978 |
"return a timestamp for when the running image was saved. |
|
1096 | 4979 |
Return nil if not running from an image." |
4980 |
||
4981 |
^ ImageSaveTime |
|
4982 |
! |
|
4983 |
||
1288 | 4984 |
nameForChanges |
4985 |
"return a reasonable filename to store the changes into. |
|
4986 |
Currently, this is defined in a classVariable and defaults to 'changes'. |
|
4987 |
In future versions, this will be the basename of the current image with '.img' replaced |
|
4988 |
by '.chg', or, if not running from an image, the default name 'st.chg'." |
|
4989 |
||
4990 |
ChangeFileName notNil ifTrue:[^ ChangeFileName]. |
|
8543
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
4991 |
^ self imageBaseName , '.chg' |
1 | 4992 |
|
335 | 4993 |
" |
10226 | 4994 |
ObjectMemory nameForChanges |
615 | 4995 |
" |
4996 |
! |
|
4997 |
||
1288 | 4998 |
nameForChanges:aFilename |
4999 |
"set the name of the file where changes are stored into." |
|
5000 |
||
5001 |
ChangeFileName := aFilename |
|
615 | 5002 |
|
5003 |
" |
|
10226 | 5004 |
ObjectMemory nameForChanges:'myChanges' |
615 | 5005 |
" |
5006 |
! |
|
5007 |
||
10019 | 5008 |
nameForCrashImage |
12648 | 5009 |
^ 'crash', '.', self suffixForSnapshot |
10019 | 5010 |
|
5011 |
" |
|
10226 | 5012 |
ObjectMemory nameForCrashImage |
10019 | 5013 |
" |
5014 |
||
5015 |
"Created: / 29-09-2006 / 13:16:52 / cg" |
|
5016 |
! |
|
5017 |
||
1288 | 5018 |
nameForSnapshot |
5019 |
"return a reasonable filename to store the snapshot image into. |
|
5020 |
This is the filename of the current image or, |
|
5021 |
if not running from an image, the default name 'st.img'" |
|
5022 |
||
12648 | 5023 |
^ self imageBaseName , '.', self suffixForSnapshot |
615 | 5024 |
|
5025 |
" |
|
10226 | 5026 |
ObjectMemory nameForSnapshot |
335 | 5027 |
" |
1 | 5028 |
! |
5029 |
||
1288 | 5030 |
nameForSources |
5031 |
"return a reasonable filename to store the sources into. |
|
5032 |
This is the basename of the current image with '.img' replaced |
|
5033 |
by '.src', or, if not running from an image, the default name 'st.src'" |
|
615 | 5034 |
|
5035 |
^ self imageBaseName , '.src' |
|
362 | 5036 |
|
5037 |
" |
|
10226 | 5038 |
ObjectMemory nameForSources |
615 | 5039 |
" |
5040 |
! |
|
5041 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5042 |
primSnapShotOn:aFilename |
1288 | 5043 |
"create a snapshot in the given file. |
5044 |
Low level entry. Does not notify classes or write an entry to |
|
10226 | 5045 |
the changes file. Also, no image backup is created. |
1704 | 5046 |
Returns true if the snapshot worked, false if it failed for some reason. |
1288 | 5047 |
This method should not be used in normal cases." |
5048 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5049 |
|ok oldImageName oldImageTime filenameString| |
1704 | 5050 |
|
5051 |
" |
|
5052 |
save the name and time with it ... |
|
5053 |
" |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5054 |
|
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5055 |
filenameString := aFilename asString. |
1704 | 5056 |
oldImageName := ImageName. |
5057 |
oldImageTime := ImageSaveTime. |
|
5058 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5059 |
ImageName := filenameString. |
8252
16ed6cd9868d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
7769
diff
changeset
|
5060 |
ImageSaveTime := Timestamp now. |
1704 | 5061 |
|
5062 |
%{ /* CALLSSTACK:32000 */ |
|
1288 | 5063 |
|
5064 |
OBJ __snapShotOn(); |
|
5065 |
OBJ funny = @symbol(funnySnapshotSymbol); |
|
5066 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5067 |
if (__isStringLike(filenameString)) { |
10226 | 5068 |
__BLOCKINTERRUPTS(); |
5069 |
ok = __snapShotOn(__context, __stringVal(filenameString), funny); |
|
5070 |
__UNBLOCKINTERRUPTS(); |
|
615 | 5071 |
} |
5072 |
%}. |
|
1704 | 5073 |
|
5074 |
ImageName := oldImageName. |
|
5075 |
ImageSaveTime := oldImageTime. |
|
5076 |
||
615 | 5077 |
^ ok |
5078 |
! |
|
5079 |
||
8543
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5080 |
refreshChangesFrom: oldChangesName |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5081 |
"The snapshot image name has changed (snapshot saved), |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5082 |
the changes file must be copied to the new name. |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5083 |
No copy when the changes name is given explicitly." |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5084 |
|
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5085 |
ChangeFileName notNil ifTrue: [ ^self]. |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5086 |
oldChangesName asFilename copyTo:self nameForChanges |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5087 |
|
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5088 |
"Created: / 15.5.2004 / 20:29:03 / masca" |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5089 |
! |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5090 |
|
1288 | 5091 |
snapShot |
5092 |
"create a snapshot file containing all of the current state." |
|
615 | 5093 |
|
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5094 |
self snapShotOn:self nameForSnapshot setImageName:true |
615 | 5095 |
|
5096 |
" |
|
5097 |
ObjectMemory snapShot |
|
362 | 5098 |
" |
1288 | 5099 |
! |
5100 |
||
5101 |
snapShotOn:aFileName |
|
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5102 |
^ self snapShotOn:aFileName setImageName:true. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5103 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5104 |
" |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5105 |
ObjectMemory snapShotOn:'myimage.img' |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5106 |
" |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5107 |
! |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5108 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5109 |
snapShotOn:aFileName setImageName:setImageName |
10226 | 5110 |
"create a snapshot in the given file. |
1288 | 5111 |
If the file exists, save it for backup. |
5112 |
Return true if the snapshot worked, false if it failed for some reason. |
|
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5113 |
Notify dependents before and after the snapshot operation. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5114 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5115 |
If setImageName is true, the name of the current image is set and |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5116 |
a copy of the change file is created." |
1288 | 5117 |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5118 |
|ok snapshotFilename tempFilename oldChangeFile| |
1288 | 5119 |
|
5120 |
" |
|
5121 |
give others a chance to fix things |
|
5122 |
" |
|
5123 |
self changed:#save. "/ will vanish ... |
|
5124 |
self changed:#aboutToSnapshot. "/ ... for ST-80 compatibility |
|
5125 |
||
5126 |
" |
|
5127 |
ST-80 compatibility; send #preSnapshot to all classes |
|
5128 |
" |
|
5581 | 5129 |
Smalltalk allClassesDo:[:aClass | |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5130 |
aClass preSnapshot |
1288 | 5131 |
]. |
5132 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5133 |
" |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5134 |
save in a temp file and rename - just in case something |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5135 |
bad happens while writing the image. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5136 |
(could be ST/X error or file-system errors etc.) |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5137 |
" |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5138 |
snapshotFilename := aFileName asFilename. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5139 |
tempFilename := snapshotFilename withSuffix:'tmp'. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5140 |
ok := self primSnapShotOn:tempFilename. |
1288 | 5141 |
|
5142 |
ok ifTrue:[ |
|
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5143 |
"keep history of one snapshot file" |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5144 |
snapshotFilename exists ifTrue:[ |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5145 |
tempFilename symbolicAccessRights:snapshotFilename symbolicAccessRights. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5146 |
snapshotFilename renameTo:(snapshotFilename withSuffix:'sav'). |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5147 |
] ifFalse:[ |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5148 |
"image file hat stx as interpreter and can be executed" |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5149 |
tempFilename makeExecutable. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5150 |
]. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5151 |
tempFilename renameTo:snapshotFilename. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5152 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5153 |
Class addChangeRecordForSnapshot:aFileName. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5154 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5155 |
setImageName ifTrue:[ |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5156 |
oldChangeFile := self nameForChanges. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5157 |
ImageName := snapshotFilename asAbsoluteFilename asString. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5158 |
self refreshChangesFrom:oldChangeFile. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5159 |
]. |
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5160 |
] ifFalse:[ |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5161 |
tempFilename remove. |
1288 | 5162 |
]. |
5163 |
||
5164 |
" |
|
5165 |
ST-80 compatibility; send #postSnapshot to all classes |
|
5166 |
" |
|
5581 | 5167 |
Smalltalk allClassesDo:[:aClass | |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5168 |
aClass postSnapshot |
1288 | 5169 |
]. |
5170 |
self changed:#finishedSnapshot. "/ ST-80 compatibility |
|
6113 | 5171 |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5172 |
ok ifFalse:[ |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5173 |
SnapshotError raise. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5174 |
"not reached" |
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5175 |
]. |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5176 |
|
10226 | 5177 |
Transcript |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5178 |
show:'Snapshot '; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5179 |
show:snapshotFilename baseName allBold; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5180 |
show:' saved '; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5181 |
show:Timestamp now; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5182 |
show:' in '; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5183 |
show:snapshotFilename asAbsoluteFilename directoryName; |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5184 |
showCR:'.'. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5185 |
|
1288 | 5186 |
^ ok |
5187 |
||
5188 |
" |
|
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5189 |
ObjectMemory snapShotOn:'myimage.img' setImageName:false |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5190 |
ObjectMemory snapShotOn:'myimage.img' setImageName:true |
1288 | 5191 |
" |
9467
be68d09088ce
snapshot save message on the transcript.
Claus Gittinger <cg@exept.de>
parents:
9451
diff
changeset
|
5192 |
|
be68d09088ce
snapshot save message on the transcript.
Claus Gittinger <cg@exept.de>
parents:
9451
diff
changeset
|
5193 |
"Modified: / 04-08-2006 / 18:14:45 / cg" |
10018 | 5194 |
! |
5195 |
||
12648 | 5196 |
suffixForSnapshot |
5197 |
"return the suffix used for snapshot files'" |
|
5198 |
||
5199 |
^ 'img'. |
|
5200 |
! |
|
5201 |
||
10018 | 5202 |
writeCrashImage |
10921
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5203 |
"create a 'crash.img' snapshot file containing all of the current state. |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5204 |
Keep the current image name." |
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5205 |
|
44e6290ed93f
Do not set the ImageName and do not create a copy of the change file when
Stefan Vogel <sv@exept.de>
parents:
10855
diff
changeset
|
5206 |
self snapShotOn:self nameForCrashImage setImageName:false |
10018 | 5207 |
|
5208 |
" |
|
5209 |
ObjectMemory writeCrashImage |
|
5210 |
" |
|
5211 |
||
5212 |
"Created: / 29-09-2006 / 12:22:54 / cg" |
|
362 | 5213 |
! ! |
615 | 5214 |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5215 |
!ObjectMemory::BinaryModuleDescriptor class methodsFor:'instance creation'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5216 |
|
12922 | 5217 |
name:n type:t id:i dynamic:d classNames:c handle:h pathName:p libraryName:l timeStamp:ts |
5218 |
^ (self basicNew) name:n type:t id:i dynamic:d classNames:c handle:h pathName:p libraryName:l timeStamp:ts |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5219 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5220 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5221 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'accessing'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5222 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5223 |
classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5224 |
"return the names of the classes contained in that module" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5225 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5226 |
^ classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5227 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5228 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5229 |
dynamic |
10226 | 5230 |
"return true, if this module was loaded dynamically |
11334 | 5231 |
(as opposed to a module which was linked into the system right from the start. |
5232 |
Do not confuse this with shared libraries - these may be dynamic or not)." |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5233 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5234 |
^ dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5235 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5236 |
|
12922 | 5237 |
handle |
5238 |
^ handle |
|
5239 |
! |
|
5240 |
||
5241 |
handle:something |
|
5242 |
handle := something. |
|
5243 |
! |
|
5244 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5245 |
id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5246 |
"return the modules internal id; this is (currently) a small number, |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5247 |
with positive values for dynamically added modules. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5248 |
Modules which were present at startup (both statically linked or shared libraries) |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5249 |
have a negative id (Do not depend on this - use #dynamic instead)." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5250 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5251 |
^ id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5252 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5253 |
|
12266 | 5254 |
isSingleMethod |
5255 |
^ type == #classObject and:[ libraryName isNil ] |
|
5256 |
! |
|
5257 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5258 |
libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5259 |
"return the name of this library. Typically, this is the libraries |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5260 |
filename without a suffix (such as 'libbasic')" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5261 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5262 |
^ libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5263 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5264 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5265 |
name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5266 |
"return the modules name - usually, some descriptive text plus the modules |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5267 |
libraryName." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5268 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5269 |
^ name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5270 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5271 |
|
4686 | 5272 |
package |
5273 |
"retrieve the modules packageId. |
|
5274 |
For now, this is constructed, but will be kept in the VM in later |
|
5275 |
versions." |
|
5276 |
||
5277 |
"/ must fetch from my classes ... |
|
5278 |
classNames do:[:className | |
|
10226 | 5279 |
|class| |
5280 |
||
5281 |
(class := Smalltalk at:className) isBehavior ifTrue:[ |
|
5282 |
^ class package |
|
5283 |
] |
|
4686 | 5284 |
]. |
5285 |
^ nil |
|
5286 |
! |
|
5287 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5288 |
pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5289 |
"return the modules pathName" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5290 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5291 |
^ pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5292 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5293 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5294 |
timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5295 |
"return the modules timeStamp" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5296 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5297 |
^ timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5298 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5299 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5300 |
type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5301 |
"return the modules type. This is a symbol, such as #classLibrary." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5302 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5303 |
^ type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5304 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5305 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5306 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'backward compatibility'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5307 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5308 |
at:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5309 |
"backward compatibility access: in previous releases, IdentityDictionaries |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5310 |
were used to hold my information. Allow access via key messages. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5311 |
This method will vanish - use the proper access protocol." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5312 |
|
12924 | 5313 |
<resource: #obsolete> |
5314 |
||
5315 |
self obsoleteMethodWarning. |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5316 |
^ self perform:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5317 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5318 |
|
4736 | 5319 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'printing & storing'! |
5320 |
||
12644
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5321 |
printOn:aStream |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5322 |
aStream |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5323 |
nextPutAll:self class name; |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5324 |
nextPut:$(. |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5325 |
|
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5326 |
name printOn:aStream. |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5327 |
aStream nextPut:$). |
4736 | 5328 |
! ! |
5329 |
||
7258 | 5330 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'private-accessing'! |
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5331 |
|
12922 | 5332 |
name:n type:t id:i dynamic:d classNames:c handle:h pathName:p libraryName:l timeStamp:ts |
5333 |
name := n. |
|
5334 |
type := t. |
|
5335 |
id := i. |
|
5336 |
dynamic := d. |
|
5337 |
classNames := c. |
|
5338 |
libraryName := l. |
|
5339 |
timeStamp := ts. |
|
5340 |
handle := h. |
|
5341 |
pathName := p. |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5342 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5343 |
|
1767 | 5344 |
!ObjectMemory class methodsFor:'documentation'! |
630 | 5345 |
|
1288 | 5346 |
version |
12924 | 5347 |
^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.249 2010-05-11 10:31:43 stefan Exp $' |
12266 | 5348 |
! |
5349 |
||
5350 |
version_CVS |
|
12924 | 5351 |
^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.249 2010-05-11 10:31:43 stefan Exp $' |
630 | 5352 |
! ! |
7055
83b9d61e4b3c
do not depend on TimeStamp - TimeStamp to return seconds-integer
Claus Gittinger <cg@exept.de>
parents:
6710
diff
changeset
|
5353 |
|
615 | 5354 |
ObjectMemory initialize! |