author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 18:02:18 +0200 | |
changeset 1286 | 4270a0b4917d |
parent 1160 | 1a30ffb90937 |
child 1288 | 9f6420305017 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Object subclass:#ObjectMemory |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
14 |
instanceVariableNames:'' |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
15 |
classVariableNames:'InternalErrorHandler UserInterruptHandler TimerInterruptHandler |
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
16 |
SpyInterruptHandler StepInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
17 |
ExceptionInterruptHandler ErrorInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
18 |
MemoryInterruptHandler SignalInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
19 |
ChildSignalInterruptHandler DisposeInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
20 |
RecursionInterruptHandler IOInterruptHandler |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
21 |
CustomInterruptHandler RegisteredErrorInterruptHandlers |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
22 |
InterruptLatencyMonitor AllocationFailureSignal |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
23 |
MallocFailureSignal LowSpaceSemaphore IncrementalGCLimit |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
24 |
FreeSpaceGCLimit FreeSpaceGCAmount BackgroundCollectProcess |
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
25 |
BackgroundFinalizationProcess FinalizationSemaphore Dependents |
1108 | 26 |
ImageName ImageSaveTime ChangeFileName MaxInterruptLatency |
27 |
InterruptLatencyGoal' |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
28 |
poolDictionaries:'' |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
29 |
category:'System-Support' |
1 | 30 |
! |
31 |
||
2 | 32 |
!ObjectMemory class methodsFor:'documentation'! |
33 |
||
615 | 34 |
caching |
35 |
" |
|
36 |
The system uses various caches to speed up method-lookup. |
|
37 |
Currently, there is a three-level cache hierarchy: |
|
38 |
||
1152 | 39 |
inline-cache keeps the target of the last send at the caller- |
40 |
side (i.e. every send goes through its private |
|
41 |
1-slot inline-cache, where the address of the last |
|
42 |
called function at this call location is kept.) |
|
43 |
||
44 |
polymorph-inline-cache keeps a limited list of all targets ever reached |
|
45 |
at this call location. The list is automatically |
|
46 |
flushed if it grows too large, or the overall number |
|
47 |
of poly-chache entries exceeds a limit. |
|
48 |
||
49 |
method-lookup-cache a global cache. Hashes on class-selector pairs, |
|
50 |
returning the target method. |
|
615 | 51 |
|
52 |
Whenever methods are added or removed from the system, or the inheritance |
|
53 |
hierarchy changes, some or all caches have to be flushed. |
|
54 |
The flushXXX methods perform the task of flushing various caches. |
|
55 |
All standard methods in Behavior call for cache flushing, when things change; |
|
56 |
however, if you use the low level access methods in Behavior |
|
57 |
(for example: #setSuperclass:) special care has to be taken. |
|
58 |
||
59 |
In some situations, not all caches need flushing, for example a change |
|
60 |
in an interpreted method (currently) needs no flushing of the inline caches. |
|
61 |
Also, flushing can be limited to entries for a specific class for most changes. |
|
62 |
||
63 |
To be 'on the brigth side of live', use ObjectMemory>>flushCaches (which |
|
64 |
flushes all of them), when in doubt of which caches should be flushed. |
|
65 |
It is better flush too much - otherwise you may end up in a wrong method after |
|
1152 | 66 |
a send (you wont really see a difference in speed after the flush, anyway). |
615 | 67 |
" |
68 |
! |
|
69 |
||
88 | 70 |
copyright |
71 |
" |
|
72 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
159 | 73 |
All Rights Reserved |
88 | 74 |
|
75 |
This software is furnished under a license and may be used |
|
76 |
only in accordance with the terms of that license and with the |
|
77 |
inclusion of the above copyright notice. This software may not |
|
78 |
be provided or otherwise made available to, or used by, any |
|
79 |
other person. No title to or ownership of the software is |
|
80 |
hereby transferred. |
|
81 |
" |
|
82 |
! |
|
83 |
||
2 | 84 |
documentation |
85 |
" |
|
403 | 86 |
This class contains access methods to the system memory and the VM. |
87 |
||
88 |
In previous ST/X versions, this stuff used to be in the Smalltalk class. |
|
89 |
It has been separated for better overall class structure and modularisation. |
|
229 | 90 |
There are no instances of ObjectMemory - all is done in class methods. |
403 | 91 |
(this is a functional interface). |
92 |
||
93 |
Many methods here are for debuging purposes, for developers |
|
94 |
or experimental, and therefore not standard. |
|
68 | 95 |
Do not depend on them being there - some may vanish ... |
96 |
(especially those, that depend on a specific GC implementation) |
|
403 | 97 |
Most of the stuff found here is not available, or different or called |
98 |
different in other smalltalk implementations. Be aware, that using these |
|
99 |
interfaces (especially: depending on them) may make your application |
|
100 |
non portable. |
|
101 |
||
102 |
See more documentation in -> caching |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
103 |
-> interrupts |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
104 |
-> garbageCollection |
2 | 105 |
|
1286 | 106 |
[Class variables:] |
2 | 107 |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
108 |
InternalErrorHandler gets informed (by VM), when some runtime |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
109 |
error occurs (usually fatal) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
110 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
111 |
UserInterruptHandler gets informed (by VM) when CNTL-C is pressed |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
112 |
TimerInterruptHandler gets alarm timer interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
113 |
SpyInterruptHandler another alarm timer (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
114 |
StepInterruptHandler gets single step interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
115 |
ExceptionInterruptHandler gets floating point exceptions (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
116 |
ErrorInterruptHandler gets primitive errors (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
117 |
MemoryInterruptHandler gets soon-out-of-memory conditions (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
118 |
SignalInterruptHandler gets unix signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
119 |
ChildSignalInterruptHandler gets child death signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
120 |
DisposeInterruptHandler gets informed, when an object is disposed from |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
121 |
a shadowArray (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
122 |
RecursionInterruptHandler gets recursion limit violations (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
123 |
IOInterruptHandler gets SIGIO unix signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
124 |
CustomInterruptHandler gets custom interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
125 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
126 |
InterruptLatencyMonitor if nonNil, that one will be notified (by the VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
127 |
with an interruptLatency:millis message for every |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
128 |
interrupt and gets the delay time |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
129 |
(between the time when the signal arrived and |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
130 |
when it was really delivered) as argument. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
131 |
This can be used to create a statistic for |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
132 |
realtime systems. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
133 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
134 |
RegisteredErrorInterruptHandlers |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
135 |
associates errorID (as passed from primitive |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
136 |
to the __errorInterruptWithID() function) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
137 |
with handlers. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
138 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
139 |
IncrementalGCLimit number of bytes, that must be allocated since |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
140 |
last full garbage collect to turn the incremental |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
141 |
collector on (at idle time). |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
142 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
143 |
FreeSpaceGCLimit low limit on freeSpace at which incremental |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
144 |
gc starts to run at idle time. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
145 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
146 |
FreeSpaceGCAmount amount to allocate once freeSpace drops |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
147 |
below FreeSpaceGCLimit |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
148 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
149 |
Dependents keep my dependents locally (its faster) for |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
150 |
all those registries |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
151 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
152 |
LowSpaceSemaphore a semaphore signalled whenever the system is |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
153 |
running in low memory (i.e. the memory manager |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
154 |
ran into memory shortage and feels that it |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
155 |
may soon no longer be able to grant allocation requests). |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
156 |
You can have a process waiting on this semaphore |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
157 |
which starts to remove (i.e. nil-out) objects |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
158 |
or preform other cleanup actions. |
213 | 159 |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
160 |
AllocationFailureSignal signal raised when a new fails (see Behavior) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
161 |
When this signal is raised, the meomory manager |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
162 |
is really in trouble (i.e. above feelings where |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
163 |
correct) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
164 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
165 |
BackgroundCollectProcess created by startBackgroundCollectorAt: |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
166 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
167 |
BackgroundFinalizationProcess created by startBackgroundFinalizationAt: |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
168 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
169 |
ImageName name of the current image (or nil) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
170 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
171 |
ImageSaveTime <AbsoluteTime> timestamp when this image was saved |
1096 | 172 |
|
173 |
||
403 | 174 |
Warning: |
175 |
The InterruptHandler variables are known by the runtime system - |
|
176 |
they are the objects that get an interrupt message when the event |
|
177 |
occurs. You may not remove any of them. |
|
1286 | 178 |
|
179 |
[author:] |
|
180 |
Claus Gittinger |
|
181 |
||
182 |
[see also:] |
|
183 |
( garbage collection : html:programming/GC.html ) |
|
2 | 184 |
" |
93 | 185 |
! |
186 |
||
187 |
garbageCollection |
|
188 |
" |
|
403 | 189 |
Currently, Smalltalk/X uses a two-level memory hierachy (actually, there |
190 |
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
|
191 |
but for the following discussion, these are not of interest). |
403 | 192 |
|
193 |
newSpace: |
|
194 |
||
93 | 195 |
Objects are created in a so-called newSpace, which is relatively small. |
403 | 196 |
This newSpace is cleaned by a so called ``scavenge''-operation, whenever |
197 |
becoming full. Scavenging means, that all still-live objects (i.e. referenced |
|
198 |
by some other) are copied over to another memory area, leaving all unreachable |
|
199 |
objects as garbage behind. Thus, the newSpace actually consists of two semispaces, |
|
200 |
of whih only one is active - the other being used only while objects are |
|
201 |
copied. |
|
202 |
After this copying, these two semispaces exchange their roles - i.e. reachable |
|
203 |
objects are copied ping-pong like between these semispaces. |
|
202 | 204 |
Once an object survives enough of these copying operations, the next scavenge |
216 | 205 |
will move it into the so called oldSpace, which is much larger, and not |
202 | 206 |
processed by the scavenger. |
403 | 207 |
This movement of an object from newSpace to oldSpace is called ``tenure''. |
208 |
(this avoids objects being copied around forever). |
|
209 |
Once tenured, an object is no longer contained in the newSpace, and |
|
210 |
thus ceases to create any scavenging overhead after that. |
|
133 | 211 |
|
93 | 212 |
Scavenging occurs automatically, and is usually done fast enough to go |
1152 | 213 |
unnoticed (typically, it takes some 5 to 40ms to perform a scavenge, |
93 | 214 |
depending on how many live objects are in the newspace). |
403 | 215 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
216 |
Interestingly, the scavenger performs better, if many garbage objects |
93 | 217 |
are to be reclaimed, since less object-copying has to be done. Therefore, |
216 | 218 |
the best-case scavenge time is almost zero, if there is only garbage in |
219 |
the newSpace. In contrast, the worst-case is when all newSpace objects are still |
|
403 | 220 |
living. Thus, from a newSpace collectors viewPoint, it makes sense to get |
221 |
objects out of the way as fast as possible. However the oldSpace is |
|
222 |
collected much less frequently and the cost to reclaim an oldspace object |
|
223 |
is much higher (actually, the cost to reclaim a newspace object is zero - |
|
224 |
its the survival of objects which we have to pay for). |
|
225 |
Therefore, from an oldSpace collectors point of view, its preferable to |
|
226 |
keep objects in the newSpace as long as possible. |
|
227 |
||
228 |
To honor this conflicting situation, the system uses an adaptive tenure-count, |
|
207 | 229 |
which adjusts the number of scavenges required for tenure (the so called |
230 |
'tenureAge') according to the fill-grade of the newSpace. |
|
403 | 231 |
If the newSpace is relatively empty, it tries to keep objects longer there. |
232 |
The controlling parameters of the tenure age can be changed dynamically, |
|
233 |
detailed information is available upon request. |
|
234 |
||
235 |
The exact speed of the scavenger depends mostly on the speed of your memory |
|
236 |
interface (and, since most of todays memories have access times in the order |
|
237 |
of 50-100ns, the raw CPU speed does not correlate linear with the GC speed). |
|
1152 | 238 |
Measurements give roughly 40ms for a full 400k newSpace |
239 |
(i.e. all objects survive) on a 486/50 - this only drops to some 20-30ms on a P5. |
|
240 |
||
403 | 241 |
The upper bounds of the scavenge blocking time can be controlled by changing |
1152 | 242 |
the size of the newSpace - either via a command line argument, or even dynamically |
403 | 243 |
by Objectmemory>>newSpaceSize:. Smaller sizes lead to shorter blocking periods, |
244 |
but greater absolute GC overhead. The default (400k) seems to be a good compromise. |
|
245 |
(if you are not happy with it, try playing around with the settings) |
|
246 |
||
247 |
oldSpace: |
|
93 | 248 |
|
249 |
To reclaim oldspace, the system uses three algorithms: mark&sweep, a copying |
|
250 |
(and compressing) baker-type collector and an incremental mark&sweep. |
|
251 |
||
252 |
The mark&sweep runs whenever the oldspace becomes full, putting dead objects |
|
253 |
onto a free list. If a memory request cannot be served from this freelist, |
|
254 |
and the total size of objects on the freelist exceeds a threshold, the system |
|
255 |
will compress the oldspace to make the free-space into one big area. |
|
207 | 256 |
This compress is done by copying all live objects into a newly allocated |
257 |
area, and freeing the previous memory afterwards (baker collector). |
|
93 | 258 |
Since a compressing oldspace collect leads to a noticable pause of the system, |
259 |
the memory manager tries hard to avoid oldspace compression. |
|
1152 | 260 |
(well, if enough real memory is available to hold both spaces in physical |
261 |
memory, the compress is actually pretty fast). |
|
202 | 262 |
|
93 | 263 |
The incremental mark&sweep runs in the background, whenever the system is idle |
403 | 264 |
(see ProcessorSceduler>>waitForEventOrTimeout), or alternatively as a low or high |
265 |
priority background process (see ObjectMemory>>startBackgroundCollector). |
|
362 | 266 |
Like the normal mark&sweep, this incremental collector follows object references |
267 |
and marks reachable objects on its way. However, this is done 'a few objects-at-a-time', |
|
268 |
to not disrupt the system noticably. Currently, there are some (theoretical) and in |
|
403 | 269 |
practice never occurring situations, in which the incremental GC still creates noticable |
1152 | 270 |
delays. A current project is involved with this and a future version of ST/X (ST/X-RT) |
403 | 271 |
will be available which shows deterministic worst case behavior in its GC pauses |
272 |
(this will be provided as an additional add-on option - certainly not for free ;-). |
|
1152 | 273 |
|
403 | 274 |
Currently, incremental GC blockings are in the order of 10-70ms. |
275 |
There is one catch with low priority background IGC: if there is never any idle |
|
276 |
time available (i.e. all processes run all the time), it would never get a chance |
|
277 |
to do any collection work. To handle this case, a background IGC can also be started |
|
278 |
as a high priority process, which gives up the cpu (by delaying on the time) after |
|
279 |
every IGC step. A high priority background collector will always make progress |
|
280 |
and eventually finish a GC cycle. However, it may have more of an influence on |
|
281 |
the other processes. So, its up to you, to decide ... |
|
362 | 282 |
|
1152 | 283 |
|
362 | 284 |
Incremental garbage collection is controlled by the variables |
285 |
'IncrementalGCLimit', 'FreeSpaceGCLimit' and 'FreeSpaceGCAmount': |
|
310 | 286 |
|
290 | 287 |
the ProcessorScheduler will perform incremental GC steps at idle time, |
288 |
if the total space allocated since the last full collect exceeds |
|
362 | 289 |
'IncrementalGCLimit', |
290 | 290 |
or if there are less than 'FreeSpaceGCLimit' bytes available in free store. |
362 | 291 |
If after the incrementalGC, less than 'FreeSpaceGCLimi't bytes are available, |
310 | 292 |
'FreeSpaceGCAmount' more bytes are requested from the memory manager. |
290 | 293 |
|
294 |
The defaults are set in ObjectMemory>>initialize and can be changed in your |
|
403 | 295 |
startup 'smalltalk.rc'-file. Setting them to nil turns incremental GC off. |
270 | 296 |
|
1152 | 297 |
|
362 | 298 |
For example, setting 'IncrementalGCLimit' to 500000 will start the background collector |
207 | 299 |
whenever 500k bytes have been allocated - usually very seldom. Setting it to some |
300 |
small number (say 10000) will have it run very often. |
|
290 | 301 |
|
362 | 302 |
Setting 'FreeSpaceGCAmount' to (say) 1meg lets the system try to always keep |
403 | 303 |
1meg of freeSpace. If less memory is available, more oldSpace will be allocated. |
304 |
Keeping some memory in the pocket may prevent the system from running into a blocking |
|
305 |
GC if memory is allocated in peaks (but only, if the incremental GC can keep up with |
|
306 |
allocation rate). The trigger level 'FreeSpaceGCLimit' should be below that amount; |
|
310 | 307 |
to avoid excessive incremental GC activity (say 1/4 if the amount). |
290 | 308 |
|
309 |
Having the background GC running often should not hurt the performance of your |
|
362 | 310 |
smalltalk processes, since the IGC only runs at times when no ST processes are runnable. |
290 | 311 |
(there are some short delays in event processing, since the IGC's steps may take |
312 |
some XX ms.) |
|
270 | 313 |
However, if you are not alone on your machine (i.e. a timesharing system) or |
314 |
you have other Unix processes to run, you should not run the IGC too often, |
|
362 | 315 |
since it may hurt OTHER users/unix processes. |
93 | 316 |
|
216 | 317 |
Since this collector only runs at idle times, even a low priority background |
318 |
process will prevent it from doing its work. You may want to start a somewhat |
|
207 | 319 |
higher priority background collect (say at prio 4), which also preempts these |
320 |
background processes. (see ObjectMemory>>startBackgroundCollectorAt:). |
|
202 | 321 |
|
325 | 322 |
Beginning with 2.10.4, a third space, called symSpace has been added. |
216 | 323 |
Objects in this space are never moved or garbage collected. |
325 | 324 |
This space is used for (some) symbols only. |
325 |
||
326 |
Beginning with 2.10.5, a fourth space, called fixSpace has been added. |
|
327 |
Objects in this space are never moved or garbage collected. |
|
328 |
This space is used for constant objects (true, false, some basic classes etc.). |
|
229 | 329 |
|
330 |
A plan for 2.11 is to offer an arbitrary number of spaces, which can be |
|
331 |
attached and detached at runtime. This will allow easy share of object |
|
332 |
with remote systems and separating objects into a per application/package |
|
333 |
space. (be prepared for changes in the future and make your application |
|
334 |
independ of the VM internals) |
|
216 | 335 |
|
403 | 336 |
default setup: |
337 |
||
338 |
The following table lists some default settings and means for changing them: |
|
339 |
||
1152 | 340 |
what default change by |
341 |
command line arg dynamically |
|
403 | 342 |
----------------------------------------------------------------------- |
1152 | 343 |
newSpace size 400k -Mnew nnn newSpaceSize:nnn |
344 |
||
345 |
oldSpace size 3000k -Mold nnn moreOldSpace: |
|
346 |
announceSpaceNeed: |
|
347 |
collectGarbage |
|
348 |
||
349 |
max tenure age 29 lockTenure: |
|
350 |
avoidTenure: |
|
351 |
(sets it to infinity) |
|
403 | 352 |
|
1152 | 353 |
adaptive tenure tenureParameters |
354 |
||
355 |
oldSpace |
|
356 |
compressor enabled -Msingle - |
|
357 |
||
358 |
limit for |
|
359 |
old-compress 8000k - oldSpaceCompressLimit: |
|
360 |
||
361 |
chunk size |
|
362 |
to increase |
|
363 |
oldpPace 256k - oldSpaceIncrement: |
|
403 | 364 |
|
1152 | 365 |
prefer moreOld |
366 |
to doing GC false - fastMoreOldSpaceAllocation: |
|
367 |
||
368 |
limit for |
|
369 |
above - - fastMoreOldSpaceLimit: |
|
370 |
||
371 |
keep size for - - freeSpaceGCAmount: |
|
372 |
IGC |
|
373 |
||
374 |
low water |
|
375 |
trigger for IGC - - freeSpaceGCLimit: |
|
376 |
||
377 |
allocated |
|
378 |
trigger for IGC 500k - incrementalGCLimit |
|
403 | 379 |
|
380 |
||
1152 | 381 |
By default, no incremental GC is started by the system; however, |
382 |
the standard startup script starts a low prio background incremental GC process. |
|
383 |
You have to edit your startup files to change this. |
|
384 |
A suggested configuration (used by the author and the default) is: |
|
385 |
||
386 |
' keep 1meg in the pocket ' |
|
387 |
||
388 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
389 |
||
390 |
' start incrementalGC when freespace drops below 250k ' |
|
391 |
' or 500k of oldSpace has been allocated ' |
|
392 |
||
393 |
ObjectMemory freeSpaceGCLimit:250000. ' |
|
394 |
ObjectMemory incrementalGCLimit:500000. ' |
|
395 |
||
396 |
' collect as a background process (the default is: at idle times) |
|
397 |
' this means that running cubes or other demo processes are suspended |
|
398 |
' for the collect; change the prio to below 4 if you want them to continue |
|
399 |
||
400 |
ObjectMemory startBackgroundCollectorAt:5. ' |
|
401 |
ObjectMemory startBackgroundFinalizationAt:5. ' |
|
402 |
||
403 |
' quickly allocate more space (i.e. avoid blocking collects) |
|
404 |
' up to 8meg - then start to collect if more memory is needed. |
|
405 |
||
406 |
ObjectMemory fastMoreOldSpaceLimit:8*1024*1024. ' |
|
407 |
ObjectMemory fastMoreOldSpaceAllocation:true. ' |
|
403 | 408 |
|
202 | 409 |
hints & tricks: |
410 |
||
213 | 411 |
normally, there is no need to call for an explicit garbage collection, or |
216 | 412 |
modify the default parameters. |
213 | 413 |
The memory system should adapt reasonable and provide good performance |
202 | 414 |
for a wide range of allocation patterns (see Example3 below for an exception). |
415 |
||
207 | 416 |
However, there may be situations, in which hints and/or explicit |
202 | 417 |
control over allocation can speedup your programs; but please: |
93 | 418 |
|
207 | 419 |
- if you think you have to play around with the memory policies, |
1152 | 420 |
first check your program - you may find useless allocations |
421 |
or bad uses of collections. A typical error that is made is to |
|
422 |
create large collections using the #, (comma) concatenation method, |
|
423 |
which shows square behavior, since it allocates many, many temporary |
|
424 |
collections. Also, watch out for #copyWith:, #add: etc. |
|
425 |
All of these create a new collection. Remember, that most collections |
|
426 |
offer methods to preallocate some space; for example, 'Set new:' creates |
|
427 |
an empty set, but preallocates space to avoid resizing over and over. |
|
428 |
||
429 |
An especially bad performace dog is to use #add: on fix-size collection |
|
430 |
objects (such as Strings or Arrays), since in addition to allocating |
|
431 |
lots of garbage, a #become: operation is required for EACH element |
|
432 |
added. NEVER use Arrays for growing/shrinking data - use OrderedCollection |
|
433 |
instead. (if you really need an array, use asArray afterwards) |
|
202 | 434 |
|
207 | 435 |
- if you are going to allocate huge data structures, think about |
1152 | 436 |
optimizing space. For example, if you allocate a million instances of |
437 |
some object, each added instance variable makes up 4Mb of additional |
|
438 |
memory need. |
|
439 |
Also, for Byte-valued, Integer-valued and Float like objects, special |
|
440 |
collections are provided, which store their values directly inside (instead |
|
441 |
of a reference to the object). A FloatArray consisting of 1 million floats |
|
442 |
requires about 4mb of memory, while an Array of Floats requires 4mb for the |
|
443 |
references to the floats, PLUS 20Mb for the floats themself. |
|
93 | 444 |
|
207 | 445 |
- check if you really need fast access to all of these objects; you may |
1152 | 446 |
try to only keep some subset in memory, and use binary storage or |
447 |
(if this is too slow) optimized store/retrieve methods and keep the bigger |
|
448 |
part in a file. |
|
449 |
(How about a DiskArray class, which does this transparently ? |
|
450 |
See the FileText class for some ideas and something to start with ...) |
|
207 | 451 |
|
452 |
||
453 |
Hint / Example 1: |
|
93 | 454 |
you are about to allocate a huge data structure, which is known to |
455 |
survive long. In this case, it is better to have these objects move into the |
|
456 |
oldspace sooner, to avoid the copying overhead during scavenges. |
|
457 |
||
458 |
To do this, you can call ObjectMemory>>tenure after allocation, which |
|
459 |
forces all new-objects immediately into the oldspace. |
|
460 |
Make certain, that not to many (ideally no) short-living objects are in the |
|
461 |
newspace when doing this. |
|
462 |
||
463 |
Another alternative is to tell the system that all allocation should be |
|
464 |
done directly in the oldspace. This completely avoids the scavenging overhead |
|
465 |
for these objects. To do so, use ObjectMemory>>turnGarbageCollectorOff |
|
466 |
before the allocation, and ObjectMemory>>turnGarbageCollectorOn afterwards. |
|
202 | 467 |
Keep in mind, that do-loops may allocate block-objects and other temporaries, |
178 | 468 |
so there is a danger of making things worse due to having all those temporaries |
93 | 469 |
in the oldspace afterwards. (which is not a fatal situation, but will |
178 | 470 |
force the system to do an oldspace collect earlier, which may not be your |
471 |
intention). |
|
93 | 472 |
|
202 | 473 |
|
207 | 474 |
Hint / Example 2: |
93 | 475 |
you know in advance, that a certain (big) amount of memory will be needed. |
476 |
For example, the fileBrowser wants to show a huge file in its text-view. |
|
133 | 477 |
In this case, it is better to tell the memory system in advance, how much |
93 | 478 |
memory will be needed, since otherwise many compresses and reallocations will |
133 | 479 |
occur (the memory system will allocate additional memory in chunks of smaller |
480 |
256k pieces, if a compress failes. Thus, if you are going to allocate (say) 1Mb of |
|
481 |
strings, it will perform 5 compressing GC's). |
|
482 |
||
202 | 483 |
This is done using ObjectMemory>>moreOldSpace: or ObjectMemory announceSpaceNeed:. |
484 |
In the above example, you would do 'ObjectMemory announceSpaceNeed:500000', which |
|
133 | 485 |
avoids those annoying 5 compressing GC's. |
207 | 486 |
BTW: if you have other smalltalk processes (threads) running which should not be |
487 |
paused if possible, it is better to use #announceSpaceNeed. This tries to avoid |
|
488 |
pausing in other processes and sometimes succeeds, while moreOldSpace will always |
|
489 |
block the whole system for a while. However, there is no 'no-pause' guarantee. |
|
133 | 490 |
|
491 |
The amount of automatic increase (in case the oldSpace becomes full) is 256k by |
|
492 |
default. This number can be changed with ObjectMemory>>oldSpaceIncrement:. |
|
493 |
||
207 | 494 |
|
495 |
Hint / Example3: |
|
178 | 496 |
There are rare cases, when an explicit GC makes a difference: since |
497 |
object finalization is done at GC time, objects which keep operatingSystem |
|
498 |
resources may be finalized late. This is normally no problem, except if |
|
499 |
the system is running out of resources. For example, allocating new colors |
|
500 |
may fail if many colors have already been allocated in the past - even |
|
501 |
though these colors are actually free. The Depth8Image calls for an |
|
502 |
explicit GC, whenever it fails to allocate a color for a bitmap, to force |
|
503 |
finalization of free, but not yet finalized colors. |
|
1152 | 504 |
The same is true for things like file descriptors, if fileStreams are not closed |
505 |
correctly. |
|
207 | 506 |
|
507 |
Hint 4: |
|
508 |
If you run in too small of physical memory, the incremental GC may have a |
|
509 |
bad effect on your working set: since it touches pages (which may otherwise |
|
510 |
not be needed at the moment, the operating system is forced to steal other |
|
511 |
(possibly more useful) pages from your set of incore pages. |
|
1152 | 512 |
Although ST/X would be willing to fix this behavior (by telling the OS about |
513 |
its page requirements, many OS's do not listen. The SGI-Iris, For example ignores |
|
514 |
the madvice system calls - other systems do not implement it. |
|
515 |
The trouble is that the standard LRU paging strategy is exactly the worst for |
|
516 |
a program which sequentially scans its memory once in a single direction ... |
|
207 | 517 |
You may get better performance, if you turn off the incremental GC while |
518 |
processing a big data structure. |
|
519 |
||
520 |
||
229 | 521 |
Warning: many of the methods found here are not standard and may not even be available in |
133 | 522 |
future versions of ST/X. Use them only in very special situations or experiments. |
229 | 523 |
|
207 | 524 |
Let me know about additional special features you think are useful, and about |
525 |
special features you are using - this provides the feedback required to decide |
|
403 | 526 |
which methods are to be removed, kept or enhanced in future versions. |
93 | 527 |
" |
615 | 528 |
! |
529 |
||
530 |
interrupts |
|
531 |
" |
|
532 |
Handling of interrupts (i.e. unix-signals) is done via handler objects, which |
|
533 |
get a #XXXInterrupt-message sent. This is more flexible than (say) signalling |
|
534 |
a semaphore, since the handler-object may do anything to react on the signal |
|
535 |
(of course, it can also signal a semaphore to emulate the above behavior). |
|
536 |
||
537 |
Another reason for having handler objects is that they allow interrupt handling |
|
538 |
without any context switch, for high speed interrupt response. |
|
539 |
However, if you do this, special care is needed, since it is not defined, |
|
1152 | 540 |
which (smalltalk-)process gets the interrupt and will do the processing |
541 |
(therefore, the default setup installs handlers which simply signal a semaphore |
|
542 |
and continue the current process). |
|
615 | 543 |
|
544 |
Typically, the handlers are set during early initialization of the system |
|
545 |
by sending 'ObjectMemory XXXInterruptHandler:aHandler' and not changed later. |
|
546 |
(see Smalltalk>>initialize or ProcessorScheduler>>initialize). |
|
547 |
To setup your own handler, create some object which responds to #xxxInterrupt, |
|
548 |
and make it the handler using the above method. |
|
549 |
||
550 |
Interrupt messages sent to handlers are: |
|
1152 | 551 |
internalError:<someString> - internal interpreter/GC errors |
552 |
userInterrupt - ^C interrupt |
|
553 |
customInterrupt - custom interrupt |
|
554 |
ioInterrupt - SIGIO interrupt |
|
555 |
timerInterrupt - alarm timer (SIGALRM) |
|
556 |
errorInterrupt:<id> - errors from other primitives/subsystems |
|
557 |
(DisplayError) |
|
558 |
spyInterrupt - spy timer interrupt (SIGVTALARM) |
|
559 |
stepInterrupt - single step interrupt |
|
560 |
disposeInterrupt - finalization required |
|
561 |
recursionInterrupt - recursion (stack) overflow |
|
562 |
memoryInterrupt - soon running out of memory |
|
563 |
fpExceptionInterrupt - floating point exception (SIGFPE) |
|
564 |
childSignalInterrupt - death of a child process (SIGCHILD) |
|
565 |
signalInterrupt:<number> - unix signal (if other than above signals) |
|
615 | 566 |
|
567 |
To avoid frustration in case of badly set handlers, these messages |
|
568 |
are also implemented in the Object class - thus anything can be defined |
|
569 |
as interrupt handler. However, the VM will not send any |
|
570 |
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
|
571 |
(which means that nil is a bad choice, if you are interested in the event). |
615 | 572 |
|
1152 | 573 |
Interrupt processing is not done immediately after the event arrives: |
574 |
there are certain ``save-places'' at which this handling is performed |
|
615 | 575 |
(message send, method return and loop-heads). |
576 |
If not explicitely enabled, primitive code is never interrupted. |
|
1152 | 577 |
However, if you do enable interrupts in your primitive (see ExternalStream as example), |
578 |
be prepared for your objects to move around ... therefore, these have to |
|
579 |
be coded very carefully. |
|
580 |
||
581 |
Interrupts may be disabled completely (OperatingSystem blockInterrupts) and |
|
582 |
reenabled (unblockInterrupts) to allow for critical data to be manipulated. |
|
583 |
The above are low-level primitive entries - you better use #valueUninterruptably, |
|
584 |
which cares for unwinds, long returns and restores the blocking state. |
|
585 |
||
615 | 586 |
Every process has its own interrupt-enable state which is switched |
587 |
when processes switch control (i.e. you cannot block interrupts across |
|
1152 | 588 |
a suspend, delay etc.). |
589 |
However, the state will be restored after a resume. |
|
615 | 590 |
" |
2 | 591 |
! ! |
592 |
||
593 |
!ObjectMemory class methodsFor:'initialization'! |
|
594 |
||
595 |
initialize |
|
178 | 596 |
"initialize the class" |
597 |
||
2 | 598 |
AllocationFailureSignal isNil ifTrue:[ |
302 | 599 |
AllocationFailureSignal := ErrorSignal newSignalMayProceed:true. |
159 | 600 |
AllocationFailureSignal nameClass:self message:#allocationFailureSignal. |
601 |
AllocationFailureSignal notifierString:'allocation failure'. |
|
178 | 602 |
|
465
fdc81f5887a1
made mallocFailureSignal a child of allocationFailureSignal
Claus Gittinger <cg@exept.de>
parents:
464
diff
changeset
|
603 |
MallocFailureSignal := AllocationFailureSignal newSignalMayProceed:true. |
464
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
604 |
MallocFailureSignal nameClass:self message:#mallocFailureSignal. |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
605 |
MallocFailureSignal notifierString:'(malloc) allocation failure'. |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
606 |
|
178 | 607 |
LowSpaceSemaphore := Semaphore new. |
2 | 608 |
]. |
290 | 609 |
DisposeInterruptHandler := self. |
2 | 610 |
IncrementalGCLimit := 500000. |
310 | 611 |
FreeSpaceGCLimit := FreeSpaceGCAmount := nil. |
13 | 612 |
MemoryInterruptHandler := self |
2 | 613 |
! ! |
614 |
||
615 | 615 |
!ObjectMemory class methodsFor:'ST-80 compatibility'! |
616 |
||
617 |
availableFreeBytes |
|
618 |
^ self freeSpace + self freeListSpace |
|
619 |
||
620 |
" |
|
621 |
ObjectMemory availableFreeBytes |
|
622 |
" |
|
623 |
! |
|
624 |
||
625 |
bytesPerOOP |
|
626 |
"return the number of bytes an object reference (for example: an instvar) |
|
627 |
takes" |
|
628 |
||
629 |
%{ /* NOCONTEXT */ |
|
630 |
RETURN(__MKSMALLINT(sizeof(OBJ))); |
|
631 |
%} |
|
632 |
||
633 |
" |
|
634 |
ObjectMemory bytesPerOOP |
|
635 |
" |
|
636 |
! |
|
637 |
||
638 |
bytesPerOTE |
|
639 |
"return the number of overhead bytes of an object. |
|
640 |
i.e. the number of bytes in every objects header." |
|
641 |
||
642 |
%{ /* NOCONTEXT */ |
|
643 |
RETURN(__MKSMALLINT(OHDR_SIZE)); |
|
644 |
%} |
|
645 |
||
646 |
" |
|
647 |
ObjectMemory bytesPerOTE |
|
648 |
" |
|
649 |
! |
|
650 |
||
651 |
compactingGC |
|
652 |
self garbageCollect |
|
653 |
! |
|
654 |
||
655 |
current |
|
656 |
^ self |
|
657 |
! |
|
658 |
||
659 |
globalCompactingGC |
|
660 |
self garbageCollect |
|
661 |
! |
|
662 |
||
663 |
growMemoryBy:numberOfBytes |
|
664 |
^ self moreOldSpace:numberOfBytes |
|
665 |
! |
|
666 |
||
667 |
numOopsNumBytes |
|
668 |
^ Array with:(self numberOfObjects) |
|
669 |
with:(self bytesUsed) |
|
670 |
||
671 |
" |
|
672 |
ObjectMemory numOopsNumBytes |
|
673 |
" |
|
674 |
! ! |
|
675 |
||
345 | 676 |
!ObjectMemory class methodsFor:'Signal constants'! |
2 | 677 |
|
678 |
allocationFailureSignal |
|
13 | 679 |
"return the signal raised when an object allocation failed" |
680 |
||
2 | 681 |
^ AllocationFailureSignal |
464
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
682 |
! |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
683 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
684 |
mallocFailureSignal |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
685 |
"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
|
686 |
(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
|
687 |
non-Object storage)" |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
688 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
689 |
^ MallocFailureSignal |
2 | 690 |
! ! |
1 | 691 |
|
375 | 692 |
!ObjectMemory class methodsFor:'VM messages'! |
693 |
||
615 | 694 |
debugPrinting |
695 |
"return true, if various debug printouts in the VM |
|
375 | 696 |
are turned on, false of off." |
697 |
||
698 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
699 |
extern int __getDebugPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
700 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
701 |
RETURN (__getDebugPrinting() ? true : false); |
375 | 702 |
%} |
703 |
! |
|
704 |
||
705 |
debugPrinting:aBoolean |
|
706 |
"turn on/off various debug printouts in the VM |
|
707 |
in case of an error. For example, a double-notUnderstood |
|
708 |
leads to a VM context dump if debugPrinting is on. |
|
709 |
If off, those messages are suppressed. |
|
710 |
The default is on, since these messages are only printed for |
|
711 |
severe errors." |
|
712 |
||
713 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
714 |
__setDebugPrinting( (aBoolean == true) ); |
375 | 715 |
%} |
716 |
! |
|
717 |
||
615 | 718 |
infoPrinting |
719 |
"return true, if various informational printouts in the VM |
|
375 | 720 |
are turned on, false of off." |
721 |
||
722 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
723 |
extern int __getInfoPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
724 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
725 |
RETURN (__getInfoPrinting() ? true : false); |
615 | 726 |
%} |
727 |
! |
|
728 |
||
729 |
infoPrinting:aBoolean |
|
730 |
"turn on/off various informational printouts in the VM. |
|
731 |
For example, the GC activity messages are controlled by |
|
732 |
this flags setting. |
|
733 |
The default is true, since (currently) those messages |
|
734 |
are useful for ST/X developers." |
|
735 |
||
736 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
737 |
__setInfoPrinting( (aBoolean == true) ); |
615 | 738 |
%} |
739 |
! ! |
|
740 |
||
703 | 741 |
!ObjectMemory class methodsFor:'access debugging'! |
742 |
||
743 |
setTrapOnAccessFor:anObject |
|
744 |
"install an access trap for anObject; |
|
745 |
An accessSignal will be raised, whenever any instvar of anObject is either read or written. |
|
746 |
This is not supported on all architectures, therefore the return value |
|
747 |
(true of trap was installed ok, false if failed) should be checked." |
|
748 |
||
749 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
750 |
RETURN (__addTrapOnAccess(anObject, 2) ? true : false); |
703 | 751 |
%} |
752 |
! |
|
753 |
||
754 |
setTrapOnReadFor:anObject |
|
755 |
"install a read trap for anObject; |
|
756 |
An accessSignal will be raised, whenever any access into anObject occurrs. |
|
757 |
This is not supported on all architectures, therefore the return value |
|
758 |
(true of trap was installed ok, false if failed) should be checked." |
|
759 |
||
760 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
761 |
RETURN (__addTrapOnAccess(anObject, 0) ? true : false); |
703 | 762 |
%} |
763 |
! |
|
764 |
||
765 |
setTrapOnWriteFor:anObject |
|
766 |
"install a write trap for anObject; |
|
767 |
An accessSignal will be raised, whenever any instvar of anObject is written to. |
|
768 |
This is not supported on all architectures, therefore the return value |
|
769 |
(true of trap was installed ok, false if failed) should be checked." |
|
770 |
||
771 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
772 |
RETURN (__addTrapOnAccess(anObject, 1) ? true : false); |
703 | 773 |
%} |
774 |
! |
|
775 |
||
776 |
unsetAllTraps |
|
777 |
"remove all access traps" |
|
778 |
||
779 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
780 |
__removeAllAccessTraps(); |
703 | 781 |
%} |
782 |
! |
|
783 |
||
784 |
unsetTrapFor:anObject |
|
785 |
"remove any access trap for anObject." |
|
786 |
||
787 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
788 |
__removeTrapOnAccess(anObject); |
703 | 789 |
%} |
790 |
! ! |
|
791 |
||
615 | 792 |
!ObjectMemory class methodsFor:'cache management'! |
793 |
||
794 |
flushCaches |
|
795 |
"flush method and inline caches for all classes" |
|
796 |
||
797 |
%{ /* NOCONTEXT */ |
|
798 |
__flushMethodCache(); |
|
799 |
__flushAllInlineCaches(); |
|
800 |
%} |
|
801 |
! |
|
802 |
||
803 |
flushCachesFor:aClass |
|
804 |
"flush method and inline caches for aClass" |
|
805 |
||
806 |
%{ /* NOCONTEXT */ |
|
807 |
__flushMethodCacheFor(aClass); |
|
808 |
__flushInlineCachesFor(aClass); |
|
809 |
%} |
|
810 |
! |
|
811 |
||
812 |
flushCachesForSelector:aSelector |
|
813 |
"flush method and inline caches for aSelector" |
|
814 |
||
815 |
%{ /* NOCONTEXT */ |
|
816 |
__flushMethodCacheForSelector(aSelector); |
|
817 |
__flushInlineCachesForSelector(aSelector); |
|
818 |
%} |
|
819 |
! |
|
820 |
||
821 |
flushInlineCaches |
|
822 |
"flush all inlinecaches" |
|
823 |
||
824 |
%{ /* NOCONTEXT */ |
|
825 |
__flushAllInlineCaches(); |
|
826 |
%} |
|
827 |
! |
|
828 |
||
829 |
flushInlineCachesFor:aClass withArgs:nargs |
|
830 |
"flush inlinecaches for calls to aClass with nargs arguments" |
|
831 |
||
832 |
%{ /* NOCONTEXT */ |
|
1133 | 833 |
__flushInlineCachesForAndNargs(aClass, __intVal(nargs)); |
615 | 834 |
%} |
835 |
! |
|
836 |
||
837 |
flushInlineCachesForClass:aClass |
|
838 |
"flush inlinecaches for calls to aClass." |
|
839 |
||
840 |
%{ /* NOCONTEXT */ |
|
841 |
__flushInlineCachesFor(aClass); |
|
842 |
%} |
|
843 |
! |
|
844 |
||
845 |
flushInlineCachesForSelector:aSelector |
|
846 |
"flush inlinecaches for sends of aSelector" |
|
847 |
||
848 |
%{ /* NOCONTEXT */ |
|
849 |
__flushInlineCachesForSelector(aSelector); |
|
850 |
%} |
|
851 |
! |
|
852 |
||
853 |
flushInlineCachesWithArgs:nargs |
|
854 |
"flush inlinecaches for calls with nargs arguments" |
|
855 |
||
856 |
%{ /* NOCONTEXT */ |
|
1133 | 857 |
__flushInlineCaches(__intVal(nargs)); |
615 | 858 |
%} |
859 |
! |
|
860 |
||
861 |
flushMethodCache |
|
862 |
"flush the method cache" |
|
863 |
||
864 |
%{ /* NOCONTEXT */ |
|
865 |
__flushMethodCache(); |
|
866 |
%} |
|
867 |
! |
|
868 |
||
869 |
flushMethodCacheFor:aClass |
|
870 |
"flush the method cache for sends to aClass" |
|
871 |
||
872 |
%{ /* NOCONTEXT */ |
|
873 |
__flushMethodCacheFor(aClass); |
|
874 |
%} |
|
875 |
! |
|
876 |
||
877 |
flushMethodCacheForSelector:aSelector |
|
878 |
"flush the method cache for sends of aSelector" |
|
879 |
||
880 |
%{ /* NOCONTEXT */ |
|
881 |
__flushMethodCacheForSelector(aSelector); |
|
882 |
%} |
|
883 |
! |
|
884 |
||
1108 | 885 |
incrementSnapshotID |
886 |
%{ /* NOCONTEXT */ |
|
887 |
__bumpSnapshotID(); |
|
888 |
%} |
|
889 |
! |
|
890 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
891 |
snapshotID |
918 | 892 |
"return the internal snapshotID number. |
893 |
This is incremented when an image is restarted, and |
|
894 |
stored with the image. |
|
895 |
Not for normal users, this is used by the VM to invalidate |
|
896 |
caches which are stored with the image" |
|
897 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
898 |
%{ /* NOCONTEXT */ |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
899 |
RETURN ( __MKSMALLINT( __snapshotID() )); |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
900 |
%} |
918 | 901 |
" |
902 |
ObjectMemory snapshotID |
|
903 |
" |
|
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
904 |
! |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
905 |
|
615 | 906 |
trapRestrictedMethods:trap |
907 |
"Allow/Deny execution of restricted Methods (see Method>>>restricted:) |
|
908 |
||
909 |
Notice: method restriction is a nonstandard feature, not supported |
|
910 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
911 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
912 |
It may change or even vanish (if it shows to be not useful)." |
|
913 |
||
914 |
|oldTrap| |
|
915 |
||
916 |
%{ |
|
917 |
if (__setTrapRestrictedMethods(trap == true)) |
|
918 |
oldTrap = true; |
|
919 |
else |
|
920 |
oldTrap = false; |
|
921 |
%}. |
|
922 |
||
923 |
(trap and:[oldTrap not]) ifTrue:[ |
|
924 |
self flushCaches |
|
925 |
]. |
|
926 |
^ oldTrap |
|
927 |
||
928 |
" |
|
929 |
ObjectMemory trapRestrictedMethods:true |
|
930 |
ObjectMemory trapRestrictedMethods:false |
|
931 |
" |
|
932 |
! ! |
|
933 |
||
934 |
!ObjectMemory class methodsFor:'debug queries'! |
|
935 |
||
936 |
addressOf:anObject |
|
937 |
"return the core address of anObject as an integer |
|
938 |
- since objects may move around, the returned value is invalid after the |
|
939 |
next scavenge/collect. |
|
940 |
WARNING: this method is for ST/X debugging only |
|
941 |
it will be removed without notice" |
|
942 |
||
943 |
%{ /* NOCONTEXT */ |
|
944 |
||
945 |
if (! __isNonNilObject(anObject)) { |
|
946 |
RETURN ( nil ); |
|
947 |
} |
|
646
b0a2e25461cb
object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
948 |
if ((unsigned)anObject <= _MAX_INT) { |
1133 | 949 |
RETURN ( __MKSMALLINT((int)anObject) ); |
615 | 950 |
} |
646
b0a2e25461cb
object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
951 |
RETURN ( __MKUINT((int)anObject) ); |
615 | 952 |
%} |
953 |
" |
|
954 |
|p| |
|
955 |
p := Point new. |
|
956 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
957 |
ObjectMemory scavenge. |
|
958 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
959 |
" |
|
960 |
! |
|
961 |
||
962 |
ageOf:anObject |
|
963 |
"return the number of scavenges, an object has survived |
|
964 |
in new space. |
|
965 |
For old objects and living contexts, the returned number is invalid. |
|
966 |
WARNING: this method is for ST/X debugging only |
|
967 |
it will be removed without notice" |
|
968 |
||
969 |
%{ /* NOCONTEXT */ |
|
970 |
||
971 |
if (! __isNonNilObject(anObject)) { |
|
972 |
RETURN ( 0 ); |
|
973 |
} |
|
1133 | 974 |
RETURN ( __MKSMALLINT( _GET_AGE(anObject) ) ); |
615 | 975 |
%} |
976 |
" |
|
977 |
|p| |
|
978 |
p := Point new. |
|
979 |
(ObjectMemory ageOf:p) printNL. |
|
980 |
ObjectMemory tenuringScavenge. |
|
981 |
(ObjectMemory spaceOf:p) printNL. |
|
982 |
ObjectMemory tenuringScavenge. |
|
983 |
(ObjectMemory spaceOf:p) printNL. |
|
984 |
ObjectMemory tenuringScavenge. |
|
985 |
(ObjectMemory spaceOf:p) printNL. |
|
986 |
ObjectMemory tenuringScavenge. |
|
987 |
(ObjectMemory spaceOf:p) printNL. |
|
988 |
" |
|
989 |
! |
|
990 |
||
991 |
dumpObject:someObject |
|
992 |
"low level dump an object. |
|
993 |
WARNING: this method is for ST/X debugging only |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
994 |
it may be removed (or replaced by a noop) without notice" |
615 | 995 |
|
996 |
%{ |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
997 |
__dumpObject__(someObject); |
615 | 998 |
%} |
999 |
" |
|
1000 |
ObjectMemory dumpObject:true |
|
1001 |
ObjectMemory dumpObject:(Array new:10) |
|
1002 |
ObjectMemory dumpObject:(10@20 corner:30@40) |
|
1003 |
" |
|
1004 |
! |
|
1005 |
||
1006 |
flagsOf:anObject |
|
1007 |
"For debugging only. |
|
1008 |
WARNING: this method is for ST/X debugging only |
|
1009 |
it will be removed without notice" |
|
1010 |
||
1011 |
%{ /* NOCONTEXT */ |
|
1012 |
||
1013 |
if (! __isNonNilObject(anObject)) { |
|
1014 |
RETURN ( nil ); |
|
1015 |
} |
|
1133 | 1016 |
RETURN ( __MKSMALLINT( anObject->o_flags ) ); |
615 | 1017 |
%} |
1018 |
" |
|
1019 |
F_ISREMEMBERED 1 /* a new-space thing being refd by some oldSpace thing */ |
|
1020 |
F_ISFORWARDED 2 /* a forwarded object (you will never see this here) */ |
|
1021 |
F_DEREFERENCED 4 /* a collection after grow (not currently used) */ |
|
1022 |
F_ISONLIFOLIST 8 /* a non-lifo-context-referencing-obj already on list */ |
|
1023 |
F_MARK 16 /* mark bit for background collector */ |
|
1024 |
" |
|
1025 |
||
1026 |
" |
|
1027 |
|arr| |
|
1028 |
||
1029 |
arr := Array new. |
|
1030 |
arr at:1 put:([thisContext] value). |
|
1031 |
(ObjectMemory flagsOf:anObject) printNL |
|
1032 |
" |
|
1033 |
! |
|
1034 |
||
1108 | 1035 |
globalRefChainTo:anObject |
1036 |
|levels objects setOfOwners indent| |
|
1037 |
||
1038 |
levels := OrderedCollection new. |
|
1039 |
objects := WeakIdentitySet with:anObject. |
|
1040 |
||
1041 |
[objects includes:Smalltalk] whileFalse:[ |
|
1042 |
setOfOwners := WeakIdentitySet new. |
|
1043 |
||
1044 |
objects do:[:o | |
|
1045 |
|owners| |
|
1046 |
||
1047 |
owners := o allOwners. |
|
1150
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1048 |
owners notNil ifTrue:[ |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1049 |
owners := owners select:[:el | (el isMemberOf:WeakArray) not]. |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1050 |
setOfOwners addAll:owners. |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1051 |
]. |
1108 | 1052 |
|
1053 |
"/ (no instVarNamed:#keyArray) atAllPut:nil. |
|
1054 |
"/ no := nil. |
|
1055 |
"/ (owners instVarNamed:#keyArray) atAllPut:nil. |
|
1056 |
"/ owners := nil. |
|
1057 |
]. |
|
1058 |
||
1059 |
levels add:objects. |
|
1060 |
'done with level: ' print. levels size print. ' found ' print. objects size print. ' refs' printNL. |
|
1061 |
||
1062 |
levels do:[:alreadyFound | |
|
1063 |
setOfOwners remove:(alreadyFound instVarNamed:#keyArray) ifAbsent:nil. |
|
1064 |
alreadyFound do:[:o | |
|
1065 |
setOfOwners remove:o ifAbsent:nil |
|
1066 |
] |
|
1067 |
]. |
|
1068 |
||
1069 |
setOfOwners remove:(objects instVarNamed:#keyArray) ifAbsent:nil. |
|
1070 |
"/ setOfOwners printNL. |
|
1071 |
||
1072 |
objects := setOfOwners. |
|
1073 |
objects isEmpty ifTrue:[ |
|
1074 |
"/ 'none found' printNL. |
|
1075 |
^ nil |
|
1076 |
]. |
|
1077 |
]. |
|
1078 |
||
1079 |
"/ '' printNL. |
|
1080 |
||
1081 |
^ self |
|
1082 |
refChainFrom:Smalltalk |
|
1083 |
to:anObject |
|
1084 |
inRefSets:levels reverse |
|
1085 |
startingAt:1 |
|
1086 |
||
1087 |
" |
|
1088 |
self globalRefChainTo:Point new |
|
1089 |
" |
|
1090 |
" |
|
1091 |
Smalltalk at:#foo put:Point new. |
|
1092 |
self globalRefChainTo:(Smalltalk at:#foo) |
|
1093 |
" |
|
1094 |
" |
|
1095 |
|p| |
|
1096 |
p := Point new. |
|
1097 |
Smalltalk at:#foo put:(#x -> p). |
|
1098 |
self globalRefChainTo:p |
|
1099 |
" |
|
1100 |
" |
|
1101 |
|a| |
|
1102 |
a := Array new:1. a at:1 put:a. |
|
1103 |
Smalltalk at:#foo put:(#x -> a). |
|
1104 |
self globalRefChainTo:a |
|
1105 |
" |
|
1106 |
" |
|
1107 |
|a| |
|
1108 |
a := Array new:1. a at:1 put:a. |
|
1109 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
|
1110 |
self globalRefChainTo:a |
|
1111 |
" |
|
1112 |
" |
|
1113 |
|a| |
|
1114 |
a := Array new:1. a at:1 put:a. |
|
1115 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
|
1116 |
self globalRefChainTo:a |
|
1117 |
" |
|
1118 |
" |
|
1119 |
|p| |
|
1120 |
p := Point new. |
|
1121 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
|
1122 |
self globalRefChainTo:p |
|
1123 |
" |
|
1124 |
" |
|
1125 |
self globalRefChainTo:Transcript topView |
|
1126 |
" |
|
1127 |
||
1150
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1128 |
"Modified: 10.4.1996 / 20:15:16 / cg" |
1108 | 1129 |
! |
1130 |
||
615 | 1131 |
objectAt:anAddress |
1132 |
"return whatever anAddress points to as object. |
|
1133 |
BIG BIG DANGER ALERT: |
|
1134 |
this method is only to be used for debugging ST/X itself |
|
1135 |
- you can easily (and badly) crash the system. |
|
1136 |
WARNING: this method is for ST/X debugging only |
|
1137 |
it will be removed without notice" |
|
1138 |
||
1139 |
|low high| |
|
1140 |
||
1141 |
low := anAddress bitAnd:16rFFFF. |
|
1142 |
high := (anAddress bitShift:16) bitAnd:16rFFFF. |
|
1143 |
%{ |
|
1144 |
if (__bothSmallInteger(low, high)) { |
|
1133 | 1145 |
RETURN ((OBJ)((__intVal(high) << 16) | __intVal(low))); |
615 | 1146 |
} |
1147 |
%} |
|
1148 |
! |
|
1149 |
||
1286 | 1150 |
nteger(low, high)) { |
1151 |
RETURN ((OBJ)((__intVal(high) << 16) | __intVal(low))); |
|
1152 |
} |
|
1153 |
%} |
|
1154 |
! |
|
1155 |
||
1156 |
oReferences: or anObject>>allOwners." |
|
615 | 1157 |
|
1158 |
%{ |
|
1159 |
__printRefChain(__context, anObject); |
|
1160 |
%} |
|
1161 |
! |
|
1162 |
||
1286 | 1163 |
to:o inRefSets:levels startingAt:1. |
1108 | 1164 |
" |
1165 |
||
1166 |
"Modified: 19.3.1996 / 23:22:41 / cg" |
|
1167 |
! |
|
1168 |
||
1286 | 1169 |
hist at:nw put:(hist at:nw) + 1 |
615 | 1170 |
]. |
1171 |
]. |
|
1172 |
hist printNL. |
|
1173 |
big printNL |
|
1174 |
" |
|
375 | 1175 |
! ! |
1176 |
||
10 | 1177 |
!ObjectMemory class methodsFor:'dependents access'! |
1178 |
||
1286 | 1179 |
INT( __qSpace(anObject) ) ); |
1180 |
%} |
|
10 | 1181 |
! |
1182 |
||
1286 | 1183 |
ts access'! |
1184 |
||
1185 |
endents:aCollection |
|
10 | 1186 |
"set the dependents collection" |
1187 |
||
1188 |
Dependents := aCollection |
|
1286 | 1189 |
! ! |
282 | 1190 |
|
1286 | 1191 |
!ObjectMemory class methodsFor:'enumerating'! |
282 | 1192 |
|
1286 | 1193 |
[ |
282 | 1194 |
aBlock value:each |
1195 |
] |
|
1196 |
] |
|
1197 |
] |
|
1286 | 1198 |
! |
1 | 1199 |
|
1286 | 1200 |
esOfDo(&aClass, &aBlock, &work COMMA_CON) < 0) { |
159 | 1201 |
RETURN (false); |
85 | 1202 |
} |
1203 |
%}. |
|
1204 |
^ true |
|
2 | 1205 |
! |
1206 |
||
1286 | 1207 |
sOfDo((OBJ *)0, &aBlock, &work COMMA_CON) < 0) { |
615 | 1208 |
RETURN (false); |
1209 |
} |
|
1210 |
%}. |
|
1211 |
^ true |
|
1 | 1212 |
! ! |
1213 |
||
615 | 1214 |
!ObjectMemory class methodsFor:'garbage collection'! |
1215 |
||
1286 | 1216 |
(false); |
1217 |
} |
|
1218 |
%}. |
|
1219 |
^ true |
|
1220 |
! |
|
615 | 1221 |
|
1286 | 1222 |
kgroundCollectProcess notNil |
500 | 1223 |
|
1224 |
" |
|
615 | 1225 |
ObjectMemory backgroundCollectorRunning |
375 | 1226 |
" |
1227 |
! |
|
1228 |
||
1286 | 1229 |
AndSweep(__context); |
178 | 1230 |
} |
1 | 1231 |
%} |
1232 |
||
93 | 1233 |
" |
375 | 1234 |
ObjectMemory compressingGarbageCollect |
93 | 1235 |
" |
1236 |
! |
|
1237 |
||
1286 | 1238 |
t to markAndSweep |
615 | 1239 |
|
1240 |
self markAndSweep |
|
1 | 1241 |
|
93 | 1242 |
" |
615 | 1243 |
ObjectMemory garbageCollect |
375 | 1244 |
" |
1245 |
! |
|
1246 |
||
1286 | 1247 |
extern int __incrGCstep(); |
133 | 1248 |
|
1249 |
RETURN (__incrGCstep(__context) ? true : false); |
|
1 | 1250 |
%} |
1251 |
! |
|
1252 |
||
1286 | 1253 |
OldSpaceIfUseful |
979 | 1254 |
]. |
1255 |
] ifFalse:[ |
|
1256 |
done := true |
|
1257 |
] |
|
1258 |
]. |
|
615 | 1259 |
]. |
1260 |
^ done not |
|
1261 |
! |
|
1262 |
||
1286 | 1263 |
ObjectMemory incrementalGC] forkAt:3 |
403 | 1264 |
[ObjectMemory incrementalGC] forkAt:9 |
133 | 1265 |
" |
194 | 1266 |
! |
1267 |
||
1286 | 1268 |
ble." |
615 | 1269 |
%{ |
1270 |
__markAndSweep(__context); |
|
1271 |
%} |
|
194 | 1272 |
|
1273 |
" |
|
615 | 1274 |
ObjectMemory markAndSweep |
1275 |
" |
|
1276 |
! |
|
1277 |
||
1286 | 1278 |
." |
615 | 1279 |
%{ |
1280 |
__reclaimSymbols(__context); |
|
1281 |
%} |
|
1282 |
" |
|
1283 |
ObjectMemory reclaimSymbols |
|
1284 |
" |
|
1285 |
! |
|
1286 |
||
1286 | 1287 |
." |
615 | 1288 |
%{ |
1289 |
__nonTenuringScavenge(__context); |
|
1290 |
%} |
|
1291 |
||
1292 |
" |
|
1293 |
ObjectMemory scavenge |
|
194 | 1294 |
" |
207 | 1295 |
! |
1296 |
||
1286 | 1297 |
tMemory freeSpaceGCLimit:1000000. |
211 | 1298 |
ObjectMemory startBackgroundCollectorAt:5 |
1299 |
" |
|
207 | 1300 |
! |
1301 |
||
1286 | 1302 |
oundCollectProcess := nil |
207 | 1303 |
] |
293 | 1304 |
|
211 | 1305 |
" |
1306 |
ObjectMemory stopBackgroundCollector |
|
1307 |
" |
|
362 | 1308 |
! |
1309 |
||
1286 | 1310 |
tMemory tenure |
615 | 1311 |
... continue - objects created above are now in oldSpace ... |
1312 |
" |
|
1313 |
! |
|
1314 |
||
1286 | 1315 |
ect)" |
615 | 1316 |
%{ |
1317 |
__scavenge(__context); |
|
1318 |
%} |
|
1319 |
||
1320 |
" |
|
1321 |
ObjectMemory tenuringScavenge |
|
1322 |
" |
|
178 | 1323 |
! ! |
1324 |
||
1325 |
!ObjectMemory class methodsFor:'garbage collector control'! |
|
133 | 1326 |
|
1286 | 1327 |
oseGarbageCollect |
1328 |
" |
|
1329 |
! |
|
615 | 1330 |
|
1286 | 1331 |
eOldSpace:howMuch |
615 | 1332 |
] |
1333 |
] |
|
310 | 1334 |
|
1335 |
" |
|
615 | 1336 |
ObjectMemory announceOldSpaceNeed:1000000 |
133 | 1337 |
" |
1338 |
! |
|
1339 |
||
1286 | 1340 |
moreOldSpace:howMuch |
202 | 1341 |
] |
1342 |
] |
|
1343 |
||
1344 |
" |
|
1345 |
ObjectMemory announceSpaceNeed:100000 |
|
1346 |
" |
|
1347 |
! |
|
1348 |
||
1286 | 1349 |
ERIMENTAL interface." |
178 | 1350 |
|
1351 |
%{ /* NOCONTEXT */ |
|
615 | 1352 |
__avoidTenure(flag == true ? 1 : 0); |
133 | 1353 |
%} |
1354 |
! |
|
1355 |
||
178 | 1356 |
! |
1357 |
||
1286 | 1358 |
eAllocation:true. |
370 | 1359 |
ObjectMemory fastMoreOldSpaceAllocation:prev. |
1360 |
^ prev |
|
1361 |
" |
|
1362 |
! |
|
1363 |
||
1286 | 1364 |
aceLimit:10*1024*1024. |
370 | 1365 |
ObjectMemory fastMoreOldSpaceLimit:prev. |
1366 |
^ prev |
|
1367 |
" |
|
133 | 1368 |
! |
1369 |
||
1286 | 1370 |
riate value" |
615 | 1371 |
|
1372 |
^ FreeSpaceGCAmount |
|
1373 |
||
1374 |
" |
|
1375 |
ObjectMemory freeSpaceGCAmount |
|
1376 |
" |
|
1377 |
! |
|
1378 |
||
1286 | 1379 |
ppropriate amount ...) |
615 | 1380 |
" |
1381 |
" |
|
1382 |
ObjectMemory freeSpaceGCAmount:nil. |
|
1383 |
" |
|
1384 |
! |
|
1385 |
||
1286 | 1386 |
trigger off." |
615 | 1387 |
|
1388 |
^ FreeSpaceGCLimit |
|
1389 |
||
1390 |
" |
|
1391 |
ObjectMemory freeSpaceGCLimit |
|
1392 |
" |
|
133 | 1393 |
! |
1394 |
||
1286 | 1395 |
ystem hit the wall ...) |
615 | 1396 |
" |
1397 |
" |
|
1398 |
ObjectMemory freeSpaceGCLimit:nil. |
|
1399 |
" |
|
1 | 1400 |
! |
1401 |
||
1286 | 1402 |
gger off." |
615 | 1403 |
|
1404 |
^ IncrementalGCLimit |
|
1405 |
||
1406 |
" |
|
1407 |
ObjectMemory incrementalGCLimit |
|
1408 |
" |
|
178 | 1409 |
! |
85 | 1410 |
|
1286 | 1411 |
'do incr. GC very often' |
615 | 1412 |
ObjectMemory incrementalGCLimit:nil. 'never' |
1413 |
" |
|
370 | 1414 |
! |
1415 |
||
1286 | 1416 |
flag == true) { |
370 | 1417 |
__tenure(__context); |
1418 |
} |
|
379 | 1419 |
__lockTenure(flag == true ? 1 : 0); |
1420 |
%} |
|
1421 |
! |
|
1422 |
||
1286 | 1423 |
if (__moveToOldSpace(anObject, __context) < 0) { |
615 | 1424 |
RETURN (false); |
1425 |
} |
|
1426 |
%}. |
|
1427 |
^ true |
|
1428 |
! |
|
1429 |
||
1286 | 1430 |
lse ); |
615 | 1431 |
} |
1432 |
RETURN (false); |
|
379 | 1433 |
%} |
615 | 1434 |
" |
1435 |
ObjectMemory moreOldSpace:1000000 |
|
1436 |
" |
|
379 | 1437 |
! |
1438 |
||
1286 | 1439 |
ease oldSpace - reset limit' errorPrintNL. |
615 | 1440 |
FreeSpaceGCLimit := nil |
1441 |
] |
|
1442 |
]. |
|
1443 |
]. |
|
370 | 1444 |
! |
1445 |
||
1286 | 1446 |
Size:200*1024 |
370 | 1447 |
" |
1448 |
||
1449 |
" the default: |
|
1450 |
||
1451 |
ObjectMemory newSpaceSize:400*1024 |
|
1452 |
" |
|
615 | 1453 |
! |
1454 |
||
1286 | 1455 |
T( __compressingGCLimit(-1) )); |
1105
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1456 |
%} |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1457 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1458 |
ObjectMemory oldSpaceCompressLimit |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1459 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1460 |
! |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
1461 |
|
1286 | 1462 |
e the limit to 12Mb:" |
615 | 1463 |
" |
1464 |
ObjectMemory oldSpaceCompressLimit:12*1024*1024 |
|
1465 |
" |
|
1466 |
! |
|
1467 |
||
1286 | 1468 |
LLINT( __oldSpaceIncrement(-1) )); |
615 | 1469 |
%} |
1470 |
" |
|
1471 |
ObjectMemory oldSpaceIncrement |
|
1472 |
" |
|
1473 |
! |
|
1474 |
||
1286 | 1475 |
o change increment to 1Meg:" |
615 | 1476 |
" |
1477 |
ObjectMemory oldSpaceIncrement:1024*1024 |
|
1478 |
" |
|
1479 |
! |
|
1480 |
||
1286 | 1481 |
e system may behave very strange." |
615 | 1482 |
|
1483 |
%{ /* NOCONTEXT */ |
|
1484 |
__tenureParams(magic); |
|
1485 |
%}. |
|
1486 |
! |
|
1487 |
||
1286 | 1488 |
n by the time you read this." |
615 | 1489 |
|
1490 |
%{ /* NOCONTEXT */ |
|
1491 |
__allocForceSpace(OLDSPACE); |
|
1492 |
%} |
|
1493 |
! |
|
1494 |
||
1286 | 1495 |
Memory>>turnGarbageCollectorOff)" |
615 | 1496 |
|
1497 |
%{ /* NOCONTEXT */ |
|
1498 |
__allocForceSpace(9999); |
|
1499 |
%} |
|
178 | 1500 |
! ! |
1501 |
||
615 | 1502 |
!ObjectMemory class methodsFor:'interrupt handler access'! |
1503 |
||
1286 | 1504 |
lag == true ? 1 : 0); |
1505 |
%} |
|
1506 |
! |
|
1507 |
||
1508 |
for UNIX-death-of-a-childprocess-signal interrupts" |
|
615 | 1509 |
|
1510 |
^ ChildSignalInterruptHandler |
|
1511 |
! |
|
1512 |
||
1286 | 1513 |
reated: 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
|
1514 |
"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
|
1515 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
1516 |
|
1286 | 1517 |
ptHandler |
615 | 1518 |
"return the handler for custom interrupts" |
1519 |
||
1520 |
^ CustomInterruptHandler |
|
1521 |
! |
|
1522 |
||
1286 | 1523 |
er |
615 | 1524 |
"set the handler for custom interrupts" |
1525 |
||
1526 |
CustomInterruptHandler := aHandler |
|
1527 |
! |
|
1528 |
||
1286 | 1529 |
"return the handler for object disposal interrupts" |
615 | 1530 |
|
1531 |
^ DisposeInterruptHandler |
|
1532 |
! |
|
1533 |
||
1286 | 1534 |
t the handler for object disposal interrupts" |
615 | 1535 |
|
1536 |
DisposeInterruptHandler := aHandler |
|
1537 |
! |
|
1538 |
||
1286 | 1539 |
ler |
615 | 1540 |
"return the handler for display error interrupts" |
1541 |
||
1542 |
^ ErrorInterruptHandler |
|
1543 |
! |
|
1544 |
||
1286 | 1545 |
"set the handler for display error interrupts" |
615 | 1546 |
|
1547 |
ErrorInterruptHandler := aHandler |
|
1548 |
! |
|
1549 |
||
1286 | 1550 |
the handler for floating point exception interrupts" |
615 | 1551 |
|
1552 |
^ ExceptionInterruptHandler |
|
1553 |
! |
|
1554 |
||
1286 | 1555 |
c. |
615 | 1556 |
Those should not occur in normal circumstances." |
1557 |
||
1558 |
^ InternalErrorHandler |
|
1559 |
! |
|
1560 |
||
1286 | 1561 |
handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
615 | 1562 |
|
1563 |
^ IOInterruptHandler |
|
1564 |
! |
|
1565 |
||
1286 | 1566 |
r I/O available signal interrupts (SIGIO/SIGPOLL)" |
615 | 1567 |
|
1568 |
IOInterruptHandler := aHandler |
|
1569 |
! |
|
1570 |
||
1286 | 1571 |
the handler for recursion/stack overflow interrupts" |
615 | 1572 |
|
1573 |
^ RecursionInterruptHandler |
|
1574 |
! |
|
1575 |
||
1286 | 1576 |
er for recursion/stack overflow interrupts" |
615 | 1577 |
|
1578 |
RecursionInterruptHandler := aHandler |
|
1579 |
! |
|
1580 |
||
1286 | 1581 |
ctionary new |
615 | 1582 |
]. |
1583 |
RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler |
|
1584 |
! |
|
1585 |
||
1286 | 1586 |
rruptHandlers |
615 | 1587 |
"return registered handlers" |
1588 |
||
1589 |
^ RegisteredErrorInterruptHandlers |
|
1590 |
! |
|
1591 |
||
1286 | 1592 |
dler |
615 | 1593 |
"return the handler for UNIX-signal interrupts" |
1594 |
||
1595 |
^ SignalInterruptHandler |
|
1596 |
! |
|
1597 |
||
1286 | 1598 |
"set the handler for UNIX-signal interrupts" |
615 | 1599 |
|
1600 |
SignalInterruptHandler := aHandler |
|
1601 |
! |
|
1602 |
||
1286 | 1603 |
ptHandler |
615 | 1604 |
"return the handler for spy-timer interrupts" |
1605 |
||
1606 |
^ SpyInterruptHandler |
|
1607 |
! |
|
1608 |
||
1286 | 1609 |
er |
615 | 1610 |
"set the handler for spy-timer interrupts" |
1611 |
||
1612 |
SpyInterruptHandler := aHandler |
|
1613 |
! |
|
1614 |
||
1286 | 1615 |
andler |
615 | 1616 |
"return the handler for single step interrupts" |
1617 |
||
1618 |
^ StepInterruptHandler |
|
1619 |
! |
|
1620 |
||
1286 | 1621 |
"set the handler for single step interrupts" |
615 | 1622 |
|
1623 |
StepInterruptHandler := aHandler |
|
1624 |
! |
|
1625 |
||
1286 | 1626 |
ruptHandler |
615 | 1627 |
"return the handler for timer interrupts" |
1628 |
||
1629 |
^ TimerInterruptHandler |
|
1630 |
! |
|
1631 |
||
1286 | 1632 |
dler |
615 | 1633 |
"set the handler for timer interrupts" |
1634 |
||
1635 |
TimerInterruptHandler := aHandler |
|
1636 |
! |
|
1637 |
||
1286 | 1638 |
ler |
615 | 1639 |
"return the handler for CNTL-C interrupt handling" |
1640 |
||
1641 |
^ UserInterruptHandler |
|
1642 |
! ! |
|
1643 |
||
1644 |
!ObjectMemory class methodsFor:'interrupt statistics'! |
|
1645 |
||
1286 | 1646 |
InterruptHandler := aHandler |
1647 |
! |
|
615 | 1648 |
|
1286 | 1649 |
" |
615 | 1650 |
|
1651 |
"Created: 7.11.1995 / 21:05:50 / cg" |
|
1652 |
"Modified: 7.11.1995 / 21:13:33 / cg" |
|
1653 |
! |
|
1654 |
||
1286 | 1655 |
ptLatencyMonitor := self. |
615 | 1656 |
] |
1657 |
||
1658 |
" |
|
1659 |
ObjectMemory interruptLatencyGoal:50 |
|
1660 |
" |
|
1661 |
! |
|
1662 |
||
1286 | 1663 |
non-standard debugging/realtime instrumentation entry." |
615 | 1664 |
|
1665 |
^ InterruptLatencyMonitor |
|
1666 |
! |
|
1667 |
||
1286 | 1668 |
rd debugging/realtime instrumentation entry." |
615 | 1669 |
|
1670 |
InterruptLatencyMonitor := aHandler |
|
1671 |
! |
|
1672 |
||
1286 | 1673 |
ccumulated interrupt latency in millis. |
615 | 1674 |
DEMO Example." |
1675 |
||
1676 |
^ MaxInterruptLatency |
|
1677 |
! ! |
|
1678 |
||
1679 |
!ObjectMemory class methodsFor:'low memory handling'! |
|
1680 |
||
1286 | 1681 |
MaxInterruptLatency := 0 |
1682 |
! |
|
615 | 1683 |
|
1286 | 1684 |
orPrintNL. |
615 | 1685 |
|
1686 |
LowSpaceSemaphore signalIf. |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
1687 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
1688 |
"Modified: 12.4.1996 / 14:57:55 / cg" |
362 | 1689 |
! ! |
1690 |
||
1691 |
!ObjectMemory class methodsFor:'object finalization'! |
|
290 | 1692 |
|
1286 | 1693 |
d: 12.4.1996 / 14:57:28 / cg" |
1694 |
! |
|
1695 |
||
1696 |
lost a pointer recently." |
|
290 | 1697 |
%{ |
326 | 1698 |
__allChangedShadowObjectsDo(&aBlock COMMA_CON); |
290 | 1699 |
%} |
1700 |
! |
|
1701 |
||
1286 | 1702 |
tionSemaphore signal |
290 | 1703 |
] ifFalse:[ |
1704 |
"/ |
|
1705 |
"/ do it right here |
|
1706 |
"/ |
|
291 | 1707 |
self finalize |
290 | 1708 |
] |
1709 |
! |
|
1710 |
||
1286 | 1711 |
self allChangedShadowObjectsDo:[:aShadowArray | |
615 | 1712 |
aShadowArray lostPointer. |
1713 |
] |
|
1714 |
! |
|
1715 |
||
1286 | 1716 |
inalizationProcess := p |
290 | 1717 |
|
1718 |
" |
|
1719 |
ObjectMemory startBackgroundFinalizationAt:5 |
|
1720 |
" |
|
1721 |
! ! |
|
1722 |
||
178 | 1723 |
!ObjectMemory class methodsFor:'physical memory access'! |
93 | 1724 |
|
1286 | 1725 |
ckgroundFinalization |
1726 |
" |
|
1727 |
! |
|
1728 |
||
1729 |
llectedOldSpacePagesDo(&aBlock COMMA_CON) < 0) { |
|
615 | 1730 |
RETURN (false); |
1731 |
} |
|
1732 |
%}. |
|
1733 |
^ true |
|
1734 |
! |
|
1735 |
||
1286 | 1736 |
if (__newSpacePagesDo(&aBlock COMMA_CON) < 0) { |
159 | 1737 |
RETURN (false); |
85 | 1738 |
} |
1739 |
%}. |
|
1740 |
^ true |
|
1741 |
! |
|
1742 |
||
1286 | 1743 |
if (__oldSpacePagesDo(&aBlock COMMA_CON) < 0) { |
1744 |
RETURN (false); |
|
85 | 1745 |
} |
1746 |
%}. |
|
1747 |
^ true |
|
1748 |
! ! |
|
1749 |
||
615 | 1750 |
!ObjectMemory class methodsFor:'queries'! |
1751 |
||
1286 | 1752 |
supply this info - assume yes" |
1753 |
^ true |
|
1754 |
! |
|
615 | 1755 |
|
1286 | 1756 |
__newSpaceUsed() - __freeListSpace()) ); |
615 | 1757 |
%} |
1758 |
" |
|
1759 |
ObjectMemory bytesUsed |
|
1760 |
" |
|
1761 |
! |
|
1762 |
||
1286 | 1763 |
[ |
615 | 1764 |
"actually this cannot happen - there is always one" |
1765 |
^ nil |
|
1766 |
]. |
|
1767 |
^ aCollection |
|
1768 |
! |
|
1769 |
||
1286 | 1770 |
TURN ( __MKSMALLINT(__fixSpaceSize()) ); |
615 | 1771 |
%} |
1772 |
" |
|
1773 |
ObjectMemory fixSpaceSize |
|
1774 |
" |
|
1775 |
! |
|
1776 |
||
1286 | 1777 |
TURN ( __MKSMALLINT(__fixSpaceUsed()) ); |
615 | 1778 |
%} |
1779 |
" |
|
1780 |
ObjectMemory fixSpaceUsed |
|
1781 |
" |
|
1782 |
! |
|
1783 |
||
1286 | 1784 |
RN ( __MKSMALLINT(__freeListSpace()) ); |
615 | 1785 |
%} |
1786 |
" |
|
1787 |
ObjectMemory freeListSpace |
|
1788 |
" |
|
1789 |
! |
|
1790 |
||
1286 | 1791 |
INT(__oldSpaceSize() - __oldSpaceUsed()) ); |
615 | 1792 |
%} |
1793 |
" |
|
1794 |
ObjectMemory freeSpace |
|
1795 |
" |
|
1796 |
! |
|
1797 |
||
1286 | 1798 |
LLINT(__garbageCollectCount())); |
615 | 1799 |
%} |
1800 |
" |
|
1801 |
ObjectMemory garbageCollectCount |
|
1802 |
" |
|
1803 |
! |
|
1804 |
||
1286 | 1805 |
SMALLINT(__incrementalGCCount())); |
615 | 1806 |
%} |
1807 |
" |
|
1808 |
ObjectMemory incrementalGCCount |
|
1809 |
" |
|
1810 |
! |
|
1811 |
||
1286 | 1812 |
EXT */ |
615 | 1813 |
extern int __incrGCphase(); |
1814 |
||
1133 | 1815 |
RETURN (__MKSMALLINT(__incrGCphase())); |
615 | 1816 |
%} |
1817 |
! |
|
1818 |
||
1286 | 1819 |
ctMemory lastScavengeReclamation) |
615 | 1820 |
/ (ObjectMemory newSpaceSize)) * 100.0 |
1821 |
" |
|
1822 |
! |
|
1823 |
||
1286 | 1824 |
RETURN ( __lifoRememberedSet() ); |
615 | 1825 |
%} |
1826 |
" |
|
1827 |
ObjectMemory lifoRememberedSet |
|
1828 |
" |
|
1829 |
! |
|
1830 |
||
1286 | 1831 |
NT(__lifoRememberedSetSize())); |
615 | 1832 |
%} |
1833 |
" |
|
1834 |
ObjectMemory lifoRememberedSetSize |
|
1835 |
" |
|
1836 |
! |
|
1837 |
||
1286 | 1838 |
KSMALLINT(__markAndSweepCount())); |
615 | 1839 |
%} |
1840 |
" |
|
1841 |
ObjectMemory markAndSweepCount |
|
1842 |
" |
|
1843 |
! |
|
1844 |
||
1286 | 1845 |
HASH__ << __HASH_SHIFT__) ); |
615 | 1846 |
%} |
1847 |
" |
|
1848 |
ObjectMemory maximumIdentityHashValue |
|
1849 |
" |
|
1850 |
! |
|
1851 |
||
1286 | 1852 |
T(__newSpaceReclaimedMin()) ); |
615 | 1853 |
%} |
1854 |
" |
|
1855 |
ObjectMemory minScavengeReclamation |
|
1856 |
" |
|
1857 |
! |
|
1858 |
||
1286 | 1859 |
TURN ( __MKSMALLINT(__newSpaceSize()) ); |
615 | 1860 |
%} |
1861 |
" |
|
1862 |
ObjectMemory newSpaceSize |
|
1863 |
" |
|
1864 |
! |
|
1865 |
||
1286 | 1866 |
N ( __MKSMALLINT(__newSpaceUsed()) ); |
615 | 1867 |
%} |
1868 |
" |
|
1869 |
ObjectMemory newSpaceUsed |
|
1870 |
" |
|
1871 |
! |
|
1872 |
||
1286 | 1873 |
bj | tally := tally + 1]. |
615 | 1874 |
^ tally |
1875 |
||
1876 |
" |
|
1877 |
ObjectMemory numberOfObjects |
|
1878 |
" |
|
1879 |
! |
|
1880 |
||
1286 | 1881 |
__MKSMALLINT(__weakListSize()) ); |
615 | 1882 |
%} |
1883 |
" |
|
1884 |
ObjectMemory numberOfWeakObjects |
|
1885 |
" |
|
1886 |
! |
|
1887 |
||
1286 | 1888 |
atedSinceLastGC()) ); |
615 | 1889 |
%} |
1890 |
" |
|
1891 |
ObjectMemory oldSpaceAllocatedSinceLastGC |
|
1892 |
" |
|
1893 |
! |
|
1894 |
||
1286 | 1895 |
TURN ( __MKSMALLINT(__oldSpaceSize()) ); |
615 | 1896 |
%} |
1897 |
" |
|
1898 |
ObjectMemory oldSpaceSize |
|
1899 |
" |
|
1900 |
! |
|
1901 |
||
1286 | 1902 |
RN ( __MKSMALLINT(__oldSpaceUsed()) ); |
615 | 1903 |
%} |
1904 |
" |
|
1905 |
ObjectMemory oldSpaceUsed |
|
1906 |
" |
|
1907 |
! |
|
1908 |
||
1286 | 1909 |
MKSMALLINT(__rememberedSetSize())); |
615 | 1910 |
%} |
1911 |
" |
|
1912 |
ObjectMemory rememberedSetSize |
|
1913 |
" |
|
1914 |
! |
|
1915 |
||
1286 | 1916 |
jectMemory resetMinScavengeReclamation. |
615 | 1917 |
ObjectMemory minScavengeReclamation |
1918 |
" |
|
1919 |
! |
|
1920 |
||
1286 | 1921 |
ngleOldSpace() ? true : false) ); |
615 | 1922 |
%} |
1923 |
" |
|
1924 |
ObjectMemory runsSingleOldSpace |
|
1925 |
" |
|
1926 |
! |
|
1927 |
||
1286 | 1928 |
URN (__MKSMALLINT(__scavengeCount())); |
615 | 1929 |
%} |
1930 |
" |
|
1931 |
ObjectMemory scavengeCount |
|
1932 |
" |
|
1933 |
! |
|
1934 |
||
1286 | 1935 |
TURN ( __MKSMALLINT(__symSpaceSize()) ); |
615 | 1936 |
%} |
1937 |
" |
|
1938 |
ObjectMemory symSpaceSize |
|
1939 |
" |
|
1940 |
! |
|
1941 |
||
1286 | 1942 |
TURN ( __MKSMALLINT(__symSpaceUsed()) ); |
615 | 1943 |
%} |
1944 |
" |
|
1945 |
ObjectMemory symSpaceUsed |
|
1946 |
" |
|
1947 |
! |
|
1948 |
||
1286 | 1949 |
*/ |
615 | 1950 |
extern unsigned __tenureAge(); |
1951 |
||
1133 | 1952 |
RETURN ( __MKSMALLINT(__tenureAge()) ); |
615 | 1953 |
%} |
1954 |
! |
|
1955 |
||
1286 | 1956 |
references:anObject] |
615 | 1957 |
|
1958 |
" |
|
1959 |
(ObjectMemory whoReferences:Transcript) printNL |
|
1960 |
" |
|
1961 |
! |
|
1962 |
||
1286 | 1963 |
:aClass] |
615 | 1964 |
|
1965 |
" |
|
1966 |
(ObjectMemory whoReferencesDerivedInstancesOf:View) printNL |
|
1967 |
" |
|
1968 |
! ! |
|
1969 |
||
1970 |
!ObjectMemory class methodsFor:'semaphore access'! |
|
1971 |
||
1286 | 1972 |
sOf:SystemBrowser) printNL |
1973 |
" |
|
615 | 1974 |
! ! |
1975 |
||
379 | 1976 |
!ObjectMemory class methodsFor:'statistics'! |
1977 |
||
1286 | 1978 |
ease object." |
379 | 1979 |
|
1286 | 1980 |
^ LowSpaceSemaphore |
379 | 1981 |
! ! |
1982 |
||
1 | 1983 |
!ObjectMemory class methodsFor:'system management'! |
1984 |
||
1286 | 1985 |
T */ |
1986 |
||
1987 |
__ageStatistics(); |
|
1988 |
%} |
|
1989 |
! |
|
1990 |
||
1991 |
ay |
|
418 | 1992 |
change without notice." |
1993 |
||
1994 |
%{ |
|
1995 |
__REGISTRATION_DO_BLOCK(&aBlock COMMA_SND); |
|
1996 |
%} |
|
1997 |
! |
|
1998 |
||
1286 | 1999 |
ObjectMemory binaryModuleInfo |
418 | 2000 |
" |
2001 |
||
438 | 2002 |
"Modified: 17.9.1995 / 16:33:02 / claus" |
418 | 2003 |
! |
2004 |
||
1286 | 2005 |
ObjectMemory fullBinaryModuleInfo |
418 | 2006 |
" |
2007 |
||
2008 |
"Modified: 30.8.1995 / 17:29:30 / claus" |
|
615 | 2009 |
! |
2010 |
||
1286 | 2011 |
nm copyWithoutLast:4 |
615 | 2012 |
]. |
2013 |
^ nm |
|
2014 |
||
2015 |
" |
|
2016 |
ObjectMemory imageBaseName |
|
2017 |
" |
|
2018 |
! |
|
2019 |
||
1286 | 2020 |
not running from an image." |
615 | 2021 |
|
2022 |
^ ImageName |
|
335 | 2023 |
|
2024 |
" |
|
615 | 2025 |
ObjectMemory imageName |
335 | 2026 |
" |
1 | 2027 |
! |
2028 |
||
1286 | 2029 |
g image was saved. |
1096 | 2030 |
Return nil if not running from an image." |
2031 |
||
2032 |
^ ImageSaveTime |
|
2033 |
! |
|
2034 |
||
1286 | 2035 |
tNil and:[newClass implements:#initialize]) ifTrue:[ |
615 | 2036 |
newClass initialize |
159 | 2037 |
] |
615 | 2038 |
] |
2039 |
! |
|
2040 |
||
2041 |
"/ ^ self imageBaseName , '.chg' |
|
1 | 2042 |
|
335 | 2043 |
" |
615 | 2044 |
ObjectMemory nameForChanges |
2045 |
" |
|
2046 |
! |
|
2047 |
||
1286 | 2048 |
ngeFileName := aFilename |
615 | 2049 |
|
2050 |
" |
|
2051 |
ObjectMemory nameForChanges:'myChanges' |
|
2052 |
" |
|
2053 |
! |
|
2054 |
||
1286 | 2055 |
^ self imageBaseName , '.img' |
615 | 2056 |
|
2057 |
" |
|
2058 |
ObjectMemory nameForSnapshot |
|
335 | 2059 |
" |
1 | 2060 |
! |
2061 |
||
1286 | 2062 |
" |
615 | 2063 |
|
2064 |
^ self imageBaseName , '.src' |
|
362 | 2065 |
|
2066 |
" |
|
615 | 2067 |
ObjectMemory nameForSources |
2068 |
" |
|
2069 |
! |
|
2070 |
||
1286 | 2071 |
n(__context, _stringVal(aFileName), funny); |
615 | 2072 |
__UNBLOCKINTERRUPTS(); |
2073 |
} |
|
2074 |
%}. |
|
2075 |
^ ok |
|
2076 |
! |
|
2077 |
||
1286 | 2078 |
." |
615 | 2079 |
|
2080 |
self snapShotOn:(self nameForSnapshot) |
|
2081 |
||
2082 |
" |
|
2083 |
ObjectMemory snapShot |
|
362 | 2084 |
" |
2085 |
! ! |
|
615 | 2086 |
|
630 | 2087 |
!ObjectMemory class methodsFor:'documentation'! |
2088 |
||
1286 | 2089 |
mory snapShotOn:'myimage.img' |
2090 |
" |
|
630 | 2091 |
! ! |
615 | 2092 |
ObjectMemory initialize! |