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