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