author | Claus Gittinger <cg@exept.de> |
Thu, 27 Jun 2013 23:01:21 +0200 | |
changeset 15441 | 5a7d4a7de37d |
parent 15233 | d1ceef1dcfd2 |
child 15467 | df2d6d3d92ca |
child 18070 | d262e3aecaca |
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 |
|
14699
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
921 |
debugPrivacyChecks:aBoolean |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
922 |
"turn on/off checks for private methods being called. |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
923 |
By default, this is on in the ST/X IDE, but off for standAlone (packaged) endUser |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
924 |
applications. Method privacy is an experimental feature, which may be removed in later |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
925 |
versions, if it turns out to be not useful." |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
926 |
|
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
927 |
%{ /* NOCONTEXT */ |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
928 |
extern int __setPrivacyChecks__(); |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
929 |
|
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
930 |
RETURN ( __setPrivacyChecks__( (aBoolean == true) ) ? true : false); |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
931 |
%} |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
932 |
! |
a80577551b86
allow privacyChecks to be disabled at runtime
Claus Gittinger <cg@exept.de>
parents:
14649
diff
changeset
|
933 |
|
703 | 934 |
setTrapOnAccessFor:anObject |
935 |
"install an access trap for anObject; |
|
936 |
An accessSignal will be raised, whenever any instvar of anObject is either read or written. |
|
937 |
This is not supported on all architectures, therefore the return value |
|
938 |
(true of trap was installed ok, false if failed) should be checked." |
|
939 |
||
940 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
941 |
RETURN (__addTrapOnAccess(anObject, 2) ? true : false); |
703 | 942 |
%} |
943 |
! |
|
944 |
||
945 |
setTrapOnReadFor:anObject |
|
946 |
"install a read trap for anObject; |
|
947 |
An accessSignal will be raised, whenever any access into anObject occurrs. |
|
948 |
This is not supported on all architectures, therefore the return value |
|
949 |
(true of trap was installed ok, false if failed) should be checked." |
|
950 |
||
951 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
952 |
RETURN (__addTrapOnAccess(anObject, 0) ? true : false); |
703 | 953 |
%} |
954 |
! |
|
955 |
||
956 |
setTrapOnWriteFor:anObject |
|
957 |
"install a write trap for anObject; |
|
958 |
An accessSignal will be raised, whenever any instvar of anObject is written to. |
|
959 |
This is not supported on all architectures, therefore the return value |
|
960 |
(true of trap was installed ok, false if failed) should be checked." |
|
961 |
||
962 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
963 |
RETURN (__addTrapOnAccess(anObject, 1) ? true : false); |
703 | 964 |
%} |
965 |
! |
|
966 |
||
967 |
unsetAllTraps |
|
968 |
"remove all access traps" |
|
969 |
||
970 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
971 |
__removeAllAccessTraps(); |
10226 | 972 |
%} |
703 | 973 |
! |
974 |
||
975 |
unsetTrapFor:anObject |
|
976 |
"remove any access trap for anObject." |
|
977 |
||
978 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
979 |
__removeTrapOnAccess(anObject); |
703 | 980 |
%} |
981 |
! ! |
|
982 |
||
1767 | 983 |
!ObjectMemory class methodsFor:'cache management'! |
615 | 984 |
|
13421 | 985 |
debugBreakPoint3 |
13584 | 986 |
|
13421 | 987 |
%{ |
988 |
#ifndef WIN32 |
|
989 |
/*extern void __debugBreakPoint3__();*/ |
|
990 |
__debugBreakPoint3__(); |
|
13584 | 991 |
#endif |
13421 | 992 |
%}. |
993 |
^ 0 |
|
994 |
||
995 |
! |
|
996 |
||
615 | 997 |
flushCaches |
998 |
"flush method and inline caches for all classes" |
|
999 |
||
1000 |
%{ /* NOCONTEXT */ |
|
1001 |
__flushMethodCache(); |
|
1002 |
__flushAllInlineCaches(); |
|
1003 |
%} |
|
1004 |
! |
|
1005 |
||
1006 |
flushCachesFor:aClass |
|
1007 |
"flush method and inline caches for aClass" |
|
1008 |
||
1009 |
%{ /* NOCONTEXT */ |
|
1010 |
__flushMethodCacheFor(aClass); |
|
1011 |
__flushInlineCachesFor(aClass); |
|
1012 |
%} |
|
1013 |
! |
|
1014 |
||
1015 |
flushCachesForSelector:aSelector |
|
1016 |
"flush method and inline caches for aSelector" |
|
1017 |
||
8527 | 1018 |
self flushMethodCacheForSelector:aSelector. |
1019 |
||
1020 |
"/ self flushInlineCachesForSelector:aSelector. |
|
1021 |
self flushInlineCachesWithArgs:(aSelector numArgs). |
|
615 | 1022 |
! |
1023 |
||
1024 |
flushInlineCaches |
|
1025 |
"flush all inlinecaches" |
|
1026 |
||
1027 |
%{ /* NOCONTEXT */ |
|
1028 |
__flushAllInlineCaches(); |
|
1029 |
%} |
|
1030 |
! |
|
1031 |
||
1032 |
flushInlineCachesFor:aClass withArgs:nargs |
|
1033 |
"flush inlinecaches for calls to aClass with nargs arguments" |
|
1034 |
||
1035 |
%{ /* NOCONTEXT */ |
|
1133 | 1036 |
__flushInlineCachesForAndNargs(aClass, __intVal(nargs)); |
615 | 1037 |
%} |
8528 | 1038 |
! |
615 | 1039 |
|
1040 |
flushInlineCachesForClass:aClass |
|
1041 |
"flush inlinecaches for calls to aClass." |
|
1042 |
||
1043 |
%{ /* NOCONTEXT */ |
|
1044 |
__flushInlineCachesFor(aClass); |
|
1045 |
%} |
|
8528 | 1046 |
! |
615 | 1047 |
|
1048 |
flushInlineCachesForSelector:aSelector |
|
1049 |
"flush inlinecaches for sends of aSelector" |
|
1050 |
||
1051 |
%{ /* NOCONTEXT */ |
|
1052 |
__flushInlineCachesForSelector(aSelector); |
|
1053 |
%} |
|
1054 |
! |
|
1055 |
||
1056 |
flushInlineCachesWithArgs:nargs |
|
1057 |
"flush inlinecaches for calls with nargs arguments" |
|
1058 |
||
1059 |
%{ /* NOCONTEXT */ |
|
1133 | 1060 |
__flushInlineCaches(__intVal(nargs)); |
615 | 1061 |
%} |
1062 |
! |
|
1063 |
||
1064 |
flushMethodCache |
|
1065 |
"flush the method cache" |
|
1066 |
||
1067 |
%{ /* NOCONTEXT */ |
|
1068 |
__flushMethodCache(); |
|
1069 |
%} |
|
1070 |
! |
|
1071 |
||
1072 |
flushMethodCacheFor:aClass |
|
1073 |
"flush the method cache for sends to aClass" |
|
1074 |
||
1075 |
%{ /* NOCONTEXT */ |
|
1076 |
__flushMethodCacheFor(aClass); |
|
1077 |
%} |
|
1078 |
! |
|
1079 |
||
1080 |
flushMethodCacheForSelector:aSelector |
|
1081 |
"flush the method cache for sends of aSelector" |
|
1082 |
||
1083 |
%{ /* NOCONTEXT */ |
|
1084 |
__flushMethodCacheForSelector(aSelector); |
|
1085 |
%} |
|
1086 |
! |
|
1087 |
||
13421 | 1088 |
ilcMisses: newValue |
13584 | 1089 |
|
13421 | 1090 |
newValue class == SmallInteger ifFalse:[^self error:'Not an integer value']. |
1091 |
%{ /* NOCONTEXT */ |
|
1092 |
/*extern int __ilcMisses(int);*/ |
|
13584 | 1093 |
#ifdef ILC_PROFILING |
13421 | 1094 |
RETURN ( __MKSMALLINT ( __ilcMisses ( __intVal ( newValue ) ) ) ); |
1095 |
#endif |
|
1096 |
%}. |
|
1097 |
^ -1 |
|
1098 |
||
1099 |
! |
|
1100 |
||
1101 |
ilcMissesTrace: bool |
|
13584 | 1102 |
|
13421 | 1103 |
%{ |
1104 |
/*extern int __ilcMissesTrace(int);*/ |
|
13584 | 1105 |
#ifdef ILC_PROFILING |
13421 | 1106 |
RETURN ( __ilcMissesTrace ( bool == true ) ? true : false ); |
1107 |
#endif |
|
1108 |
%}. |
|
1109 |
^ 0 |
|
1110 |
||
1111 |
! |
|
1112 |
||
1108 | 1113 |
incrementSnapshotID |
2526 | 1114 |
"obsolete - do not use" |
1115 |
||
1108 | 1116 |
%{ /* NOCONTEXT */ |
1117 |
__bumpSnapshotID(); |
|
1118 |
%} |
|
1119 |
! |
|
1120 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1121 |
snapshotID |
918 | 1122 |
"return the internal snapshotID number. |
1123 |
This is incremented when an image is restarted, and |
|
1124 |
stored with the image. |
|
1125 |
Not for normal users, this is used by the VM to invalidate |
|
1126 |
caches which are stored with the image" |
|
1127 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1128 |
%{ /* NOCONTEXT */ |
8913 | 1129 |
RETURN ( __mkSmallInteger( __snapshotID() )); |
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1130 |
%} |
918 | 1131 |
" |
10226 | 1132 |
ObjectMemory snapshotID |
918 | 1133 |
" |
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1134 |
! |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1135 |
|
615 | 1136 |
trapRestrictedMethods:trap |
1137 |
"Allow/Deny execution of restricted Methods (see Method>>>restricted:) |
|
1138 |
||
1139 |
Notice: method restriction is a nonstandard feature, not supported |
|
1140 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1141 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1142 |
It may change or even vanish (if it shows to be not useful)." |
|
1143 |
||
1144 |
|oldTrap| |
|
1145 |
||
10226 | 1146 |
%{ |
615 | 1147 |
if (__setTrapRestrictedMethods(trap == true)) |
1148 |
oldTrap = true; |
|
1149 |
else |
|
1150 |
oldTrap = false; |
|
1151 |
%}. |
|
1152 |
||
1153 |
(trap and:[oldTrap not]) ifTrue:[ |
|
1154 |
self flushCaches |
|
1155 |
]. |
|
1156 |
^ oldTrap |
|
1157 |
||
1158 |
" |
|
1159 |
ObjectMemory trapRestrictedMethods:true |
|
1160 |
ObjectMemory trapRestrictedMethods:false |
|
1161 |
" |
|
1162 |
! ! |
|
1163 |
||
1767 | 1164 |
!ObjectMemory class methodsFor:'debug queries'! |
615 | 1165 |
|
1166 |
addressOf:anObject |
|
1167 |
"return the core address of anObject as an integer |
|
1168 |
- since objects may move around, the returned value is invalid after the |
|
1169 |
next scavenge/collect. |
|
10226 | 1170 |
WARNING: this method is for ST/X debugging only |
1171 |
it will be removed without notice" |
|
615 | 1172 |
|
1173 |
%{ /* NOCONTEXT */ |
|
1174 |
||
5783 | 1175 |
if (anObject != nil) { |
10226 | 1176 |
if (! __isNonNilObject(anObject)) { |
1177 |
RETURN ( nil ); |
|
1178 |
} |
|
615 | 1179 |
} |
2783 | 1180 |
if ((unsigned INT)anObject <= _MAX_INT) { |
10226 | 1181 |
RETURN ( __mkSmallInteger((INT)anObject) ); |
615 | 1182 |
} |
2769 | 1183 |
RETURN ( __MKUINT((INT)anObject) ); |
615 | 1184 |
%} |
1185 |
" |
|
1186 |
|p| |
|
1187 |
p := Point new. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1188 |
((ObjectMemory addressOf:p) printStringRadix:16) printCR. |
615 | 1189 |
ObjectMemory scavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1190 |
((ObjectMemory addressOf:p) printStringRadix:16) printCR. |
615 | 1191 |
" |
1192 |
! |
|
1193 |
||
1194 |
ageOf:anObject |
|
1195 |
"return the number of scavenges, an object has survived |
|
10226 | 1196 |
in new space. |
615 | 1197 |
For old objects and living contexts, the returned number is invalid. |
10226 | 1198 |
WARNING: this method is for ST/X debugging only |
1199 |
it will be removed without notice" |
|
615 | 1200 |
|
1201 |
%{ /* NOCONTEXT */ |
|
1202 |
||
1203 |
if (! __isNonNilObject(anObject)) { |
|
10226 | 1204 |
RETURN ( 0 ); |
615 | 1205 |
} |
8913 | 1206 |
RETURN ( __mkSmallInteger( _GET_AGE(anObject) ) ); |
615 | 1207 |
%} |
1208 |
" |
|
1209 |
|p| |
|
1210 |
p := Point new. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1211 |
(ObjectMemory ageOf:p) printCR. |
615 | 1212 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1213 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1214 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1215 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1216 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1217 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1218 |
ObjectMemory tenuringScavenge. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1219 |
(ObjectMemory spaceOf:p) printCR. |
615 | 1220 |
" |
1221 |
! |
|
1222 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1223 |
displayRefChainTo:anObject |
3266 | 1224 |
self displayRefChainToAny:(Array with:anObject). |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1225 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1226 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1227 |
self displayRefChainTo:Point new |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1228 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1229 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1230 |
Smalltalk at:#foo put:Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1231 |
self displayRefChainTo:(Smalltalk at:#foo) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1232 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1233 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1234 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1235 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1236 |
Smalltalk at:#foo put:(#x -> p). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1237 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1238 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1239 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1240 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1241 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1242 |
Smalltalk at:#foo put:(#x -> a). |
10226 | 1243 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1244 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1245 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1246 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1247 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1248 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
10226 | 1249 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1250 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1251 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1252 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1253 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1254 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
10226 | 1255 |
self displayRefChainTo:a |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1256 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1257 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1258 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1259 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1260 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1261 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1262 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1263 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1264 |
self displayRefChainTo:Transcript topView |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1265 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1266 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1267 |
"Created: / 2.2.1998 / 19:23:55 / cg" |
3266 | 1268 |
"Modified: / 3.2.1998 / 00:30:14 / cg" |
1269 |
! |
|
1270 |
||
1271 |
displayRefChainToAny:aCollection |
|
10855 | 1272 |
self displayRefChainToAny:aCollection limitNumberOfSearchedReferences:nil |
1273 |
! |
|
1274 |
||
1275 |
displayRefChainToAny:aCollection limitNumberOfSearchedReferences:limitOrNil |
|
3266 | 1276 |
|levels objects done showMore stop userStop chain |
10226 | 1277 |
top progress lbl h nDone nAll panel listV |
3266 | 1278 |
moreButton owners objectArray numObjects numObjectsDone |
4739 | 1279 |
found moreChainsOnThisLevel temporaryRemoved chains |
3643 | 1280 |
anyShown anyShownInAnyLevel list tLevels firstRound| |
3266 | 1281 |
|
1282 |
top := StandardSystemView new. |
|
1283 |
top extent:350@250. |
|
1284 |
top label:'Object reference finder'. |
|
1285 |
||
1286 |
lbl := Label label:'compressing garbage ...' in:top. |
|
1287 |
lbl adjust:#left. |
|
1288 |
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
|
1289 |
h := lbl preferredHeight. |
3266 | 1290 |
lbl |
15441 | 1291 |
topInset:5; |
1292 |
bottomInset:(h+5) negated; |
|
1293 |
leftInset:5; |
|
1294 |
rightInset:5. |
|
3266 | 1295 |
|
1296 |
progress := ProgressIndicator in:top. |
|
1297 |
progress origin:(0.0@45) corner:(1.0@45). |
|
1298 |
progress level:-1. |
|
11030
d23ae30a947a
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
10921
diff
changeset
|
1299 |
h := progress preferredHeight. |
10226 | 1300 |
progress |
15441 | 1301 |
topInset:(h // 2) negated; |
1302 |
bottomInset:(h // 2) negated; |
|
1303 |
leftInset:5; |
|
1304 |
rightInset:5. |
|
3266 | 1305 |
progress beInvisible. |
1306 |
||
1307 |
listV := HVScrollableView for:SelectionInListView in:top. |
|
1308 |
listV origin:(0.0@55) corner:(1.0@1.0). |
|
10226 | 1309 |
listV |
15441 | 1310 |
topInset:(h // 2); |
1311 |
bottomInset:40; |
|
1312 |
leftInset:5; |
|
1313 |
rightInset:5. |
|
3266 | 1314 |
listV beInvisible. |
10226 | 1315 |
|
3266 | 1316 |
panel := HorizontalPanelView in:top. |
1317 |
panel origin:(0.0@1.0) corner:(1.0@1.0). |
|
1318 |
panel topInset:-40. |
|
1319 |
panel horizontalLayout:#left. |
|
1320 |
||
1321 |
panel add:(Button label:'stop' action:[stop := userStop := true]). |
|
1322 |
panel add:(moreButton := Button label:'more' action:[showMore := true]). |
|
1323 |
panel ignoreInvisibleComponents:false. |
|
1324 |
moreButton beInvisible. |
|
1325 |
||
1326 |
top openWithPriority:(Processor activePriority + 1). |
|
1327 |
top waitUntilVisible. |
|
1328 |
||
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1329 |
lbl label:'compressing garbage ...'. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1330 |
self compressingGarbageCollect. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1331 |
|
3266 | 1332 |
progress beVisible. |
1333 |
||
1334 |
levels := OrderedCollection new. |
|
1335 |
objects := WeakIdentitySet withAll:aCollection. |
|
1336 |
||
1337 |
done := (objects includesIdentical:Smalltalk). |
|
1338 |
stop := userStop := false. |
|
3643 | 1339 |
anyShown := anyShownInAnyLevel := false. |
3266 | 1340 |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1341 |
"/ consider this a kludge: |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1342 |
"/ 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
|
1343 |
"/ only known to the VM. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1344 |
"/ 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
|
1345 |
"/ These are released later. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1346 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1347 |
Smalltalk at:#'__VMProcesses__' put:(self processesKnownInVM). |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1348 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1349 |
firstRound := true. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1350 |
|
3266 | 1351 |
[done] whileFalse:[ |
15441 | 1352 |
anyShown := false. |
1353 |
||
1354 |
progress percentage:0. |
|
1355 |
firstRound ifTrue:[ |
|
1356 |
firstRound := false. |
|
1357 |
] ifFalse:[ |
|
1358 |
lbl label:'compressing garbage ...'. |
|
1359 |
self garbageCollect. |
|
1360 |
]. |
|
1361 |
||
1362 |
lbl label:('searching level ' |
|
1363 |
, levels size printString |
|
1364 |
, ' (' , objects size printString , ' refs) ...'). |
|
1365 |
nAll := objects size. |
|
1366 |
nDone := 0. |
|
1367 |
||
1368 |
objectArray := objects asArray. |
|
1369 |
||
1370 |
owners := "Weak"IdentitySet new. |
|
1371 |
||
1372 |
numObjectsDone := 0. |
|
1373 |
found := false. |
|
1374 |
||
1375 |
AbortSignal handle:[] |
|
1376 |
do:[ |
|
1377 |
[self allObjectsIncludingContextsDo:[:o | |
|
1378 |
|inPrevLevel isOwner| |
|
1379 |
||
1380 |
stop ifTrue:[AbortSignal raise]. |
|
1381 |
stop ifFalse:[ |
|
1382 |
isOwner := false. |
|
1383 |
(o referencesAny:objectArray) ifTrue:[ |
|
1384 |
o isBehavior ifTrue:[ |
|
1385 |
o == Smalltalk ifTrue:[ |
|
1386 |
found := true. |
|
1387 |
] ifFalse:[ |
|
1388 |
"/ only add it if it has classInstVars |
|
1389 |
o instSize ~~ Class instSize ifTrue:[ |
|
1390 |
isOwner := true. |
|
1391 |
] |
|
1392 |
] |
|
1393 |
] ifFalse:[ |
|
1394 |
o class ~~ WeakArray ifTrue:[ |
|
1395 |
isOwner := true. |
|
1396 |
] |
|
1397 |
]. |
|
1398 |
]. |
|
1399 |
||
1400 |
isOwner ifTrue:[ |
|
1401 |
(objects includesIdentical:o) ifFalse:[ |
|
1402 |
inPrevLevel := false. |
|
1403 |
levels do:[:lColl | |
|
1404 |
lColl == o ifTrue:[ |
|
1405 |
inPrevLevel := true |
|
1406 |
] ifFalse:[ |
|
1407 |
(lColl includesIdentical:o) ifTrue:[inPrevLevel := true]. |
|
1408 |
] |
|
1409 |
]. |
|
1410 |
inPrevLevel ifFalse:[ |
|
1411 |
owners add:o. |
|
1412 |
(limitOrNil notNil and:[owners size >= limitOrNil]) ifTrue:[ |
|
1413 |
AbortSignal raise |
|
1414 |
]. |
|
1415 |
] |
|
1416 |
] |
|
1417 |
]. |
|
1418 |
||
1419 |
numObjectsDone := numObjectsDone + 1. |
|
1420 |
numObjects notNil ifTrue:[ |
|
1421 |
numObjectsDone \\ 1000 == 0 ifTrue:[ |
|
1422 |
progress percentage:(numObjectsDone / numObjects * 100). |
|
1423 |
Processor yield. |
|
1424 |
] |
|
1425 |
] |
|
1426 |
] |
|
1427 |
]] whileFalse. |
|
1428 |
]. |
|
1429 |
progress percentage:100. |
|
1430 |
||
1431 |
numObjects isNil ifTrue:[ |
|
1432 |
numObjects := numObjectsDone. |
|
1433 |
]. |
|
1434 |
||
1435 |
owners remove:aCollection ifAbsent:nil. |
|
1436 |
owners remove:thisContext ifAbsent:nil. |
|
1437 |
owners remove:objectArray ifAbsent:nil. |
|
1438 |
owners remove:objects keyArray ifAbsent:nil. |
|
1439 |
owners remove:owners keyArray ifAbsent:nil. |
|
3266 | 1440 |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1441 |
"/ 'done with level: ' print. levels size print. ' found ' print. owners size print. ' refs' printCR. |
3266 | 1442 |
|
15441 | 1443 |
owners isEmpty ifTrue:[ |
1444 |
found ifFalse:[ |
|
1445 |
stop := true. |
|
1446 |
] |
|
1447 |
]. |
|
1448 |
||
1449 |
stop ifFalse:[ |
|
1450 |
done := found or:[(owners includesIdentical:Smalltalk)]. |
|
1451 |
done ifTrue:[ |
|
1452 |
moreChainsOnThisLevel := true. |
|
1453 |
temporaryRemoved := IdentitySet new. |
|
1454 |
||
1455 |
levels size > 0 ifTrue:[ |
|
1456 |
"/ show what we found so far. |
|
1457 |
levels last add:Smalltalk. |
|
1458 |
levels reverse. |
|
1459 |
]. |
|
1460 |
||
1461 |
chains := OrderedCollection new. |
|
1462 |
||
1463 |
tLevels := levels collect:[:lColl | lColl copy]. |
|
1464 |
||
1465 |
lbl label:('building refchains ...'). |
|
1466 |
||
1467 |
nAll := aCollection size. |
|
1468 |
nDone := 0. |
|
1469 |
aCollection do:[:anObject | |theseChains| |
|
1470 |
stop ifFalse:[ |
|
1471 |
theseChains := self |
|
1472 |
refChainsFrom:Smalltalk |
|
1473 |
to:anObject |
|
1474 |
inRefSets:tLevels |
|
1475 |
startingAt:1. |
|
1476 |
||
1477 |
theseChains size > 0 ifTrue:[ |
|
1478 |
chains addAll:theseChains |
|
1479 |
]. |
|
1480 |
nDone := nDone + 1. |
|
1481 |
progress percentage:(nDone / nAll * 100). |
|
1482 |
] |
|
1483 |
]. |
|
1484 |
||
1485 |
tLevels := nil. |
|
1486 |
||
1487 |
levels size > 0 ifTrue:[ |
|
1488 |
levels reverse. |
|
1489 |
levels last remove:Smalltalk. |
|
1490 |
]. |
|
1491 |
||
1492 |
[stop not |
|
1493 |
and:[chains size > 0]] whileTrue:[ |
|
1494 |
chain := chains first. |
|
1495 |
chains removeFirst. |
|
1496 |
||
1497 |
lbl label:('found a reference chain.'). |
|
1498 |
progress beInvisible. |
|
1499 |
||
1500 |
chain addFirst:Smalltalk. |
|
1501 |
list := OrderedCollection withSize:chain size. |
|
1502 |
1 to:chain size-1 do:[:i | |
|
1503 |
list |
|
1504 |
at:i |
|
1505 |
put:(self refNameFor:(chain at:i+1) in:(chain at:i)) |
|
1506 |
]. |
|
1507 |
list at:list size put:(chain last classNameWithArticle). |
|
1508 |
||
1509 |
"/ hide the VMProcesses stuff from the user ... |
|
1510 |
(list at:1) string = 'Smalltalk:__VMProcesses__' ifTrue:[ |
|
1511 |
list at:1 put:'__VMProcesses__ (a hidden VM reference)'. |
|
1512 |
list removeIndex:2. |
|
1513 |
chain at:1 put:nil. |
|
1514 |
chain removeIndex:2. |
|
1515 |
]. |
|
1516 |
||
1517 |
listV list:list. |
|
1518 |
||
1519 |
listV beVisible. |
|
1520 |
listV doubleClickAction:[:idx | |o| |
|
1521 |
(o := chain at:idx) notNil ifTrue:[ |
|
1522 |
o inspect. |
|
1523 |
] |
|
1524 |
]. |
|
1525 |
moreButton beVisible. |
|
1526 |
anyShown := anyShownInAnyLevel := true. |
|
1527 |
showMore := false. |
|
1528 |
||
1529 |
"/ kludge - wait for some user action |
|
1530 |
||
1531 |
[showMore or:[stop or:[top realized not]]] whileFalse:[ |
|
1532 |
Delay waitForSeconds:0.1 |
|
1533 |
]. |
|
1534 |
||
1535 |
chain := nil. |
|
1536 |
||
1537 |
top realized ifFalse:[ |
|
1538 |
stop := true |
|
1539 |
] ifTrue:[ |
|
1540 |
listV doubleClickAction:nil. |
|
1541 |
showMore ifFalse:[ |
|
1542 |
stop := true. |
|
1543 |
]. |
|
1544 |
]. |
|
1545 |
done := false. |
|
1546 |
||
1547 |
stop ifFalse:[ |
|
1548 |
progress beVisible. |
|
1549 |
listV beInvisible. |
|
1550 |
moreButton beInvisible. |
|
1551 |
||
1552 |
chain := nil. |
|
1553 |
] |
|
1554 |
]. |
|
1555 |
levels size > 0 ifTrue:[ |
|
1556 |
levels last addAll:temporaryRemoved. |
|
1557 |
] |
|
1558 |
]. |
|
1559 |
]. |
|
1560 |
||
1561 |
owners remove:Smalltalk ifAbsent:nil. |
|
1562 |
owners remove:(owners keyArray) ifAbsent:nil. |
|
1563 |
owners remove:objectArray ifAbsent:nil. |
|
1564 |
levels do:[:lColl | |
|
1565 |
owners remove:lColl ifAbsent:nil |
|
1566 |
]. |
|
1567 |
||
1568 |
levels add:owners. |
|
1569 |
||
1570 |
objects := owners. |
|
1571 |
||
1572 |
objects size == 0 ifTrue:[ |
|
1573 |
stop := true |
|
1574 |
]. |
|
1575 |
||
1576 |
stop ifTrue:[ |
|
1577 |
Smalltalk at:#'__VMProcesses__' put:nil. |
|
1578 |
top destroy. |
|
1579 |
anyShown ifFalse:[ |
|
1580 |
userStop ifFalse:[ |
|
1581 |
self information:(anyShownInAnyLevel ifTrue:['no more references'] ifFalse:['no references']). |
|
1582 |
] |
|
1583 |
]. |
|
1584 |
^ self. |
|
1585 |
]. |
|
3266 | 1586 |
|
1587 |
]. |
|
1588 |
||
1589 |
anyShown ifTrue:[ |
|
15441 | 1590 |
userStop ifFalse:[ |
1591 |
self information:'no more references'. |
|
1592 |
] |
|
3266 | 1593 |
]. |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1594 |
Smalltalk at:#'__VMProcesses__' put:nil. |
3266 | 1595 |
^ self |
1596 |
||
1597 |
" |
|
1598 |
self displayRefChainTo:Point new |
|
1599 |
" |
|
1600 |
" |
|
1601 |
Smalltalk at:#foo put:Point new. |
|
1602 |
self displayRefChainTo:(Smalltalk at:#foo) |
|
1603 |
" |
|
1604 |
" |
|
1605 |
|p| |
|
1606 |
p := Point new. |
|
1607 |
Smalltalk at:#foo put:(#x -> p). |
|
1608 |
self displayRefChainTo:p |
|
1609 |
" |
|
1610 |
" |
|
1611 |
|a| |
|
1612 |
a := Array new:1. a at:1 put:a. |
|
1613 |
Smalltalk at:#foo put:(#x -> a). |
|
1614 |
Smalltalk at:#bar put:(Array with:(#y -> a)). |
|
10226 | 1615 |
self displayRefChainTo:a |
3266 | 1616 |
" |
1617 |
" |
|
1618 |
|a| |
|
1619 |
a := Array new:1. a at:1 put:a. |
|
1620 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
|
10226 | 1621 |
self displayRefChainTo:a |
3266 | 1622 |
" |
1623 |
" |
|
1624 |
|a| |
|
1625 |
a := Array new:1. a at:1 put:a. |
|
1626 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
|
10226 | 1627 |
self displayRefChainTo:a |
3266 | 1628 |
" |
1629 |
" |
|
1630 |
|p| |
|
1631 |
p := Point new. |
|
1632 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
|
1633 |
self displayRefChainTo:p |
|
1634 |
" |
|
1635 |
" |
|
1636 |
self displayRefChainTo:Transcript topView |
|
1637 |
" |
|
1638 |
||
1639 |
"Created: / 2.2.1998 / 23:58:04 / cg" |
|
3643 | 1640 |
"Modified: / 10.7.1998 / 17:22:06 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1641 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1642 |
|
615 | 1643 |
dumpObject:someObject |
1644 |
"low level dump an object. |
|
10226 | 1645 |
WARNING: this method is for ST/X debugging only |
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1646 |
it may be removed (or replaced by a noop) without notice" |
615 | 1647 |
|
1648 |
%{ |
|
14068 | 1649 |
__dumpObject__(someObject, __LINE__); |
615 | 1650 |
%} |
1651 |
" |
|
1652 |
ObjectMemory dumpObject:true |
|
10226 | 1653 |
ObjectMemory dumpObject:(Array new:10) |
1654 |
ObjectMemory dumpObject:(10@20 corner:30@40) |
|
615 | 1655 |
" |
1656 |
! |
|
1657 |
||
7326 | 1658 |
dumpSender |
1659 |
"dump my senders context" |
|
1660 |
||
1661 |
%{ |
|
1662 |
__PATCHUPCONTEXT(__thisContext); |
|
1663 |
__dumpContext__(__ContextInstPtr(__thisContext)->c_sender); |
|
1664 |
%} |
|
1665 |
" |
|
1666 |
ObjectMemory dumpSender |
|
1667 |
" |
|
1668 |
! |
|
1669 |
||
615 | 1670 |
flagsOf:anObject |
1671 |
"For debugging only. |
|
10226 | 1672 |
WARNING: this method is for ST/X debugging only |
1673 |
it will be removed without notice" |
|
615 | 1674 |
|
1675 |
%{ /* NOCONTEXT */ |
|
1676 |
||
1677 |
if (! __isNonNilObject(anObject)) { |
|
10226 | 1678 |
RETURN ( nil ); |
615 | 1679 |
} |
8913 | 1680 |
RETURN ( __mkSmallInteger( anObject->o_flags ) ); |
615 | 1681 |
%} |
1682 |
" |
|
1683 |
F_ISREMEMBERED 1 /* a new-space thing being refd by some oldSpace thing */ |
|
1684 |
F_ISFORWARDED 2 /* a forwarded object (you will never see this here) */ |
|
1685 |
F_DEREFERENCED 4 /* a collection after grow (not currently used) */ |
|
1686 |
F_ISONLIFOLIST 8 /* a non-lifo-context-referencing-obj already on list */ |
|
1687 |
F_MARK 16 /* mark bit for background collector */ |
|
1688 |
" |
|
1689 |
||
1690 |
" |
|
1691 |
|arr| |
|
1692 |
||
1693 |
arr := Array new. |
|
1694 |
arr at:1 put:([thisContext] value). |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1695 |
(ObjectMemory flagsOf:anObject) printCR |
615 | 1696 |
" |
1697 |
! |
|
1698 |
||
1699 |
objectAt:anAddress |
|
1700 |
"return whatever anAddress points to as object. |
|
10226 | 1701 |
BIG BIG DANGER ALERT: |
1702 |
this method is only to be used for debugging ST/X itself |
|
615 | 1703 |
- you can easily (and badly) crash the system. |
10226 | 1704 |
WARNING: this method is for ST/X debugging only |
615 | 1705 |
it will be removed without notice" |
1706 |
||
1288 | 1707 |
%{ /* NOCONTEXT */ |
4104 | 1708 |
INT addr = __longIntVal(anAddress); |
1288 | 1709 |
|
1710 |
if (addr) { |
|
1711 |
RETURN ((OBJ)(addr)); |
|
615 | 1712 |
} |
1288 | 1713 |
RETURN (nil); |
615 | 1714 |
%} |
1715 |
! |
|
1716 |
||
1288 | 1717 |
printReferences:anObject |
1718 |
"for debugging: print referents to anObject. |
|
10226 | 1719 |
WARNING: this method is for ST/X debugging only |
1288 | 1720 |
it will be removed without notice |
1721 |
use ObjectMemory>>whoReferences: or anObject>>allOwners." |
|
615 | 1722 |
|
1723 |
%{ |
|
1724 |
__printRefChain(__context, anObject); |
|
1725 |
%} |
|
1726 |
! |
|
1727 |
||
1288 | 1728 |
refChainFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1729 |
|chain| |
1288 | 1730 |
|
1731 |
index > levels size ifTrue:[ |
|
10226 | 1732 |
(start referencesObject:anObject) ifTrue:[ |
1733 |
^ OrderedCollection with:anObject. "/ (self refNameFor:anObject in:start) |
|
1734 |
]. |
|
1735 |
^ nil. |
|
1288 | 1736 |
]. |
1737 |
||
1738 |
(levels at:index) do:[:el | |
|
3266 | 1739 |
el ~~ start ifTrue:[ |
10226 | 1740 |
(start referencesObject:el) ifTrue:[ |
1741 |
chain := self |
|
1742 |
refChainFrom:el |
|
1743 |
to:anObject |
|
1744 |
inRefSets:levels |
|
1745 |
startingAt:(index+1). |
|
1746 |
||
1747 |
chain notNil ifTrue:[ |
|
1748 |
(levels at:index) saveRemove:el. |
|
1749 |
chain addFirst:el. "/ (self refNameFor:el in:start). |
|
1750 |
^ chain. |
|
1751 |
] |
|
1752 |
]. |
|
3266 | 1753 |
]. |
1288 | 1754 |
]. |
1755 |
^ nil |
|
1756 |
||
1757 |
||
1758 |
" |
|
1759 |
|o a1 a2| |
|
1760 |
||
1761 |
o := Object new. |
|
1762 |
a1 := Array with:o with:nil with:nil. |
|
1763 |
a2 := Array with:a1 with:nil with:nil. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1764 |
a2 referencesObject:a1 |
1288 | 1765 |
" |
1766 |
||
1767 |
" |
|
1768 |
|o a1 a2 a3 a4 levels| |
|
1769 |
||
1770 |
o := Object new. |
|
1771 |
a1 := Array with:o. |
|
1772 |
a2 := Array with:a1. |
|
1773 |
a3 := Array with:a2. |
|
1774 |
a4 := Array with:a3. |
|
1775 |
levels := Array with:(Array with:a3) |
|
10226 | 1776 |
with:(Array with:a2) |
1777 |
with:(Array with:a1). |
|
1778 |
||
1779 |
self refChainFrom:a4 to:o inRefSets:levels startingAt:1. |
|
1108 | 1780 |
" |
1781 |
||
3266 | 1782 |
"Modified: / 3.2.1998 / 02:38:27 / cg" |
1108 | 1783 |
! |
1784 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1785 |
refChainsFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1786 |
|chains chain c| |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1787 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1788 |
chains := OrderedCollection new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1789 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1790 |
index > levels size ifTrue:[ |
10226 | 1791 |
(start referencesObject:anObject) ifTrue:[ |
1792 |
chains add:(OrderedCollection with:anObject "(self refNameFor:anObject in:start)"). |
|
1793 |
]. |
|
1794 |
^ chains |
|
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1795 |
]. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1796 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1797 |
(levels at:index) do:[:el | |
3266 | 1798 |
el ~~ start ifTrue:[ |
10226 | 1799 |
(start referencesObject:el) ifTrue:[ |
1800 |
chain := self |
|
1801 |
refChainFrom:el |
|
1802 |
to:anObject |
|
1803 |
inRefSets:levels |
|
1804 |
startingAt:(index+1). |
|
1805 |
||
1806 |
chain size > 0 ifTrue:[ |
|
1807 |
(levels at:index) saveRemove:el. |
|
1808 |
||
1809 |
c := chain copy. |
|
1810 |
c addFirst:el "(self refNameFor:el in:start)". |
|
1811 |
chains add:c. |
|
1812 |
] |
|
3266 | 1813 |
]. |
10226 | 1814 |
]. |
3266 | 1815 |
]. |
1816 |
^ chains |
|
1817 |
||
1818 |
"Created: / 2.2.1998 / 19:09:22 / cg" |
|
1819 |
"Modified: / 3.2.1998 / 02:38:17 / cg" |
|
1820 |
! |
|
1821 |
||
1822 |
refNameFor:anObject in:referent |
|
1823 |
|names oClass| |
|
1824 |
||
1825 |
referent == Smalltalk ifTrue:[ |
|
13584 | 1826 |
referent keysAndValuesDo:[:key :val | |
1827 |
|idx| |
|
1828 |
||
1829 |
(anObject == val) ifTrue:[ |
|
1830 |
"/ for our convenience - if its a nameSpace, cut off Smalltalk. |
|
1831 |
idx := key string indexOf:$:. |
|
1832 |
(idx ~~ 0 |
|
1833 |
and:[idx < key string size |
|
1834 |
and:[(key string at:(idx+1)) == $:]]) ifTrue:[ |
|
1835 |
^ key allBold "/ (key copyFrom:(idx+2)) allBold |
|
1836 |
]. |
|
1837 |
^ 'Smalltalk:' , (key allBold). |
|
1838 |
] |
|
1839 |
]. |
|
3266 | 1840 |
] ifFalse:[ |
13584 | 1841 |
names := referent class allInstVarNames. |
1842 |
oClass := referent class. |
|
1843 |
1 to:oClass instSize do:[:i | |
|
1844 |
((referent instVarAt:i) == anObject) ifTrue:[ |
|
1845 |
^ '%1 [%2]' bindWith:referent classNameWithArticle with:(names at:i) allBold. |
|
1846 |
]. |
|
1847 |
]. |
|
1848 |
oClass isVariable ifTrue:[ |
|
1849 |
oClass isPointers ifTrue:[ |
|
1850 |
1 to:referent basicSize do:[:i | |
|
1851 |
((referent basicAt:i) == anObject) ifTrue:[ |
|
1852 |
^ '%1 [%2] (sz=%2)' bindWith:referent classNameWithArticle with:i printString allBold with:referent basicSize printString |
|
1853 |
] |
|
1854 |
] |
|
1855 |
] |
|
1856 |
]. |
|
3266 | 1857 |
]. |
10833 | 1858 |
self error:'no reference' mayProceed:true. |
6568 | 1859 |
^ nil. |
3266 | 1860 |
|
1861 |
"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
|
1862 |
"Modified: / 4.2.1998 / 22:03:36 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1863 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1864 |
|
1288 | 1865 |
sizeOf:anObject |
1866 |
"return the size of anObject in bytes. |
|
1867 |
(this is not the same as 'anObject size'). |
|
10226 | 1868 |
WARNING: this method is for ST/X debugging only |
1869 |
it will be removed without notice" |
|
1288 | 1870 |
|
1871 |
%{ /* NOCONTEXT */ |
|
1872 |
||
8913 | 1873 |
RETURN ( __isNonNilObject(anObject) ? __mkSmallInteger(__qSize(anObject)) : __mkSmallInteger(0) ) |
1288 | 1874 |
%} |
1875 |
" |
|
1876 |
|hist big nw| |
|
1877 |
||
1878 |
hist := Array new:100 withAll:0. |
|
1879 |
big := 0. |
|
1880 |
ObjectMemory allObjectsDo:[:o | |
|
10226 | 1881 |
nw := (ObjectMemory sizeOf:o) // 4 + 1. |
1882 |
nw > 100 ifTrue:[ |
|
1883 |
big := big + 1 |
|
1884 |
] ifFalse:[ |
|
1885 |
hist at:nw put:(hist at:nw) + 1 |
|
1886 |
]. |
|
615 | 1887 |
]. |
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1888 |
hist printCR. |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
1889 |
big printCR |
615 | 1890 |
" |
1288 | 1891 |
! |
1892 |
||
1893 |
spaceOf:anObject |
|
1894 |
"return the memory space, in which anObject is. |
|
10226 | 1895 |
- since objects may move between spaces, |
1288 | 1896 |
the returned value may be invalid after the next scavenge/collect. |
10226 | 1897 |
WARNING: this method is for ST/X debugging only |
1288 | 1898 |
it will be removed without notice" |
1899 |
||
1900 |
%{ /* NOCONTEXT */ |
|
1901 |
||
1902 |
if (! __isNonNilObject(anObject)) { |
|
1903 |
RETURN ( nil ); |
|
1904 |
} |
|
8913 | 1905 |
RETURN ( __mkSmallInteger( __qSpace(anObject) ) ); |
1288 | 1906 |
%} |
375 | 1907 |
! ! |
1908 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1909 |
!ObjectMemory class methodsFor:'debugging ST/X'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1910 |
|
13946 | 1911 |
checkConsistency |
1912 |
"call the object memory consistency checker. |
|
1913 |
Useful to check if all obejct references are still valid, |
|
1914 |
especially when primitive (inline-C) code is developped. |
|
1915 |
If called before and after a primitive, missing STORE checks or |
|
1916 |
overwritten object headers etc. might be detected. |
|
1917 |
(there is no real guarantee, that all such errors are detected, though)" |
|
1918 |
||
1919 |
%{ |
|
1920 |
__checkConsistency("user call"); |
|
1921 |
%} |
|
1922 |
||
1923 |
" |
|
1924 |
ObjectMemory checkConsistency |
|
1925 |
" |
|
1926 |
||
1927 |
"Created: / 18-01-2012 / 12:10:37 / cg" |
|
1928 |
! |
|
1929 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1930 |
printPolyCaches |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1931 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1932 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1933 |
"dump poly caches. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1934 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1935 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1936 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1937 |
__dumpILCCaches(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1938 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1939 |
|
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 |
ObjectMemory printPolyCaches |
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 |
! |
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 |
printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1946 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1947 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1948 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1949 |
(You may turn off the stack print with debugPrinting:false) |
10226 | 1950 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1951 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1952 |
|
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 |
__printStack(__context); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1955 |
%} |
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 |
ObjectMemory printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1959 |
" |
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 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1963 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1964 |
printStackBacktraceFrom:aContext |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1965 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1966 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1967 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1968 |
(You may turn off the stack print with debugPrinting:false) |
10226 | 1969 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1970 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1971 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1972 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1973 |
__printStack(aContext); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1974 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1975 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1976 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1977 |
ObjectMemory printStackBacktraceFrom:thisContext sender sender |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1978 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1979 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1980 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1981 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1982 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1983 |
printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1984 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1985 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1986 |
"dump the internal symbol table. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1987 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
1988 |
it will be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1989 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1990 |
#ifdef DEBUG |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1991 |
__dumpSymbols(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1992 |
#endif |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1993 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1994 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1995 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1996 |
ObjectMemory printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1997 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1998 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1999 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2000 |
sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2001 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2002 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2003 |
"turns tracing of message sends off. |
10226 | 2004 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2005 |
it may be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2006 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2007 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2008 |
__setMessageTrace__(0); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2009 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2010 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2011 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2012 |
ObjectMemory sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2013 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2014 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2015 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2016 |
sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2017 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2018 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2019 |
"turns tracing of message sends on. |
10226 | 2020 |
WARNING: this method is for debugging only |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2021 |
it may be removed without notice" |
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2022 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2023 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2024 |
__setMessageTrace__(1); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2025 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2026 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2027 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2028 |
ObjectMemory sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2029 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2030 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
2031 |
|
1767 | 2032 |
!ObjectMemory class methodsFor:'dependents access'! |
10 | 2033 |
|
1288 | 2034 |
dependents |
3223 | 2035 |
"return the collection of my dependents" |
1288 | 2036 |
|
3057
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
2037 |
^ Dependents ? #() |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
2038 |
|
3223 | 2039 |
"Modified: / 26.1.1998 / 11:17:59 / cg" |
10 | 2040 |
! |
2041 |
||
1288 | 2042 |
dependents:aCollection |
10 | 2043 |
"set the dependents collection" |
2044 |
||
2045 |
Dependents := aCollection |
|
1288 | 2046 |
! |
2047 |
||
2048 |
dependentsDo:aBlock |
|
2049 |
"evaluate aBlock for all of my dependents. |
|
2050 |
Since this is performed at startup time (under the scheduler), |
|
2051 |
this is redefined here to catch abort signals. |
|
2052 |
Thus, if any error occurs in a #returnFromSnapshot, |
|
2053 |
the user can press abort to continue." |
|
2054 |
||
2055 |
|deps| |
|
2056 |
||
2057 |
deps := Dependents. |
|
2058 |
deps notNil ifTrue:[ |
|
10226 | 2059 |
deps do:[:each | |
2060 |
AbortOperationRequest handle:[:ex | |
|
2061 |
ex return |
|
2062 |
] do:[ |
|
2063 |
aBlock value:each |
|
2064 |
] |
|
2065 |
] |
|
282 | 2066 |
] |
1288 | 2067 |
! ! |
2068 |
||
1767 | 2069 |
!ObjectMemory class methodsFor:'enumerating'! |
1288 | 2070 |
|
2071 |
allInstancesOf:aClass do:aBlock |
|
2072 |
"evaluate the argument, aBlock for all instances of aClass in the system. |
|
2073 |
There is one caveat: if a compressing oldSpace collect |
|
2074 |
occurs while looping over the objects, the loop cannot be |
|
2075 |
continued (for some internal reasons). In this case, false |
|
2076 |
is returned." |
|
2077 |
||
2078 |
|work| |
|
2079 |
||
2080 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
2081 |
__nonTenuringScavenge(__context); |
|
2082 |
/* |
|
2083 |
* allInstancesDo needs a temporary to hold newSpace objects |
|
2084 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2085 |
if (__allInstancesOfDo(&aClass, &aBlock, &work) < 0) { |
159 | 2086 |
RETURN (false); |
85 | 2087 |
} |
2088 |
%}. |
|
2089 |
^ true |
|
2 | 2090 |
! |
2091 |
||
1288 | 2092 |
allObjectsDo:aBlock |
2093 |
"evaluate the argument, aBlock for all objects in the system. |
|
2094 |
There is one caveat: if a compressing oldSpace collect |
|
2095 |
occurs while looping over the objects, the loop cannot be |
|
2096 |
continued (for some internal reasons). In this case, false |
|
2097 |
is returned." |
|
2098 |
||
2099 |
|work| |
|
2100 |
||
2101 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
2102 |
__nonTenuringScavenge(__context); |
|
2103 |
/* |
|
2104 |
* allObjectsDo needs a temporary to hold newSpace objects |
|
2105 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2106 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, &work) < 0) { |
615 | 2107 |
RETURN (false); |
2108 |
} |
|
2109 |
%}. |
|
2110 |
^ true |
|
1288 | 2111 |
! |
2112 |
||
3266 | 2113 |
allObjectsIncludingContextsDo:aBlock |
2114 |
"like allObjectsDo, but also walks over all contexts |
|
2115 |
of living processes" |
|
2116 |
||
2117 |
self allObjectsDo:aBlock. |
|
2118 |
ProcessorScheduler knownProcesses do:[:p | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2119 |
|con| |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2120 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2121 |
con := p suspendedContext. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2122 |
[con notNil] whileTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2123 |
aBlock value:con. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2124 |
con := con sender. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2125 |
]. |
3266 | 2126 |
]. |
2127 |
||
2128 |
"Created: / 3.2.1998 / 11:32:08 / cg" |
|
2129 |
! |
|
2130 |
||
1288 | 2131 |
allOldObjectsDo:aBlock |
2132 |
"evaluate the argument, aBlock for all old objects in the system. |
|
2133 |
For debugging and tests only - do not use" |
|
2134 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2135 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, (OBJ *)0) < 0) { |
1288 | 2136 |
RETURN (false); |
2137 |
} |
|
10226 | 2138 |
%}. |
1288 | 2139 |
^ true |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2140 |
! |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2141 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2142 |
processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2143 |
"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
|
2144 |
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
|
2145 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2146 |
%{ |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2147 |
extern OBJ __processesKnownInVM(); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2148 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2149 |
RETURN (__processesKnownInVM()); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2150 |
%} |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2151 |
" |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2152 |
ObjectMemory processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2153 |
" |
1 | 2154 |
! ! |
2155 |
||
1767 | 2156 |
!ObjectMemory class methodsFor:'garbage collection'! |
615 | 2157 |
|
3725
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2158 |
backgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2159 |
"return the backgroundCollectProcess (or nil, if noone is running)" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2160 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2161 |
^ BackgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2162 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2163 |
"Created: / 4.8.1998 / 01:54:16 / cg" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2164 |
! |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2165 |
|
1288 | 2166 |
backgroundCollectorRunning |
2167 |
"return true, if a backgroundCollector is running" |
|
2168 |
||
2169 |
^ BackgroundCollectProcess notNil |
|
500 | 2170 |
|
2171 |
" |
|
615 | 2172 |
ObjectMemory backgroundCollectorRunning |
375 | 2173 |
" |
2174 |
! |
|
2175 |
||
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2176 |
compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2177 |
"COMPRESS the oldSpace memory area. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2178 |
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
|
2179 |
be slightly slower than the semispace compress if lots of real memory |
10226 | 2180 |
is available. |
2181 |
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
|
2182 |
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
|
2183 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2184 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2185 |
This can take a long time." |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2186 |
%{ |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2187 |
__compressOldSpace(__context); |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2188 |
%} |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2189 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2190 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2191 |
ObjectMemory compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2192 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2193 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2194 |
Transcript showCR:(Time millisecondsToRun:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2195 |
ObjectMemory markAndSweep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2196 |
ObjectMemory compressOldSpace. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2197 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2198 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2199 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2200 |
Transcript showCR:(Time millisecondsToRun:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2201 |
ObjectMemory compressingGarbageCollect. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2202 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2203 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2204 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2205 |
! |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2206 |
|
1288 | 2207 |
compressingGarbageCollect |
10226 | 2208 |
"search for and free garbage in the oldSpace (newSpace is cleaned automatically) |
1288 | 2209 |
performing a COMPRESSING garbage collect. |
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2210 |
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
|
2211 |
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
|
2212 |
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
|
2213 |
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
|
2214 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2215 |
|
1288 | 2216 |
This can take a long time - especially, if paging is involved |
2217 |
(when no paging is involved, its faster than I thought :-). |
|
2218 |
If no memory is available for the compress, or the system has been started with |
|
2219 |
the -Msingle option, this does a non-COMPRESSING collect." |
|
2220 |
%{ |
|
2221 |
if (! __garbageCollect(__context)) { |
|
10226 | 2222 |
__markAndSweep(); |
2223 |
RETURN (false); |
|
178 | 2224 |
} |
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2225 |
RETURN (true); |
1 | 2226 |
%} |
2227 |
||
93 | 2228 |
" |
375 | 2229 |
ObjectMemory compressingGarbageCollect |
93 | 2230 |
" |
2231 |
! |
|
2232 |
||
1288 | 2233 |
garbageCollect |
2234 |
"search for and free garbage in the oldSpace. |
|
2235 |
This can take a long time - especially, if paging is involved." |
|
2236 |
||
10226 | 2237 |
"/ used to be |
2238 |
"/ self compressingGarbageCollect |
|
1288 | 2239 |
"/ here; changed to default to markAndSweep |
615 | 2240 |
|
2241 |
self markAndSweep |
|
1 | 2242 |
|
93 | 2243 |
" |
615 | 2244 |
ObjectMemory garbageCollect |
375 | 2245 |
" |
2246 |
! |
|
2247 |
||
1288 | 2248 |
gcStep |
2249 |
"one incremental garbage collect step. |
|
2250 |
Mark or sweep some small number of objects. This |
|
2251 |
method will return after a reasonable (short) time. |
|
2252 |
This is used by the ProcessorScheduler at idle times. |
|
2253 |
Returns true, if an incremental GC cycle has finished." |
|
2254 |
%{ |
|
2255 |
extern int __incrGCstep(); |
|
133 | 2256 |
|
5461 | 2257 |
RETURN (__incrGCstep() ? true : false); |
1 | 2258 |
%} |
2259 |
! |
|
2260 |
||
1288 | 2261 |
gcStepIfUseful |
2262 |
"If either the IncrementalGCLimit or the FreeSpaceGCLimits have been |
|
2263 |
reached, perform one incremental garbage collect step. |
|
2264 |
Return true, if more gcSteps are required to finish the cycle, |
|
2265 |
false if done with a gc round. |
|
2266 |
If no limit has been reached yet, do nothing and return false. |
|
10226 | 2267 |
This is called by the ProcessorScheduler at idle times or by the |
1288 | 2268 |
backgroundCollector." |
2269 |
||
2270 |
|done limit| |
|
2271 |
||
2272 |
AbortSignal handle:[:ex | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2273 |
"/ in case of abort (from the debugger), |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2274 |
"/ disable gcSteps. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2275 |
done := true. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2276 |
IncrementalGCLimit := FreeSpaceGCLimit := nil. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2277 |
'ObjectMemory [error]: IGC aborted; turning off incremental GC' errorPrintCR |
1288 | 2278 |
] do:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2279 |
limit := IncrementalGCLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2280 |
(limit notNil and:[self oldSpaceAllocatedSinceLastGC > limit]) ifTrue:[ |
3761 | 2281 |
"/ 'IGC [info]: start since allocatedSinceLastGC > IncrementalGCLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2282 |
done := ObjectMemory gcStep |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2283 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2284 |
limit := FreeSpaceGCLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2285 |
(limit notNil and:[(self freeSpace + self freeListSpace) < limit]) ifTrue:[ |
3761 | 2286 |
"/ 'IGC [info]: start since freeSpace < FreeSpaceGCLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2287 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2288 |
done ifTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2289 |
self moreOldSpaceIfUseful |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2290 |
]. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2291 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2292 |
limit := DynamicCodeGCTrigger. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2293 |
(limit notNil and:[self compiledCodeCounter > limit]) ifTrue:[ |
3761 | 2294 |
"/ 'IGC [info]: start since compiledCodeCounter > DynamicCodeGCTrigger' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2295 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2296 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2297 |
limit := DynamicCodeLimit. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2298 |
(limit notNil and:[self compiledCodeSpaceUsed > limit]) ifTrue:[ |
3761 | 2299 |
"/ 'IGC [info]: start since compiledCodeSpaceUsed > DynamicCodeLimit' infoPrintCR. |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2300 |
done := ObjectMemory gcStep. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2301 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2302 |
done := true |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2303 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2304 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2305 |
] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2306 |
]. |
615 | 2307 |
]. |
2308 |
^ done not |
|
1768 | 2309 |
|
3761 | 2310 |
"Modified: / 14.8.1998 / 13:08:15 / cg" |
615 | 2311 |
! |
2312 |
||
1288 | 2313 |
incrementalGC |
2314 |
"perform one round of incremental GC steps. |
|
10226 | 2315 |
The overall effect of this method is (almost) the same as calling |
1288 | 2316 |
markAndSweep. However, #incrementalGC is interruptable while #markAndSweep |
2317 |
is atomic and blocks for a while. The code here performs incremental |
|
2318 |
GC steps, until one complete gc-cycle is completed. If running at a higher |
|
2319 |
than userBackground priority, it will give up the CPU after every such |
|
2320 |
step for a while. |
|
10226 | 2321 |
Thus this method can be called either from a low prio (background) process |
1288 | 2322 |
or from a high prio process. |
2323 |
(however, if you have nothing else to do, its better to call for markAndSweep, |
|
2324 |
since it is faster) |
|
2325 |
For example, someone allocating huge amounts of memory could |
|
2326 |
ask for the possibility of a quick allocation using |
|
2327 |
#checkForFastNew: and try a #incrementalGC if not. In many |
|
10226 | 2328 |
cases, this can avoid a pause (in the higher prio processes) due to |
1288 | 2329 |
a blocking GC." |
2330 |
||
1669 | 2331 |
|delay| |
1288 | 2332 |
|
2333 |
Processor activeProcess priority > Processor userBackgroundPriority ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2334 |
delay := Delay forMilliseconds:1 |
1288 | 2335 |
]. |
2336 |
||
3742 | 2337 |
((self incrementalGCPhaseSymbolic ~~ #idle) |
2338 |
or:[self gcStepIfUseful]) ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2339 |
[self gcStep] whileFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2340 |
delay notNil ifTrue:[delay wait] |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
2341 |
] |
1288 | 2342 |
]. |
2343 |
self moreOldSpaceIfUseful |
|
2344 |
||
2345 |
" |
|
2346 |
ObjectMemory incrementalGC |
|
2347 |
[ObjectMemory incrementalGC] forkAt:3 |
|
10226 | 2348 |
[ObjectMemory incrementalGC] forkAt:9 |
133 | 2349 |
" |
3108 | 2350 |
|
3742 | 2351 |
"Modified: / 10.8.1998 / 15:03:07 / cg" |
194 | 2352 |
! |
2353 |
||
1288 | 2354 |
markAndSweep |
2355 |
"mark/sweep garbage collector. |
|
2356 |
perform a full mark&sweep collect. |
|
2357 |
Warning: this may take some time and it is NOT interruptable. |
|
2358 |
If you want to do a collect from a background process, or have |
|
2359 |
other things to do, better use #incrementalGC which is interruptable." |
|
615 | 2360 |
%{ |
5461 | 2361 |
__markAndSweep(); |
615 | 2362 |
%} |
194 | 2363 |
|
2364 |
" |
|
615 | 2365 |
ObjectMemory markAndSweep |
2366 |
" |
|
2367 |
! |
|
2368 |
||
8304 | 2369 |
nonVerboseGarbageCollect |
2370 |
"perform a compressing garbage collect or fallback to non-compressing collect, |
|
2371 |
if required." |
|
2372 |
||
2373 |
"/ try 1pass baker collect first. |
|
2374 |
"/ this will fail if oldSpace size is above compressLimit |
|
2375 |
(self compressingGarbageCollect) ifFalse:[ |
|
10226 | 2376 |
"/ fallBack - use 2pass inplace compress |
2377 |
self compressOldSpace |
|
8304 | 2378 |
]. |
2379 |
||
2380 |
" |
|
2381 |
ObjectMemory nonVerboseGarbageCollect |
|
2382 |
" |
|
2383 |
! |
|
2384 |
||
1288 | 2385 |
reclaimSymbols |
2386 |
"reclaim unused symbols; |
|
2387 |
Unused symbols are (currently) not reclaimed automatically, |
|
10226 | 2388 |
but only upon request with this method. |
1288 | 2389 |
It takes some time to do this ... and it is NOT interruptable. |
2390 |
Future versions may do this automatically, while garbage collecting." |
|
615 | 2391 |
%{ |
5461 | 2392 |
__reclaimSymbols(); |
615 | 2393 |
%} |
2394 |
" |
|
2395 |
ObjectMemory reclaimSymbols |
|
2396 |
" |
|
2397 |
! |
|
2398 |
||
8455 | 2399 |
resumeBackgroundCollector |
10743 | 2400 |
"resume the background collector process" |
8455 | 2401 |
|
2402 |
BackgroundCollectProcess notNil ifTrue:[ |
|
13584 | 2403 |
BackgroundCollectProcess resume. |
8455 | 2404 |
] |
2405 |
||
2406 |
" |
|
2407 |
ObjectMemory resumeBackgroundCollector |
|
2408 |
" |
|
2409 |
||
2410 |
"Created: / 03-08-2004 / 18:12:30 / stefan" |
|
10743 | 2411 |
"Modified: / 17-10-2007 / 13:14:46 / cg" |
8455 | 2412 |
! |
2413 |
||
1288 | 2414 |
scavenge |
2415 |
"collect young objects, without aging (i.e. no tenure). |
|
2416 |
Can be used to quickly get rid of shortly before allocated |
|
2417 |
stuff. This is relatively fast (compared to oldspace collect). |
|
2418 |
||
2419 |
An example where a non-tenuring scavenge makes sense is when |
|
10226 | 2420 |
allocating some OperatingSystem resource (a Color, File or View) |
1288 | 2421 |
and the OS runs out of resources. In this case, the scavenge may |
2422 |
free some ST-objects and therefore (by signalling the WeakArrays |
|
2423 |
or Registries) free the OS resources too. |
|
2424 |
Of course, only recently allocated resources will be freed this |
|
2425 |
way. If none was freed, a full collect will be needed." |
|
615 | 2426 |
%{ |
5461 | 2427 |
__nonTenuringScavenge(); |
615 | 2428 |
%} |
2429 |
||
2430 |
" |
|
2431 |
ObjectMemory scavenge |
|
194 | 2432 |
" |
207 | 2433 |
! |
2434 |
||
1288 | 2435 |
startBackgroundCollectorAt:aPriority |
2436 |
"start a process doing incremental GC in the background. |
|
2437 |
Use this, if you have suspendable background processes which |
|
2438 |
run all the time, and therefore would prevent the idle-collector |
|
2439 |
from running. See documentation in this class for more details." |
|
2440 |
||
2441 |
|p| |
|
2442 |
||
2443 |
"/ |
|
2444 |
"/ its not useful, to run it more than once |
|
2445 |
"/ |
|
2446 |
BackgroundCollectProcess notNil ifTrue:[ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2447 |
BackgroundCollectProcess priority:aPriority. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2448 |
^ self |
1288 | 2449 |
]. |
2450 |
||
2451 |
p := |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2452 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2453 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2454 |
|myDelay timeOfLastGC doGC| |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2455 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2456 |
myDelay := Delay forSeconds:5. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2457 |
timeOfLastGC := Timestamp now. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2458 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2459 |
[true] whileTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2460 |
doGC := self gcStepIfUseful. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2461 |
doGC ifFalse:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2462 |
(BackgroundCollectMaximumInterval notNil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2463 |
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
|
2464 |
ifTrue:[ |
3743 | 2465 |
"/ '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
|
2466 |
doGC := true. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2467 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2468 |
]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2469 |
|
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2470 |
doGC ifTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2471 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2472 |
"/ perform a full cycle (finish cycle) |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2473 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2474 |
[self gcStep] whileFalse:[]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2475 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2476 |
"/ 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
|
2477 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2478 |
self moreOldSpaceIfUseful. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2479 |
timeOfLastGC := Timestamp now. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2480 |
]. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2481 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2482 |
"/ wait a bit |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2483 |
"/ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2484 |
myDelay wait. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2485 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2486 |
] ifCurtailed:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2487 |
BackgroundCollectProcess := nil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2488 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
2489 |
] newProcess. |
1288 | 2490 |
p name:'background collector'. |
2491 |
p priority:aPriority. |
|
2492 |
p restartable:true. |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
2493 |
p beSystemProcess. |
1288 | 2494 |
p resume. |
2495 |
BackgroundCollectProcess := p |
|
2496 |
||
2497 |
" |
|
2498 |
the following lets the backgroundCollector run at prio 5 |
|
2499 |
whenever 100000 bytes have been allocated, OR freeSpace drops |
|
2500 |
below 1meg. Having the system keep 1meg as reserve for peak allocation. |
|
2501 |
||
2502 |
Doing this may reduce pauses due to inevitable collects when running |
|
2503 |
out of freeSpace, if the collector can keep up with allocation rate. |
|
2504 |
" |
|
2505 |
||
2506 |
" |
|
2258 | 2507 |
ObjectMemory stopBackgroundCollector. |
2508 |
||
1288 | 2509 |
ObjectMemory incrementalGCLimit:100000. |
2510 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
2258 | 2511 |
ObjectMemory startBackgroundCollectorAt:5. |
211 | 2512 |
" |
2258 | 2513 |
|
3761 | 2514 |
"Modified: / 14.8.1998 / 13:09:19 / cg" |
207 | 2515 |
! |
2516 |
||
1288 | 2517 |
stopBackgroundCollector |
2518 |
"stop the background collector" |
|
2519 |
||
2520 |
BackgroundCollectProcess notNil ifTrue:[ |
|
2521 |
BackgroundCollectProcess terminate. |
|
2522 |
BackgroundCollectProcess := nil |
|
207 | 2523 |
] |
293 | 2524 |
|
211 | 2525 |
" |
2526 |
ObjectMemory stopBackgroundCollector |
|
2527 |
" |
|
362 | 2528 |
! |
2529 |
||
8455 | 2530 |
suspendBackgroundCollector |
10743 | 2531 |
"suspend the background collector process. |
2532 |
Answer true, if the background collector was running before" |
|
8455 | 2533 |
|
2534 |
|backgroundCollectorWasRunning| |
|
2535 |
||
2536 |
backgroundCollectorWasRunning := false. |
|
2537 |
||
2538 |
BackgroundCollectProcess notNil ifTrue:[ |
|
13584 | 2539 |
"suspend doesn't work due to interrupt processing" |
2540 |
backgroundCollectorWasRunning := BackgroundCollectProcess isStopped not. |
|
2541 |
BackgroundCollectProcess stop. |
|
8455 | 2542 |
]. |
2543 |
||
2544 |
^ backgroundCollectorWasRunning |
|
10226 | 2545 |
|
8455 | 2546 |
|
2547 |
" |
|
2548 |
ObjectMemory suspendBackgroundCollector. |
|
2549 |
ObjectMemory resumeBackgroundCollector |
|
2550 |
" |
|
2551 |
||
2552 |
"Created: / 03-08-2004 / 18:11:41 / stefan" |
|
10743 | 2553 |
"Modified: / 17-10-2007 / 13:15:01 / cg" |
8455 | 2554 |
! |
2555 |
||
1288 | 2556 |
tenure |
2557 |
"force all living new stuff into old-space - effectively making |
|
2558 |
all living young objects become old objects immediately. |
|
2559 |
This is relatively fast (compared to oldspace collect). |
|
2560 |
||
2561 |
This method should only be used in very special situations: |
|
2562 |
for example, when building up some long-living data structure |
|
2563 |
in a time critical application. |
|
2564 |
To do so, you have to do a scavenge followed by a tenure after the |
|
2565 |
objects are created. Be careful, to not reference any other chunk- |
|
2566 |
data when calling for a tenure (this will lead to lots of garbage in |
|
2567 |
the oldspace). |
|
2568 |
In normal situations, explicit tenures are not needed." |
|
2569 |
%{ |
|
5461 | 2570 |
__tenure(); |
1288 | 2571 |
%} |
2572 |
||
2573 |
" |
|
2574 |
ObjectMemory tenure |
|
2575 |
" |
|
2576 |
" |
|
2577 |
... build up long living objects ... |
|
2578 |
ObjectMemory scavenge. |
|
2579 |
ObjectMemory tenure |
|
615 | 2580 |
... continue - objects created above are now in oldSpace ... |
2581 |
" |
|
2582 |
! |
|
2583 |
||
1288 | 2584 |
tenuringScavenge |
2585 |
"collect newspace stuff, with aging (i.e. objects old enough |
|
2586 |
will be moved into the oldSpace). |
|
2587 |
Use this for debugging and testing only - the system performs |
|
2588 |
this automatically when the newspace fills up. |
|
2589 |
This is relatively fast (compared to oldspace collect)" |
|
615 | 2590 |
%{ |
5461 | 2591 |
__scavenge(); |
615 | 2592 |
%} |
2593 |
||
2594 |
" |
|
2595 |
ObjectMemory tenuringScavenge |
|
2596 |
" |
|
1288 | 2597 |
! |
2598 |
||
2599 |
verboseGarbageCollect |
|
2600 |
"perform a compressing garbage collect and show some informational |
|
2601 |
output on the Transcript" |
|
2602 |
||
2603 |
|nBytesBefore nReclaimed value unit| |
|
2604 |
||
2605 |
nBytesBefore := self oldSpaceUsed. |
|
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2606 |
|
8304 | 2607 |
self nonVerboseGarbageCollect. |
3649 | 2608 |
|
2609 |
"/ show what we reclaimed |
|
1288 | 2610 |
nReclaimed := nBytesBefore - self oldSpaceUsed. |
2611 |
nReclaimed > 0 ifTrue:[ |
|
10226 | 2612 |
nReclaimed > 1024 ifTrue:[ |
2613 |
nReclaimed > (1024 * 1024) ifTrue:[ |
|
2614 |
value := nReclaimed * 10 // (1024 * 1024) / 10.0. |
|
2615 |
unit := ' Mb.' |
|
2616 |
] ifFalse:[ |
|
2617 |
value := nReclaimed // 1024. |
|
2618 |
unit := ' Kb.' |
|
2619 |
] |
|
2620 |
] ifFalse:[ |
|
2621 |
value := nReclaimed. |
|
2622 |
unit := ' bytes.' |
|
2623 |
]. |
|
2624 |
Transcript show:'reclaimed '; show:value. |
|
2625 |
Transcript showCR:unit |
|
1288 | 2626 |
] |
2627 |
||
2628 |
" |
|
2629 |
ObjectMemory verboseGarbageCollect |
|
2630 |
" |
|
1418 | 2631 |
|
3649 | 2632 |
"Modified: / 15.7.1998 / 13:28:05 / cg" |
178 | 2633 |
! ! |
2634 |
||
1767 | 2635 |
!ObjectMemory class methodsFor:'garbage collector control'! |
133 | 2636 |
|
1288 | 2637 |
announceOldSpaceNeed:howMuch |
2638 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
10226 | 2639 |
soon, which is going to live longer (whatever that means). |
1288 | 2640 |
It first checks if the memory can be allocated without forcing a compressing |
2641 |
GC. If not, the oldSpace is increased. This may also lead to a slow compressing |
|
2642 |
collect. However, many smaller increases are avoided afterwards. Calling this |
|
2643 |
method before allocating huge chunks of data may provide better overall performance. |
|
2644 |
Notice: this is a nonstandard interface - use only in special situations." |
|
2645 |
||
2646 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2647 |
self incrementalGC. |
|
2648 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2649 |
self moreOldSpace:howMuch |
|
615 | 2650 |
] |
2651 |
] |
|
310 | 2652 |
|
2653 |
" |
|
615 | 2654 |
ObjectMemory announceOldSpaceNeed:1000000 |
133 | 2655 |
" |
2656 |
! |
|
2657 |
||
1288 | 2658 |
announceSpaceNeed:howMuch |
2659 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
2660 |
soon. The VM tries to prepare itself for this allocation to be performed |
|
2661 |
with less overhead. For example, it could preallocate some memory in one |
|
2662 |
big chunk (instead of doing many smaller reallocations later). |
|
2663 |
Notice: this is a nonstandard interface - use only in special situations. |
|
2664 |
Also, this does a background collect before the big chunk of memory is |
|
2665 |
allocated, not locking other processes while doing so." |
|
2666 |
||
2667 |
(howMuch < (self newSpaceSize // 2)) ifTrue:[ |
|
2668 |
self scavenge. |
|
2669 |
]. |
|
2670 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2671 |
(howMuch > (self newSpaceSize // 2)) ifFalse:[ |
|
2672 |
self scavenge. |
|
2673 |
]. |
|
2674 |
self incrementalGC. |
|
2675 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2676 |
self moreOldSpace:howMuch |
|
202 | 2677 |
] |
2678 |
] |
|
2679 |
||
2680 |
" |
|
2681 |
ObjectMemory announceSpaceNeed:100000 |
|
2682 |
" |
|
2683 |
! |
|
2684 |
||
1288 | 2685 |
avoidTenure:flag |
2686 |
"set/clear the avoidTenure flag. If set, aging of newSpace is turned off |
|
2687 |
as long as the newSpace fill-grade stays below some magic high-water mark. |
|
2688 |
If off (the default), aging is done as usual. |
|
2689 |
If the flag is turned on, scavenge may be a bit slower, due to more |
|
2690 |
objects being copied around. However, chances are high that in an idle |
|
2691 |
or (almost idle) system, less objects are moved into oldSpace. |
|
2692 |
Therefore, this helps to avoid oldSpace colelcts, in systems which go into |
|
2693 |
some standby mode and are reactivated by some external event. |
|
2694 |
(the avoid-flag should be turned off there, and set again once the idle loop |
|
2695 |
is reentered). |
|
2696 |
||
2697 |
This is an EXPERIMENTAL interface." |
|
178 | 2698 |
|
2699 |
%{ /* NOCONTEXT */ |
|
615 | 2700 |
__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
|
2701 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2702 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2703 |
self saveGarbageCollectorSetting:#avoidTenure: value:flag. |
133 | 2704 |
! |
2705 |
||
1288 | 2706 |
checkForFastNew:amount |
2707 |
"this method returns true, if amount bytes could be allocated |
|
2708 |
quickly (i.e. without forcing a full GC or compress). |
|
2709 |
This can be used for smart background processes, which want to |
|
2710 |
allocate big chunks of data without disturbing foreground processes |
|
2711 |
too much. Such a process would check for fast-allocation, and perform |
|
10226 | 2712 |
incremental GC-steps if required. Thus, avoiding the long blocking pause |
2713 |
due to a forced (non-incremental) GC. |
|
1288 | 2714 |
Especially: doing so will not block higher priority foreground processes. |
2715 |
See an example use in Behavior>>niceBasicNew:. |
|
2716 |
This is experimental and not guaranteed to be in future versions." |
|
2717 |
||
2718 |
%{ /* NOCONTEXT */ |
|
2719 |
extern int __checkForFastNew(); |
|
2720 |
||
2721 |
if (__isSmallInteger(amount)) { |
|
2722 |
if (! __checkForFastNew(__intVal(amount))) { |
|
2723 |
RETURN (false); |
|
2724 |
} |
|
2725 |
} |
|
2726 |
||
2727 |
%}. |
|
2728 |
^ true |
|
178 | 2729 |
! |
2730 |
||
1768 | 2731 |
dynamicCodeGCTrigger |
2732 |
"return the dynamic code trigger limit for incremental GC activation. |
|
2733 |
The system will start doing incremental background GC, whenever this amount |
|
10226 | 2734 |
of code was dynamically generated. |
1768 | 2735 |
The default is nil; which disables this trigger" |
2736 |
||
2737 |
^ DynamicCodeGCTrigger |
|
2738 |
||
2739 |
" |
|
2740 |
ObjectMemory dynamicCodeGCTrigger |
|
2741 |
" |
|
2742 |
||
2743 |
"Created: 16.10.1996 / 17:42:01 / cg" |
|
2744 |
! |
|
2745 |
||
2746 |
dynamicCodeGCTrigger:numberOfBytesOrNil |
|
2747 |
"set the dynamic code trigger limit for incremental GC activation. |
|
2748 |
The system will start doing incremental background GC, whenever this amount |
|
10226 | 2749 |
of code was dynamically generated. |
1768 | 2750 |
The default is nil; which disables this trigger" |
2751 |
||
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2752 |
(numberOfBytesOrNil notNil and:[numberOfBytesOrNil > 0]) ifTrue:[ |
10226 | 2753 |
DynamicCodeGCTrigger := numberOfBytesOrNil. |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2754 |
] ifFalse:[ |
10226 | 2755 |
DynamicCodeGCTrigger := nil |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2756 |
] |
1768 | 2757 |
|
2758 |
" |
|
2759 |
ObjectMemory dynamicCodeGCTrigger:50000 |
|
2760 |
" |
|
2761 |
||
2762 |
"Created: 16.10.1996 / 17:42:29 / cg" |
|
2763 |
! |
|
2764 |
||
2765 |
dynamicCodeLimit |
|
2766 |
"return the dynamic code limit. |
|
2767 |
The system will start doing incremental background GC, whenever this amount |
|
2768 |
of code has been generated (overall), and start to flush the code cache, |
|
10226 | 2769 |
if (after the GC), more code is still allocated. |
1768 | 2770 |
The default is nil; which disables this trigger" |
2771 |
||
1781 | 2772 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 2773 |
^ DynamicCodeLimit |
2774 |
||
2775 |
" |
|
2776 |
ObjectMemory dynamicCodeLimit |
|
2777 |
" |
|
2778 |
||
2779 |
"Created: 16.10.1996 / 17:43:37 / cg" |
|
2780 |
! |
|
2781 |
||
2782 |
dynamicCodeLimit:nBytesOrNil |
|
2783 |
"set the dynamic code limit. |
|
2784 |
The system will start doing incremental background GC, whenever this amount |
|
2785 |
of code has been generated (overall), and start to flush the code cache, |
|
10226 | 2786 |
if (after the GC), more code is still allocated. |
1768 | 2787 |
The default is nil; which disables this trigger" |
2788 |
||
1770 | 2789 |
self setCompiledCodeLimit:nBytesOrNil. |
4565
cae420a1d1ac
care for 0 dynamic code triggers
Claus Gittinger <cg@exept.de>
parents:
4186
diff
changeset
|
2790 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 2791 |
|
2792 |
" |
|
2793 |
ObjectMemory dynamicCodeLimit:100000 |
|
2794 |
" |
|
2795 |
||
2796 |
"Created: 16.10.1996 / 17:43:58 / cg" |
|
1770 | 2797 |
"Modified: 16.10.1996 / 19:30:46 / cg" |
1768 | 2798 |
! |
2799 |
||
1288 | 2800 |
fastMoreOldSpaceAllocation:aBoolean |
2801 |
"this method turns on/off fastMoreOldSpace allocation. |
|
2802 |
By default, this is turned off (false), which means that in case of |
|
10226 | 2803 |
a filled-up oldSpace, a GC is tried first before more oldSpace is allocated. |
1288 | 2804 |
This strategy is ok for the normal operation of the system, |
2805 |
but behaves badly, if the program allocates huge data structures (say a |
|
2806 |
game tree of 30Mb in size) which survives and therefore will not be reclaimed |
|
2807 |
by a GC. |
|
10226 | 2808 |
Of course while building this tree, and the memory becomes full, the system |
1288 | 2809 |
would not know in advance, that the GC will not reclaim anything. |
2810 |
||
8455 | 2811 |
Setting fastMoreOldSpaceAllocation to true will avoid this, by forcing the |
1288 | 2812 |
memory system to allocate more memory right away, without doing a GC first. |
2813 |
||
2814 |
WARNING: make certain that this flag is turned off, after your huge data |
|
2815 |
is allocated, since otherwise the system may continue to increase its |
|
2816 |
virtual memory without ever checking for garbage. |
|
2817 |
This method returns the previous value of the flag; typically this return |
|
2818 |
value should be used to switch back." |
|
2819 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2820 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2821 |
|
13584 | 2822 |
%{ |
1288 | 2823 |
extern int __fastMoreOldSpaceAllocation(); |
2824 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2825 |
result = __fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false; |
5441 | 2826 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2827 |
self saveGarbageCollectorSetting:#fastMoreOldSpaceAllocation: value:aBoolean. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2828 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2829 |
^ result |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2830 |
|
1288 | 2831 |
" |
2832 |
|previousSetting| |
|
2833 |
||
2834 |
previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
2835 |
[ |
|
13584 | 2836 |
... |
2837 |
allocate your huge data |
|
2838 |
... |
|
8455 | 2839 |
] ensure:[ |
13584 | 2840 |
ObjectMemory fastMoreOldSpaceAllocation:previousSetting |
1288 | 2841 |
] |
2842 |
" |
|
2843 |
||
2844 |
" |
|
2845 |
|prev this| |
|
2846 |
||
2847 |
prev := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
370 | 2848 |
ObjectMemory fastMoreOldSpaceAllocation:prev. |
2849 |
^ prev |
|
2850 |
" |
|
8455 | 2851 |
|
2852 |
"Modified: / 03-08-2004 / 18:05:31 / stefan" |
|
370 | 2853 |
! |
2854 |
||
1288 | 2855 |
fastMoreOldSpaceLimit:aNumber |
2856 |
"this method sets and returns the fastMoreOldSpace limit. |
|
2857 |
If fastMoreOldSpaceAllocation is true, and the current oldSpace size is |
|
2858 |
below this limit, the memory manager will NOT do a GC when running out of |
|
2859 |
oldSpace, but instead quickly go ahead increasing the size of the oldSpace. |
|
2860 |
Setting the limit to 0 turns off any limit (i.e. it will continue to |
|
2861 |
increase the oldSpace forwever - actually, until the OS refuses to give us |
|
2862 |
more memory). The returned value is the previous setting of the limit." |
|
2863 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2864 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2865 |
|
13584 | 2866 |
%{ |
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2867 |
extern unsigned int __fastMoreOldSpaceLimit(); |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2868 |
|
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
2869 |
if (__isInteger(aNumber)) { |
13584 | 2870 |
result = __MKUINT( __fastMoreOldSpaceLimit(__unsignedLongIntVal(aNumber))); |
1288 | 2871 |
} |
2872 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2873 |
result isNil ifTrue:[ |
13584 | 2874 |
^ 0. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2875 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2876 |
self saveGarbageCollectorSetting:#fastMoreOldSpaceLimit: value:aNumber. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2877 |
^ result. |
10226 | 2878 |
|
1288 | 2879 |
" |
2880 |
|prev this| |
|
2881 |
||
2882 |
prev := ObjectMemory fastMoreOldSpaceLimit:10*1024*1024. |
|
370 | 2883 |
ObjectMemory fastMoreOldSpaceLimit:prev. |
2884 |
^ prev |
|
2885 |
" |
|
133 | 2886 |
! |
2887 |
||
1288 | 2888 |
freeSpaceGCAmount |
2889 |
"return the amount to be allocated if, after an incrementalGC, |
|
2890 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2891 |
The default is nil, which lets the system compute an abbpropriate value" |
|
615 | 2892 |
|
2893 |
^ FreeSpaceGCAmount |
|
2894 |
||
2895 |
" |
|
2896 |
ObjectMemory freeSpaceGCAmount |
|
2897 |
" |
|
2898 |
! |
|
2899 |
||
1288 | 2900 |
freeSpaceGCAmount:aNumber |
2901 |
"set the amount to be allocated if, after an incrementalGC, |
|
2902 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2903 |
The amount should be greater than the limit, otherwise the incremental |
|
2904 |
GC may try over and over to get the memory (actually waisting time)." |
|
2905 |
||
2906 |
FreeSpaceGCAmount := aNumber |
|
2907 |
||
2908 |
" |
|
2909 |
the following will try to always keep at least 1meg of free space |
|
2910 |
(in the background) and start to do so, whenever the freeSpace drops |
|
2911 |
below 250k. |
|
2912 |
" |
|
2913 |
" |
|
10226 | 2914 |
ObjectMemory freeSpaceGCLimit:250000. |
2915 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
1288 | 2916 |
" |
2917 |
||
2918 |
" |
|
2919 |
turn it off (i.e. let the system compute an appropriate amount ...) |
|
615 | 2920 |
" |
2921 |
" |
|
10226 | 2922 |
ObjectMemory freeSpaceGCAmount:nil. |
615 | 2923 |
" |
2924 |
! |
|
2925 |
||
1288 | 2926 |
freeSpaceGCLimit |
2927 |
"return the freeSpace limit for incremental GC activation. |
|
10226 | 2928 |
The system will start doing incremental background GC, once less than this number |
1288 | 2929 |
of bytes are available in the compact free space. |
2930 |
The default is 100000; setting it to nil will turn this trigger off." |
|
615 | 2931 |
|
2932 |
^ FreeSpaceGCLimit |
|
2933 |
||
2934 |
" |
|
2935 |
ObjectMemory freeSpaceGCLimit |
|
2936 |
" |
|
133 | 2937 |
! |
2938 |
||
1288 | 2939 |
freeSpaceGCLimit:aNumber |
2940 |
"set the freeSpace limit for incremental GC activation. |
|
10226 | 2941 |
The system will start doing incremental background GC, once less than this number |
1288 | 2942 |
of bytes are available for allocation. |
2943 |
The default is nil; setting it to nil will turn this trigger off." |
|
2944 |
||
2945 |
FreeSpaceGCLimit := aNumber |
|
2946 |
||
2947 |
" |
|
2948 |
the following will start the incrementalGC (in the background) |
|
2949 |
whenever the freeSpace drops below 1meg of free space |
|
2950 |
" |
|
2951 |
" |
|
10226 | 2952 |
ObjectMemory freeSpaceGCLimit:1000000. |
1288 | 2953 |
" |
2954 |
||
2955 |
" |
|
2956 |
turn it off (i.e. let the system hit the wall ...) |
|
615 | 2957 |
" |
2958 |
" |
|
10226 | 2959 |
ObjectMemory freeSpaceGCLimit:nil. |
615 | 2960 |
" |
1 | 2961 |
! |
2962 |
||
1288 | 2963 |
incrementalGCLimit |
2964 |
"return the allocatedSinceLastGC limit for incremental GC activation. |
|
10226 | 2965 |
The system will start doing incremental background GC, once more than this number |
2966 |
of bytes have been allocated since the last GC. |
|
1288 | 2967 |
The default is 500000; setting it to nil will turn this trigger off." |
615 | 2968 |
|
2969 |
^ IncrementalGCLimit |
|
2970 |
||
2971 |
" |
|
2972 |
ObjectMemory incrementalGCLimit |
|
2973 |
" |
|
178 | 2974 |
! |
85 | 2975 |
|
1288 | 2976 |
incrementalGCLimit:aNumber |
2977 |
"set the allocatedSinceLastGC limit for incremental GC activation. |
|
10226 | 2978 |
The system will start doing incremental background GC, once more than this number |
2979 |
of bytes have been allocated since the last GC. |
|
1288 | 2980 |
The default is 500000; setting it to nil will turn this trigger off." |
2981 |
||
2982 |
IncrementalGCLimit := aNumber |
|
2983 |
||
2984 |
" |
|
2985 |
ObjectMemory incrementalGCLimit:500000. 'do incr. GC very seldom' |
|
2986 |
ObjectMemory incrementalGCLimit:100000. 'medium' |
|
2987 |
ObjectMemory incrementalGCLimit:10000. 'do incr. GC very often' |
|
615 | 2988 |
ObjectMemory incrementalGCLimit:nil. 'never' |
2989 |
" |
|
370 | 2990 |
! |
2991 |
||
3859 | 2992 |
incrementalSweep:aBoolean |
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2993 |
"ineable/disable incremental sweeps during background GC. |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2994 |
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
|
2995 |
used by applications - it may vanish without notice" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2996 |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2997 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
2998 |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2999 |
%{ |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3000 |
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
|
3001 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3002 |
self saveGarbageCollectorSetting:#incrementalSweep: value:aBoolean. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3003 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3004 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3005 |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
3006 |
" |
3859 | 3007 |
ObjectMemory incrementalSweep:false. |
3008 |
ObjectMemory incrementalSweep:true |
|
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
3009 |
" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
3010 |
! |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
3011 |
|
1288 | 3012 |
lockTenure:flag |
3013 |
"set/clear the tenureLock. If the lock is set, the system |
|
3014 |
completely turns off tenuring, and objects remain in newSpace (forever). |
|
10226 | 3015 |
Once this lock is set, the system operates only in the newSpace and no memory |
3016 |
allocations from oldSpace are allowed (except for explicit tenure calls). |
|
1288 | 3017 |
If any allocation request cannot be resoved, the VM raises a memory interrupt, |
3018 |
clears the lockTenure-flag and returns nil. Thus, it automatically falls back into |
|
10226 | 3019 |
the normal mode of operation, to avoid big trouble |
1288 | 3020 |
(fail to allocate memory when handling the exception). |
3021 |
||
3022 |
This interface can be used in applications, which are guaranteed to have their |
|
3023 |
working set completely in the newSpace AND want to limit the worst case |
|
10226 | 3024 |
pause times to the worst case scavenge time |
3025 |
(which itself is limitd by the size of the newSpace). |
|
1288 | 3026 |
I.e. systems which go into some event loop after initial startup, |
10226 | 3027 |
may turn on the tenureLock to make certain that no oldSpace memory is |
1288 | 3028 |
allocated in the future; thereby limiting any GC activity to newSpace scavenges only. |
3029 |
||
3030 |
This is an EXPERIMENTAL interface. |
|
3031 |
" |
|
3032 |
||
3033 |
%{ |
|
3034 |
if (flag == true) { |
|
13584 | 3035 |
__tenure(__context); |
370 | 3036 |
} |
379 | 3037 |
__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
|
3038 |
%}. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3039 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3040 |
self saveGarbageCollectorSetting:#lockTenure: value:flag. |
379 | 3041 |
! |
3042 |
||
1288 | 3043 |
makeOld:anObject |
3044 |
"move anObject into oldSpace. |
|
3045 |
This method is for internal & debugging purposes only - |
|
3046 |
it may vanish. Dont use it." |
|
3047 |
%{ |
|
3048 |
if (__moveToOldSpace(anObject, __context) < 0) { |
|
615 | 3049 |
RETURN (false); |
3050 |
} |
|
3051 |
%}. |
|
3052 |
^ true |
|
3053 |
! |
|
3054 |
||
2337 | 3055 |
maxOldSpace |
2339 | 3056 |
"return the maxOldSpace value. If non-zero, thats the limit for which the |
3057 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 3058 |
If zero, it will allocate forever (until the OS wont hand out more). |
3059 |
The default is zero." |
|
3060 |
||
3061 |
%{ /* NOCONTEXT */ |
|
14721 | 3062 |
extern unsigned INT __maxOldSpace(); |
3063 |
||
3064 |
RETURN (__MKUINT( __maxOldSpace((unsigned INT)-1) )); |
|
5441 | 3065 |
%}. |
3066 |
^ 0 |
|
2337 | 3067 |
" |
3068 |
ObjectMemory maxOldSpace |
|
3069 |
" |
|
3070 |
! |
|
3071 |
||
3072 |
maxOldSpace:amount |
|
2339 | 3073 |
"set the maxOldSpace value. If non-zero, thats the limit for which the |
3074 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 3075 |
If zero, it will allocate forever (until the OS wont hand out more). |
2338 | 3076 |
The default is zero. |
10226 | 3077 |
WARNING: |
13584 | 3078 |
an oldSpace limit may lead to trashing due to exorbitant GC activity; |
3079 |
its usually better to let it allocate more and page in/page out. |
|
3080 |
Usually, the background GC will catch up sooner or later and reclaim |
|
3081 |
the memory without blocking the system" |
|
3082 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3083 |
|result| |
13584 | 3084 |
%{ |
14721 | 3085 |
extern unsigned INT __maxOldSpace(); |
2337 | 3086 |
|
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3087 |
if (__isInteger(amount)) { |
13584 | 3088 |
result = __MKUINT( __maxOldSpace(__unsignedLongIntVal(amount))); |
2337 | 3089 |
} |
5441 | 3090 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3091 |
result notNil ifTrue:[ |
13584 | 3092 |
self saveGarbageCollectorSetting:#maxOldSpace: value:amount. |
3093 |
^ result. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3094 |
]. |
5441 | 3095 |
^ 0 |
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3096 |
|
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3097 |
" |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3098 |
to change maximum to 1GByte: |
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3099 |
|
13584 | 3100 |
ObjectMemory maxOldSpace:1024*1024*1024 |
2337 | 3101 |
" |
3102 |
! |
|
3103 |
||
1288 | 3104 |
moreOldSpace:howMuch |
3105 |
"allocate howMuch bytes more for old objects; return true if this worked, |
|
3106 |
false if that failed. |
|
3107 |
This is done automatically, when running out of space, but makes |
|
3108 |
sense, if its known in advance that a lot of memory is needed to |
|
3109 |
avoid multiple reallocations and compresses. |
|
3110 |
On systems which do not support the mmap (or equivalent) system call, |
|
3111 |
this (currently) implies a compressing garbage collect - so its slow. |
|
3112 |
Notice: this is a nonstandard interface - use only in special situations." |
|
3113 |
||
10226 | 3114 |
%{ |
1288 | 3115 |
if (__isSmallInteger(howMuch)) { |
3116 |
RETURN( __moreOldSpace(__context, __intVal(howMuch)) ? true : false ); |
|
615 | 3117 |
} |
3118 |
RETURN (false); |
|
379 | 3119 |
%} |
615 | 3120 |
" |
3121 |
ObjectMemory moreOldSpace:1000000 |
|
3122 |
" |
|
379 | 3123 |
! |
3124 |
||
1288 | 3125 |
moreOldSpaceIfUseful |
3126 |
"to be called after an incremental GC cycle; |
|
3127 |
if freeSpace is still below limit, allocate more oldSpace" |
|
3128 |
||
3129 |
|limit free amount| |
|
3130 |
||
3131 |
limit := FreeSpaceGCLimit. |
|
3132 |
limit notNil ifTrue:[ |
|
10226 | 3133 |
"/ if reclaimed space is below limit, we have to allocate more |
3134 |
"/ oldSpace, to avoid excessive gcSteps (due to freeSpaceLimit |
|
3135 |
"/ still not reached) |
|
3136 |
"/ |
|
3137 |
free := self freeSpace + self freeListSpace. |
|
3138 |
free < (limit * 3 // 2) ifTrue:[ |
|
3139 |
amount := FreeSpaceGCAmount. |
|
3140 |
amount isNil ifTrue:[ |
|
3141 |
amount := limit * 3 // 2. |
|
3142 |
]. |
|
3143 |
"/ 'ObjectMemory [info]: moreOldSpace to satisfy free-limit' infoPrintCR. |
|
3144 |
(self moreOldSpace:(amount - free + (64*1024))) ifFalse:[ |
|
3145 |
"/ |
|
3146 |
"/ could not increase oldspace; reset FreeSpaceGCLimit to avoid |
|
3147 |
"/ useless retries |
|
3148 |
'ObjectMemory [warning]: could not increase oldSpace - reset limit' errorPrintCR. |
|
3149 |
FreeSpaceGCLimit := nil |
|
3150 |
] |
|
3151 |
]. |
|
615 | 3152 |
]. |
2122 | 3153 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3154 |
"Modified: 10.1.1997 / 17:59:48 / cg" |
370 | 3155 |
! |
3156 |
||
1288 | 3157 |
newSpaceSize:newSize |
3158 |
"change the size of the newSpace. To do this, the current contents |
|
3159 |
of the newSpace may have to be tenured (if size is smaller). |
|
3160 |
Returns false, if it failed for any reason. |
|
3161 |
Experimental: this interface may valish without notice. |
|
3162 |
||
3163 |
DANGER ALERT: |
|
13584 | 3164 |
be careful too big of a size may lead to longer scavenge pauses. |
3165 |
Too small of a newSpace may lead to more CPU overhead, due to |
|
3166 |
excessive scavenges. You have been warned." |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3167 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3168 |
|result| |
10226 | 3169 |
|
3170 |
%{ |
|
1288 | 3171 |
extern int __setNewSpaceSize(); |
3172 |
||
3173 |
if (__isSmallInteger(newSize)) { |
|
13584 | 3174 |
result = __setNewSpaceSize(__intVal(newSize)) ? true : false; |
1288 | 3175 |
} |
3176 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3177 |
result isNil ifTrue:[ |
13584 | 3178 |
self primitiveFailed. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3179 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3180 |
result ifTrue:[ |
13584 | 3181 |
self saveGarbageCollectorSetting:#newSpaceSize: value:newSize. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3182 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3183 |
^ result. |
1288 | 3184 |
|
3185 |
" less absolute CPU overhead (but longer pauses): |
|
3186 |
||
8423 | 3187 |
ObjectMemory newSpaceSize:1600*1024 |
1288 | 3188 |
" |
3189 |
||
3190 |
" smaller pauses, but more overall CPU overhead: |
|
3191 |
||
3192 |
ObjectMemory newSpaceSize:200*1024 |
|
370 | 3193 |
" |
3194 |
||
3195 |
" the default: |
|
3196 |
||
8423 | 3197 |
ObjectMemory newSpaceSize:800*1024 |
370 | 3198 |
" |
615 | 3199 |
! |
3200 |
||
1288 | 3201 |
oldSpaceCompressLimit |
3202 |
"return the limit for oldSpace compression. If more memory than this |
|
3203 |
limit is in use, the system will not perform compresses on the oldspace, |
|
3204 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
3205 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
3206 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
3207 |
you may want to increase this limit." |
|
3208 |
||
3209 |
%{ /* NOCONTEXT */ |
|
15441 | 3210 |
extern unsigned INT __compressingGCLimit(); |
3211 |
||
3212 |
RETURN (__MKUINT( __compressingGCLimit((unsigned INT)-1) )); |
|
5441 | 3213 |
%}. |
3214 |
^ 0 |
|
1105
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3215 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3216 |
ObjectMemory oldSpaceCompressLimit |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3217 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3218 |
! |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3219 |
|
1288 | 3220 |
oldSpaceCompressLimit:amount |
3221 |
"set the limit for oldSpace compression. If more memory than this |
|
3222 |
limit is in use, the system will not perform compresses on the oldspace, |
|
3223 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
3224 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
3225 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
3226 |
you may want to increase this limit. |
|
3227 |
This method returns the previous increment value." |
|
3228 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3229 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3230 |
|
13584 | 3231 |
%{ |
15441 | 3232 |
extern unsigned INT __compressingGCLimit(); |
1288 | 3233 |
|
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3234 |
if (__isInteger(amount)) { |
15441 | 3235 |
result = __MKUINT( __compressingGCLimit((unsigned INT)__unsignedLongIntVal(amount)) ); |
1288 | 3236 |
} |
5441 | 3237 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3238 |
result isNil ifTrue:[ |
13584 | 3239 |
^ 0. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3240 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3241 |
self saveGarbageCollectorSetting:#oldSpaceCompressLimit: value:amount. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3242 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3243 |
|
1288 | 3244 |
"to change the limit to 12Mb:" |
615 | 3245 |
" |
3246 |
ObjectMemory oldSpaceCompressLimit:12*1024*1024 |
|
3247 |
" |
|
3248 |
! |
|
3249 |
||
1288 | 3250 |
oldSpaceIncrement |
3251 |
"return the oldSpaceIncrement value. Thats the amount by which |
|
3252 |
more memory is allocated in case the oldSpace gets filled up. |
|
3253 |
In normal situations, the default value used in the VM is fine |
|
3254 |
and there is no need to change it." |
|
3255 |
||
3256 |
%{ /* NOCONTEXT */ |
|
15441 | 3257 |
extern unsigned INT __oldSpaceIncrement(); |
3258 |
||
3259 |
RETURN (__MKUINT( __oldSpaceIncrement((unsigned INT)-1) )); |
|
5441 | 3260 |
%}. |
3261 |
^ 0 |
|
615 | 3262 |
" |
3263 |
ObjectMemory oldSpaceIncrement |
|
3264 |
" |
|
3265 |
! |
|
3266 |
||
1288 | 3267 |
oldSpaceIncrement:amount |
3268 |
"set the oldSpaceIncrement value. Thats the amount by which |
|
3269 |
more memory is allocated in case the oldSpace gets filled up. |
|
3270 |
In normal situations, the default value used in the VM is fine |
|
10226 | 3271 |
and there is no need to change it. This method returns the |
1288 | 3272 |
previous increment value." |
13584 | 3273 |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3274 |
|result| |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3275 |
|
13584 | 3276 |
%{ |
15441 | 3277 |
extern unsigned INT __oldSpaceIncrement(); |
1288 | 3278 |
|
8983
ef429fa3d4e0
Allow oldSpace size >= 1 GByte (remove Smallinteger limit)
Stefan Vogel <sv@exept.de>
parents:
8963
diff
changeset
|
3279 |
if (__isInteger(amount)) { |
15441 | 3280 |
result = __MKUINT( __oldSpaceIncrement((unsigned INT)__unsignedLongIntVal(amount)) ); |
1288 | 3281 |
} |
5441 | 3282 |
%}. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3283 |
result isNil ifTrue:[ |
13584 | 3284 |
^ 0. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3285 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3286 |
self saveGarbageCollectorSetting:#oldSpaceIncrement: value:amount. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3287 |
^ result. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3288 |
|
1288 | 3289 |
"to change increment to 1Meg:" |
615 | 3290 |
" |
3291 |
ObjectMemory oldSpaceIncrement:1024*1024 |
|
3292 |
" |
|
3293 |
! |
|
3294 |
||
1288 | 3295 |
tenureParameters:magic |
3296 |
"this is pure magic and not for public eyes ... |
|
3297 |
This method allows fine tuning the scavenger internals, |
|
3298 |
in cooperation to some statistic & test programs. |
|
10226 | 3299 |
It is undocumented, secret and may vanish. |
1288 | 3300 |
If you play around here, the system may behave very strange." |
615 | 3301 |
|
3302 |
%{ /* NOCONTEXT */ |
|
3303 |
__tenureParams(magic); |
|
3304 |
%}. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3305 |
self saveGarbageCollectorSetting:#tenureParameters: value:magic. |
615 | 3306 |
! |
3307 |
||
1288 | 3308 |
turnGarbageCollectorOff |
3309 |
"turn off the generational garbage collector by forcing new objects to be |
|
3310 |
allocated directly in oldSpace (instead of newSpace) |
|
3311 |
WARNING: |
|
3312 |
This is somewhat dangerous: if collector is turned off, |
|
3313 |
and too many objects are created, the system may run into trouble |
|
3314 |
(i.e. oldSpace becomes full) and be forced to perform a full mark&sweep |
|
3315 |
or even a compressing collect - making the overall realtime behavior worse. |
|
3316 |
Use this only for special purposes or when realtime behavior |
|
3317 |
is required for a limited time period. |
|
3318 |
||
10226 | 3319 |
OBSOLETE: this is no longer supported |
1288 | 3320 |
- it may be a no-operation by the time you read this." |
615 | 3321 |
|
3322 |
%{ /* NOCONTEXT */ |
|
3323 |
__allocForceSpace(OLDSPACE); |
|
3324 |
%} |
|
3325 |
! |
|
3326 |
||
1288 | 3327 |
turnGarbageCollectorOn |
3328 |
"turn garbage collector on again (see ObjectMemory>>turnGarbageCollectorOff)" |
|
615 | 3329 |
|
3330 |
%{ /* NOCONTEXT */ |
|
3331 |
__allocForceSpace(9999); |
|
3332 |
%} |
|
1288 | 3333 |
! |
3334 |
||
3335 |
watchTenure:flag |
|
3336 |
"set/clear the tenureWatch. If set, an internalError exception will be raised, |
|
3337 |
whenever objects are tenured from newSpace into oldSpace |
|
10226 | 3338 |
(except for an explicit tenure request). |
1288 | 3339 |
This can be used to validate that no oldSpace objects are created |
10226 | 3340 |
(i.e. the system operates fully in newSpace). |
3341 |
Be careful, if the avoidTenure flag is not set, |
|
1288 | 3342 |
there will almost always be a tenure sooner or later. |
3343 |
||
3344 |
EXPERIMENTAL - no warranty" |
|
3345 |
||
3346 |
%{ /* NOCONTEXT */ |
|
3347 |
__watchTenure(flag == true ? 1 : 0); |
|
3348 |
%} |
|
178 | 3349 |
! ! |
3350 |
||
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3351 |
!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
|
3352 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3353 |
restoreGarbageCollectorSettings |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3354 |
"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
|
3355 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3356 |
SavedGarbageCollectorSettings isEmptyOrNil ifTrue:[ |
13584 | 3357 |
^ self. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3358 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3359 |
SavedGarbageCollectorSettings keysAndValuesDo:[:eachKey :eachValue| |
13584 | 3360 |
eachKey numArgs == 1 ifTrue:[ |
3361 |
self perform:eachKey with:eachValue. |
|
3362 |
] ifFalse:[ |
|
3363 |
self perform:eachKey. |
|
3364 |
]. |
|
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3365 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3366 |
! |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3367 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3368 |
saveGarbageCollectorSetting:aSymbol value:something |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3369 |
"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
|
3370 |
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
|
3371 |
|
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3372 |
SavedGarbageCollectorSettings isNil ifTrue:[ |
13584 | 3373 |
SavedGarbageCollectorSettings := IdentityDictionary new. |
12781
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3374 |
]. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3375 |
SavedGarbageCollectorSettings at:aSymbol put:something. |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3376 |
! ! |
1db2d89385ac
Save garbage collector settings and reinstall them after snapIn
Stefan Vogel <sv@exept.de>
parents:
12650
diff
changeset
|
3377 |
|
1767 | 3378 |
!ObjectMemory class methodsFor:'interrupt handler access'! |
615 | 3379 |
|
1288 | 3380 |
childSignalInterruptHandler |
3381 |
"return the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
615 | 3382 |
|
3383 |
^ ChildSignalInterruptHandler |
|
3384 |
! |
|
3385 |
||
1288 | 3386 |
childSignalInterruptHandler:aHandler |
3387 |
"set the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
3388 |
||
3389 |
ChildSignalInterruptHandler := aHandler |
|
3390 |
||
3391 |
"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
|
3392 |
"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
|
3393 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
3394 |
|
1288 | 3395 |
customInterruptHandler |
615 | 3396 |
"return the handler for custom interrupts" |
3397 |
||
3398 |
^ CustomInterruptHandler |
|
3399 |
! |
|
3400 |
||
1288 | 3401 |
customInterruptHandler:aHandler |
615 | 3402 |
"set the handler for custom interrupts" |
3403 |
||
3404 |
CustomInterruptHandler := aHandler |
|
3405 |
! |
|
3406 |
||
1288 | 3407 |
disposeInterruptHandler |
3408 |
"return the handler for object disposal interrupts" |
|
615 | 3409 |
|
3410 |
^ DisposeInterruptHandler |
|
3411 |
! |
|
3412 |
||
1288 | 3413 |
disposeInterruptHandler:aHandler |
3414 |
"set the handler for object disposal interrupts" |
|
615 | 3415 |
|
3416 |
DisposeInterruptHandler := aHandler |
|
3417 |
! |
|
3418 |
||
1288 | 3419 |
errorInterruptHandler |
615 | 3420 |
"return the handler for display error interrupts" |
3421 |
||
3422 |
^ ErrorInterruptHandler |
|
3423 |
! |
|
3424 |
||
1288 | 3425 |
errorInterruptHandler:aHandler |
3426 |
"set the handler for display error interrupts" |
|
615 | 3427 |
|
3428 |
ErrorInterruptHandler := aHandler |
|
3429 |
! |
|
3430 |
||
1288 | 3431 |
exceptionInterruptHandler |
3432 |
"return the handler for floating point exception interrupts" |
|
615 | 3433 |
|
3434 |
^ ExceptionInterruptHandler |
|
3435 |
! |
|
3436 |
||
1288 | 3437 |
internalErrorHandler |
3438 |
"return the handler for ST/X internal errors. |
|
3439 |
An internal error is reported for example when a methods |
|
3440 |
bytecode is not a ByteArray, the selector table is not an Array |
|
10226 | 3441 |
etc. |
615 | 3442 |
Those should not occur in normal circumstances." |
3443 |
||
3444 |
^ InternalErrorHandler |
|
3445 |
! |
|
3446 |
||
1288 | 3447 |
ioInterruptHandler |
3448 |
"return the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3449 |
|
3450 |
^ IOInterruptHandler |
|
3451 |
! |
|
3452 |
||
1288 | 3453 |
ioInterruptHandler:aHandler |
3454 |
"set the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3455 |
|
3456 |
IOInterruptHandler := aHandler |
|
3457 |
! |
|
3458 |
||
1288 | 3459 |
recursionInterruptHandler |
3460 |
"return the handler for recursion/stack overflow interrupts" |
|
615 | 3461 |
|
3462 |
^ RecursionInterruptHandler |
|
3463 |
! |
|
3464 |
||
1288 | 3465 |
recursionInterruptHandler:aHandler |
3466 |
"set the handler for recursion/stack overflow interrupts" |
|
615 | 3467 |
|
3468 |
RecursionInterruptHandler := aHandler |
|
3469 |
! |
|
3470 |
||
1288 | 3471 |
registerErrorInterruptHandler:aHandler forID:errorIDSymbol |
3472 |
"register a handler" |
|
3473 |
||
3474 |
RegisteredErrorInterruptHandlers isNil ifTrue:[ |
|
3475 |
RegisteredErrorInterruptHandlers := IdentityDictionary new |
|
615 | 3476 |
]. |
3477 |
RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler |
|
3478 |
! |
|
3479 |
||
1288 | 3480 |
registeredErrorInterruptHandlers |
615 | 3481 |
"return registered handlers" |
3482 |
||
3483 |
^ RegisteredErrorInterruptHandlers |
|
3484 |
! |
|
3485 |
||
1288 | 3486 |
signalInterruptHandler |
615 | 3487 |
"return the handler for UNIX-signal interrupts" |
3488 |
||
3489 |
^ SignalInterruptHandler |
|
3490 |
! |
|
3491 |
||
1288 | 3492 |
signalInterruptHandler:aHandler |
3493 |
"set the handler for UNIX-signal interrupts" |
|
615 | 3494 |
|
3495 |
SignalInterruptHandler := aHandler |
|
3496 |
! |
|
3497 |
||
1288 | 3498 |
spyInterruptHandler |
615 | 3499 |
"return the handler for spy-timer interrupts" |
3500 |
||
3501 |
^ SpyInterruptHandler |
|
3502 |
! |
|
3503 |
||
1288 | 3504 |
spyInterruptHandler:aHandler |
615 | 3505 |
"set the handler for spy-timer interrupts" |
3506 |
||
3507 |
SpyInterruptHandler := aHandler |
|
3508 |
! |
|
3509 |
||
1288 | 3510 |
stepInterruptHandler |
615 | 3511 |
"return the handler for single step interrupts" |
3512 |
||
3513 |
^ StepInterruptHandler |
|
3514 |
! |
|
3515 |
||
1288 | 3516 |
stepInterruptHandler:aHandler |
3517 |
"set the handler for single step interrupts" |
|
615 | 3518 |
|
3519 |
StepInterruptHandler := aHandler |
|
3520 |
! |
|
3521 |
||
1288 | 3522 |
timerInterruptHandler |
615 | 3523 |
"return the handler for timer interrupts" |
3524 |
||
3525 |
^ TimerInterruptHandler |
|
3526 |
! |
|
3527 |
||
1288 | 3528 |
timerInterruptHandler:aHandler |
615 | 3529 |
"set the handler for timer interrupts" |
3530 |
||
3531 |
TimerInterruptHandler := aHandler |
|
3532 |
! |
|
3533 |
||
1288 | 3534 |
userInterruptHandler |
615 | 3535 |
"return the handler for CNTL-C interrupt handling" |
3536 |
||
3537 |
^ UserInterruptHandler |
|
1288 | 3538 |
! |
3539 |
||
3540 |
userInterruptHandler:aHandler |
|
3541 |
"set the handler for CNTL-C interrupt handling" |
|
3542 |
||
3543 |
UserInterruptHandler := aHandler |
|
615 | 3544 |
! ! |
3545 |
||
1767 | 3546 |
!ObjectMemory class methodsFor:'interrupt statistics'! |
615 | 3547 |
|
1288 | 3548 |
interruptLatency:ms receiver:rec class:cls selector:sel vmActivity:vmActivity id:pid |
3549 |
"example implementation of latencyTime monitoring: |
|
3550 |
This method simply measures the max-latency time. |
|
3551 |
You may want to use some other handler (see #interruptLatencyMonitor:) |
|
3552 |
and extract more information (blocking context). |
|
3553 |
DEMO Example." |
|
3554 |
||
3555 |
ms > MaxInterruptLatency ifTrue:[ |
|
10226 | 3556 |
MaxInterruptLatency := ms. |
3557 |
'IRQ-LATENCY: ' infoPrint. cls infoPrint. ' ' infoPrint. sel infoPrint. '(' infoPrint. vmActivity infoPrint . ') ---> ' infoPrint. ms infoPrintCR. |
|
1288 | 3558 |
]. |
3559 |
(InterruptLatencyGoal notNil and:[ms > InterruptLatencyGoal]) ifTrue:[ |
|
10226 | 3560 |
'*** IRQ REALTIME-DEADLINE MISSED: ' errorPrint. |
3561 |
cls errorPrint. |
|
3562 |
' ' errorPrint. sel errorPrint. '(' errorPrint. vmActivity errorPrint . ') ---> ' errorPrint. |
|
3563 |
ms errorPrintCR. |
|
1288 | 3564 |
]. |
3565 |
||
3566 |
"to enable the demo handler: |
|
3567 |
||
3568 |
ObjectMemory resetMaxInterruptLatency. |
|
3569 |
ObjectMemory interruptLatencyMonitor:ObjectMemory. |
|
3570 |
" |
|
3571 |
"to disable timing statistics: |
|
3572 |
||
3573 |
ObjectMemory interruptLatencyMonitor:nil. |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
3574 |
ObjectMemory maxInterruptLatency printCR. |
1288 | 3575 |
" |
615 | 3576 |
|
3577 |
"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
|
3578 |
"Modified: 18.6.1996 / 14:15:52 / stefan" |
2138 | 3579 |
"Modified: 10.1.1997 / 19:09:53 / cg" |
615 | 3580 |
! |
3581 |
||
1288 | 3582 |
interruptLatencyGoal:millis |
3583 |
"setup to report an error message, whenever a realtime goal could not be |
|
3584 |
met due to blocked interrupts or long primitives or GC activity. |
|
3585 |
An argument of nil clears the check. |
|
3586 |
DEMO Example." |
|
3587 |
||
3588 |
InterruptLatencyGoal := millis. |
|
3589 |
millis isNil ifTrue:[ |
|
3590 |
InterruptLatencyMonitor := nil. |
|
3591 |
] ifFalse:[ |
|
3592 |
MaxInterruptLatency := 0. |
|
3593 |
InterruptLatencyMonitor := self. |
|
615 | 3594 |
] |
3595 |
||
3596 |
" |
|
3597 |
ObjectMemory interruptLatencyGoal:50 |
|
3598 |
" |
|
3599 |
! |
|
3600 |
||
1288 | 3601 |
interruptLatencyMonitor |
10226 | 3602 |
"return the interrupt-latency-monitor if any. |
1288 | 3603 |
See comment in #interruptLatencyMonitor:. |
3604 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3605 |
|
3606 |
^ InterruptLatencyMonitor |
|
3607 |
! |
|
3608 |
||
1288 | 3609 |
interruptLatencyMonitor:aHandler |
3610 |
"set the interrupt latency monitor. If non-nil, this one will be sent |
|
3611 |
an interruptLatency: message with the millisecond delay between |
|
3612 |
the interrupt and its handling. |
|
3613 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3614 |
|
3615 |
InterruptLatencyMonitor := aHandler |
|
3616 |
! |
|
3617 |
||
1288 | 3618 |
maxInterruptLatency |
3619 |
"return the maximum accumulated interrupt latency in millis. |
|
615 | 3620 |
DEMO Example." |
3621 |
||
3622 |
^ MaxInterruptLatency |
|
1288 | 3623 |
! |
3624 |
||
3625 |
resetMaxInterruptLatency |
|
3626 |
"reset the maximum accumulated interrupt latency probe time. |
|
3627 |
DEMO Example." |
|
3628 |
||
3629 |
MaxInterruptLatency := 0 |
|
615 | 3630 |
! ! |
3631 |
||
1767 | 3632 |
!ObjectMemory class methodsFor:'just in time compilation'! |
3633 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3634 |
byteCodeSizeLimitForDynamicCompilation:aNumber |
2526 | 3635 |
"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
|
3636 |
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
|
3637 |
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
|
3638 |
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
|
3639 |
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
|
3640 |
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
|
3641 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3642 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3643 |
extern int __byteCodeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3644 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3645 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3646 |
prev = __byteCodeSizeLimitForDynamicCompilation( |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3647 |
__isSmallInteger(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3648 |
? __intVal(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3649 |
: -1); |
8913 | 3650 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3651 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3652 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3653 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3654 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3655 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3656 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3657 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3658 |
|
2638 | 3659 |
codeForCPU:aCPUSymbol |
3660 |
"instruct the just in time compiler that some specific CPU |
|
3661 |
is present (forcing it to generate code for that). |
|
3662 |
The default is set correct for the architecture, and the |
|
3663 |
runTime system tries to figure out the cpu - but who knows ... |
|
3664 |
The valid symbols depend on the architecture: |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3665 |
i386: #i486 / #i586 (affects code ordering) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3666 |
sparc: #sparcV8 / #sparcV8 (affects instruction set) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3667 |
mips: #rs2000 / #rs4000 (affects delay slot generation) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3668 |
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
|
3669 |
the setting (but only return the current). |
2638 | 3670 |
|
10226 | 3671 |
This is a nonstandard entry and may be removed without notice - |
2638 | 3672 |
not for the general user." |
3673 |
||
3674 |
%{ /* NOCONTEXT */ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3675 |
extern OBJ __codeForCPU(); |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3676 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3677 |
RETURN (__codeForCPU(aCPUSymbol)); |
2638 | 3678 |
%}. |
3679 |
||
3680 |
" |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3681 |
ObjectMemory codeForCPU:nil |
2638 | 3682 |
ObjectMemory codeForCPU:#i486 |
3683 |
ObjectMemory codeForCPU:#i586 |
|
3684 |
" |
|
3685 |
! |
|
3686 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3687 |
codeSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3688 |
"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
|
3689 |
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
|
3690 |
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
|
3691 |
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
|
3692 |
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
|
3693 |
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
|
3694 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3695 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3696 |
extern int __codeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3697 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3698 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3699 |
prev = __codeSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3700 |
? __intVal(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3701 |
: -1); |
8913 | 3702 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3703 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3704 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3705 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3706 |
ObjectMemory codeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3707 |
ObjectMemory codeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3708 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3709 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3710 |
|
1767 | 3711 |
compiledCodeCounter |
3712 |
"return the number of additional code-bytes which |
|
3713 |
were generated since the counter was last reset" |
|
3714 |
||
3715 |
%{ /* NOCONTEXT */ |
|
3716 |
||
3717 |
extern __compiledCodeCounter(); |
|
3718 |
int nBytes; |
|
3719 |
||
3720 |
nBytes = __compiledCodeCounter(); |
|
8913 | 3721 |
RETURN (__mkSmallInteger(nBytes)); |
1767 | 3722 |
%} |
3723 |
" |
|
3724 |
ObjectMemory compiledCodeCounter |
|
3725 |
" |
|
3726 |
! |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3727 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3728 |
compiledCodeSpaceUsed |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3729 |
"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
|
3730 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3731 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3732 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3733 |
extern __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3734 |
int nBytes; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3735 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3736 |
nBytes = __compiledCodeSpaceUsed(); |
8913 | 3737 |
RETURN (__mkSmallInteger(nBytes)); |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3738 |
%} |
1767 | 3739 |
" |
3740 |
ObjectMemory compiledCodeSpaceUsed |
|
3741 |
" |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3742 |
! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3743 |
|
1948
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3744 |
fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3745 |
"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
|
3746 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3747 |
%{ /* NOCONTEXT */ |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3748 |
extern int __fullSingleStep(); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3749 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3750 |
RETURN (__fullSingleStep(-1) ? true : false); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3751 |
%} |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3752 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3753 |
ObjectMemory fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3754 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3755 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3756 |
! |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3757 |
|
1795 | 3758 |
fullSingleStepSupport:aBoolean |
10226 | 3759 |
"enable/disable full single step support for the just-in-time-compiled code. |
1795 | 3760 |
If off, things like simple increment/decrement, additions and variable- |
3761 |
stores are not steppable, but treated like atomar invisible operations. |
|
10226 | 3762 |
If on, single step halts at those operations. |
1795 | 3763 |
Execution is a bit slower if enabled." |
3764 |
||
3765 |
%{ /* NOCONTEXT */ |
|
3766 |
extern int __fullSingleStep(); |
|
3767 |
int prev; |
|
3768 |
||
3769 |
prev = __fullSingleStep(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3770 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3771 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3772 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3773 |
: -1); |
1795 | 3774 |
RETURN (prev ? true : false); |
3775 |
%} |
|
3776 |
" |
|
3777 |
ObjectMemory fullSingleStepSupport:true |
|
3778 |
ObjectMemory fullSingleStepSupport:false |
|
3779 |
" |
|
3780 |
||
3781 |
! |
|
3782 |
||
3783 |
getCompiledCodeLimit |
|
3784 |
"get the codeLimit from the VM" |
|
3785 |
||
3786 |
%{ /* NOCONTEXT */ |
|
3787 |
extern int __dynamicCodeLimit(); |
|
3788 |
int limit; |
|
3789 |
||
3790 |
limit = __dynamicCodeLimit(); |
|
3791 |
if (limit) { |
|
8913 | 3792 |
RETURN (__mkSmallInteger(limit)); |
1795 | 3793 |
} |
3794 |
RETURN (nil); |
|
3795 |
%} |
|
3796 |
! |
|
3797 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3798 |
insnSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3799 |
"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
|
3800 |
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
|
3801 |
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
|
3802 |
internal insns are generated. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3803 |
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
|
3804 |
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
|
3805 |
systems. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3806 |
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
|
3807 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3808 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3809 |
extern int __insnSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3810 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3811 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3812 |
prev = __insnSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3813 |
? __intVal(aNumber) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3814 |
: -1); |
8913 | 3815 |
RETURN (__mkSmallInteger(prev)); |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3816 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3817 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3818 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3819 |
ObjectMemory insnSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3820 |
ObjectMemory insnSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3821 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3822 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3823 |
|
3912 | 3824 |
javaJustInTimeCompilation |
3825 |
"return the value of the java-just-in-time-compilation flag" |
|
3826 |
||
3827 |
%{ /* NOCONTEXT */ |
|
3828 |
extern int __javaJustInTimeCompilation(); |
|
3829 |
||
3830 |
RETURN (__javaJustInTimeCompilation(-1) ? true : false); |
|
3831 |
%} |
|
3832 |
" |
|
3833 |
ObjectMemory javaJustInTimeCompilation |
|
3834 |
" |
|
3835 |
||
3836 |
! |
|
3837 |
||
3838 |
javaJustInTimeCompilation:aBoolean |
|
3839 |
"enable/disable java just-in-time-compilation." |
|
3840 |
||
3841 |
aBoolean notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3842 |
JavaJustInTimeCompilationEnabled := aBoolean. |
3912 | 3843 |
]. |
3844 |
||
3845 |
%{ /* NOCONTEXT */ |
|
3846 |
extern int __javaJustInTimeCompilation(); |
|
3847 |
int prev; |
|
3848 |
||
3849 |
prev = __javaJustInTimeCompilation(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3850 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3851 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3852 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3853 |
: -1); |
3912 | 3854 |
RETURN (prev ? true : false); |
3855 |
%}. |
|
3856 |
" |
|
3857 |
ObjectMemory javaJustInTimeCompilation:true |
|
3858 |
ObjectMemory javaJustInTimeCompilation:false |
|
3859 |
" |
|
3860 |
! |
|
3861 |
||
3862 |
javaNativeCodeOptimization |
|
3863 |
"return the value of the java-native-code-optimization flag" |
|
3864 |
||
3865 |
%{ /* NOCONTEXT */ |
|
3866 |
extern int __javaNativeCodeOptimization(); |
|
3867 |
||
3868 |
RETURN (__javaNativeCodeOptimization(-1) ? true : false); |
|
3869 |
%} |
|
3870 |
" |
|
3871 |
ObjectMemory javaNativeCodeOptimization |
|
3872 |
" |
|
3873 |
||
3874 |
! |
|
3875 |
||
3876 |
javaNativeCodeOptimization:aBoolean |
|
3877 |
"enable/disable java native code-optimization." |
|
3878 |
||
3879 |
aBoolean notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3880 |
JavaNativeCodeOptimization := aBoolean. |
3912 | 3881 |
]. |
3882 |
||
3883 |
%{ /* NOCONTEXT */ |
|
3884 |
extern int __javaNativeCodeOptimization(); |
|
3885 |
int prev; |
|
3886 |
||
3887 |
prev = __javaNativeCodeOptimization(aBoolean == true |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3888 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3889 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3890 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3891 |
: -1); |
3912 | 3892 |
RETURN (prev ? true : false); |
3893 |
%}. |
|
3894 |
" |
|
3895 |
ObjectMemory javaNativeCodeOptimization:true |
|
3896 |
ObjectMemory javaNativeCodeOptimization:false |
|
3897 |
" |
|
3898 |
! |
|
3899 |
||
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3900 |
justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3901 |
"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
|
3902 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3903 |
%{ /* NOCONTEXT */ |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3904 |
extern int __justInTimeCompilation(); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3905 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3906 |
RETURN (__justInTimeCompilation(-1) ? true : false); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3907 |
%} |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3908 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3909 |
ObjectMemory justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3910 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3911 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3912 |
! |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3913 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3914 |
justInTimeCompilation:aBoolean |
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3915 |
"enable/disable just-in-time-compilation." |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3916 |
|
1939
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3917 |
aBoolean notNil ifTrue:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3918 |
JustInTimeCompilationEnabled := aBoolean. |
1939
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3919 |
]. |
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3920 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3921 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3922 |
extern int __justInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3923 |
int prev; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3924 |
|
1657 | 3925 |
prev = __justInTimeCompilation(aBoolean == true |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3926 |
? 1 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3927 |
: (aBoolean == false) |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3928 |
? 0 |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3929 |
: -1); |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3930 |
RETURN (prev ? true : false); |
2017 | 3931 |
%}. |
1767 | 3932 |
" |
3933 |
ObjectMemory justInTimeCompilation:true |
|
3934 |
ObjectMemory justInTimeCompilation:false |
|
3935 |
" |
|
2017 | 3936 |
! |
3937 |
||
13421 | 3938 |
optimizeContexts |
3939 |
"return the setting of the optimize contexts flag" |
|
3940 |
||
3941 |
%{ /* NOCONTEXT */ |
|
3942 |
extern int __optimizeContexts(); |
|
3943 |
||
3944 |
RETURN (__optimizeContexts(-1) ? true : false); |
|
3945 |
%} |
|
3946 |
" |
|
3947 |
ObjectMemory optimizeContexts |
|
3948 |
" |
|
3949 |
! |
|
3950 |
||
3951 |
optimizeContexts:aBoolean |
|
3952 |
"enable/disable restartable contexts for the just-in-time-compiled code. |
|
3953 |
If off, contexts that does not contain blocks are not restartable. |
|
3954 |
Execution is a bit slower if enabled." |
|
3955 |
||
3956 |
%{ /* NOCONTEXT */ |
|
3957 |
extern int __optimizeContexts(); |
|
3958 |
int prev; |
|
3959 |
||
3960 |
prev = __optimizeContexts(aBoolean == true |
|
15441 | 3961 |
? 1 |
3962 |
: (aBoolean == false) |
|
3963 |
? 0 |
|
3964 |
: -1); |
|
13421 | 3965 |
RETURN (prev ? true : false); |
3966 |
%} |
|
3967 |
" |
|
3968 |
ObjectMemory optimizeContexts:true |
|
3969 |
ObjectMemory optimizeContexts:false |
|
3970 |
" |
|
3971 |
! |
|
3972 |
||
1940 | 3973 |
reEnableJustInTimeCompilation |
3974 |
"to be called after a snapshot restart; if justInTimeCompiler |
|
10226 | 3975 |
was enabled before, do it again. |
1940 | 3976 |
For now, this is not done automatically, to allow restarting |
3977 |
a system with the dynamic compiler turned off (its still experimental). |
|
3978 |
Therefore, this reenabling is done in the smalltalk_r.rc file." |
|
3979 |
||
3980 |
JustInTimeCompilationEnabled == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3981 |
self justInTimeCompilation:true |
3913 | 3982 |
]. |
3983 |
JavaJustInTimeCompilationEnabled == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3984 |
self javaJustInTimeCompilation:true |
3913 | 3985 |
]. |
3986 |
JavaNativeCodeOptimization == true ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
3987 |
self javaNativeCodeOptimization:true |
3913 | 3988 |
]. |
3989 |
||
3990 |
"Modified: / 5.11.1998 / 15:00:00 / cg" |
|
1940 | 3991 |
! |
3992 |
||
1770 | 3993 |
resetCompiledCodeCounter |
3994 |
"reset the counter of additional code-bytes" |
|
3995 |
||
3996 |
%{ /* NOCONTEXT */ |
|
3997 |
||
3998 |
extern void __resetDynamicCodeGeneratedCounter(); |
|
3999 |
||
4000 |
__resetDynamicCodeGeneratedCounter(); |
|
4001 |
%} |
|
4002 |
" |
|
4003 |
ObjectMemory resetCompiledCodeCounter |
|
4004 |
" |
|
4005 |
||
4006 |
! |
|
4007 |
||
1769 | 4008 |
setCompiledCodeLimit:newLimit |
4009 |
"set the VM's limit" |
|
4010 |
||
4011 |
%{ /* NOCONTEXT */ |
|
4012 |
extern __setDynamicCodeLimit(); |
|
4013 |
||
4014 |
if (__isSmallInteger(newLimit)) { |
|
4015 |
__setDynamicCodeLimit(__intVal(newLimit)); |
|
4016 |
} else if (newLimit == nil) { |
|
4017 |
__setDynamicCodeLimit(0); |
|
4018 |
} |
|
4019 |
%} |
|
4020 |
! |
|
4021 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4022 |
supportsJustInTimeCompilation |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4023 |
"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
|
4024 |
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
|
4025 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4026 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4027 |
extern int __canDoJustInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4028 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4029 |
RETURN (__canDoJustInTimeCompilation() ? true : false); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4030 |
%} |
1767 | 4031 |
" |
4032 |
ObjectMemory supportsJustInTimeCompilation |
|
4033 |
" |
|
4034 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4035 |
! ! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
4036 |
|
1767 | 4037 |
!ObjectMemory class methodsFor:'low memory handling'! |
615 | 4038 |
|
3781 | 4039 |
allocationFailed |
4040 |
"memory allocation has failed in the VM |
|
4041 |
This is triggered by the runtime system (or possibly by |
|
4042 |
a user primitive)" |
|
4043 |
||
8963
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
4044 |
^ AllocationFailure raiseRequest |
3781 | 4045 |
! |
4046 |
||
1288 | 4047 |
memoryInterrupt |
4048 |
"when a low-memory condition arises, ask all classes to |
|
4049 |
remove possibly cached data. You may help the system a bit, |
|
4050 |
in providing a lowSpaceCleanup method in your classes which have |
|
4051 |
lots of data kept somewhere (usually, cached data). |
|
4052 |
- this may or may not help." |
|
4053 |
||
13584 | 4054 |
self changed:#memoryLow. |
1288 | 4055 |
self performLowSpaceCleanup. |
4056 |
"/ self error:'almost out of memory' |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
4057 |
'ObjectMemory [warning]: almost out of memory' errorPrintCR. |
615 | 4058 |
|
4059 |
LowSpaceSemaphore signalIf. |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
4060 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
4061 |
"Modified: 10.1.1997 / 17:59:31 / cg" |
1288 | 4062 |
! |
4063 |
||
4064 |
performLowSpaceCleanup |
|
10226 | 4065 |
"ask all classes to remove possibly cached data. |
4066 |
You may help the system a bit, in providing a lowSpaceCleanup method |
|
13573
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4067 |
in your classes which have lots of data kept somewhere (usually, cached data). |
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4068 |
Notice: it may never hurt to call lowSpaceCleanup (i.e. the data must always be |
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4069 |
reconstructable)" |
1288 | 4070 |
|
8963
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
4071 |
"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
|
4072 |
which allocates an IdentitySet" |
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
4073 |
|
e81373595ecf
Take care not to allocate memory in #lowSpaceCleanup
Stefan Vogel <sv@exept.de>
parents:
8913
diff
changeset
|
4074 |
Smalltalk do:[:eachGlobal| |
13584 | 4075 |
eachGlobal isBehavior ifTrue:[ |
4076 |
eachGlobal lowSpaceCleanup |
|
4077 |
]. |
|
1288 | 4078 |
]. |
4079 |
||
10226 | 4080 |
" |
13573
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4081 |
ObjectMemory performLowSpaceCleanup |
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4082 |
" |
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4083 |
|
3de2d68dda25
comment: #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
13421
diff
changeset
|
4084 |
"Created: / 12-04-1996 / 14:57:28 / cg" |
362 | 4085 |
! ! |
4086 |
||
1767 | 4087 |
!ObjectMemory class methodsFor:'object finalization'! |
290 | 4088 |
|
1288 | 4089 |
allChangedShadowObjectsDo:aBlock |
4090 |
"evaluate the argument, aBlock for all known shadow objects which have |
|
4091 |
lost a pointer recently." |
|
290 | 4092 |
%{ |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4093 |
__allChangedShadowObjectsDo(&aBlock); |
290 | 4094 |
%} |
4095 |
! |
|
4096 |
||
3733 | 4097 |
backgroundFinalizationProcess |
4098 |
"return the backgroundFinalizationProcess (or nil, if noone is running)" |
|
4099 |
||
4100 |
^ BackgroundFinalizationProcess |
|
4101 |
||
4102 |
"Created: / 4.8.1998 / 02:00:13 / cg" |
|
4103 |
! |
|
4104 |
||
1288 | 4105 |
disposeInterrupt |
4106 |
"this is triggered by the garbage collector, |
|
4107 |
whenever any shadowArray looses a pointer." |
|
4108 |
||
4109 |
FinalizationSemaphore notNil ifTrue:[ |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4110 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4111 |
"/ background finalizer is waiting ... |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4112 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4113 |
FinalizationSemaphore signalOnce |
290 | 4114 |
] ifFalse:[ |
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4115 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4116 |
"/ do it right here |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4117 |
"/ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4118 |
self finalize |
290 | 4119 |
] |
2160
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
4120 |
|
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
4121 |
"Modified: 13.1.1997 / 17:26:16 / cg" |
290 | 4122 |
! |
4123 |
||
1288 | 4124 |
finalize |
4125 |
"tell all weak objects that something happened." |
|
4126 |
||
10226 | 4127 |
self allChangedShadowObjectsDo:[:aShadowArray | |
4128 |
Error handle:[:ex | |
|
4129 |
'ObjectMemory [warning]: cought error in weakArray processing: ' errorPrint. |
|
4130 |
ex description errorPrintCR. |
|
4131 |
ex suspendedContext fullPrintAllLevels:10. |
|
4132 |
"Restart the do block to clean up the rest of the shadow array. |
|
4133 |
This is safe here, because the old executor that triggered the error |
|
4134 |
has already been removed from the Registry" |
|
4135 |
ex restart. |
|
4136 |
] do:[ |
|
4137 |
aShadowArray lostPointer. |
|
4138 |
]. |
|
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4139 |
]. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4140 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4141 |
"/ we should change the setup, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4142 |
"/ to make the Dependencies collection a dependent |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4143 |
"/ of all the WeakArrays and WeakIDSets there, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4144 |
"/ and send a changed message when any of them looses |
10226 | 4145 |
"/ a pointer. |
2100 | 4146 |
"/ This would automize the send below. |
4147 |
"/ |
|
4148 |
"/ WARNING: |
|
4149 |
"/ this can only be done, if the WeakIDSet holds its |
|
10226 | 4150 |
"/ dependends itself (like a WeakArray), |
2100 | 4151 |
"/ otherwise we might get trouble. |
4152 |
"/ 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
|
4153 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4154 |
Dependencies removeEmptyDependencyValues |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4155 |
|
3885
b699abd9476f
catch errors while finalizing
Claus Gittinger <cg@exept.de>
parents:
3859
diff
changeset
|
4156 |
"Modified: / 19.10.1998 / 22:03:12 / cg" |
4675 | 4157 |
"Modified: / 3.9.1999 / 14:03:05 / ps" |
615 | 4158 |
! |
4159 |
||
1288 | 4160 |
startBackgroundFinalizationAt:aPriority |
4161 |
"start a process doing finalization work in the background. |
|
4162 |
Can be used to reduce the pauses created by finalization. |
|
4163 |
Normally, these pauses are not noticed; however if you have (say) |
|
4164 |
ten thousands of weak objects, these could become long enough to |
|
4165 |
make background finalization usefull. |
|
4166 |
WARNING: background finalization may lead to much delayed freeing of |
|
4167 |
system resources. Especially, you may temporarily run out of free |
|
4168 |
color table entries or fileDescriptors etc. Use at your own risk (if at all)" |
|
4169 |
||
4170 |
|p| |
|
4171 |
||
4172 |
"/ |
|
4173 |
"/ its not useful, to run it more than once |
|
4174 |
"/ |
|
4175 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4176 |
BackgroundFinalizationProcess priority:aPriority. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4177 |
^ self |
1288 | 4178 |
]. |
4179 |
||
2262 | 4180 |
FinalizationSemaphore := Semaphore new name:'FinalizationSemaphore'. |
1288 | 4181 |
|
4182 |
p := |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4183 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4184 |
[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4185 |
[true] whileTrue:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4186 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4187 |
wait till something to do ... |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4188 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4189 |
FinalizationSemaphore wait. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4190 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4191 |
... and do it |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4192 |
" |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4193 |
self finalize |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4194 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4195 |
] ifCurtailed:[ |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4196 |
BackgroundFinalizationProcess := nil. |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4197 |
FinalizationSemaphore := nil |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4198 |
] |
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4199 |
] newProcess. |
1288 | 4200 |
p name:'background finalizer'. |
4201 |
p priority:aPriority. |
|
4202 |
p restartable:true. |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
4203 |
p beSystemProcess. |
1288 | 4204 |
p resume. |
4205 |
BackgroundFinalizationProcess := p |
|
290 | 4206 |
|
4207 |
" |
|
10493
ed3649e79223
Start background processes as system processes (background collector and finalizer)
Stefan Vogel <sv@exept.de>
parents:
10226
diff
changeset
|
4208 |
ObjectMemory stopBackgroundFinalization. |
290 | 4209 |
ObjectMemory startBackgroundFinalizationAt:5 |
4210 |
" |
|
3733 | 4211 |
|
4212 |
"Modified: / 5.8.1998 / 14:53:27 / cg" |
|
1288 | 4213 |
! |
4214 |
||
4215 |
stopBackgroundFinalization |
|
4216 |
"stop the background finalizer" |
|
4217 |
||
4218 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
4219 |
BackgroundFinalizationProcess terminate. |
|
4220 |
BackgroundFinalizationProcess := nil |
|
4221 |
]. |
|
4222 |
||
4223 |
" |
|
4224 |
ObjectMemory stopBackgroundFinalization |
|
4225 |
" |
|
290 | 4226 |
! ! |
4227 |
||
1767 | 4228 |
!ObjectMemory class methodsFor:'physical memory access'! |
93 | 4229 |
|
1288 | 4230 |
collectedOldSpacePagesDo:aBlock |
4231 |
"evaluates aBlock for all pages in the prev. oldSpace, passing |
|
10226 | 4232 |
the pages address as argument. |
1288 | 4233 |
For internal & debugging use only." |
4234 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4235 |
if (__collectedOldSpacePagesDo(&aBlock) < 0) { |
615 | 4236 |
RETURN (false); |
4237 |
} |
|
4238 |
%}. |
|
4239 |
^ true |
|
4240 |
! |
|
4241 |
||
1288 | 4242 |
newSpacePagesDo:aBlock |
4243 |
"evaluates aBlock for all pages in the newSpace, passing |
|
4244 |
the pages address as argument. |
|
4245 |
For internal & debugging use only." |
|
4246 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4247 |
if (__newSpacePagesDo(&aBlock) < 0) { |
159 | 4248 |
RETURN (false); |
85 | 4249 |
} |
4250 |
%}. |
|
4251 |
^ true |
|
4252 |
! |
|
4253 |
||
1288 | 4254 |
oldSpacePagesDo:aBlock |
4255 |
"evaluates aBlock for all pages in the oldSpace, passing |
|
10226 | 4256 |
the pages address as argument. |
1288 | 4257 |
For internal & debugging use only." |
4258 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
4259 |
if (__oldSpacePagesDo(&aBlock) < 0) { |
1286 | 4260 |
RETURN (false); |
85 | 4261 |
} |
4262 |
%}. |
|
4263 |
^ true |
|
1288 | 4264 |
! |
4265 |
||
4266 |
pageIsInCore:aPageNumber |
|
4267 |
"return true, if the page (as enumerated via oldSpacePagesDo:) |
|
4268 |
is in memory; false, if currently paged out. For internal |
|
4269 |
use / monitors only; may vanish. |
|
4270 |
NOTICE: not all systems provide this information; on those that |
|
4271 |
do not, true is returned for all pages." |
|
4272 |
%{ |
|
4273 |
#ifdef HAS_MINCORE |
|
4274 |
int pageSize = getpagesize(); |
|
4275 |
char result[10]; |
|
4276 |
INT addr; |
|
4277 |
||
4278 |
if (__isSmallInteger(aPageNumber)) { |
|
4279 |
addr = __intVal(aPageNumber) & ~(pageSize - 1); |
|
4280 |
} else { |
|
4281 |
addr = ((INT)aPageNumber) & ~(pageSize - 1); |
|
4282 |
} |
|
4283 |
if (mincore(addr, pageSize-1, result) < 0) { |
|
4284 |
RETURN (true); |
|
4285 |
} |
|
4286 |
RETURN ((result[0] & 1) ? true : false); |
|
4287 |
#endif |
|
4288 |
%}. |
|
4289 |
"OS does not supply this info - assume yes" |
|
4290 |
^ true |
|
85 | 4291 |
! ! |
4292 |
||
1767 | 4293 |
!ObjectMemory class methodsFor:'queries'! |
615 | 4294 |
|
1288 | 4295 |
bytesUsed |
4296 |
"return the number of bytes allocated for objects - |
|
4297 |
this number is not exact, since some objects may already be dead |
|
4298 |
(i.e. not yet reclaimed by the garbage collector). |
|
4299 |
If you need the exact number, you have to loop over all |
|
4300 |
objects and ask for the bytesize using ObjectMemory>>sizeOf:." |
|
4301 |
||
4302 |
%{ /* NOCONTEXT */ |
|
14649 | 4303 |
extern unsigned INT __oldSpaceUsed(), __freeListSpace(); |
4304 |
extern unsigned int __newSpaceUsed(); |
|
4305 |
||
4306 |
RETURN ( __MKUINT(__oldSpaceUsed() + (INT)__newSpaceUsed() - __freeListSpace()) ); |
|
615 | 4307 |
%} |
4308 |
" |
|
10226 | 4309 |
ObjectMemory bytesUsed |
615 | 4310 |
" |
4311 |
! |
|
4312 |
||
1288 | 4313 |
collectObjectsWhich:aBlock |
4314 |
"helper for the whoReferences queries. Returns a collection |
|
4315 |
of objects for which aBlock returns true." |
|
4316 |
||
4317 |
|aCollection| |
|
4318 |
||
15011 | 4319 |
aCollection := OrderedCollection new. |
4320 |
self allObjectsIncludingContextsDo:[:o | |
|
15441 | 4321 |
(aBlock value:o) ifTrue:[ |
4322 |
aCollection add:o |
|
4323 |
] |
|
1288 | 4324 |
]. |
4325 |
(aCollection size == 0) ifTrue:[ |
|
15441 | 4326 |
"actually this cannot happen - there is always one" |
4327 |
^ nil |
|
615 | 4328 |
]. |
4329 |
^ aCollection |
|
4330 |
! |
|
4331 |
||
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4332 |
collectedOldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4333 |
%{ |
14649 | 4334 |
#ifdef COLLECTEDOLD_ADDRESS |
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4335 |
RETURN(__MKUINT(COLLECTEDOLD_ADDRESS)); |
14622 | 4336 |
#else |
4337 |
RETURN(__MKUINT(0)); |
|
4338 |
#endif |
|
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4339 |
%} |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4340 |
|
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4341 |
" |
13584 | 4342 |
self collectedOldSpaceAddress |
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4343 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4344 |
! |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4345 |
|
1288 | 4346 |
fixSpaceSize |
4347 |
"return the total size of the fix space." |
|
4348 |
||
4349 |
%{ /* NOCONTEXT */ |
|
4350 |
extern unsigned __fixSpaceSize(); |
|
4351 |
||
14381 | 4352 |
RETURN ( __MKUINT(__fixSpaceSize()) ); |
615 | 4353 |
%} |
4354 |
" |
|
4355 |
ObjectMemory fixSpaceSize |
|
4356 |
" |
|
4357 |
! |
|
4358 |
||
1288 | 4359 |
fixSpaceUsed |
4360 |
"return the number of bytes allocated for old objects in fix space." |
|
4361 |
||
4362 |
%{ /* NOCONTEXT */ |
|
4363 |
extern unsigned __fixSpaceUsed(); |
|
4364 |
||
14381 | 4365 |
RETURN ( __MKUINT(__fixSpaceUsed()) ); |
615 | 4366 |
%} |
4367 |
" |
|
4368 |
ObjectMemory fixSpaceUsed |
|
4369 |
" |
|
4370 |
! |
|
4371 |
||
1288 | 4372 |
freeListSpace |
4373 |
"return the number of bytes in the free lists. |
|
4374 |
(which is included in oldSpaceUsed)" |
|
4375 |
||
4376 |
%{ /* NOCONTEXT */ |
|
14649 | 4377 |
extern unsigned INT __freeListSpace(); |
1288 | 4378 |
|
14381 | 4379 |
RETURN ( __MKUINT(__freeListSpace()) ); |
615 | 4380 |
%} |
4381 |
" |
|
4382 |
ObjectMemory freeListSpace |
|
4383 |
" |
|
4384 |
! |
|
4385 |
||
1288 | 4386 |
freeSpace |
4387 |
"return the number of bytes in the compact free area. |
|
4388 |
(oldSpaceUsed + freeSpaceSize = oldSpaceSize)" |
|
4389 |
||
4390 |
%{ /* NOCONTEXT */ |
|
14649 | 4391 |
extern unsigned INT __oldSpaceSize(), __oldSpaceUsed(); |
1288 | 4392 |
|
14381 | 4393 |
RETURN ( __MKUINT(__oldSpaceSize() - __oldSpaceUsed()) ); |
615 | 4394 |
%} |
4395 |
" |
|
4396 |
ObjectMemory freeSpace |
|
4397 |
" |
|
4398 |
! |
|
4399 |
||
1288 | 4400 |
garbageCollectCount |
4401 |
"return the number of compressing collects that occurred since startup" |
|
4402 |
||
4403 |
%{ /* NOCONTEXT */ |
|
4404 |
extern int __garbageCollectCount(); |
|
4405 |
||
8913 | 4406 |
RETURN (__mkSmallInteger(__garbageCollectCount())); |
615 | 4407 |
%} |
4408 |
" |
|
10226 | 4409 |
ObjectMemory garbageCollectCount |
615 | 4410 |
" |
4411 |
! |
|
4412 |
||
1288 | 4413 |
incrementalGCCount |
4414 |
"return the number of incremental collects that occurred since startup" |
|
4415 |
||
4416 |
%{ /* NOCONTEXT */ |
|
4417 |
extern int __incrementalGCCount(); |
|
4418 |
||
8913 | 4419 |
RETURN (__mkSmallInteger(__incrementalGCCount())); |
615 | 4420 |
%} |
4421 |
" |
|
4422 |
ObjectMemory incrementalGCCount |
|
4423 |
" |
|
4424 |
! |
|
4425 |
||
1288 | 4426 |
incrementalGCPhase |
4427 |
"returns the internal state of the incremental GC. |
|
4428 |
The meaning of those numbers is a secret :-). |
|
4429 |
(for the curious: (currently) |
|
4430 |
2 is idle, 3..11 are various mark phases, |
|
4431 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4432 |
incr. GC gets interrupted by a full GC). |
|
4433 |
Do not depend on the values - there may be additional phases in |
|
4434 |
future versions (incremental compact ;-). |
|
4435 |
This is for debugging and monitoring only - and may change or vanish" |
|
4436 |
||
4437 |
%{ /* NOCONTEXT */ |
|
615 | 4438 |
extern int __incrGCphase(); |
4439 |
||
8913 | 4440 |
RETURN (__mkSmallInteger(__incrGCphase())); |
615 | 4441 |
%} |
4442 |
! |
|
4443 |
||
3742 | 4444 |
incrementalGCPhaseSymbolic |
4445 |
"returns the internal state of the incremental GC |
|
4446 |
in a symbolic form. |
|
4447 |
(for the curious: (currently) |
|
4448 |
2 is idle, 3..11 are various mark phases, |
|
4449 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4450 |
incr. GC gets interrupted by a full GC). |
|
4451 |
Do not depend on the values - there may be additional phases in |
|
4452 |
future versions (incremental compact ;-). |
|
4453 |
This is for debugging and monitoring only - and may change or vanish" |
|
4454 |
||
4455 |
|phase| |
|
4456 |
||
4457 |
phase := self incrementalGCPhase. |
|
4458 |
phase < 2 ifTrue:[^ #cleanup]. |
|
4459 |
phase == 2 ifTrue:[^ #idle]. |
|
4460 |
phase < 12 ifTrue:[^ #marking]. |
|
4461 |
^ #sweeping |
|
4462 |
||
4463 |
"Created: / 10.8.1998 / 15:02:52 / cg" |
|
4464 |
! |
|
4465 |
||
1288 | 4466 |
lastScavengeReclamation |
4467 |
"returns the number of bytes replacimed by the last scavenge. |
|
4468 |
For statistic only - this may vanish." |
|
4469 |
||
4470 |
%{ /* NOCONTEXT */ |
|
4471 |
extern int __newSpaceReclaimed(); |
|
4472 |
||
8913 | 4473 |
RETURN ( __mkSmallInteger(__newSpaceReclaimed()) ); |
1288 | 4474 |
%} |
4475 |
"percentage of reclaimed objects is returned by: |
|
4476 |
||
4477 |
((ObjectMemory lastScavengeReclamation) |
|
10226 | 4478 |
/ (ObjectMemory newSpaceSize)) * 100.0 |
615 | 4479 |
" |
4480 |
! |
|
4481 |
||
1288 | 4482 |
lifoRememberedSet |
4483 |
"return the lifoRemSet. |
|
4484 |
This is pure VM debugging and will vanish without notice." |
|
4485 |
||
4486 |
%{ /* NOCONTEXT */ |
|
4487 |
extern OBJ __lifoRememberedSet(); |
|
4488 |
||
4489 |
RETURN ( __lifoRememberedSet() ); |
|
615 | 4490 |
%} |
4491 |
" |
|
4492 |
ObjectMemory lifoRememberedSet |
|
4493 |
" |
|
4494 |
! |
|
4495 |
||
1288 | 4496 |
lifoRememberedSetSize |
4497 |
"return the size of the lifoRemSet. |
|
4498 |
This is a VM debugging interface and may vanish without notice." |
|
4499 |
||
4500 |
%{ /* NOCONTEXT */ |
|
4501 |
extern int __lifoRememberedSetSize(); |
|
4502 |
||
8913 | 4503 |
RETURN (__mkSmallInteger(__lifoRememberedSetSize())); |
615 | 4504 |
%} |
4505 |
" |
|
4506 |
ObjectMemory lifoRememberedSetSize |
|
4507 |
" |
|
4508 |
! |
|
4509 |
||
13585 | 4510 |
mallocAllocated |
4511 |
"return the number of bytes allocated (and used) by malloc." |
|
4512 |
||
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4513 |
%{ /* NOCONTEXT */ |
13587 | 4514 |
extern int __stx_malloc_stats(); |
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4515 |
long statsArray[3]; |
13585 | 4516 |
int filled; |
4517 |
||
4518 |
filled = __stx_malloc_stats(statsArray, sizeof(statsArray)); |
|
4519 |
if (filled < 1) { |
|
14068 | 4520 |
RETURN(__mkSmallInteger(0)); |
13585 | 4521 |
} |
4522 |
RETURN ( __MKUINT(statsArray[0])); |
|
4523 |
%} |
|
4524 |
" |
|
4525 |
ObjectMemory mallocAllocated |
|
4526 |
" |
|
4527 |
! |
|
4528 |
||
4529 |
mallocStatsArray |
|
4530 |
"return the number of bytes allocated (and used) by malloc." |
|
4531 |
||
4532 |
|allStats| |
|
4533 |
||
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4534 |
%{ |
13587 | 4535 |
extern int __stx_malloc_stats(); |
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4536 |
long statsArray[30]; |
13585 | 4537 |
int filled, i; |
4538 |
OBJ temp; |
|
4539 |
||
4540 |
filled = __stx_malloc_stats(statsArray, sizeof(statsArray)); |
|
4541 |
if (filled < 1) { |
|
14068 | 4542 |
RETURN(nil); |
13585 | 4543 |
} |
4544 |
allStats = __ARRAY_NEW_INT(filled); |
|
4545 |
for (i = 0; i < filled; i++) { |
|
14068 | 4546 |
__arrayVal(allStats)[i] = temp = __MKUINT(statsArray[i]); |
4547 |
__STORE(allStats, temp); |
|
13585 | 4548 |
} |
4549 |
||
4550 |
RETURN ( allStats ); |
|
4551 |
%} |
|
4552 |
" |
|
4553 |
ObjectMemory mallocStatsArray |
|
4554 |
" |
|
4555 |
! |
|
4556 |
||
4557 |
mallocTotal |
|
4558 |
"return the number of bytes reserved by malloc (may not have been used yet)." |
|
4559 |
||
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4560 |
%{ /* NOCONTEXT */ |
13587 | 4561 |
extern int __stx_malloc_stats(); |
13586
636b2e7b2748
do not use unix types (size_t)
Claus Gittinger <cg@exept.de>
parents:
13585
diff
changeset
|
4562 |
long statsArray[3]; |
13585 | 4563 |
int filled; |
4564 |
||
4565 |
filled = __stx_malloc_stats(statsArray, sizeof(statsArray)); |
|
4566 |
if (filled < 2) { |
|
14068 | 4567 |
RETURN(__mkSmallInteger(0)); |
13585 | 4568 |
} |
4569 |
RETURN ( __MKUINT(statsArray[1])); |
|
4570 |
%} |
|
4571 |
" |
|
4572 |
ObjectMemory mallocTotal |
|
4573 |
" |
|
4574 |
! |
|
4575 |
||
1288 | 4576 |
markAndSweepCount |
4577 |
"return the number of mark&sweep collects that occurred since startup" |
|
4578 |
||
4579 |
%{ /* NOCONTEXT */ |
|
4580 |
extern int __markAndSweepCount(); |
|
4581 |
||
8913 | 4582 |
RETURN (__mkSmallInteger(__markAndSweepCount())); |
615 | 4583 |
%} |
4584 |
" |
|
10226 | 4585 |
ObjectMemory markAndSweepCount |
615 | 4586 |
" |
4587 |
! |
|
4588 |
||
1288 | 4589 |
maximumIdentityHashValue |
4590 |
"for ST-80 compatibility: return the maximum value |
|
4591 |
a hashKey as returned by identityHash can get. |
|
4592 |
Since ST/X uses direct pointers, a field in the objectHeader |
|
4593 |
is used, which is currently 11 bits in size." |
|
4594 |
||
4595 |
%{ /* NOCONTEXT */ |
|
8913 | 4596 |
RETURN ( __mkSmallInteger( __MAX_HASH__ << __HASH_SHIFT__) ); |
615 | 4597 |
%} |
4598 |
" |
|
4599 |
ObjectMemory maximumIdentityHashValue |
|
4600 |
" |
|
4601 |
! |
|
4602 |
||
1288 | 4603 |
minScavengeReclamation |
4604 |
"returns the number of bytes replacimed by the least effective scavenge. |
|
4605 |
For statistic only - this may vanish." |
|
4606 |
||
4607 |
%{ /* NOCONTEXT */ |
|
4608 |
extern int __newSpaceReclaimedMin(); |
|
4609 |
||
8913 | 4610 |
RETURN ( __mkSmallInteger(__newSpaceReclaimedMin()) ); |
615 | 4611 |
%} |
4612 |
" |
|
4613 |
ObjectMemory minScavengeReclamation |
|
4614 |
" |
|
4615 |
! |
|
4616 |
||
1288 | 4617 |
newSpaceSize |
4618 |
"return the total size of the new space - this is usually fix" |
|
4619 |
||
4620 |
%{ /* NOCONTEXT */ |
|
4621 |
extern unsigned __newSpaceSize(); |
|
4622 |
||
14381 | 4623 |
RETURN ( __MKUINT(__newSpaceSize()) ); |
615 | 4624 |
%} |
4625 |
" |
|
4626 |
ObjectMemory newSpaceSize |
|
4627 |
" |
|
4628 |
! |
|
4629 |
||
1288 | 4630 |
newSpaceUsed |
4631 |
"return the number of bytes allocated for new objects. |
|
4632 |
The returned value is usually obsolete as soon as you do |
|
4633 |
something with it ..." |
|
4634 |
||
4635 |
%{ /* NOCONTEXT */ |
|
14649 | 4636 |
extern unsigned int __newSpaceUsed(); |
1288 | 4637 |
|
14381 | 4638 |
RETURN ( __MKUINT(__newSpaceUsed()) ); |
615 | 4639 |
%} |
4640 |
" |
|
10226 | 4641 |
ObjectMemory newSpaceUsed |
615 | 4642 |
" |
4643 |
! |
|
4644 |
||
1288 | 4645 |
numberOfObjects |
4646 |
"return the number of objects in the system." |
|
4647 |
||
4648 |
|tally "{ Class: SmallInteger }"| |
|
4649 |
||
4650 |
tally := 0. |
|
4651 |
self allObjectsDo:[:obj | tally := tally + 1]. |
|
615 | 4652 |
^ tally |
4653 |
||
4654 |
" |
|
10226 | 4655 |
ObjectMemory numberOfObjects |
615 | 4656 |
" |
4657 |
! |
|
4658 |
||
1288 | 4659 |
numberOfWeakObjects |
4660 |
"return the number of weak objects in the system" |
|
4661 |
||
4662 |
%{ /* NOCONTEXT */ |
|
4663 |
extern int __weakListSize(); |
|
4664 |
||
8913 | 4665 |
RETURN ( __mkSmallInteger(__weakListSize()) ); |
615 | 4666 |
%} |
4667 |
" |
|
4668 |
ObjectMemory numberOfWeakObjects |
|
4669 |
" |
|
4670 |
! |
|
4671 |
||
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4672 |
oldSpaceAddress |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4673 |
%{ |
14622 | 4674 |
#ifdef OLDSPACE_ADDRESS |
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4675 |
RETURN(__MKUINT(OLDSPACE_ADDRESS)); |
14622 | 4676 |
#else |
4677 |
RETURN(__MKUINT(0)); |
|
4678 |
#endif |
|
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4679 |
%} |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4680 |
|
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4681 |
" |
13584 | 4682 |
self oldSpaceAddress |
11554
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4683 |
" |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4684 |
! |
1d045beabc5f
Add queries for old space addresses
Stefan Vogel <sv@exept.de>
parents:
11334
diff
changeset
|
4685 |
|
1288 | 4686 |
oldSpaceAllocatedSinceLastGC |
4687 |
"return the number of bytes allocated for old objects since the |
|
4688 |
last oldspace garbage collect occured. This information is used |
|
4689 |
by ProcessorScheduler to decide when to start the incremental |
|
4690 |
background GC." |
|
4691 |
||
4692 |
%{ /* NOCONTEXT */ |
|
14649 | 4693 |
extern unsigned INT __oldSpaceAllocatedSinceLastGC(); |
1288 | 4694 |
|
14381 | 4695 |
RETURN ( __MKUINT(__oldSpaceAllocatedSinceLastGC()) ); |
615 | 4696 |
%} |
4697 |
" |
|
10226 | 4698 |
ObjectMemory oldSpaceAllocatedSinceLastGC |
615 | 4699 |
" |
4700 |
! |
|
4701 |
||
1288 | 4702 |
oldSpaceSize |
4703 |
"return the total size of the old space. - may grow slowly" |
|
4704 |
||
4705 |
%{ /* NOCONTEXT */ |
|
14649 | 4706 |
extern unsigned INT __oldSpaceSize(); |
1288 | 4707 |
|
14381 | 4708 |
RETURN ( __MKUINT(__oldSpaceSize()) ); |
615 | 4709 |
%} |
4710 |
" |
|
4711 |
ObjectMemory oldSpaceSize |
|
4712 |
" |
|
4713 |
! |
|
4714 |
||
1288 | 4715 |
oldSpaceUsed |
4716 |
"return the number of bytes allocated for old objects. |
|
4717 |
(This includes the free lists)" |
|
4718 |
||
4719 |
%{ /* NOCONTEXT */ |
|
14649 | 4720 |
extern unsigned INT __oldSpaceUsed(); |
1288 | 4721 |
|
14381 | 4722 |
RETURN ( __MKUINT(__oldSpaceUsed()) ); |
615 | 4723 |
%} |
4724 |
" |
|
10226 | 4725 |
ObjectMemory oldSpaceUsed |
615 | 4726 |
" |
4727 |
! |
|
4728 |
||
1288 | 4729 |
rememberedSetSize |
4730 |
"return the number of old objects referencing new ones. |
|
4731 |
This is a VM debugging interface and may vanish without notice." |
|
4732 |
||
4733 |
%{ /* NOCONTEXT */ |
|
14649 | 4734 |
extern unsigned int __rememberedSetSize(); |
1288 | 4735 |
|
8913 | 4736 |
RETURN (__mkSmallInteger(__rememberedSetSize())); |
615 | 4737 |
%} |
4738 |
" |
|
4739 |
ObjectMemory rememberedSetSize |
|
4740 |
" |
|
4741 |
! |
|
4742 |
||
1288 | 4743 |
resetMinScavengeReclamation |
4744 |
"resets the number of bytes replacimed by the least effective scavenge. |
|
4745 |
For statistic only - this may vanish." |
|
4746 |
||
4747 |
%{ /* NOCONTEXT */ |
|
14649 | 4748 |
extern void __resetNewSpaceReclaimedMin(); |
1288 | 4749 |
|
4750 |
__resetNewSpaceReclaimedMin(); |
|
4751 |
%}. |
|
4752 |
^ self |
|
4753 |
" |
|
4754 |
ObjectMemory resetMinScavengeReclamation. |
|
615 | 4755 |
ObjectMemory minScavengeReclamation |
4756 |
" |
|
4757 |
! |
|
4758 |
||
1288 | 4759 |
runsSingleOldSpace |
4760 |
"return true, if the system runs in a single oldSpace or |
|
4761 |
false if not. |
|
10226 | 4762 |
The memory system will always drop the second semispace when |
1288 | 4763 |
running out of virtual memory, or the baker-limit is reached. |
10226 | 4764 |
OBSOLETE: |
4765 |
the system may now decide at any time to switch between |
|
4766 |
single and double-space algorithms, depending on the overall memory |
|
4767 |
size. You will now almost always get true as result, since the |
|
4768 |
second semispace is only allocated when needed, and released |
|
4769 |
immediately afterwards. |
|
1288 | 4770 |
" |
4771 |
||
4772 |
%{ /* NOCONTEXT */ |
|
4773 |
extern int __runsSingleOldSpace(); |
|
4774 |
||
4775 |
RETURN ( (__runsSingleOldSpace() ? true : false) ); |
|
615 | 4776 |
%} |
4777 |
" |
|
10226 | 4778 |
ObjectMemory runsSingleOldSpace |
615 | 4779 |
" |
4780 |
! |
|
4781 |
||
1288 | 4782 |
scavengeCount |
4783 |
"return the number of scavenges that occurred since startup" |
|
4784 |
||
4785 |
%{ /* NOCONTEXT */ |
|
4786 |
extern int __scavengeCount(); |
|
4787 |
||
8913 | 4788 |
RETURN (__mkSmallInteger(__scavengeCount())); |
615 | 4789 |
%} |
4790 |
" |
|
10226 | 4791 |
ObjectMemory scavengeCount |
615 | 4792 |
" |
4793 |
! |
|
4794 |
||
1288 | 4795 |
symSpaceSize |
4796 |
"return the total size of the sym space." |
|
4797 |
||
4798 |
%{ /* NOCONTEXT */ |
|
4799 |
extern unsigned __symSpaceSize(); |
|
4800 |
||
8913 | 4801 |
RETURN ( __mkSmallInteger(__symSpaceSize()) ); |
615 | 4802 |
%} |
4803 |
" |
|
4804 |
ObjectMemory symSpaceSize |
|
4805 |
" |
|
4806 |
! |
|
4807 |
||
1288 | 4808 |
symSpaceUsed |
4809 |
"return the number of bytes allocated for old objects in sym space." |
|
4810 |
||
4811 |
%{ /* NOCONTEXT */ |
|
4812 |
extern unsigned __symSpaceUsed(); |
|
4813 |
||
8913 | 4814 |
RETURN ( __mkSmallInteger(__symSpaceUsed()) ); |
615 | 4815 |
%} |
4816 |
" |
|
4817 |
ObjectMemory symSpaceUsed |
|
4818 |
" |
|
4819 |
! |
|
4820 |
||
1288 | 4821 |
tenureAge |
4822 |
"return the current tenure age - thats the number of times |
|
4823 |
an object has to survive scavenges to be moved into oldSpace. |
|
4824 |
For statistic/debugging only - this method may vanish" |
|
4825 |
||
4826 |
%{ /* NOCONTEXT */ |
|
615 | 4827 |
extern unsigned __tenureAge(); |
4828 |
||
8913 | 4829 |
RETURN ( __mkSmallInteger(__tenureAge()) ); |
615 | 4830 |
%} |
4831 |
! |
|
4832 |
||
3181
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4833 |
vmSymbols |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4834 |
"return a collection of symbols used by the VM" |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4835 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4836 |
"/ DO NOT REMOVE THIS METHOD. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4837 |
"/ 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
|
4838 |
"/ in fixed (non-moving) memory. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4839 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4840 |
^ #( |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4841 |
"/ interpreter stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4842 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4843 |
"/ JavaVM stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4844 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4845 |
nativeMethodInvokation |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4846 |
newCleared |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4847 |
monitorEnter: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4848 |
monitorExit: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4849 |
classInit |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4850 |
javaClass |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4851 |
resolve |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4852 |
resolveStatic |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4853 |
) |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4854 |
! |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4855 |
|
1288 | 4856 |
whoReferences:anObject |
4857 |
"return a collection of objects referencing the argument, anObject" |
|
4858 |
||
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4859 |
^ self collectObjectsWhich:[:o | o referencesObject:anObject] |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4860 |
|
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4861 |
" |
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4862 |
(ObjectMemory whoReferences:Transcript) printCR |
615 | 4863 |
" |
4864 |
! |
|
4865 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4866 |
whoReferencesAny:aCollection |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4867 |
"return a collection of objects referencing any object from |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4868 |
the argument, aCollection" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4869 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4870 |
^ self collectObjectsWhich:[:o | o referencesAny:aCollection] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4871 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4872 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4873 |
ObjectMemory whoReferencesAny:(Array with:Transcript with:Smalltalk) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4874 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4875 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4876 |
"Modified: / 2.2.1998 / 16:08:18 / cg" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4877 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4878 |
|
1288 | 4879 |
whoReferencesDerivedInstancesOf:aClass |
4880 |
"return a collection of objects refering to instances |
|
4881 |
of the argument, aClass or a subclass of it." |
|
4882 |
||
4883 |
^ self collectObjectsWhich:[:o | o referencesDerivedInstanceOf:aClass] |
|
615 | 4884 |
|
4885 |
" |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4886 |
(ObjectMemory whoReferencesDerivedInstancesOf:View) printCR |
615 | 4887 |
" |
1288 | 4888 |
! |
4889 |
||
4890 |
whoReferencesInstancesOf:aClass |
|
4891 |
"return a collection of objects refering to instances |
|
4892 |
of the argument, aClass" |
|
4893 |
||
4894 |
^ self collectObjectsWhich:[:o | o referencesInstanceOf:aClass] |
|
4895 |
||
4896 |
" |
|
8556
96a185c5058d
Use #referencesObject instead of #references:
Stefan Vogel <sv@exept.de>
parents:
8543
diff
changeset
|
4897 |
(ObjectMemory whoReferencesInstancesOf:SystemBrowser) printCR |
1288 | 4898 |
" |
615 | 4899 |
! ! |
4900 |
||
1767 | 4901 |
!ObjectMemory class methodsFor:'semaphore access'! |
615 | 4902 |
|
1288 | 4903 |
lowSpaceSemaphore |
4904 |
"return the semaphore that is signalled when the system detects a |
|
4905 |
low space condition. Usually, some time after this, an allocationFailure |
|
4906 |
will happen. You can have a cleanup process sitting in that semaphore and |
|
4907 |
start to release object." |
|
379 | 4908 |
|
1286 | 4909 |
^ LowSpaceSemaphore |
379 | 4910 |
! ! |
4911 |
||
1767 | 4912 |
!ObjectMemory class methodsFor:'statistics'! |
1288 | 4913 |
|
4914 |
ageStatistic |
|
2524 | 4915 |
"for ST/X developers only: |
4916 |
dump contents of newSpace with objects age information. |
|
4917 |
This method may be removed without notice" |
|
4918 |
||
1288 | 4919 |
%{ /* NOCONTEXT */ |
1286 | 4920 |
|
4921 |
__ageStatistics(); |
|
4922 |
%} |
|
2524 | 4923 |
" |
4924 |
ObjectMemory ageStatistic |
|
4925 |
" |
|
4926 |
! |
|
4927 |
||
4928 |
codeCacheInfo |
|
4929 |
"for ST/X developers only: |
|
4930 |
dump contents of dynamic code cache LRU lists. |
|
4931 |
This method may be removed without notice" |
|
4932 |
||
4933 |
%{ /* NOCONTEXT */ |
|
2525 | 4934 |
OBJ __codeCacheInfo(); |
2524 | 4935 |
|
4936 |
RETURN (__codeCacheInfo()); |
|
4937 |
%} |
|
4938 |
" |
|
4939 |
ObjectMemory codeCacheInfo do:[:item | |
|
4186
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4940 |
|n nMethods nBytes| |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4941 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4942 |
n := item at:1. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4943 |
nMethods := item at:2. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4944 |
nBytes := item at:3. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4945 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4946 |
n isNil ifTrue:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4947 |
|
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4948 |
] ifFalse:[ |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4949 |
(n printStringLeftPaddedTo:2) print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4950 |
]. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4951 |
' ' print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4952 |
(nMethods printStringLeftPaddedTo:4) print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4953 |
' ' print. |
e1b3efd74643
codeForCPU: returns the old setting
Claus Gittinger <cg@exept.de>
parents:
4104
diff
changeset
|
4954 |
(nBytes printStringLeftPaddedTo:6) printCR. |
2524 | 4955 |
] |
4956 |
" |
|
4957 |
||
13581 | 4958 |
! |
4959 |
||
4960 |
mallocStatistics |
|
4961 |
"for ST/X developers only: |
|
13584 | 4962 |
dump statistics on malloc memory allocation (used, for example for ExternalBytes) on |
4963 |
the standard output. Dummy on some architectures, where the standard malloc is used (win32, for example). |
|
13581 | 4964 |
This method may be removed without notice" |
4965 |
||
4966 |
%{ /* NOCONTEXT */ |
|
4967 |
void __malloc_print_stats(); |
|
4968 |
||
13582 | 4969 |
__malloc_print_stats(); |
13581 | 4970 |
%} |
4971 |
" |
|
4972 |
ObjectMemory mallocStatistics |
|
4973 |
" |
|
1288 | 4974 |
! ! |
4975 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4976 |
!ObjectMemory class methodsFor:'system configuration queries'! |
1288 | 4977 |
|
4978 |
allBinaryModulesDo:aBlock |
|
4979 |
"internal private method - walk over all known binary |
|
4980 |
modules and evaluate aBlock for each entry. |
|
4981 |
Do not depend on the information returned for each - this may |
|
418 | 4982 |
change without notice." |
4983 |
||
4984 |
%{ |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4985 |
__REGISTRATION_DO_BLOCK5__(&aBlock COMMA_SND); |
418 | 4986 |
%} |
4987 |
! |
|
4988 |
||
1288 | 4989 |
binaryModuleInfo |
4990 |
"return a collection of moduleInfo entries. |
|
4991 |
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
|
4992 |
with one entry for each binary package (module)." |
1288 | 4993 |
|
4994 |
|modules| |
|
4995 |
||
4996 |
modules := IdentityDictionary new. |
|
10660
4c0906a6d369
be careful with invalid objects during module-enumeration
Claus Gittinger <cg@exept.de>
parents:
10493
diff
changeset
|
4997 |
self allBinaryModulesDo:[:idArg :nameArg :flagsArg :libName :timeStamp | |
13584 | 4998 |
|type subModuleName module dynamic infoRec handle pathName |
4999 |
typeName name nameString| |
|
5000 |
||
5001 |
nameArg class == String ifFalse:[ |
|
5002 |
'Error in binaryModuleInfo - skip entry' errorPrintCR. |
|
5003 |
] ifTrue:[ |
|
5004 |
name := nameArg. |
|
5005 |
subModuleName := name asSymbol. |
|
5006 |
||
5007 |
idArg > 0 ifTrue:[ |
|
5008 |
dynamic := true. |
|
5009 |
typeName := 'dynamic '. |
|
5010 |
handle := ObjectFileLoader handleFromID:idArg. |
|
5011 |
(handle isNil or:[(pathName := handle pathName) isNil]) ifTrue:[ |
|
5012 |
name := '?' |
|
5013 |
] ifFalse:[ |
|
5014 |
name := pathName asFilename baseName |
|
5015 |
] |
|
5016 |
] ifFalse:[ |
|
5017 |
dynamic := false. |
|
5018 |
typeName := 'builtIn '. |
|
5019 |
pathName := nil. |
|
5020 |
libName isNil ifTrue:[ |
|
5021 |
name := subModuleName |
|
5022 |
] ifFalse:[ |
|
5023 |
name := libName |
|
5024 |
]. |
|
5025 |
]. |
|
5026 |
nameString := typeName. |
|
5027 |
libName isNil ifTrue:[ |
|
5028 |
nameString := nameString, 'module ' |
|
5029 |
] ifFalse:[ |
|
5030 |
nameString := nameString, 'classLib ' |
|
5031 |
]. |
|
5032 |
nameString := nameString , name. |
|
5033 |
||
5034 |
libName isNil ifTrue:[ |
|
5035 |
type := #classObject |
|
5036 |
] ifFalse:[ |
|
5037 |
type := #classLibrary |
|
5038 |
]. |
|
5039 |
||
5040 |
infoRec := modules at:idArg ifAbsent:nil. |
|
5041 |
infoRec notNil ifTrue:[ |
|
5042 |
infoRec classNames add:subModuleName. |
|
5043 |
] ifFalse:[ |
|
5044 |
infoRec := BinaryModuleDescriptor |
|
5045 |
name:nameString |
|
5046 |
type:type |
|
5047 |
id:idArg |
|
5048 |
dynamic:dynamic |
|
5049 |
classNames:( (OrderedSet ? Set) with:subModuleName) |
|
5050 |
handle:handle |
|
5051 |
pathName:pathName |
|
5052 |
libraryName:libName |
|
5053 |
timeStamp:nil. |
|
5054 |
||
5055 |
modules at:idArg put:infoRec. |
|
5056 |
]. |
|
5057 |
]. |
|
1288 | 5058 |
]. |
5059 |
^ modules |
|
5060 |
||
5061 |
" |
|
5062 |
ObjectMemory binaryModuleInfo |
|
418 | 5063 |
" |
5064 |
||
438 | 5065 |
"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
|
5066 |
"Modified: 22.4.1997 / 23:42:59 / cg" |
418 | 5067 |
! |
5068 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5069 |
getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5070 |
"return a collection of release strings giving information |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5071 |
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
|
5072 |
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
|
5073 |
change or vanish without notice." |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5074 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5075 |
%{ |
3729
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
5076 |
extern OBJ __getVMReleaseStrings(); |
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
5077 |
|
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5078 |
RETURN (__getVMReleaseStrings()); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5079 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5080 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5081 |
ObjectMemory getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5082 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5083 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5084 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5085 |
!ObjectMemory class methodsFor:'system management'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
5086 |
|
1288 | 5087 |
imageBaseName |
5088 |
"return a reasonable filename to use as baseName (i.e. without extension). |
|
5089 |
This is the filename of the current image (without '.img') or, |
|
5090 |
if not running from an image, the default name 'st'" |
|
5091 |
||
12648 | 5092 |
|nm filename suffix| |
1288 | 5093 |
|
5094 |
nm := ImageName. |
|
12648 | 5095 |
(nm isEmptyOrNil or:[nm isBlank]) ifTrue:[ |
13584 | 5096 |
^ 'st' |
1288 | 5097 |
]. |
12648 | 5098 |
|
5099 |
filename := nm asFilename. |
|
5100 |
suffix := filename suffix. |
|
5101 |
(suffix = 'sav' or:[suffix = self suffixForSnapshot]) ifTrue:[ |
|
13584 | 5102 |
^ filename nameWithoutSuffix. |
615 | 5103 |
]. |
12648 | 5104 |
|
615 | 5105 |
^ nm |
5106 |
||
5107 |
" |
|
10226 | 5108 |
ObjectMemory imageBaseName |
615 | 5109 |
" |
5110 |
! |
|
5111 |
||
1288 | 5112 |
imageName |
5113 |
"return the filename of the current image, or nil |
|
5114 |
if not running from an image." |
|
615 | 5115 |
|
5116 |
^ ImageName |
|
335 | 5117 |
|
5118 |
" |
|
10226 | 5119 |
ObjectMemory imageName |
335 | 5120 |
" |
1 | 5121 |
! |
5122 |
||
1288 | 5123 |
imageSaveTime |
5124 |
"return a timestamp for when the running image was saved. |
|
1096 | 5125 |
Return nil if not running from an image." |
5126 |
||
5127 |
^ ImageSaveTime |
|
5128 |
! |
|
5129 |
||
1288 | 5130 |
nameForChanges |
5131 |
"return a reasonable filename to store the changes into. |
|
5132 |
Currently, this is defined in a classVariable and defaults to 'changes'. |
|
5133 |
In future versions, this will be the basename of the current image with '.img' replaced |
|
5134 |
by '.chg', or, if not running from an image, the default name 'st.chg'." |
|
5135 |
||
5136 |
ChangeFileName notNil ifTrue:[^ ChangeFileName]. |
|
13302
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5137 |
^ self nameForChangesLocal |
1 | 5138 |
|
335 | 5139 |
" |
10226 | 5140 |
ObjectMemory nameForChanges |
615 | 5141 |
" |
13302
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5142 |
|
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5143 |
"Modified: / 09-02-2011 / 20:44:37 / cg" |
615 | 5144 |
! |
5145 |
||
1288 | 5146 |
nameForChanges:aFilename |
5147 |
"set the name of the file where changes are stored into." |
|
5148 |
||
5149 |
ChangeFileName := aFilename |
|
615 | 5150 |
|
5151 |
" |
|
10226 | 5152 |
ObjectMemory nameForChanges:'myChanges' |
615 | 5153 |
" |
5154 |
! |
|
5155 |
||
13302
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5156 |
nameForChangesLocal |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5157 |
"return a reasonable filename to store the changes into." |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5158 |
|
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5159 |
^ self imageBaseName , '.chg' |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5160 |
|
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5161 |
" |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5162 |
ObjectMemory nameForChanges |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5163 |
" |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5164 |
|
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5165 |
"Created: / 09-02-2011 / 20:44:31 / cg" |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5166 |
! |
24c3c50a0750
added: #nameForChangesLocal
Claus Gittinger <cg@exept.de>
parents:
12924
diff
changeset
|
5167 |
|
10019 | 5168 |
nameForCrashImage |
12648 | 5169 |
^ 'crash', '.', self suffixForSnapshot |
10019 | 5170 |
|
5171 |
" |
|
10226 | 5172 |
ObjectMemory nameForCrashImage |
10019 | 5173 |
" |
5174 |
||
5175 |
"Created: / 29-09-2006 / 13:16:52 / cg" |
|
5176 |
! |
|
5177 |
||
1288 | 5178 |
nameForSnapshot |
5179 |
"return a reasonable filename to store the snapshot image into. |
|
5180 |
This is the filename of the current image or, |
|
5181 |
if not running from an image, the default name 'st.img'" |
|
5182 |
||
12648 | 5183 |
^ self imageBaseName , '.', self suffixForSnapshot |
615 | 5184 |
|
5185 |
" |
|
10226 | 5186 |
ObjectMemory nameForSnapshot |
335 | 5187 |
" |
1 | 5188 |
! |
5189 |
||
1288 | 5190 |
nameForSources |
5191 |
"return a reasonable filename to store the sources into. |
|
5192 |
This is the basename of the current image with '.img' replaced |
|
5193 |
by '.src', or, if not running from an image, the default name 'st.src'" |
|
615 | 5194 |
|
5195 |
^ self imageBaseName , '.src' |
|
362 | 5196 |
|
5197 |
" |
|
10226 | 5198 |
ObjectMemory nameForSources |
615 | 5199 |
" |
5200 |
! |
|
5201 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5202 |
primSnapShotOn:aFilename |
1288 | 5203 |
"create a snapshot in the given file. |
5204 |
Low level entry. Does not notify classes or write an entry to |
|
10226 | 5205 |
the changes file. Also, no image backup is created. |
1704 | 5206 |
Returns true if the snapshot worked, false if it failed for some reason. |
1288 | 5207 |
This method should not be used in normal cases." |
5208 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5209 |
|ok oldImageName oldImageTime filenameString| |
1704 | 5210 |
|
5211 |
" |
|
5212 |
save the name and time with it ... |
|
5213 |
" |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5214 |
|
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5215 |
filenameString := aFilename asString. |
1704 | 5216 |
oldImageName := ImageName. |
5217 |
oldImageTime := ImageSaveTime. |
|
5218 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5219 |
ImageName := filenameString. |
8252
16ed6cd9868d
Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents:
7769
diff
changeset
|
5220 |
ImageSaveTime := Timestamp now. |
1704 | 5221 |
|
5222 |
%{ /* CALLSSTACK:32000 */ |
|
1288 | 5223 |
|
5224 |
OBJ __snapShotOn(); |
|
5225 |
OBJ funny = @symbol(funnySnapshotSymbol); |
|
5226 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5227 |
if (__isStringLike(filenameString)) { |
10226 | 5228 |
__BLOCKINTERRUPTS(); |
5229 |
ok = __snapShotOn(__context, __stringVal(filenameString), funny); |
|
5230 |
__UNBLOCKINTERRUPTS(); |
|
615 | 5231 |
} |
5232 |
%}. |
|
1704 | 5233 |
|
5234 |
ImageName := oldImageName. |
|
5235 |
ImageSaveTime := oldImageTime. |
|
5236 |
||
615 | 5237 |
^ ok |
5238 |
! |
|
5239 |
||
8543
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5240 |
refreshChangesFrom: oldChangesName |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5241 |
"The snapshot image name has changed (snapshot saved), |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5242 |
the changes file must be copied to the new name. |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5243 |
No copy when the changes name is given explicitly." |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5244 |
|
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5245 |
ChangeFileName notNil ifTrue: [ ^self]. |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5246 |
oldChangesName asFilename copyTo:self nameForChanges |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5247 |
|
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5248 |
"Created: / 15.5.2004 / 20:29:03 / masca" |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5249 |
! |
ebe9ec9d4dec
changefile handling (experimental)
Claus Gittinger <cg@exept.de>
parents:
8528
diff
changeset
|
5250 |
|
1288 | 5251 |
snapShot |
5252 |
"create a snapshot file containing all of the current state." |
|
615 | 5253 |
|
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
|
5254 |
self snapShotOn:self nameForSnapshot setImageName:true |
615 | 5255 |
|
5256 |
" |
|
5257 |
ObjectMemory snapShot |
|
362 | 5258 |
" |
1288 | 5259 |
! |
5260 |
||
5261 |
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
|
5262 |
^ 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
|
5263 |
|
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
|
5264 |
" |
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
|
5265 |
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
|
5266 |
" |
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
|
5267 |
! |
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
|
5268 |
|
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
|
5269 |
snapShotOn:aFileName setImageName:setImageName |
10226 | 5270 |
"create a snapshot in the given file. |
1288 | 5271 |
If the file exists, save it for backup. |
5272 |
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
|
5273 |
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
|
5274 |
|
13584 | 5275 |
If setImageName is true, the name of the current image is set and |
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
|
5276 |
a copy of the change file is created." |
1288 | 5277 |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5278 |
|ok snapshotFilename tempFilename oldChangeFile| |
1288 | 5279 |
|
5280 |
" |
|
5281 |
give others a chance to fix things |
|
5282 |
" |
|
5283 |
self changed:#save. "/ will vanish ... |
|
5284 |
self changed:#aboutToSnapshot. "/ ... for ST-80 compatibility |
|
5285 |
||
5286 |
" |
|
5287 |
ST-80 compatibility; send #preSnapshot to all classes |
|
5288 |
" |
|
5581 | 5289 |
Smalltalk allClassesDo:[:aClass | |
13584 | 5290 |
aClass preSnapshot |
1288 | 5291 |
]. |
5292 |
||
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5293 |
" |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5294 |
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
|
5295 |
bad happens while writing the image. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5296 |
(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
|
5297 |
" |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5298 |
snapshotFilename := aFileName asFilename. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5299 |
tempFilename := snapshotFilename withSuffix:'tmp'. |
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5300 |
ok := self primSnapShotOn:tempFilename. |
1288 | 5301 |
|
5302 |
ok ifTrue:[ |
|
13584 | 5303 |
"keep history of one snapshot file" |
5304 |
snapshotFilename exists ifTrue:[ |
|
5305 |
tempFilename symbolicAccessRights:snapshotFilename symbolicAccessRights. |
|
5306 |
snapshotFilename renameTo:(snapshotFilename withSuffix:'sav'). |
|
5307 |
] ifFalse:[ |
|
5308 |
"image file hat stx as interpreter and can be executed" |
|
5309 |
tempFilename makeExecutable. |
|
5310 |
]. |
|
5311 |
tempFilename renameTo:snapshotFilename. |
|
5312 |
||
5313 |
Class addChangeRecordForSnapshot:aFileName. |
|
5314 |
||
5315 |
setImageName ifTrue:[ |
|
5316 |
oldChangeFile := self nameForChanges. |
|
5317 |
ImageName := snapshotFilename asAbsoluteFilename asString. |
|
5318 |
self refreshChangesFrom:oldChangeFile. |
|
5319 |
]. |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5320 |
] ifFalse:[ |
13584 | 5321 |
tempFilename remove. |
1288 | 5322 |
]. |
5323 |
||
5324 |
" |
|
5325 |
ST-80 compatibility; send #postSnapshot to all classes |
|
5326 |
" |
|
5581 | 5327 |
Smalltalk allClassesDo:[:aClass | |
13584 | 5328 |
aClass postSnapshot |
1288 | 5329 |
]. |
5330 |
self changed:#finishedSnapshot. "/ ST-80 compatibility |
|
6113 | 5331 |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5332 |
ok ifFalse:[ |
13584 | 5333 |
SnapshotError raise. |
5334 |
"not reached" |
|
8805
573157b1b5dd
Make snapshot writing more robust against errors
Stefan Vogel <sv@exept.de>
parents:
8713
diff
changeset
|
5335 |
]. |
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
|
5336 |
|
10226 | 5337 |
Transcript |
13584 | 5338 |
show:'Snapshot '; |
5339 |
show:snapshotFilename baseName allBold; |
|
5340 |
show:' saved '; |
|
5341 |
show:Timestamp now; |
|
5342 |
show:' in '; |
|
5343 |
show:snapshotFilename asAbsoluteFilename directoryName; |
|
5344 |
showCR:'.'. |
|
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
|
5345 |
|
1288 | 5346 |
^ ok |
5347 |
||
5348 |
" |
|
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
|
5349 |
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
|
5350 |
ObjectMemory snapShotOn:'myimage.img' setImageName:true |
1288 | 5351 |
" |
9467
be68d09088ce
snapshot save message on the transcript.
Claus Gittinger <cg@exept.de>
parents:
9451
diff
changeset
|
5352 |
|
be68d09088ce
snapshot save message on the transcript.
Claus Gittinger <cg@exept.de>
parents:
9451
diff
changeset
|
5353 |
"Modified: / 04-08-2006 / 18:14:45 / cg" |
10018 | 5354 |
! |
5355 |
||
12648 | 5356 |
suffixForSnapshot |
5357 |
"return the suffix used for snapshot files'" |
|
5358 |
||
5359 |
^ 'img'. |
|
5360 |
! |
|
5361 |
||
10018 | 5362 |
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
|
5363 |
"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
|
5364 |
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
|
5365 |
|
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
|
5366 |
self snapShotOn:self nameForCrashImage setImageName:false |
10018 | 5367 |
|
5368 |
" |
|
5369 |
ObjectMemory writeCrashImage |
|
5370 |
" |
|
5371 |
||
5372 |
"Created: / 29-09-2006 / 12:22:54 / cg" |
|
362 | 5373 |
! ! |
615 | 5374 |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5375 |
!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
|
5376 |
|
12922 | 5377 |
name:n type:t id:i dynamic:d classNames:c handle:h pathName:p libraryName:l timeStamp:ts |
5378 |
^ (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
|
5379 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5380 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5381 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'accessing'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5382 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5383 |
classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5384 |
"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
|
5385 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5386 |
^ classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5387 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5388 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5389 |
dynamic |
10226 | 5390 |
"return true, if this module was loaded dynamically |
11334 | 5391 |
(as opposed to a module which was linked into the system right from the start. |
5392 |
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
|
5393 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5394 |
^ dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5395 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5396 |
|
12922 | 5397 |
handle |
5398 |
^ handle |
|
5399 |
! |
|
5400 |
||
5401 |
handle:something |
|
5402 |
handle := something. |
|
5403 |
! |
|
5404 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5405 |
id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5406 |
"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
|
5407 |
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
|
5408 |
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
|
5409 |
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
|
5410 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5411 |
^ id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5412 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5413 |
|
12266 | 5414 |
isSingleMethod |
13584 | 5415 |
^ type == #classObject and:[ libraryName isNil ] |
12266 | 5416 |
! |
5417 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5418 |
libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5419 |
"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
|
5420 |
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
|
5421 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5422 |
^ libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5423 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5424 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5425 |
name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5426 |
"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
|
5427 |
libraryName." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5428 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5429 |
^ name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5430 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5431 |
|
4686 | 5432 |
package |
5433 |
"retrieve the modules packageId. |
|
5434 |
For now, this is constructed, but will be kept in the VM in later |
|
5435 |
versions." |
|
5436 |
||
5437 |
"/ must fetch from my classes ... |
|
5438 |
classNames do:[:className | |
|
10226 | 5439 |
|class| |
5440 |
||
5441 |
(class := Smalltalk at:className) isBehavior ifTrue:[ |
|
5442 |
^ class package |
|
5443 |
] |
|
4686 | 5444 |
]. |
5445 |
^ nil |
|
5446 |
! |
|
5447 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5448 |
pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5449 |
"return the modules pathName" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5450 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5451 |
^ pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5452 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5453 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5454 |
timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5455 |
"return the modules timeStamp" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5456 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5457 |
^ timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5458 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5459 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5460 |
type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5461 |
"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
|
5462 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5463 |
^ type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5464 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5465 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5466 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'backward compatibility'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5467 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5468 |
at:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5469 |
"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
|
5470 |
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
|
5471 |
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
|
5472 |
|
12924 | 5473 |
<resource: #obsolete> |
5474 |
||
5475 |
self obsoleteMethodWarning. |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5476 |
^ self perform:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5477 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5478 |
|
4736 | 5479 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'printing & storing'! |
5480 |
||
12644
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5481 |
printOn:aStream |
13584 | 5482 |
aStream |
5483 |
nextPutAll:self class name; |
|
5484 |
nextPut:$(. |
|
12644
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5485 |
|
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5486 |
name printOn:aStream. |
ea39ef35da93
BinaryModuleDescriptor >> printOn:
Stefan Vogel <sv@exept.de>
parents:
12266
diff
changeset
|
5487 |
aStream nextPut:$). |
4736 | 5488 |
! ! |
5489 |
||
7258 | 5490 |
!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
|
5491 |
|
12922 | 5492 |
name:n type:t id:i dynamic:d classNames:c handle:h pathName:p libraryName:l timeStamp:ts |
5493 |
name := n. |
|
5494 |
type := t. |
|
5495 |
id := i. |
|
5496 |
dynamic := d. |
|
5497 |
classNames := c. |
|
5498 |
libraryName := l. |
|
5499 |
timeStamp := ts. |
|
5500 |
handle := h. |
|
5501 |
pathName := p. |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5502 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
5503 |
|
1767 | 5504 |
!ObjectMemory class methodsFor:'documentation'! |
630 | 5505 |
|
12266 | 5506 |
version_CVS |
15441 | 5507 |
^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.269 2013-06-27 21:01:21 cg Exp $' |
13421 | 5508 |
! |
5509 |
||
5510 |
version_SVN |
|
15233 | 5511 |
^ '$ Id: ObjectMemory.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
630 | 5512 |
! ! |
7055
83b9d61e4b3c
do not depend on TimeStamp - TimeStamp to return seconds-integer
Claus Gittinger <cg@exept.de>
parents:
6710
diff
changeset
|
5513 |
|
15011 | 5514 |
|
615 | 5515 |
ObjectMemory initialize! |