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