author | Claus Gittinger <cg@exept.de> |
Tue, 29 Sep 1998 12:44:05 +0200 | |
changeset 3858 | 4be800f88b8e |
parent 3781 | d35bce118ed1 |
child 3859 | 9b422cede70d |
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 |
1767 | 27 |
InterruptLatencyGoal VMSelectors DynamicCodeGCTrigger |
3733 | 28 |
DynamicCodeLimit JustInTimeCompilationEnabled |
29 |
BackgroundCollectMaximumInterval' |
|
827
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
30 |
poolDictionaries:'' |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
31 |
category:'System-Support' |
1 | 32 |
! |
33 |
||
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
34 |
Object subclass:#BinaryModuleDescriptor |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
35 |
instanceVariableNames:'name type id dynamic classNames pathName libraryName timeStamp' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
36 |
classVariableNames:'' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
37 |
poolDictionaries:'' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
38 |
privateIn:ObjectMemory |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
39 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
40 |
|
1767 | 41 |
!ObjectMemory class methodsFor:'documentation'! |
2 | 42 |
|
615 | 43 |
caching |
44 |
" |
|
45 |
The system uses various caches to speed up method-lookup. |
|
46 |
Currently, there is a three-level cache hierarchy: |
|
47 |
||
1152 | 48 |
inline-cache keeps the target of the last send at the caller- |
49 |
side (i.e. every send goes through its private |
|
50 |
1-slot inline-cache, where the address of the last |
|
51 |
called function at this call location is kept.) |
|
52 |
||
53 |
polymorph-inline-cache keeps a limited list of all targets ever reached |
|
54 |
at this call location. The list is automatically |
|
55 |
flushed if it grows too large, or the overall number |
|
56 |
of poly-chache entries exceeds a limit. |
|
57 |
||
58 |
method-lookup-cache a global cache. Hashes on class-selector pairs, |
|
59 |
returning the target method. |
|
615 | 60 |
|
61 |
Whenever methods are added or removed from the system, or the inheritance |
|
62 |
hierarchy changes, some or all caches have to be flushed. |
|
63 |
The flushXXX methods perform the task of flushing various caches. |
|
64 |
All standard methods in Behavior call for cache flushing, when things change; |
|
65 |
however, if you use the low level access methods in Behavior |
|
66 |
(for example: #setSuperclass:) special care has to be taken. |
|
67 |
||
68 |
In some situations, not all caches need flushing, for example a change |
|
69 |
in an interpreted method (currently) needs no flushing of the inline caches. |
|
70 |
Also, flushing can be limited to entries for a specific class for most changes. |
|
71 |
||
72 |
To be 'on the brigth side of live', use ObjectMemory>>flushCaches (which |
|
73 |
flushes all of them), when in doubt of which caches should be flushed. |
|
74 |
It is better flush too much - otherwise you may end up in a wrong method after |
|
1152 | 75 |
a send (you wont really see a difference in speed after the flush, anyway). |
615 | 76 |
" |
77 |
! |
|
78 |
||
88 | 79 |
copyright |
80 |
" |
|
81 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
159 | 82 |
All Rights Reserved |
88 | 83 |
|
84 |
This software is furnished under a license and may be used |
|
85 |
only in accordance with the terms of that license and with the |
|
86 |
inclusion of the above copyright notice. This software may not |
|
87 |
be provided or otherwise made available to, or used by, any |
|
88 |
other person. No title to or ownership of the software is |
|
89 |
hereby transferred. |
|
90 |
" |
|
91 |
! |
|
92 |
||
2 | 93 |
documentation |
94 |
" |
|
403 | 95 |
This class contains access methods to the system memory and the VM. |
96 |
||
97 |
In previous ST/X versions, this stuff used to be in the Smalltalk class. |
|
98 |
It has been separated for better overall class structure and modularisation. |
|
229 | 99 |
There are no instances of ObjectMemory - all is done in class methods. |
403 | 100 |
(this is a functional interface). |
101 |
||
102 |
Many methods here are for debuging purposes, for developers |
|
103 |
or experimental, and therefore not standard. |
|
68 | 104 |
Do not depend on them being there - some may vanish ... |
105 |
(especially those, that depend on a specific GC implementation) |
|
403 | 106 |
Most of the stuff found here is not available, or different or called |
107 |
different in other smalltalk implementations. Be aware, that using these |
|
108 |
interfaces (especially: depending on them) may make your application |
|
109 |
non portable. |
|
110 |
||
111 |
See more documentation in -> caching |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
112 |
-> interrupts |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
113 |
-> garbageCollection |
2 | 114 |
|
1300 | 115 |
[Class variables:] |
2 | 116 |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
117 |
InternalErrorHandler gets informed (by VM), when some runtime |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
118 |
error occurs (usually fatal) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
119 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
120 |
UserInterruptHandler gets informed (by VM) when CNTL-C is pressed |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
121 |
TimerInterruptHandler gets alarm timer interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
122 |
SpyInterruptHandler another alarm timer (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
123 |
StepInterruptHandler gets single step interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
124 |
ExceptionInterruptHandler gets floating point exceptions (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
125 |
ErrorInterruptHandler gets primitive errors (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
126 |
MemoryInterruptHandler gets soon-out-of-memory conditions (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
127 |
SignalInterruptHandler gets unix signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
128 |
ChildSignalInterruptHandler gets child death signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
129 |
DisposeInterruptHandler gets informed, when an object is disposed from |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
130 |
a shadowArray (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
131 |
RecursionInterruptHandler gets recursion limit violations (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
132 |
IOInterruptHandler gets SIGIO unix signals (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
133 |
CustomInterruptHandler gets custom interrupts (from VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
134 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
135 |
InterruptLatencyMonitor if nonNil, that one will be notified (by the VM) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
136 |
with an interruptLatency:millis message for every |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
137 |
interrupt and gets the delay time |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
138 |
(between the time when the signal arrived and |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
139 |
when it was really delivered) as argument. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
140 |
This can be used to create a statistic for |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
141 |
realtime systems. |
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 |
RegisteredErrorInterruptHandlers |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
144 |
associates errorID (as passed from primitive |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
145 |
to the __errorInterruptWithID() function) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
146 |
with handlers. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
147 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
148 |
IncrementalGCLimit number of bytes, that must be allocated since |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
149 |
last full garbage collect to turn the incremental |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
150 |
collector on (at idle time). |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
151 |
|
3733 | 152 |
FreeSpaceGCLimit low limit on freeSpace, at which incremental |
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
153 |
gc starts to run at idle time. |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
154 |
|
3733 | 155 |
FreeSpaceGCAmount amount to allocate, once freeSpace drops |
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
156 |
below FreeSpaceGCLimit |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
157 |
|
3733 | 158 |
DynamicCodeGCTrigger amount of generated dynamically compiled code |
159 |
to trigger the incremental garbage collector |
|
160 |
nil means: no trigger |
|
161 |
||
162 |
DynamicCodeLimit max. amount of space allocated for dynamically compiled code |
|
163 |
nil means: unlimited. |
|
164 |
||
165 |
JustInTimeCompilationEnabled boolean - enables/disables JIT-compilation of |
|
166 |
bytecode to machine code. |
|
167 |
(this has nothing to do with stc-compilation) |
|
1767 | 168 |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
169 |
Dependents keep my dependents locally (its faster) for |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
170 |
all those registries |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
171 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
172 |
LowSpaceSemaphore a semaphore signalled whenever the system is |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
173 |
running in low memory (i.e. the memory manager |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
174 |
ran into memory shortage and feels that it |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
175 |
may soon no longer be able to grant allocation requests). |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
176 |
You can have a process waiting on this semaphore |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
177 |
which starts to remove (i.e. nil-out) objects |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
178 |
or preform other cleanup actions. |
213 | 179 |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
180 |
AllocationFailureSignal signal raised when a new fails (see Behavior) |
3733 | 181 |
When this signal is raised, the memory manager |
182 |
is really in trouble (i.e. above low-mem feelings |
|
183 |
were correct) |
|
184 |
||
185 |
MallocFailureSignal signal raised when a malloc fails |
|
186 |
mallocs are used internally in the VM and/or |
|
187 |
by some classes (ExternalBytes) |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
188 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
189 |
BackgroundCollectProcess created by startBackgroundCollectorAt: |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
190 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
191 |
BackgroundFinalizationProcess created by startBackgroundFinalizationAt: |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
192 |
|
3733 | 193 |
BackgroundCollectMaximumInterval |
194 |
number of seconds after which an incremental background |
|
195 |
collection is started - regardless of the allocation |
|
196 |
rate or freeSpace situation. If nil, IGC is only done |
|
197 |
when the space situation makes it feasable. |
|
198 |
Can be set to (say) 3600, to have the memory cleaned |
|
199 |
at least once an hour. |
|
200 |
||
201 |
FinalizationSemaphore triggered by the VM, when any weak pointer is |
|
202 |
lost. Been waited upon by the backgroundFinalizer. |
|
203 |
||
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
204 |
ImageName name of the current image (or nil) |
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
205 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
206 |
ImageSaveTime <AbsoluteTime> timestamp when this image was saved |
1096 | 207 |
|
208 |
||
403 | 209 |
Warning: |
210 |
The InterruptHandler variables are known by the runtime system - |
|
211 |
they are the objects that get an interrupt message when the event |
|
212 |
occurs. You may not remove any of them. |
|
1300 | 213 |
|
214 |
[author:] |
|
215 |
Claus Gittinger |
|
2 | 216 |
" |
93 | 217 |
! |
218 |
||
219 |
garbageCollection |
|
220 |
" |
|
403 | 221 |
Currently, Smalltalk/X uses a two-level memory hierachy (actually, there |
222 |
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
|
223 |
but for the following discussion, these are not of interest). |
403 | 224 |
|
225 |
newSpace: |
|
226 |
||
93 | 227 |
Objects are created in a so-called newSpace, which is relatively small. |
403 | 228 |
This newSpace is cleaned by a so called ``scavenge''-operation, whenever |
229 |
becoming full. Scavenging means, that all still-live objects (i.e. referenced |
|
230 |
by some other) are copied over to another memory area, leaving all unreachable |
|
231 |
objects as garbage behind. Thus, the newSpace actually consists of two semispaces, |
|
232 |
of whih only one is active - the other being used only while objects are |
|
233 |
copied. |
|
234 |
After this copying, these two semispaces exchange their roles - i.e. reachable |
|
235 |
objects are copied ping-pong like between these semispaces. |
|
202 | 236 |
Once an object survives enough of these copying operations, the next scavenge |
216 | 237 |
will move it into the so called oldSpace, which is much larger, and not |
202 | 238 |
processed by the scavenger. |
403 | 239 |
This movement of an object from newSpace to oldSpace is called ``tenure''. |
240 |
(this avoids objects being copied around forever). |
|
241 |
Once tenured, an object is no longer contained in the newSpace, and |
|
242 |
thus ceases to create any scavenging overhead after that. |
|
133 | 243 |
|
93 | 244 |
Scavenging occurs automatically, and is usually done fast enough to go |
1152 | 245 |
unnoticed (typically, it takes some 5 to 40ms to perform a scavenge, |
93 | 246 |
depending on how many live objects are in the newspace). |
403 | 247 |
|
759
908363ce8a32
interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents:
703
diff
changeset
|
248 |
Interestingly, the scavenger performs better, if many garbage objects |
93 | 249 |
are to be reclaimed, since less object-copying has to be done. Therefore, |
216 | 250 |
the best-case scavenge time is almost zero, if there is only garbage in |
251 |
the newSpace. In contrast, the worst-case is when all newSpace objects are still |
|
403 | 252 |
living. Thus, from a newSpace collectors viewPoint, it makes sense to get |
253 |
objects out of the way as fast as possible. However the oldSpace is |
|
254 |
collected much less frequently and the cost to reclaim an oldspace object |
|
255 |
is much higher (actually, the cost to reclaim a newspace object is zero - |
|
256 |
its the survival of objects which we have to pay for). |
|
257 |
Therefore, from an oldSpace collectors point of view, its preferable to |
|
258 |
keep objects in the newSpace as long as possible. |
|
259 |
||
260 |
To honor this conflicting situation, the system uses an adaptive tenure-count, |
|
207 | 261 |
which adjusts the number of scavenges required for tenure (the so called |
262 |
'tenureAge') according to the fill-grade of the newSpace. |
|
403 | 263 |
If the newSpace is relatively empty, it tries to keep objects longer there. |
264 |
The controlling parameters of the tenure age can be changed dynamically, |
|
265 |
detailed information is available upon request. |
|
266 |
||
267 |
The exact speed of the scavenger depends mostly on the speed of your memory |
|
268 |
interface (and, since most of todays memories have access times in the order |
|
269 |
of 50-100ns, the raw CPU speed does not correlate linear with the GC speed). |
|
1152 | 270 |
Measurements give roughly 40ms for a full 400k newSpace |
271 |
(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
|
272 |
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
|
273 |
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
|
274 |
help a lot. |
1152 | 275 |
|
403 | 276 |
The upper bounds of the scavenge blocking time can be controlled by changing |
1152 | 277 |
the size of the newSpace - either via a command line argument, or even dynamically |
403 | 278 |
by Objectmemory>>newSpaceSize:. Smaller sizes lead to shorter blocking periods, |
279 |
but greater absolute GC overhead. The default (400k) seems to be a good compromise. |
|
280 |
(if you are not happy with it, try playing around with the settings) |
|
281 |
||
282 |
oldSpace: |
|
93 | 283 |
|
284 |
To reclaim oldspace, the system uses three algorithms: mark&sweep, a copying |
|
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
285 |
(and compressing) baker-type collector and an incremental mark&sweep, augmented |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
286 |
by an inplace compress algorithm. |
93 | 287 |
|
288 |
The mark&sweep runs whenever the oldspace becomes full, putting dead objects |
|
289 |
onto a free list. If a memory request cannot be served from this freelist, |
|
290 |
and the total size of objects on the freelist exceeds a threshold, the system |
|
291 |
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
|
292 |
This compress is either done by a 1-pass semispace copy algorithm, or |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
293 |
a 2pass inplace compress - depending on the setting of the compress limit. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
294 |
|
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
295 |
The 1pass algorithm copies all live objects into a newly allocated |
3733 | 296 |
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
|
297 |
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
|
298 |
a second pass. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
299 |
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
|
300 |
slightly faster, if enough real memory is available. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
301 |
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
|
302 |
since it is less affected by paging. |
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
|
3733 | 306 |
We recommend setting the compressLimit to roughly 1/4th of the physical |
307 |
memory size of the machine, if other programs are to run beside ST/X |
|
308 |
(i.e. an XServer, some xterms etc.). |
|
309 |
If ST/X is running almost alone (i.e. using an XTerminal), the compressLimit |
|
310 |
can be set to 1/3rd of the physical memory. |
|
311 |
This is only a rough estimate - you may want to play around with this |
|
312 |
parameter, to find a value which avoids paging due to a 1pass compress. |
|
313 |
||
93 | 314 |
Since a compressing oldspace collect leads to a noticable pause of the system, |
315 |
the memory manager tries hard to avoid oldspace compression. |
|
1152 | 316 |
(well, if enough real memory is available to hold both spaces in physical |
3733 | 317 |
memory, the compress algorithms are actually pretty fast). |
202 | 318 |
|
93 | 319 |
The incremental mark&sweep runs in the background, whenever the system is idle |
403 | 320 |
(see ProcessorSceduler>>waitForEventOrTimeout), or alternatively as a low or high |
321 |
priority background process (see ObjectMemory>>startBackgroundCollector). |
|
362 | 322 |
Like the normal mark&sweep, this incremental collector follows object references |
323 |
and marks reachable objects on its way. However, this is done 'a few objects-at-a-time', |
|
3733 | 324 |
to not disrupt the system noticably. |
325 |
Currently, there are some (theoretical) and in practice never occurring situations, |
|
326 |
in which the incremental GC still creates noticable delays. |
|
327 |
A current project is involved with this and a future version of ST/X (ST/X-RT) |
|
403 | 328 |
will be available which shows deterministic worst case behavior in its GC pauses |
329 |
(this will be provided as an additional add-on option - certainly not for free ;-). |
|
1152 | 330 |
|
403 | 331 |
Currently, incremental GC blockings are in the order of 10-70ms. |
332 |
There is one catch with low priority background IGC: if there is never any idle |
|
333 |
time available (i.e. all processes run all the time), it would never get a chance |
|
3733 | 334 |
to do any collection work. |
335 |
To handle this case, a background IGC can either be started as a high priority |
|
336 |
process, which gives up the cpu (by delaying on the time) after every IGC step, |
|
337 |
or it can be gicen a dynamic priority, where the max-prio is above UserSchedulingPriority. |
|
338 |
A high priority background collector will always make progress and eventually finish |
|
339 |
a GC cycle. However, it may have more of an influence on the other processes. |
|
340 |
So, its up to you, to decide ... |
|
362 | 341 |
|
1152 | 342 |
|
362 | 343 |
Incremental garbage collection is controlled by the variables |
344 |
'IncrementalGCLimit', 'FreeSpaceGCLimit' and 'FreeSpaceGCAmount': |
|
310 | 345 |
|
290 | 346 |
the ProcessorScheduler will perform incremental GC steps at idle time, |
347 |
if the total space allocated since the last full collect exceeds |
|
362 | 348 |
'IncrementalGCLimit', |
290 | 349 |
or if there are less than 'FreeSpaceGCLimit' bytes available in free store. |
362 | 350 |
If after the incrementalGC, less than 'FreeSpaceGCLimi't bytes are available, |
310 | 351 |
'FreeSpaceGCAmount' more bytes are requested from the memory manager. |
290 | 352 |
|
353 |
The defaults are set in ObjectMemory>>initialize and can be changed in your |
|
403 | 354 |
startup 'smalltalk.rc'-file. Setting them to nil turns incremental GC off. |
270 | 355 |
|
1152 | 356 |
|
362 | 357 |
For example, setting 'IncrementalGCLimit' to 500000 will start the background collector |
207 | 358 |
whenever 500k bytes have been allocated - usually very seldom. Setting it to some |
359 |
small number (say 10000) will have it run very often. |
|
290 | 360 |
|
362 | 361 |
Setting 'FreeSpaceGCAmount' to (say) 1meg lets the system try to always keep |
403 | 362 |
1meg of freeSpace. If less memory is available, more oldSpace will be allocated. |
363 |
Keeping some memory in the pocket may prevent the system from running into a blocking |
|
364 |
GC if memory is allocated in peaks (but only, if the incremental GC can keep up with |
|
365 |
allocation rate). The trigger level 'FreeSpaceGCLimit' should be below that amount; |
|
310 | 366 |
to avoid excessive incremental GC activity (say 1/4 if the amount). |
290 | 367 |
|
368 |
Having the background GC running often should not hurt the performance of your |
|
362 | 369 |
smalltalk processes, since the IGC only runs at times when no ST processes are runnable. |
290 | 370 |
(there are some short delays in event processing, since the IGC's steps may take |
371 |
some XX ms.) |
|
270 | 372 |
However, if you are not alone on your machine (i.e. a timesharing system) or |
373 |
you have other Unix processes to run, you should not run the IGC too often, |
|
362 | 374 |
since it may hurt OTHER users/unix processes. |
93 | 375 |
|
216 | 376 |
Since this collector only runs at idle times, even a low priority background |
377 |
process will prevent it from doing its work. You may want to start a somewhat |
|
207 | 378 |
higher priority background collect (say at prio 4), which also preempts these |
379 |
background processes. (see ObjectMemory>>startBackgroundCollectorAt:). |
|
202 | 380 |
|
325 | 381 |
Beginning with 2.10.4, a third space, called symSpace has been added. |
216 | 382 |
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
|
383 |
This space is (currently) used for symbols only. |
325 | 384 |
|
385 |
Beginning with 2.10.5, a fourth space, called fixSpace has been added. |
|
386 |
Objects in this space are never moved or garbage collected. |
|
387 |
This space is used for constant objects (true, false, some basic classes etc.). |
|
229 | 388 |
|
389 |
A plan for 2.11 is to offer an arbitrary number of spaces, which can be |
|
390 |
attached and detached at runtime. This will allow easy share of object |
|
391 |
with remote systems and separating objects into a per application/package |
|
392 |
space. (be prepared for changes in the future and make your application |
|
393 |
independ of the VM internals) |
|
216 | 394 |
|
403 | 395 |
default setup: |
396 |
||
3733 | 397 |
The following table lists some default settings and means for changing them; |
398 |
Notice, that the defaults below are those of the VM and or ObjectMemory class. |
|
399 |
These may already be changed by a smalltalk.rc or private.rc startup file. |
|
403 | 400 |
|
1152 | 401 |
what default change by |
402 |
command line arg dynamically |
|
403 | 403 |
----------------------------------------------------------------------- |
1152 | 404 |
newSpace size 400k -Mnew nnn newSpaceSize:nnn |
405 |
||
406 |
oldSpace size 3000k -Mold nnn moreOldSpace: |
|
407 |
announceSpaceNeed: |
|
408 |
collectGarbage |
|
409 |
||
410 |
max tenure age 29 lockTenure: |
|
411 |
avoidTenure: |
|
412 |
(sets it to infinity) |
|
403 | 413 |
|
3733 | 414 |
adaptive tenure - - tenureParameters |
1152 | 415 |
|
3652 | 416 |
2pass oldSpace |
1152 | 417 |
compressor enabled -Msingle - |
418 |
||
3647
f653279988f8
updated doc for inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3646
diff
changeset
|
419 |
limit for 1pass |
1152 | 420 |
old-compress 8000k - oldSpaceCompressLimit: |
421 |
||
422 |
chunk size |
|
423 |
to increase |
|
3733 | 424 |
oldSpace 256k - oldSpaceIncrement: |
403 | 425 |
|
3733 | 426 |
prefer moreOld |
1152 | 427 |
to doing GC false - fastMoreOldSpaceAllocation: |
428 |
||
429 |
limit for |
|
430 |
above - - fastMoreOldSpaceLimit: |
|
431 |
||
432 |
keep size for - - freeSpaceGCAmount: |
|
433 |
IGC |
|
434 |
||
435 |
low water |
|
436 |
trigger for IGC - - freeSpaceGCLimit: |
|
437 |
||
438 |
allocated |
|
439 |
trigger for IGC 500k - incrementalGCLimit |
|
403 | 440 |
|
3733 | 441 |
maximum time |
442 |
interval between |
|
443 |
IGC's - - BackgroundCollectMaximumInterval |
|
444 |
||
3652 | 445 |
JIT codeCache |
446 |
size unlimited - dynamicCodeLimit: |
|
447 |
||
448 |
new JIT code |
|
449 |
trigger for IGC none - dynamicCodeGCTrigger: |
|
450 |
||
451 |
||
1152 | 452 |
By default, no incremental GC is started by the system; however, |
453 |
the standard startup script starts a low prio background incremental GC process. |
|
454 |
You have to edit your startup files to change this. |
|
455 |
A suggested configuration (used by the author and the default) is: |
|
456 |
||
457 |
' keep 1meg in the pocket ' |
|
458 |
||
459 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
460 |
||
461 |
' start incrementalGC when freespace drops below 250k ' |
|
462 |
' or 500k of oldSpace has been allocated ' |
|
463 |
||
464 |
ObjectMemory freeSpaceGCLimit:250000. ' |
|
465 |
ObjectMemory incrementalGCLimit:500000. ' |
|
466 |
||
467 |
' collect as a background process (the default is: at idle times) |
|
468 |
' this means that running cubes or other demo processes are suspended |
|
469 |
' for the collect; change the prio to below 4 if you want them to continue |
|
470 |
||
471 |
ObjectMemory startBackgroundCollectorAt:5. ' |
|
472 |
ObjectMemory startBackgroundFinalizationAt:5. ' |
|
473 |
||
474 |
' quickly allocate more space (i.e. avoid blocking collects) |
|
475 |
' up to 8meg - then start to collect if more memory is needed. |
|
476 |
||
477 |
ObjectMemory fastMoreOldSpaceLimit:8*1024*1024. ' |
|
478 |
ObjectMemory fastMoreOldSpaceAllocation:true. ' |
|
403 | 479 |
|
202 | 480 |
hints & tricks: |
481 |
||
213 | 482 |
normally, there is no need to call for an explicit garbage collection, or |
216 | 483 |
modify the default parameters. |
213 | 484 |
The memory system should adapt reasonable and provide good performance |
202 | 485 |
for a wide range of allocation patterns (see Example3 below for an exception). |
486 |
||
207 | 487 |
However, there may be situations, in which hints and/or explicit |
202 | 488 |
control over allocation can speedup your programs; but please: |
93 | 489 |
|
207 | 490 |
- if you think you have to play around with the memory policies, |
1152 | 491 |
first check your program - you may find useless allocations |
492 |
or bad uses of collections. A typical error that is made is to |
|
493 |
create large collections using the #, (comma) concatenation method, |
|
494 |
which shows square behavior, since it allocates many, many temporary |
|
495 |
collections. Also, watch out for #copyWith:, #add: etc. |
|
496 |
All of these create a new collection. Remember, that most collections |
|
497 |
offer methods to preallocate some space; for example, 'Set new:' creates |
|
498 |
an empty set, but preallocates space to avoid resizing over and over. |
|
499 |
||
500 |
An especially bad performace dog is to use #add: on fix-size collection |
|
501 |
objects (such as Strings or Arrays), since in addition to allocating |
|
502 |
lots of garbage, a #become: operation is required for EACH element |
|
503 |
added. NEVER use Arrays for growing/shrinking data - use OrderedCollection |
|
504 |
instead. (if you really need an array, use asArray afterwards) |
|
202 | 505 |
|
207 | 506 |
- if you are going to allocate huge data structures, think about |
1152 | 507 |
optimizing space. For example, if you allocate a million instances of |
508 |
some object, each added instance variable makes up 4Mb of additional |
|
509 |
memory need. |
|
510 |
Also, for Byte-valued, Integer-valued and Float like objects, special |
|
511 |
collections are provided, which store their values directly inside (instead |
|
512 |
of a reference to the object). A FloatArray consisting of 1 million floats |
|
513 |
requires about 4mb of memory, while an Array of Floats requires 4mb for the |
|
514 |
references to the floats, PLUS 20Mb for the floats themself. |
|
93 | 515 |
|
207 | 516 |
- check if you really need fast access to all of these objects; you may |
1152 | 517 |
try to only keep some subset in memory, and use binary storage or |
518 |
(if this is too slow) optimized store/retrieve methods and keep the bigger |
|
519 |
part in a file. |
|
520 |
(How about a DiskArray class, which does this transparently ? |
|
521 |
See the FileText class for some ideas and something to start with ...) |
|
207 | 522 |
|
523 |
||
524 |
Hint / Example 1: |
|
93 | 525 |
you are about to allocate a huge data structure, which is known to |
526 |
survive long. In this case, it is better to have these objects move into the |
|
527 |
oldspace sooner, to avoid the copying overhead during scavenges. |
|
528 |
||
529 |
To do this, you can call ObjectMemory>>tenure after allocation, which |
|
530 |
forces all new-objects immediately into the oldspace. |
|
531 |
Make certain, that not to many (ideally no) short-living objects are in the |
|
532 |
newspace when doing this. |
|
533 |
||
534 |
Another alternative is to tell the system that all allocation should be |
|
535 |
done directly in the oldspace. This completely avoids the scavenging overhead |
|
536 |
for these objects. To do so, use ObjectMemory>>turnGarbageCollectorOff |
|
537 |
before the allocation, and ObjectMemory>>turnGarbageCollectorOn afterwards. |
|
202 | 538 |
Keep in mind, that do-loops may allocate block-objects and other temporaries, |
178 | 539 |
so there is a danger of making things worse due to having all those temporaries |
93 | 540 |
in the oldspace afterwards. (which is not a fatal situation, but will |
178 | 541 |
force the system to do an oldspace collect earlier, which may not be your |
542 |
intention). |
|
93 | 543 |
|
202 | 544 |
|
207 | 545 |
Hint / Example 2: |
93 | 546 |
you know in advance, that a certain (big) amount of memory will be needed. |
547 |
For example, the fileBrowser wants to show a huge file in its text-view. |
|
133 | 548 |
In this case, it is better to tell the memory system in advance, how much |
93 | 549 |
memory will be needed, since otherwise many compresses and reallocations will |
133 | 550 |
occur (the memory system will allocate additional memory in chunks of smaller |
551 |
256k pieces, if a compress failes. Thus, if you are going to allocate (say) 1Mb of |
|
552 |
strings, it will perform 5 compressing GC's). |
|
553 |
||
202 | 554 |
This is done using ObjectMemory>>moreOldSpace: or ObjectMemory announceSpaceNeed:. |
555 |
In the above example, you would do 'ObjectMemory announceSpaceNeed:500000', which |
|
133 | 556 |
avoids those annoying 5 compressing GC's. |
207 | 557 |
BTW: if you have other smalltalk processes (threads) running which should not be |
558 |
paused if possible, it is better to use #announceSpaceNeed. This tries to avoid |
|
559 |
pausing in other processes and sometimes succeeds, while moreOldSpace will always |
|
560 |
block the whole system for a while. However, there is no 'no-pause' guarantee. |
|
133 | 561 |
|
562 |
The amount of automatic increase (in case the oldSpace becomes full) is 256k by |
|
563 |
default. This number can be changed with ObjectMemory>>oldSpaceIncrement:. |
|
564 |
||
207 | 565 |
|
566 |
Hint / Example3: |
|
178 | 567 |
There are rare cases, when an explicit GC makes a difference: since |
568 |
object finalization is done at GC time, objects which keep operatingSystem |
|
569 |
resources may be finalized late. This is normally no problem, except if |
|
570 |
the system is running out of resources. For example, allocating new colors |
|
571 |
may fail if many colors have already been allocated in the past - even |
|
572 |
though these colors are actually free. The Depth8Image calls for an |
|
573 |
explicit GC, whenever it fails to allocate a color for a bitmap, to force |
|
574 |
finalization of free, but not yet finalized colors. |
|
1152 | 575 |
The same is true for things like file descriptors, if fileStreams are not closed |
576 |
correctly. |
|
207 | 577 |
|
578 |
Hint 4: |
|
579 |
If you run in too small of physical memory, the incremental GC may have a |
|
580 |
bad effect on your working set: since it touches pages (which may otherwise |
|
581 |
not be needed at the moment, the operating system is forced to steal other |
|
582 |
(possibly more useful) pages from your set of incore pages. |
|
1152 | 583 |
Although ST/X would be willing to fix this behavior (by telling the OS about |
584 |
its page requirements, many OS's do not listen. The SGI-Iris, For example ignores |
|
585 |
the madvice system calls - other systems do not implement it. |
|
586 |
The trouble is that the standard LRU paging strategy is exactly the worst for |
|
587 |
a program which sequentially scans its memory once in a single direction ... |
|
207 | 588 |
You may get better performance, if you turn off the incremental GC while |
589 |
processing a big data structure. |
|
590 |
||
591 |
||
229 | 592 |
Warning: many of the methods found here are not standard and may not even be available in |
133 | 593 |
future versions of ST/X. Use them only in very special situations or experiments. |
229 | 594 |
|
207 | 595 |
Let me know about additional special features you think are useful, and about |
596 |
special features you are using - this provides the feedback required to decide |
|
403 | 597 |
which methods are to be removed, kept or enhanced in future versions. |
93 | 598 |
" |
615 | 599 |
! |
600 |
||
601 |
interrupts |
|
602 |
" |
|
603 |
Handling of interrupts (i.e. unix-signals) is done via handler objects, which |
|
604 |
get a #XXXInterrupt-message sent. This is more flexible than (say) signalling |
|
605 |
a semaphore, since the handler-object may do anything to react on the signal |
|
606 |
(of course, it can also signal a semaphore to emulate the above behavior). |
|
607 |
||
608 |
Another reason for having handler objects is that they allow interrupt handling |
|
609 |
without any context switch, for high speed interrupt response. |
|
610 |
However, if you do this, special care is needed, since it is not defined, |
|
1152 | 611 |
which (smalltalk-)process gets the interrupt and will do the processing |
612 |
(therefore, the default setup installs handlers which simply signal a semaphore |
|
613 |
and continue the current process). |
|
615 | 614 |
|
615 |
Typically, the handlers are set during early initialization of the system |
|
616 |
by sending 'ObjectMemory XXXInterruptHandler:aHandler' and not changed later. |
|
617 |
(see Smalltalk>>initialize or ProcessorScheduler>>initialize). |
|
618 |
To setup your own handler, create some object which responds to #xxxInterrupt, |
|
619 |
and make it the handler using the above method. |
|
620 |
||
621 |
Interrupt messages sent to handlers are: |
|
1152 | 622 |
internalError:<someString> - internal interpreter/GC errors |
623 |
userInterrupt - ^C interrupt |
|
624 |
customInterrupt - custom interrupt |
|
625 |
ioInterrupt - SIGIO interrupt |
|
626 |
timerInterrupt - alarm timer (SIGALRM) |
|
627 |
errorInterrupt:<id> - errors from other primitives/subsystems |
|
628 |
(DisplayError) |
|
629 |
spyInterrupt - spy timer interrupt (SIGVTALARM) |
|
630 |
stepInterrupt - single step interrupt |
|
631 |
disposeInterrupt - finalization required |
|
632 |
recursionInterrupt - recursion (stack) overflow |
|
633 |
memoryInterrupt - soon running out of memory |
|
634 |
fpExceptionInterrupt - floating point exception (SIGFPE) |
|
635 |
childSignalInterrupt - death of a child process (SIGCHILD) |
|
636 |
signalInterrupt:<number> - unix signal (if other than above signals) |
|
615 | 637 |
|
638 |
To avoid frustration in case of badly set handlers, these messages |
|
639 |
are also implemented in the Object class - thus anything can be defined |
|
640 |
as interrupt handler. However, the VM will not send any |
|
641 |
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
|
642 |
(which means that nil is a bad choice, if you are interested in the event). |
615 | 643 |
|
1152 | 644 |
Interrupt processing is not done immediately after the event arrives: |
645 |
there are certain ``save-places'' at which this handling is performed |
|
615 | 646 |
(message send, method return and loop-heads). |
647 |
If not explicitely enabled, primitive code is never interrupted. |
|
1152 | 648 |
However, if you do enable interrupts in your primitive (see ExternalStream as example), |
649 |
be prepared for your objects to move around ... therefore, these have to |
|
650 |
be coded very carefully. |
|
651 |
||
652 |
Interrupts may be disabled completely (OperatingSystem blockInterrupts) and |
|
653 |
reenabled (unblockInterrupts) to allow for critical data to be manipulated. |
|
654 |
The above are low-level primitive entries - you better use #valueUninterruptably, |
|
655 |
which cares for unwinds, long returns and restores the blocking state. |
|
656 |
||
615 | 657 |
Every process has its own interrupt-enable state which is switched |
658 |
when processes switch control (i.e. you cannot block interrupts across |
|
1152 | 659 |
a suspend, delay etc.). |
660 |
However, the state will be restored after a resume. |
|
615 | 661 |
" |
2 | 662 |
! ! |
663 |
||
1767 | 664 |
!ObjectMemory class methodsFor:'initialization'! |
2 | 665 |
|
666 |
initialize |
|
178 | 667 |
"initialize the class" |
668 |
||
2 | 669 |
AllocationFailureSignal isNil ifTrue:[ |
1926 | 670 |
AllocationFailureSignal := ErrorSignal newSignalMayProceed:true. |
671 |
AllocationFailureSignal nameClass:self message:#allocationFailureSignal. |
|
672 |
AllocationFailureSignal notifierString:'allocation failure'. |
|
673 |
||
674 |
MallocFailureSignal := AllocationFailureSignal newSignalMayProceed:true. |
|
675 |
MallocFailureSignal nameClass:self message:#mallocFailureSignal. |
|
676 |
MallocFailureSignal notifierString:'(malloc) allocation failure'. |
|
677 |
||
2262 | 678 |
LowSpaceSemaphore := Semaphore new name:'LowSpaceSemaphore' |
2 | 679 |
]. |
290 | 680 |
DisposeInterruptHandler := self. |
3733 | 681 |
|
682 |
"/ BackgroundCollectMaximumInterval := 3600. "/ run it at least once an hour |
|
683 |
BackgroundCollectMaximumInterval := nil. "/ only run when space situation makes it feasable |
|
684 |
IncrementalGCLimit := 500000. "/ run it whenever 500k have been allocated |
|
685 |
FreeSpaceGCLimit := FreeSpaceGCAmount := nil. "/ no minumum-freeSpace trigger. |
|
1729
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
686 |
MemoryInterruptHandler := self. |
1926 | 687 |
ExceptionInterruptHandler := self. |
1729
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
688 |
|
48196b43bb18
added a reference to some VM symbols (in case libwidg/libtool is not
Claus Gittinger <cg@exept.de>
parents:
1704
diff
changeset
|
689 |
VMSelectors := #( #noByteCode #invalidCodeObject #invalidByteCode #invalidInstruction |
1926 | 690 |
#tooManyArguments #badLiteralTable #receiverNotBoolean: #typeCheckError |
691 |
#integerCheckError #wrongNumberOfArguments: #privateMethodCalled |
|
692 |
#doesNotUnderstand: #invalidReturn: #invalidReturnOrRestart: |
|
693 |
#userInterrupt #internalError: #spyInterrupt #timerInterrupt #stepInterrupt |
|
694 |
#errorInterrupt:with: #disposeInterrupt #recursionInterrupt |
|
695 |
#memoryInterrupt #fpExceptionInterrupt #signalInterrupt: #childSignalInterrupt |
|
696 |
#ioInterrupt #customInterrupt #schedulerInterrupt #contextInterrupt |
|
697 |
#interruptLatency:receiver:class:selector:vmActivity:id:). |
|
698 |
||
3733 | 699 |
"Modified: / 5.8.1998 / 15:30:12 / cg" |
2 | 700 |
! ! |
701 |
||
1767 | 702 |
!ObjectMemory class methodsFor:'ST-80 compatibility'! |
615 | 703 |
|
704 |
availableFreeBytes |
|
2320 | 705 |
"return the amount of free memory |
706 |
(both in the compact free area and in the free lists)" |
|
707 |
||
615 | 708 |
^ self freeSpace + self freeListSpace |
709 |
||
710 |
" |
|
711 |
ObjectMemory availableFreeBytes |
|
712 |
" |
|
2320 | 713 |
|
714 |
"Modified: 29.1.1997 / 23:43:05 / cg" |
|
615 | 715 |
! |
716 |
||
717 |
bytesPerOOP |
|
718 |
"return the number of bytes an object reference (for example: an instvar) |
|
719 |
takes" |
|
720 |
||
721 |
%{ /* NOCONTEXT */ |
|
722 |
RETURN(__MKSMALLINT(sizeof(OBJ))); |
|
723 |
%} |
|
724 |
||
725 |
" |
|
726 |
ObjectMemory bytesPerOOP |
|
727 |
" |
|
728 |
! |
|
729 |
||
730 |
bytesPerOTE |
|
731 |
"return the number of overhead bytes of an object. |
|
732 |
i.e. the number of bytes in every objects header." |
|
733 |
||
734 |
%{ /* NOCONTEXT */ |
|
735 |
RETURN(__MKSMALLINT(OHDR_SIZE)); |
|
736 |
%} |
|
737 |
||
738 |
" |
|
739 |
ObjectMemory bytesPerOTE |
|
740 |
" |
|
741 |
! |
|
742 |
||
743 |
compactingGC |
|
2320 | 744 |
"perform a compacting garbage collect" |
745 |
||
615 | 746 |
self garbageCollect |
2320 | 747 |
|
748 |
"Modified: 29.1.1997 / 23:43:25 / cg" |
|
615 | 749 |
! |
750 |
||
751 |
current |
|
2320 | 752 |
"the 'current' ObjectMemory - thats myself" |
753 |
||
615 | 754 |
^ self |
2320 | 755 |
|
756 |
"Modified: 29.1.1997 / 23:43:39 / cg" |
|
615 | 757 |
! |
758 |
||
759 |
globalCompactingGC |
|
2320 | 760 |
"perform a compacting garbage collect" |
761 |
||
3605
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
762 |
self reclaimSymbols. |
615 | 763 |
self garbageCollect |
2320 | 764 |
|
3605
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
765 |
"Modified: / 18.6.1998 / 15:00:52 / cg" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
766 |
! |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
767 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
768 |
globalGarbageCollect |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
769 |
"perform a compacting garbage collect" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
770 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
771 |
self reclaimSymbols. |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
772 |
|
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
773 |
"Created: / 18.6.1998 / 15:00:05 / cg" |
50d548f8de87
ST-80 compat: added #globalGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3277
diff
changeset
|
774 |
"Modified: / 18.6.1998 / 15:00:47 / cg" |
615 | 775 |
! |
776 |
||
777 |
growMemoryBy:numberOfBytes |
|
2320 | 778 |
"allocate more memory" |
779 |
||
615 | 780 |
^ self moreOldSpace:numberOfBytes |
2320 | 781 |
|
782 |
"Modified: 29.1.1997 / 23:44:01 / cg" |
|
615 | 783 |
! |
784 |
||
785 |
numOopsNumBytes |
|
2320 | 786 |
"return an array filled with the number of objects |
787 |
and the number of used bytes." |
|
788 |
||
615 | 789 |
^ Array with:(self numberOfObjects) |
2320 | 790 |
with:(self bytesUsed) |
615 | 791 |
|
792 |
" |
|
793 |
ObjectMemory numOopsNumBytes |
|
794 |
" |
|
2320 | 795 |
|
796 |
"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
|
797 |
! |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
798 |
|
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
799 |
versionId |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
800 |
"return this systems version. |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
801 |
For ST80 compatibility." |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
802 |
|
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
803 |
^ Smalltalk versionString |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
804 |
|
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
805 |
"Created: / 27.10.1997 / 13:51:59 / cg" |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
806 |
"Modified: / 28.10.1997 / 20:06:14 / cg" |
615 | 807 |
! ! |
808 |
||
1767 | 809 |
!ObjectMemory class methodsFor:'Signal constants'! |
2 | 810 |
|
811 |
allocationFailureSignal |
|
13 | 812 |
"return the signal raised when an object allocation failed" |
813 |
||
2 | 814 |
^ AllocationFailureSignal |
464
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
815 |
! |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
816 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
817 |
mallocFailureSignal |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
818 |
"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
|
819 |
(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
|
820 |
non-Object storage)" |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
821 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
822 |
^ MallocFailureSignal |
2 | 823 |
! ! |
1 | 824 |
|
1767 | 825 |
!ObjectMemory class methodsFor:'VM messages'! |
375 | 826 |
|
615 | 827 |
debugPrinting |
828 |
"return true, if various debug printouts in the VM |
|
375 | 829 |
are turned on, false of off." |
830 |
||
831 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
832 |
extern int __getDebugPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
833 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
834 |
RETURN (__getDebugPrinting() ? true : false); |
375 | 835 |
%} |
836 |
! |
|
837 |
||
838 |
debugPrinting:aBoolean |
|
839 |
"turn on/off various debug printouts in the VM |
|
840 |
in case of an error. For example, a double-notUnderstood |
|
841 |
leads to a VM context dump if debugPrinting is on. |
|
842 |
If off, those messages are suppressed. |
|
843 |
The default is on, since these messages are only printed for |
|
844 |
severe errors." |
|
845 |
||
846 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
847 |
__setDebugPrinting( (aBoolean == true) ); |
375 | 848 |
%} |
849 |
! |
|
850 |
||
615 | 851 |
infoPrinting |
852 |
"return true, if various informational printouts in the VM |
|
375 | 853 |
are turned on, false of off." |
854 |
||
855 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
856 |
extern int __getInfoPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
857 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
858 |
RETURN (__getInfoPrinting() ? true : false); |
615 | 859 |
%} |
860 |
! |
|
861 |
||
862 |
infoPrinting:aBoolean |
|
863 |
"turn on/off various informational printouts in the VM. |
|
864 |
For example, the GC activity messages are controlled by |
|
865 |
this flags setting. |
|
866 |
The default is true, since (currently) those messages |
|
867 |
are useful for ST/X developers." |
|
868 |
||
869 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
870 |
__setInfoPrinting( (aBoolean == true) ); |
615 | 871 |
%} |
872 |
! ! |
|
873 |
||
1767 | 874 |
!ObjectMemory class methodsFor:'access debugging'! |
703 | 875 |
|
876 |
setTrapOnAccessFor:anObject |
|
877 |
"install an access trap for anObject; |
|
878 |
An accessSignal will be raised, whenever any instvar of anObject is either read or written. |
|
879 |
This is not supported on all architectures, therefore the return value |
|
880 |
(true of trap was installed ok, false if failed) should be checked." |
|
881 |
||
882 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
883 |
RETURN (__addTrapOnAccess(anObject, 2) ? true : false); |
703 | 884 |
%} |
885 |
! |
|
886 |
||
887 |
setTrapOnReadFor:anObject |
|
888 |
"install a read trap for anObject; |
|
889 |
An accessSignal will be raised, whenever any access into anObject occurrs. |
|
890 |
This is not supported on all architectures, therefore the return value |
|
891 |
(true of trap was installed ok, false if failed) should be checked." |
|
892 |
||
893 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
894 |
RETURN (__addTrapOnAccess(anObject, 0) ? true : false); |
703 | 895 |
%} |
896 |
! |
|
897 |
||
898 |
setTrapOnWriteFor:anObject |
|
899 |
"install a write trap for anObject; |
|
900 |
An accessSignal will be raised, whenever any instvar of anObject is written to. |
|
901 |
This is not supported on all architectures, therefore the return value |
|
902 |
(true of trap was installed ok, false if failed) should be checked." |
|
903 |
||
904 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
905 |
RETURN (__addTrapOnAccess(anObject, 1) ? true : false); |
703 | 906 |
%} |
907 |
! |
|
908 |
||
909 |
unsetAllTraps |
|
910 |
"remove all access traps" |
|
911 |
||
912 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
913 |
__removeAllAccessTraps(); |
703 | 914 |
%} |
915 |
! |
|
916 |
||
917 |
unsetTrapFor:anObject |
|
918 |
"remove any access trap for anObject." |
|
919 |
||
920 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
921 |
__removeTrapOnAccess(anObject); |
703 | 922 |
%} |
923 |
! ! |
|
924 |
||
1767 | 925 |
!ObjectMemory class methodsFor:'cache management'! |
615 | 926 |
|
927 |
flushCaches |
|
928 |
"flush method and inline caches for all classes" |
|
929 |
||
930 |
%{ /* NOCONTEXT */ |
|
931 |
__flushMethodCache(); |
|
932 |
__flushAllInlineCaches(); |
|
933 |
%} |
|
934 |
! |
|
935 |
||
936 |
flushCachesFor:aClass |
|
937 |
"flush method and inline caches for aClass" |
|
938 |
||
939 |
%{ /* NOCONTEXT */ |
|
940 |
__flushMethodCacheFor(aClass); |
|
941 |
__flushInlineCachesFor(aClass); |
|
942 |
%} |
|
943 |
! |
|
944 |
||
945 |
flushCachesForSelector:aSelector |
|
946 |
"flush method and inline caches for aSelector" |
|
947 |
||
948 |
%{ /* NOCONTEXT */ |
|
949 |
__flushMethodCacheForSelector(aSelector); |
|
950 |
__flushInlineCachesForSelector(aSelector); |
|
951 |
%} |
|
952 |
! |
|
953 |
||
954 |
flushInlineCaches |
|
955 |
"flush all inlinecaches" |
|
956 |
||
957 |
%{ /* NOCONTEXT */ |
|
958 |
__flushAllInlineCaches(); |
|
959 |
%} |
|
960 |
! |
|
961 |
||
962 |
flushInlineCachesFor:aClass withArgs:nargs |
|
963 |
"flush inlinecaches for calls to aClass with nargs arguments" |
|
964 |
||
965 |
%{ /* NOCONTEXT */ |
|
1133 | 966 |
__flushInlineCachesForAndNargs(aClass, __intVal(nargs)); |
615 | 967 |
%} |
968 |
! |
|
969 |
||
970 |
flushInlineCachesForClass:aClass |
|
971 |
"flush inlinecaches for calls to aClass." |
|
972 |
||
973 |
%{ /* NOCONTEXT */ |
|
974 |
__flushInlineCachesFor(aClass); |
|
975 |
%} |
|
976 |
! |
|
977 |
||
978 |
flushInlineCachesForSelector:aSelector |
|
979 |
"flush inlinecaches for sends of aSelector" |
|
980 |
||
981 |
%{ /* NOCONTEXT */ |
|
982 |
__flushInlineCachesForSelector(aSelector); |
|
983 |
%} |
|
984 |
! |
|
985 |
||
986 |
flushInlineCachesWithArgs:nargs |
|
987 |
"flush inlinecaches for calls with nargs arguments" |
|
988 |
||
989 |
%{ /* NOCONTEXT */ |
|
1133 | 990 |
__flushInlineCaches(__intVal(nargs)); |
615 | 991 |
%} |
992 |
! |
|
993 |
||
994 |
flushMethodCache |
|
995 |
"flush the method cache" |
|
996 |
||
997 |
%{ /* NOCONTEXT */ |
|
998 |
__flushMethodCache(); |
|
999 |
%} |
|
1000 |
! |
|
1001 |
||
1002 |
flushMethodCacheFor:aClass |
|
1003 |
"flush the method cache for sends to aClass" |
|
1004 |
||
1005 |
%{ /* NOCONTEXT */ |
|
1006 |
__flushMethodCacheFor(aClass); |
|
1007 |
%} |
|
1008 |
! |
|
1009 |
||
1010 |
flushMethodCacheForSelector:aSelector |
|
1011 |
"flush the method cache for sends of aSelector" |
|
1012 |
||
1013 |
%{ /* NOCONTEXT */ |
|
1014 |
__flushMethodCacheForSelector(aSelector); |
|
1015 |
%} |
|
1016 |
! |
|
1017 |
||
1108 | 1018 |
incrementSnapshotID |
2526 | 1019 |
"obsolete - do not use" |
1020 |
||
1108 | 1021 |
%{ /* NOCONTEXT */ |
1022 |
__bumpSnapshotID(); |
|
1023 |
%} |
|
1024 |
! |
|
1025 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1026 |
snapshotID |
918 | 1027 |
"return the internal snapshotID number. |
1028 |
This is incremented when an image is restarted, and |
|
1029 |
stored with the image. |
|
1030 |
Not for normal users, this is used by the VM to invalidate |
|
1031 |
caches which are stored with the image" |
|
1032 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1033 |
%{ /* NOCONTEXT */ |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1034 |
RETURN ( __MKSMALLINT( __snapshotID() )); |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1035 |
%} |
918 | 1036 |
" |
1037 |
ObjectMemory snapshotID |
|
1038 |
" |
|
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1039 |
! |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1040 |
|
615 | 1041 |
trapRestrictedMethods:trap |
1042 |
"Allow/Deny execution of restricted Methods (see Method>>>restricted:) |
|
1043 |
||
1044 |
Notice: method restriction is a nonstandard feature, not supported |
|
1045 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
1046 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
1047 |
It may change or even vanish (if it shows to be not useful)." |
|
1048 |
||
1049 |
|oldTrap| |
|
1050 |
||
1051 |
%{ |
|
1052 |
if (__setTrapRestrictedMethods(trap == true)) |
|
1053 |
oldTrap = true; |
|
1054 |
else |
|
1055 |
oldTrap = false; |
|
1056 |
%}. |
|
1057 |
||
1058 |
(trap and:[oldTrap not]) ifTrue:[ |
|
1059 |
self flushCaches |
|
1060 |
]. |
|
1061 |
^ oldTrap |
|
1062 |
||
1063 |
" |
|
1064 |
ObjectMemory trapRestrictedMethods:true |
|
1065 |
ObjectMemory trapRestrictedMethods:false |
|
1066 |
" |
|
1067 |
! ! |
|
1068 |
||
1767 | 1069 |
!ObjectMemory class methodsFor:'debug queries'! |
615 | 1070 |
|
1071 |
addressOf:anObject |
|
1072 |
"return the core address of anObject as an integer |
|
1073 |
- since objects may move around, the returned value is invalid after the |
|
1074 |
next scavenge/collect. |
|
1075 |
WARNING: this method is for ST/X debugging only |
|
1076 |
it will be removed without notice" |
|
1077 |
||
1078 |
%{ /* NOCONTEXT */ |
|
1079 |
||
1080 |
if (! __isNonNilObject(anObject)) { |
|
1081 |
RETURN ( nil ); |
|
1082 |
} |
|
2783 | 1083 |
if ((unsigned INT)anObject <= _MAX_INT) { |
2769 | 1084 |
RETURN ( __MKSMALLINT((INT)anObject) ); |
615 | 1085 |
} |
2769 | 1086 |
RETURN ( __MKUINT((INT)anObject) ); |
615 | 1087 |
%} |
1088 |
" |
|
1089 |
|p| |
|
1090 |
p := Point new. |
|
1091 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
1092 |
ObjectMemory scavenge. |
|
1093 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
1094 |
" |
|
1095 |
! |
|
1096 |
||
1097 |
ageOf:anObject |
|
1098 |
"return the number of scavenges, an object has survived |
|
1099 |
in new space. |
|
1100 |
For old objects and living contexts, the returned number is invalid. |
|
1101 |
WARNING: this method is for ST/X debugging only |
|
1102 |
it will be removed without notice" |
|
1103 |
||
1104 |
%{ /* NOCONTEXT */ |
|
1105 |
||
1106 |
if (! __isNonNilObject(anObject)) { |
|
1107 |
RETURN ( 0 ); |
|
1108 |
} |
|
1133 | 1109 |
RETURN ( __MKSMALLINT( _GET_AGE(anObject) ) ); |
615 | 1110 |
%} |
1111 |
" |
|
1112 |
|p| |
|
1113 |
p := Point new. |
|
1114 |
(ObjectMemory ageOf:p) printNL. |
|
1115 |
ObjectMemory tenuringScavenge. |
|
1116 |
(ObjectMemory spaceOf:p) printNL. |
|
1117 |
ObjectMemory tenuringScavenge. |
|
1118 |
(ObjectMemory spaceOf:p) printNL. |
|
1119 |
ObjectMemory tenuringScavenge. |
|
1120 |
(ObjectMemory spaceOf:p) printNL. |
|
1121 |
ObjectMemory tenuringScavenge. |
|
1122 |
(ObjectMemory spaceOf:p) printNL. |
|
1123 |
" |
|
1124 |
! |
|
1125 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1126 |
displayRefChainTo:anObject |
3266 | 1127 |
self displayRefChainToAny:(Array with:anObject). |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1128 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1129 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1130 |
self displayRefChainTo:Point new |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1131 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1132 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1133 |
Smalltalk at:#foo put:Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1134 |
self displayRefChainTo:(Smalltalk at:#foo) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1135 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1136 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1137 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1138 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1139 |
Smalltalk at:#foo put:(#x -> p). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1140 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1141 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1142 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1143 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1144 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1145 |
Smalltalk at:#foo put:(#x -> a). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1146 |
self displayRefChainTo:a |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1147 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1148 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1149 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1150 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1151 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1152 |
self displayRefChainTo:a |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1153 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1154 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1155 |
|a| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1156 |
a := Array new:1. a at:1 put:a. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1157 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1158 |
self displayRefChainTo:a |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1159 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1160 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1161 |
|p| |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1162 |
p := Point new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1163 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1164 |
self displayRefChainTo:p |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1165 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1166 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1167 |
self displayRefChainTo:Transcript topView |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1168 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1169 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1170 |
"Created: / 2.2.1998 / 19:23:55 / cg" |
3266 | 1171 |
"Modified: / 3.2.1998 / 00:30:14 / cg" |
1172 |
! |
|
1173 |
||
1174 |
displayRefChainToAny:aCollection |
|
1175 |
|levels objects done showMore stop userStop chain |
|
1176 |
top progress lbl h nDone nAll panel listV stopButton |
|
1177 |
moreButton owners objectArray numObjects numObjectsDone |
|
1178 |
found moreChainsOnThisLevel temporaryRemoved chains chainObjs |
|
3643 | 1179 |
anyShown anyShownInAnyLevel list tLevels firstRound| |
3266 | 1180 |
|
1181 |
top := StandardSystemView new. |
|
1182 |
top extent:350@250. |
|
1183 |
top label:'Object reference finder'. |
|
1184 |
||
1185 |
lbl := Label label:'compressing garbage ...' in:top. |
|
1186 |
lbl adjust:#left. |
|
1187 |
lbl origin:(0.0@0.0) corner:(1.0@0.0). |
|
1188 |
h := lbl preferredExtent y. |
|
1189 |
lbl |
|
1190 |
topInset:5; |
|
1191 |
bottomInset:(h+5) negated; |
|
1192 |
leftInset:5; |
|
1193 |
rightInset:5. |
|
1194 |
||
1195 |
progress := ProgressIndicator in:top. |
|
1196 |
progress origin:(0.0@45) corner:(1.0@45). |
|
1197 |
progress level:-1. |
|
1198 |
h := progress preferredExtent y. |
|
1199 |
progress |
|
1200 |
topInset:(h // 2) negated; |
|
1201 |
bottomInset:(h // 2) negated; |
|
1202 |
leftInset:5; |
|
1203 |
rightInset:5. |
|
1204 |
progress beInvisible. |
|
1205 |
||
1206 |
listV := HVScrollableView for:SelectionInListView in:top. |
|
1207 |
listV origin:(0.0@55) corner:(1.0@1.0). |
|
1208 |
listV |
|
1209 |
topInset:(h // 2); |
|
1210 |
bottomInset:40; |
|
1211 |
leftInset:5; |
|
1212 |
rightInset:5. |
|
1213 |
listV beInvisible. |
|
1214 |
||
1215 |
panel := HorizontalPanelView in:top. |
|
1216 |
panel origin:(0.0@1.0) corner:(1.0@1.0). |
|
1217 |
panel topInset:-40. |
|
1218 |
panel horizontalLayout:#left. |
|
1219 |
||
1220 |
panel add:(Button label:'stop' action:[stop := userStop := true]). |
|
1221 |
panel add:(moreButton := Button label:'more' action:[showMore := true]). |
|
1222 |
panel ignoreInvisibleComponents:false. |
|
1223 |
moreButton beInvisible. |
|
1224 |
||
1225 |
top openWithPriority:(Processor activePriority + 1). |
|
1226 |
top waitUntilVisible. |
|
1227 |
||
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1228 |
lbl label:'compressing garbage ...'. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1229 |
self compressingGarbageCollect. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1230 |
|
3266 | 1231 |
progress beVisible. |
1232 |
||
1233 |
levels := OrderedCollection new. |
|
1234 |
objects := WeakIdentitySet withAll:aCollection. |
|
1235 |
||
1236 |
done := (objects includesIdentical:Smalltalk). |
|
1237 |
stop := userStop := false. |
|
3643 | 1238 |
anyShown := anyShownInAnyLevel := false. |
3266 | 1239 |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1240 |
"/ consider this a kludge: |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1241 |
"/ 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
|
1242 |
"/ only known to the VM. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1243 |
"/ 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
|
1244 |
"/ These are released later. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1245 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1246 |
Smalltalk at:#'__VMProcesses__' put:(self processesKnownInVM). |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1247 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1248 |
firstRound := true. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1249 |
|
3266 | 1250 |
[done] whileFalse:[ |
1251 |
anyShown := false. |
|
1252 |
||
1253 |
progress percentage:0. |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1254 |
firstRound ifTrue:[ |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1255 |
firstRound := false. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1256 |
] ifFalse:[ |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1257 |
lbl label:'compressing garbage ...'. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1258 |
self garbageCollect. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1259 |
]. |
3266 | 1260 |
|
1261 |
lbl label:('searching level ' |
|
1262 |
, levels size printString |
|
1263 |
, ' (' , objects size printString , ' refs) ...'). |
|
1264 |
nAll := objects size. |
|
1265 |
nDone := 0. |
|
1266 |
||
1267 |
objectArray := objects asArray. |
|
1268 |
||
1269 |
owners := "Weak"IdentitySet new. |
|
1270 |
||
1271 |
numObjectsDone := 0. |
|
1272 |
found := false. |
|
1273 |
||
1274 |
[self allObjectsDo:[:o | |
|
1275 |
|inPrevLevel| |
|
1276 |
||
1277 |
stop ifFalse:[ |
|
1278 |
(o referencesAny:objectArray) ifTrue:[ |
|
1279 |
o isBehavior ifTrue:[ |
|
1280 |
o == Smalltalk ifTrue:[ |
|
1281 |
found := true. |
|
1282 |
] ifFalse:[ |
|
1283 |
"/ only add it if it has classInstVars |
|
1284 |
o instSize ~~ Class instSize ifTrue:[ |
|
1285 |
(objects includesIdentical:o) ifFalse:[ |
|
1286 |
inPrevLevel := false. |
|
1287 |
levels do:[:lColl | |
|
1288 |
lColl == o ifTrue:[ |
|
1289 |
inPrevLevel := true |
|
1290 |
] ifFalse:[ |
|
1291 |
(lColl includesIdentical:o) ifTrue:[inPrevLevel := true]. |
|
1292 |
] |
|
1293 |
]. |
|
1294 |
inPrevLevel ifFalse:[ |
|
1295 |
owners add:o. |
|
1296 |
] |
|
1297 |
] |
|
1298 |
] |
|
1299 |
] |
|
1300 |
] ifFalse:[ |
|
1301 |
o class ~~ WeakArray ifTrue:[ |
|
1302 |
(objects includesIdentical:o) ifFalse:[ |
|
1303 |
inPrevLevel := false. |
|
1304 |
levels do:[:lColl | |
|
1305 |
lColl == o ifTrue:[ |
|
1306 |
inPrevLevel := true |
|
1307 |
] ifFalse:[ |
|
1308 |
(lColl includesIdentical:o) ifTrue:[inPrevLevel := true]. |
|
1309 |
] |
|
1310 |
]. |
|
1311 |
inPrevLevel ifFalse:[ |
|
1312 |
owners add:o. |
|
1313 |
] |
|
1314 |
] |
|
1315 |
] |
|
1316 |
]. |
|
1317 |
]. |
|
1318 |
numObjectsDone := numObjectsDone + 1. |
|
1319 |
numObjects notNil ifTrue:[ |
|
1320 |
numObjectsDone \\ 1000 == 0 ifTrue:[ |
|
1321 |
progress percentage:(numObjectsDone / numObjects * 100). |
|
1322 |
Processor yield. |
|
1323 |
] |
|
1324 |
] |
|
1325 |
] |
|
1326 |
]] whileFalse. |
|
1327 |
progress percentage:100. |
|
1328 |
||
1329 |
numObjects isNil ifTrue:[ |
|
1330 |
numObjects := numObjectsDone. |
|
1331 |
]. |
|
1332 |
||
1333 |
owners remove:aCollection ifAbsent:nil. |
|
1334 |
owners remove:thisContext ifAbsent:nil. |
|
1335 |
owners remove:objectArray ifAbsent:nil. |
|
1336 |
owners remove:objects keyArray ifAbsent:nil. |
|
1337 |
owners remove:owners keyArray ifAbsent:nil. |
|
1338 |
||
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1339 |
"/ 'done with level: ' print. levels size print. ' found ' print. owners size print. ' refs' printCR. |
3266 | 1340 |
|
1341 |
owners isEmpty ifTrue:[ |
|
1342 |
found ifFalse:[ |
|
1343 |
stop := true. |
|
1344 |
] |
|
1345 |
]. |
|
1346 |
||
1347 |
stop ifFalse:[ |
|
1348 |
done := found or:[(owners includesIdentical:Smalltalk)]. |
|
1349 |
done ifTrue:[ |
|
1350 |
moreChainsOnThisLevel := true. |
|
1351 |
temporaryRemoved := IdentitySet new. |
|
1352 |
||
1353 |
levels size > 0 ifTrue:[ |
|
1354 |
"/ show what we found so far. |
|
1355 |
levels last add:Smalltalk. |
|
1356 |
levels reverse. |
|
1357 |
]. |
|
1358 |
||
1359 |
chains := OrderedCollection new. |
|
1360 |
||
1361 |
tLevels := levels collect:[:lColl | lColl copy]. |
|
1362 |
||
1363 |
lbl label:('building refchains ...'). |
|
1364 |
||
1365 |
nAll := aCollection size. |
|
1366 |
nDone := 0. |
|
1367 |
aCollection do:[:anObject | |theseChains| |
|
1368 |
stop ifFalse:[ |
|
1369 |
theseChains := self |
|
1370 |
refChainsFrom:Smalltalk |
|
1371 |
to:anObject |
|
1372 |
inRefSets:tLevels |
|
1373 |
startingAt:1. |
|
1374 |
||
1375 |
theseChains size > 0 ifTrue:[ |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1376 |
chains addAll:theseChains |
3266 | 1377 |
]. |
1378 |
nDone := nDone + 1. |
|
1379 |
progress percentage:(nDone / nAll * 100). |
|
1380 |
] |
|
1381 |
]. |
|
1382 |
||
1383 |
tLevels := nil. |
|
1384 |
||
1385 |
levels size > 0 ifTrue:[ |
|
1386 |
levels reverse. |
|
1387 |
levels last remove:Smalltalk. |
|
1388 |
]. |
|
1389 |
||
1390 |
[stop not |
|
1391 |
and:[chains size > 0]] whileTrue:[ |
|
1392 |
chain := chains first. |
|
1393 |
chains removeFirst. |
|
1394 |
||
1395 |
lbl label:('found a reference chain.'). |
|
1396 |
progress beInvisible. |
|
1397 |
||
1398 |
chain addFirst:Smalltalk. |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1399 |
list := OrderedCollection new grow:chain size. |
3266 | 1400 |
1 to:chain size-1 do:[:i | |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1401 |
list |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1402 |
at:i |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1403 |
put:(self refNameFor:(chain at:i+1) in:(chain at:i)) |
3266 | 1404 |
]. |
1405 |
list at:list size put:(chain last classNameWithArticle). |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1406 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1407 |
"/ hide the VMProcesses stuff from the user ... |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1408 |
(list at:1) string = 'Smalltalk:__VMProcesses__' ifTrue:[ |
3642 | 1409 |
list at:1 put:'__VMProcesses__ (a hidden VM reference)'. |
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1410 |
list removeIndex:2. |
3643 | 1411 |
chain at:1 put:nil. |
1412 |
chain removeIndex:2. |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1413 |
]. |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1414 |
|
3266 | 1415 |
listV list:list. |
1416 |
||
1417 |
listV beVisible. |
|
1418 |
listV doubleClickAction:[:idx | |o| |
|
1419 |
(o := chain at:idx) notNil ifTrue:[ |
|
1420 |
o inspect. |
|
1421 |
] |
|
1422 |
]. |
|
1423 |
moreButton beVisible. |
|
3643 | 1424 |
anyShown := anyShownInAnyLevel := true. |
3266 | 1425 |
showMore := false. |
1426 |
||
1427 |
"/ kludge - wait for some user action |
|
1428 |
||
1429 |
[showMore or:[stop or:[top realized not]]] whileFalse:[ |
|
1430 |
Delay waitForSeconds:0.1 |
|
1431 |
]. |
|
1432 |
||
1433 |
listV doubleClickAction:nil. |
|
1434 |
chain := nil. |
|
1435 |
||
1436 |
top realized not ifTrue:[ |
|
1437 |
stop := true |
|
1438 |
] ifFalse:[ |
|
1439 |
showMore ifFalse:[ |
|
1440 |
stop := true. |
|
1441 |
]. |
|
1442 |
]. |
|
1443 |
done := false. |
|
1444 |
||
1445 |
stop ifFalse:[ |
|
1446 |
progress beVisible. |
|
1447 |
listV beInvisible. |
|
1448 |
moreButton beInvisible. |
|
1449 |
||
1450 |
chain := nil. |
|
1451 |
] |
|
1452 |
]. |
|
1453 |
levels size > 0 ifTrue:[ |
|
1454 |
levels last addAll:temporaryRemoved. |
|
1455 |
] |
|
1456 |
]. |
|
1457 |
]. |
|
1458 |
||
1459 |
owners remove:Smalltalk ifAbsent:nil. |
|
1460 |
owners remove:(owners keyArray) ifAbsent:nil. |
|
1461 |
owners remove:objectArray ifAbsent:nil. |
|
1462 |
levels do:[:lColl | |
|
1463 |
owners remove:lColl ifAbsent:nil |
|
1464 |
]. |
|
1465 |
||
1466 |
levels add:owners. |
|
1467 |
||
1468 |
objects := owners. |
|
1469 |
||
1470 |
objects size == 0 ifTrue:[ |
|
1471 |
stop := true |
|
1472 |
]. |
|
1473 |
||
1474 |
stop ifTrue:[ |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1475 |
Smalltalk at:#'__VMProcesses__' put:nil. |
3266 | 1476 |
top destroy. |
1477 |
anyShown ifFalse:[ |
|
1478 |
userStop ifFalse:[ |
|
3643 | 1479 |
self information:(anyShownInAnyLevel ifTrue:['no more references'] ifFalse:['no references']). |
3266 | 1480 |
] |
1481 |
]. |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1482 |
^ self. |
3266 | 1483 |
]. |
1484 |
||
1485 |
]. |
|
1486 |
||
1487 |
anyShown ifTrue:[ |
|
1488 |
userStop ifFalse:[ |
|
1489 |
self information:'no more references'. |
|
1490 |
] |
|
1491 |
]. |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
1492 |
Smalltalk at:#'__VMProcesses__' put:nil. |
3266 | 1493 |
^ self |
1494 |
||
1495 |
" |
|
1496 |
self displayRefChainTo:Point new |
|
1497 |
" |
|
1498 |
" |
|
1499 |
Smalltalk at:#foo put:Point new. |
|
1500 |
self displayRefChainTo:(Smalltalk at:#foo) |
|
1501 |
" |
|
1502 |
" |
|
1503 |
|p| |
|
1504 |
p := Point new. |
|
1505 |
Smalltalk at:#foo put:(#x -> p). |
|
1506 |
self displayRefChainTo:p |
|
1507 |
" |
|
1508 |
" |
|
1509 |
|a| |
|
1510 |
a := Array new:1. a at:1 put:a. |
|
1511 |
Smalltalk at:#foo put:(#x -> a). |
|
1512 |
Smalltalk at:#bar put:(Array with:(#y -> a)). |
|
1513 |
self displayRefChainTo:a |
|
1514 |
" |
|
1515 |
" |
|
1516 |
|a| |
|
1517 |
a := Array new:1. a at:1 put:a. |
|
1518 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
|
1519 |
self displayRefChainTo:a |
|
1520 |
" |
|
1521 |
" |
|
1522 |
|a| |
|
1523 |
a := Array new:1. a at:1 put:a. |
|
1524 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
|
1525 |
self displayRefChainTo:a |
|
1526 |
" |
|
1527 |
" |
|
1528 |
|p| |
|
1529 |
p := Point new. |
|
1530 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
|
1531 |
self displayRefChainTo:p |
|
1532 |
" |
|
1533 |
" |
|
1534 |
self displayRefChainTo:Transcript topView |
|
1535 |
" |
|
1536 |
||
1537 |
"Created: / 2.2.1998 / 23:58:04 / cg" |
|
3643 | 1538 |
"Modified: / 10.7.1998 / 17:22:06 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1539 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1540 |
|
615 | 1541 |
dumpObject:someObject |
1542 |
"low level dump an object. |
|
1543 |
WARNING: this method is for ST/X debugging only |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1544 |
it may be removed (or replaced by a noop) without notice" |
615 | 1545 |
|
1546 |
%{ |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1547 |
__dumpObject__(someObject); |
615 | 1548 |
%} |
1549 |
" |
|
1550 |
ObjectMemory dumpObject:true |
|
1551 |
ObjectMemory dumpObject:(Array new:10) |
|
1552 |
ObjectMemory dumpObject:(10@20 corner:30@40) |
|
1553 |
" |
|
1554 |
! |
|
1555 |
||
1556 |
flagsOf:anObject |
|
1557 |
"For debugging only. |
|
1558 |
WARNING: this method is for ST/X debugging only |
|
1559 |
it will be removed without notice" |
|
1560 |
||
1561 |
%{ /* NOCONTEXT */ |
|
1562 |
||
1563 |
if (! __isNonNilObject(anObject)) { |
|
1564 |
RETURN ( nil ); |
|
1565 |
} |
|
1133 | 1566 |
RETURN ( __MKSMALLINT( anObject->o_flags ) ); |
615 | 1567 |
%} |
1568 |
" |
|
1569 |
F_ISREMEMBERED 1 /* a new-space thing being refd by some oldSpace thing */ |
|
1570 |
F_ISFORWARDED 2 /* a forwarded object (you will never see this here) */ |
|
1571 |
F_DEREFERENCED 4 /* a collection after grow (not currently used) */ |
|
1572 |
F_ISONLIFOLIST 8 /* a non-lifo-context-referencing-obj already on list */ |
|
1573 |
F_MARK 16 /* mark bit for background collector */ |
|
1574 |
" |
|
1575 |
||
1576 |
" |
|
1577 |
|arr| |
|
1578 |
||
1579 |
arr := Array new. |
|
1580 |
arr at:1 put:([thisContext] value). |
|
1581 |
(ObjectMemory flagsOf:anObject) printNL |
|
1582 |
" |
|
1583 |
! |
|
1584 |
||
1585 |
objectAt:anAddress |
|
1586 |
"return whatever anAddress points to as object. |
|
1587 |
BIG BIG DANGER ALERT: |
|
1588 |
this method is only to be used for debugging ST/X itself |
|
1589 |
- you can easily (and badly) crash the system. |
|
1590 |
WARNING: this method is for ST/X debugging only |
|
1591 |
it will be removed without notice" |
|
1592 |
||
1288 | 1593 |
%{ /* NOCONTEXT */ |
1594 |
int addr = __longIntVal(anAddress); |
|
1595 |
||
1596 |
if (addr) { |
|
1597 |
RETURN ((OBJ)(addr)); |
|
615 | 1598 |
} |
1288 | 1599 |
RETURN (nil); |
615 | 1600 |
%} |
1601 |
! |
|
1602 |
||
1288 | 1603 |
printReferences:anObject |
1604 |
"for debugging: print referents to anObject. |
|
1605 |
WARNING: this method is for ST/X debugging only |
|
1606 |
it will be removed without notice |
|
1607 |
use ObjectMemory>>whoReferences: or anObject>>allOwners." |
|
615 | 1608 |
|
1609 |
%{ |
|
1610 |
__printRefChain(__context, anObject); |
|
1611 |
%} |
|
1612 |
! |
|
1613 |
||
1288 | 1614 |
refChainFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1615 |
|chain| |
1288 | 1616 |
|
1617 |
index > levels size ifTrue:[ |
|
3266 | 1618 |
(start references:anObject) ifTrue:[ |
1619 |
^ OrderedCollection with:anObject. "/ (self refNameFor:anObject in:start) |
|
1620 |
]. |
|
1621 |
^ nil. |
|
1288 | 1622 |
]. |
1623 |
||
1624 |
(levels at:index) do:[:el | |
|
3266 | 1625 |
el ~~ start ifTrue:[ |
1288 | 1626 |
(start references:el) ifTrue:[ |
1627 |
chain := self |
|
1628 |
refChainFrom:el |
|
1629 |
to:anObject |
|
1630 |
inRefSets:levels |
|
1631 |
startingAt:(index+1). |
|
1632 |
||
1633 |
chain notNil ifTrue:[ |
|
3266 | 1634 |
(levels at:index) saveRemove:el. |
1635 |
chain addFirst:el. "/ (self refNameFor:el in:start). |
|
1636 |
^ chain. |
|
1288 | 1637 |
] |
1638 |
]. |
|
3266 | 1639 |
]. |
1288 | 1640 |
]. |
1641 |
^ nil |
|
1642 |
||
1643 |
||
1644 |
" |
|
1645 |
|o a1 a2| |
|
1646 |
||
1647 |
o := Object new. |
|
1648 |
a1 := Array with:o with:nil with:nil. |
|
1649 |
a2 := Array with:a1 with:nil with:nil. |
|
1650 |
a2 references:a1 |
|
1651 |
" |
|
1652 |
||
1653 |
" |
|
1654 |
|o a1 a2 a3 a4 levels| |
|
1655 |
||
1656 |
o := Object new. |
|
1657 |
a1 := Array with:o. |
|
1658 |
a2 := Array with:a1. |
|
1659 |
a3 := Array with:a2. |
|
1660 |
a4 := Array with:a3. |
|
1661 |
levels := Array with:(Array with:a3) |
|
1662 |
with:(Array with:a2) |
|
1663 |
with:(Array with:a1). |
|
1664 |
||
1665 |
self refChainFrom:a4 to:o inRefSets:levels startingAt:1. |
|
1108 | 1666 |
" |
1667 |
||
3266 | 1668 |
"Modified: / 3.2.1998 / 02:38:27 / cg" |
1108 | 1669 |
! |
1670 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1671 |
refChainsFrom:start to:anObject inRefSets:levels startingAt:index |
3266 | 1672 |
|chains chain c| |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1673 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1674 |
chains := OrderedCollection new. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1675 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1676 |
index > levels size ifTrue:[ |
3266 | 1677 |
(start references:anObject) ifTrue:[ |
1678 |
chains add:(OrderedCollection with:anObject "(self refNameFor:anObject in:start)"). |
|
1679 |
]. |
|
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1680 |
^ chains |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1681 |
]. |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1682 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1683 |
(levels at:index) do:[:el | |
3266 | 1684 |
el ~~ start ifTrue:[ |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1685 |
(start references:el) ifTrue:[ |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1686 |
chain := self |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1687 |
refChainFrom:el |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1688 |
to:anObject |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1689 |
inRefSets:levels |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1690 |
startingAt:(index+1). |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1691 |
|
3266 | 1692 |
chain size > 0 ifTrue:[ |
1693 |
(levels at:index) saveRemove:el. |
|
1694 |
||
1695 |
c := chain copy. |
|
1696 |
c addFirst:el "(self refNameFor:el in:start)". |
|
1697 |
chains add:c. |
|
1698 |
] |
|
1699 |
]. |
|
1700 |
]. |
|
1701 |
]. |
|
1702 |
^ chains |
|
1703 |
||
1704 |
"Created: / 2.2.1998 / 19:09:22 / cg" |
|
1705 |
"Modified: / 3.2.1998 / 02:38:17 / cg" |
|
1706 |
! |
|
1707 |
||
1708 |
refNameFor:anObject in:referent |
|
1709 |
|names oClass| |
|
1710 |
||
1711 |
referent == Smalltalk ifTrue:[ |
|
1712 |
referent keysAndValuesDo:[:key :val | |
|
3275
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1713 |
|idx| |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1714 |
|
3266 | 1715 |
(anObject == val) ifTrue:[ |
3275
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1716 |
"/ for our convenience - if its a nameSpace, cut off Smalltalk. |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1717 |
idx := key string indexOf:$:. |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1718 |
(idx ~~ 0 |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1719 |
and:[idx < key string size |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1720 |
and:[(key string at:(idx+1)) == $:]]) ifTrue:[ |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1721 |
^ (key copyFrom:(idx+2)) asText allBold |
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1722 |
]. |
3266 | 1723 |
^ 'Smalltalk:' , (key asText allBold). |
1724 |
] |
|
1725 |
]. |
|
1726 |
] ifFalse:[ |
|
1727 |
names := referent class allInstVarNames. |
|
1728 |
oClass := referent class. |
|
1729 |
1 to:oClass instSize do:[:i | |
|
1730 |
((referent instVarAt:i) == anObject) ifTrue:[ |
|
1731 |
^ (referent classNameWithArticle , ' [' , (names at:i) asText allBold, ']'). |
|
1732 |
]. |
|
1733 |
]. |
|
1734 |
oClass isVariable ifTrue:[ |
|
1735 |
oClass isPointers ifTrue:[ |
|
1736 |
1 to:referent basicSize do:[:i | |
|
1737 |
((referent basicAt:i) == anObject) ifTrue:[ |
|
1738 |
^ (referent classNameWithArticle , ' [' , i printString asText allBold, ']'). |
|
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1739 |
] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1740 |
] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1741 |
] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1742 |
]. |
3266 | 1743 |
]. |
1744 |
self halt:'no reference'. |
|
1745 |
||
1746 |
"Created: / 2.2.1998 / 23:46:12 / cg" |
|
3275
0ecdf7a69acf
better refName (see memoryUsage - ref chain menu action)
Claus Gittinger <cg@exept.de>
parents:
3266
diff
changeset
|
1747 |
"Modified: / 4.2.1998 / 22:03:36 / cg" |
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1748 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
1749 |
|
1288 | 1750 |
sizeOf:anObject |
1751 |
"return the size of anObject in bytes. |
|
1752 |
(this is not the same as 'anObject size'). |
|
1753 |
WARNING: this method is for ST/X debugging only |
|
1754 |
it will be removed without notice" |
|
1755 |
||
1756 |
%{ /* NOCONTEXT */ |
|
1757 |
||
1758 |
RETURN ( __isNonNilObject(anObject) ? __MKSMALLINT(__qSize(anObject)) : __MKSMALLINT(0) ) |
|
1759 |
%} |
|
1760 |
" |
|
1761 |
|hist big nw| |
|
1762 |
||
1763 |
hist := Array new:100 withAll:0. |
|
1764 |
big := 0. |
|
1765 |
ObjectMemory allObjectsDo:[:o | |
|
1766 |
nw := (ObjectMemory sizeOf:o) // 4 + 1. |
|
1767 |
nw > 100 ifTrue:[ |
|
1768 |
big := big + 1 |
|
1769 |
] ifFalse:[ |
|
1770 |
hist at:nw put:(hist at:nw) + 1 |
|
615 | 1771 |
]. |
1772 |
]. |
|
1773 |
hist printNL. |
|
1774 |
big printNL |
|
1775 |
" |
|
1288 | 1776 |
! |
1777 |
||
1778 |
spaceOf:anObject |
|
1779 |
"return the memory space, in which anObject is. |
|
1780 |
- since objects may move between spaces, |
|
1781 |
the returned value may be invalid after the next scavenge/collect. |
|
1782 |
WARNING: this method is for ST/X debugging only |
|
1783 |
it will be removed without notice" |
|
1784 |
||
1785 |
%{ /* NOCONTEXT */ |
|
1786 |
||
1787 |
if (! __isNonNilObject(anObject)) { |
|
1788 |
RETURN ( nil ); |
|
1789 |
} |
|
1790 |
RETURN ( __MKSMALLINT( __qSpace(anObject) ) ); |
|
1791 |
%} |
|
375 | 1792 |
! ! |
1793 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1794 |
!ObjectMemory class methodsFor:'debugging ST/X'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1795 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1796 |
printPolyCaches |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1797 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1798 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1799 |
"dump poly caches. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1800 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1801 |
it will be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1802 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1803 |
__dumpILCCaches(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1804 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1805 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1806 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1807 |
ObjectMemory printPolyCaches |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1808 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1809 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1810 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1811 |
printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1812 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1813 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1814 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1815 |
(You may turn off the stack print with debugPrinting:false) |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1816 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1817 |
it will be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1818 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1819 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1820 |
__printStack(__context); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1821 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1822 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1823 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1824 |
ObjectMemory printStackBacktrace |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1825 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1826 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1827 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1828 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1829 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1830 |
printStackBacktraceFrom:aContext |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1831 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1832 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1833 |
"print a stack backtrace - then continue. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1834 |
(You may turn off the stack print with debugPrinting:false) |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1835 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1836 |
it will be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1837 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1838 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1839 |
__printStack(aContext); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1840 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1841 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1842 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1843 |
ObjectMemory printStackBacktraceFrom:thisContext sender sender |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1844 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1845 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1846 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1847 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1848 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1849 |
printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1850 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1851 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1852 |
"dump the internal symbol table. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1853 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1854 |
it will be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1855 |
%{ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1856 |
#ifdef DEBUG |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1857 |
__dumpSymbols(); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1858 |
#endif |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1859 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1860 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1861 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1862 |
ObjectMemory printSymbols |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1863 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1864 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1865 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1866 |
sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1867 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1868 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1869 |
"turns tracing of message sends off. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1870 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1871 |
it may be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1872 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1873 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1874 |
__setMessageTrace__(0); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1875 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1876 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1877 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1878 |
ObjectMemory sendTraceOff |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1879 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1880 |
! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1881 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1882 |
sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1883 |
"{ Pragma: +optSpace }" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1884 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1885 |
"turns tracing of message sends on. |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1886 |
WARNING: this method is for debugging only |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1887 |
it may be removed without notice" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1888 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1889 |
%{ /* NOCONTEXT */ |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1890 |
__setMessageTrace__(1); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1891 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1892 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1893 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1894 |
ObjectMemory sendTraceOn |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1895 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1896 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
1897 |
|
1767 | 1898 |
!ObjectMemory class methodsFor:'dependents access'! |
10 | 1899 |
|
1288 | 1900 |
dependents |
3223 | 1901 |
"return the collection of my dependents" |
1288 | 1902 |
|
3057
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
1903 |
^ Dependents ? #() |
f9199215f9b0
dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents:
2924
diff
changeset
|
1904 |
|
3223 | 1905 |
"Modified: / 26.1.1998 / 11:17:59 / cg" |
10 | 1906 |
! |
1907 |
||
1288 | 1908 |
dependents:aCollection |
10 | 1909 |
"set the dependents collection" |
1910 |
||
1911 |
Dependents := aCollection |
|
1288 | 1912 |
! |
1913 |
||
1914 |
dependentsDo:aBlock |
|
1915 |
"evaluate aBlock for all of my dependents. |
|
1916 |
Since this is performed at startup time (under the scheduler), |
|
1917 |
this is redefined here to catch abort signals. |
|
1918 |
Thus, if any error occurs in a #returnFromSnapshot, |
|
1919 |
the user can press abort to continue." |
|
1920 |
||
1921 |
|deps| |
|
1922 |
||
1923 |
deps := Dependents. |
|
1924 |
deps notNil ifTrue:[ |
|
1925 |
deps do:[:each | |
|
1926 |
AbortSignal handle:[:ex | |
|
1927 |
ex return |
|
1928 |
] do:[ |
|
282 | 1929 |
aBlock value:each |
1930 |
] |
|
1931 |
] |
|
1932 |
] |
|
1288 | 1933 |
! ! |
1934 |
||
1767 | 1935 |
!ObjectMemory class methodsFor:'enumerating'! |
1288 | 1936 |
|
1937 |
allInstancesOf:aClass do:aBlock |
|
1938 |
"evaluate the argument, aBlock for all instances of aClass in the system. |
|
1939 |
There is one caveat: if a compressing oldSpace collect |
|
1940 |
occurs while looping over the objects, the loop cannot be |
|
1941 |
continued (for some internal reasons). In this case, false |
|
1942 |
is returned." |
|
1943 |
||
1944 |
|work| |
|
1945 |
||
1946 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1947 |
__nonTenuringScavenge(__context); |
|
1948 |
/* |
|
1949 |
* allInstancesDo needs a temporary to hold newSpace objects |
|
1950 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1951 |
if (__allInstancesOfDo(&aClass, &aBlock, &work) < 0) { |
159 | 1952 |
RETURN (false); |
85 | 1953 |
} |
1954 |
%}. |
|
1955 |
^ true |
|
2 | 1956 |
! |
1957 |
||
1288 | 1958 |
allObjectsDo:aBlock |
1959 |
"evaluate the argument, aBlock for all objects in the system. |
|
1960 |
There is one caveat: if a compressing oldSpace collect |
|
1961 |
occurs while looping over the objects, the loop cannot be |
|
1962 |
continued (for some internal reasons). In this case, false |
|
1963 |
is returned." |
|
1964 |
||
1965 |
|work| |
|
1966 |
||
1967 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1968 |
__nonTenuringScavenge(__context); |
|
1969 |
/* |
|
1970 |
* allObjectsDo needs a temporary to hold newSpace objects |
|
1971 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1972 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, &work) < 0) { |
615 | 1973 |
RETURN (false); |
1974 |
} |
|
1975 |
%}. |
|
1976 |
^ true |
|
1288 | 1977 |
! |
1978 |
||
3266 | 1979 |
allObjectsIncludingContextsDo:aBlock |
1980 |
"like allObjectsDo, but also walks over all contexts |
|
1981 |
of living processes" |
|
1982 |
||
1983 |
self allObjectsDo:aBlock. |
|
1984 |
ProcessorScheduler knownProcesses do:[:p | |
|
1985 |
|con| |
|
1986 |
||
1987 |
con := p suspendedContext. |
|
1988 |
[con notNil] whileTrue:[ |
|
1989 |
aBlock value:con. |
|
1990 |
con := con sender. |
|
1991 |
]. |
|
1992 |
]. |
|
1993 |
||
1994 |
"Created: / 3.2.1998 / 11:32:08 / cg" |
|
1995 |
! |
|
1996 |
||
1288 | 1997 |
allOldObjectsDo:aBlock |
1998 |
"evaluate the argument, aBlock for all old objects in the system. |
|
1999 |
For debugging and tests only - do not use" |
|
2000 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2001 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, (OBJ *)0) < 0) { |
1288 | 2002 |
RETURN (false); |
2003 |
} |
|
2004 |
%}. |
|
2005 |
^ true |
|
3277
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2006 |
! |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2007 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2008 |
processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2009 |
"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
|
2010 |
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
|
2011 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2012 |
%{ |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2013 |
extern OBJ __processesKnownInVM(); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2014 |
|
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2015 |
RETURN (__processesKnownInVM()); |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2016 |
%} |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2017 |
" |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2018 |
ObjectMemory processesKnownInVM |
35bc5ebe73ce
now, also track references from the (hidden) processes
Claus Gittinger <cg@exept.de>
parents:
3275
diff
changeset
|
2019 |
" |
1 | 2020 |
! ! |
2021 |
||
1767 | 2022 |
!ObjectMemory class methodsFor:'garbage collection'! |
615 | 2023 |
|
3725
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2024 |
backgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2025 |
"return the backgroundCollectProcess (or nil, if noone is running)" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2026 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2027 |
^ BackgroundCollectProcess |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2028 |
|
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2029 |
"Created: / 4.8.1998 / 01:54:16 / cg" |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2030 |
! |
b50bfa6fdbca
added accessors for BackgroundCollectProcess and
Claus Gittinger <cg@exept.de>
parents:
3699
diff
changeset
|
2031 |
|
1288 | 2032 |
backgroundCollectorRunning |
2033 |
"return true, if a backgroundCollector is running" |
|
2034 |
||
2035 |
^ BackgroundCollectProcess notNil |
|
500 | 2036 |
|
2037 |
" |
|
615 | 2038 |
ObjectMemory backgroundCollectorRunning |
375 | 2039 |
" |
2040 |
! |
|
2041 |
||
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2042 |
compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2043 |
"COMPRESS the oldSpace memory area. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2044 |
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
|
2045 |
be slightly slower than the semispace compress if lots of real memory |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2046 |
is available. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2047 |
In memory limited systems, this inplace compress is usually preferable. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2048 |
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
|
2049 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2050 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2051 |
This can take a long time." |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2052 |
%{ |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2053 |
__compressOldSpace(__context); |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2054 |
%} |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2055 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2056 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2057 |
ObjectMemory compressOldSpace |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2058 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2059 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2060 |
Transcript showCR:(Time millisecondsToRun:[ |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2061 |
ObjectMemory markAndSweep. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2062 |
ObjectMemory compressOldSpace. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2063 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2064 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2065 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2066 |
Transcript showCR:(Time millisecondsToRun:[ |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2067 |
ObjectMemory compressingGarbageCollect. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2068 |
]). |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2069 |
" |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2070 |
|
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2071 |
! |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2072 |
|
1288 | 2073 |
compressingGarbageCollect |
2074 |
"search for and free garbage in the oldSpace (newSpace is cleaned automatically) |
|
2075 |
performing a COMPRESSING garbage collect. |
|
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2076 |
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
|
2077 |
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
|
2078 |
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
|
2079 |
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
|
2080 |
small number. |
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2081 |
|
1288 | 2082 |
This can take a long time - especially, if paging is involved |
2083 |
(when no paging is involved, its faster than I thought :-). |
|
2084 |
If no memory is available for the compress, or the system has been started with |
|
2085 |
the -Msingle option, this does a non-COMPRESSING collect." |
|
2086 |
%{ |
|
2087 |
if (! __garbageCollect(__context)) { |
|
3646
42a4c18146a2
added #compressOldSpace method - a 2-pass inplace compress.
Claus Gittinger <cg@exept.de>
parents:
3643
diff
changeset
|
2088 |
__markAndSweep(__context); |
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2089 |
RETURN (false); |
178 | 2090 |
} |
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2091 |
RETURN (true); |
1 | 2092 |
%} |
2093 |
||
93 | 2094 |
" |
375 | 2095 |
ObjectMemory compressingGarbageCollect |
93 | 2096 |
" |
2097 |
! |
|
2098 |
||
1288 | 2099 |
garbageCollect |
2100 |
"search for and free garbage in the oldSpace. |
|
2101 |
This can take a long time - especially, if paging is involved." |
|
2102 |
||
2103 |
"/ used to be |
|
2104 |
"/ self compressingGarbageCollect |
|
2105 |
"/ here; changed to default to markAndSweep |
|
615 | 2106 |
|
2107 |
self markAndSweep |
|
1 | 2108 |
|
93 | 2109 |
" |
615 | 2110 |
ObjectMemory garbageCollect |
375 | 2111 |
" |
2112 |
! |
|
2113 |
||
1288 | 2114 |
gcStep |
2115 |
"one incremental garbage collect step. |
|
2116 |
Mark or sweep some small number of objects. This |
|
2117 |
method will return after a reasonable (short) time. |
|
2118 |
This is used by the ProcessorScheduler at idle times. |
|
2119 |
Returns true, if an incremental GC cycle has finished." |
|
2120 |
%{ |
|
2121 |
extern int __incrGCstep(); |
|
133 | 2122 |
|
2123 |
RETURN (__incrGCstep(__context) ? true : false); |
|
1 | 2124 |
%} |
2125 |
! |
|
2126 |
||
1288 | 2127 |
gcStepIfUseful |
2128 |
"If either the IncrementalGCLimit or the FreeSpaceGCLimits have been |
|
2129 |
reached, perform one incremental garbage collect step. |
|
2130 |
Return true, if more gcSteps are required to finish the cycle, |
|
2131 |
false if done with a gc round. |
|
2132 |
If no limit has been reached yet, do nothing and return false. |
|
2133 |
This is called by the ProcessorScheduler at idle times or by the |
|
2134 |
backgroundCollector." |
|
2135 |
||
2136 |
|done limit| |
|
2137 |
||
2138 |
AbortSignal handle:[:ex | |
|
1768 | 2139 |
"/ in case of abort (from the debugger), |
2140 |
"/ disable gcSteps. |
|
2141 |
done := true. |
|
2142 |
IncrementalGCLimit := FreeSpaceGCLimit := nil. |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
2143 |
'ObjectMemory [error]: IGC aborted; turning off incremental GC' errorPrintCR |
1288 | 2144 |
] do:[ |
1768 | 2145 |
limit := IncrementalGCLimit. |
2146 |
(limit notNil and:[self oldSpaceAllocatedSinceLastGC > limit]) ifTrue:[ |
|
3761 | 2147 |
"/ 'IGC [info]: start since allocatedSinceLastGC > IncrementalGCLimit' infoPrintCR. |
1768 | 2148 |
done := ObjectMemory gcStep |
2149 |
] ifFalse:[ |
|
2150 |
limit := FreeSpaceGCLimit. |
|
2151 |
(limit notNil and:[(self freeSpace + self freeListSpace) < limit]) ifTrue:[ |
|
3761 | 2152 |
"/ 'IGC [info]: start since freeSpace < FreeSpaceGCLimit' infoPrintCR. |
1768 | 2153 |
done := ObjectMemory gcStep. |
2154 |
done ifTrue:[ |
|
2155 |
self moreOldSpaceIfUseful |
|
2156 |
]. |
|
2157 |
] ifFalse:[ |
|
2158 |
limit := DynamicCodeGCTrigger. |
|
2159 |
(limit notNil and:[self compiledCodeCounter > limit]) ifTrue:[ |
|
3761 | 2160 |
"/ 'IGC [info]: start since compiledCodeCounter > DynamicCodeGCTrigger' infoPrintCR. |
1768 | 2161 |
done := ObjectMemory gcStep. |
2162 |
] ifFalse:[ |
|
2163 |
limit := DynamicCodeLimit. |
|
2164 |
(limit notNil and:[self compiledCodeSpaceUsed > limit]) ifTrue:[ |
|
3761 | 2165 |
"/ 'IGC [info]: start since compiledCodeSpaceUsed > DynamicCodeLimit' infoPrintCR. |
1768 | 2166 |
done := ObjectMemory gcStep. |
2167 |
] ifFalse:[ |
|
2168 |
done := true |
|
2169 |
] |
|
2170 |
] |
|
2171 |
] |
|
2172 |
]. |
|
615 | 2173 |
]. |
2174 |
^ done not |
|
1768 | 2175 |
|
3761 | 2176 |
"Modified: / 14.8.1998 / 13:08:15 / cg" |
615 | 2177 |
! |
2178 |
||
1288 | 2179 |
incrementalGC |
2180 |
"perform one round of incremental GC steps. |
|
2181 |
The overall effect of this method is (almost) the same as calling |
|
2182 |
markAndSweep. However, #incrementalGC is interruptable while #markAndSweep |
|
2183 |
is atomic and blocks for a while. The code here performs incremental |
|
2184 |
GC steps, until one complete gc-cycle is completed. If running at a higher |
|
2185 |
than userBackground priority, it will give up the CPU after every such |
|
2186 |
step for a while. |
|
2187 |
Thus this method can be called either from a low prio (background) process |
|
2188 |
or from a high prio process. |
|
2189 |
(however, if you have nothing else to do, its better to call for markAndSweep, |
|
2190 |
since it is faster) |
|
2191 |
For example, someone allocating huge amounts of memory could |
|
2192 |
ask for the possibility of a quick allocation using |
|
2193 |
#checkForFastNew: and try a #incrementalGC if not. In many |
|
2194 |
cases, this can avoid a pause (in the higher prio processes) due to |
|
2195 |
a blocking GC." |
|
2196 |
||
1669 | 2197 |
|delay| |
1288 | 2198 |
|
2199 |
Processor activeProcess priority > Processor userBackgroundPriority ifTrue:[ |
|
3108 | 2200 |
delay := Delay forMilliseconds:1 |
1288 | 2201 |
]. |
2202 |
||
3742 | 2203 |
((self incrementalGCPhaseSymbolic ~~ #idle) |
2204 |
or:[self gcStepIfUseful]) ifTrue:[ |
|
3108 | 2205 |
[self gcStep] whileFalse:[ |
2206 |
delay notNil ifTrue:[delay wait] |
|
2207 |
] |
|
1288 | 2208 |
]. |
2209 |
self moreOldSpaceIfUseful |
|
2210 |
||
2211 |
" |
|
2212 |
ObjectMemory incrementalGC |
|
2213 |
[ObjectMemory incrementalGC] forkAt:3 |
|
403 | 2214 |
[ObjectMemory incrementalGC] forkAt:9 |
133 | 2215 |
" |
3108 | 2216 |
|
3742 | 2217 |
"Modified: / 10.8.1998 / 15:03:07 / cg" |
194 | 2218 |
! |
2219 |
||
1288 | 2220 |
markAndSweep |
2221 |
"mark/sweep garbage collector. |
|
2222 |
perform a full mark&sweep collect. |
|
2223 |
Warning: this may take some time and it is NOT interruptable. |
|
2224 |
If you want to do a collect from a background process, or have |
|
2225 |
other things to do, better use #incrementalGC which is interruptable." |
|
615 | 2226 |
%{ |
2227 |
__markAndSweep(__context); |
|
2228 |
%} |
|
194 | 2229 |
|
2230 |
" |
|
615 | 2231 |
ObjectMemory markAndSweep |
2232 |
" |
|
2233 |
! |
|
2234 |
||
1288 | 2235 |
reclaimSymbols |
2236 |
"reclaim unused symbols; |
|
2237 |
Unused symbols are (currently) not reclaimed automatically, |
|
2238 |
but only upon request with this method. |
|
2239 |
It takes some time to do this ... and it is NOT interruptable. |
|
2240 |
Future versions may do this automatically, while garbage collecting." |
|
615 | 2241 |
%{ |
2242 |
__reclaimSymbols(__context); |
|
2243 |
%} |
|
2244 |
" |
|
2245 |
ObjectMemory reclaimSymbols |
|
2246 |
" |
|
2247 |
! |
|
2248 |
||
1288 | 2249 |
scavenge |
2250 |
"collect young objects, without aging (i.e. no tenure). |
|
2251 |
Can be used to quickly get rid of shortly before allocated |
|
2252 |
stuff. This is relatively fast (compared to oldspace collect). |
|
2253 |
||
2254 |
An example where a non-tenuring scavenge makes sense is when |
|
2255 |
allocating some OperatingSystem resource (a Color, File or View) |
|
2256 |
and the OS runs out of resources. In this case, the scavenge may |
|
2257 |
free some ST-objects and therefore (by signalling the WeakArrays |
|
2258 |
or Registries) free the OS resources too. |
|
2259 |
Of course, only recently allocated resources will be freed this |
|
2260 |
way. If none was freed, a full collect will be needed." |
|
615 | 2261 |
%{ |
2262 |
__nonTenuringScavenge(__context); |
|
2263 |
%} |
|
2264 |
||
2265 |
" |
|
2266 |
ObjectMemory scavenge |
|
194 | 2267 |
" |
207 | 2268 |
! |
2269 |
||
1288 | 2270 |
startBackgroundCollectorAt:aPriority |
2271 |
"start a process doing incremental GC in the background. |
|
2272 |
Use this, if you have suspendable background processes which |
|
2273 |
run all the time, and therefore would prevent the idle-collector |
|
2274 |
from running. See documentation in this class for more details." |
|
2275 |
||
2276 |
|p| |
|
2277 |
||
2278 |
"/ |
|
2279 |
"/ its not useful, to run it more than once |
|
2280 |
"/ |
|
2281 |
BackgroundCollectProcess notNil ifTrue:[ |
|
2258 | 2282 |
BackgroundCollectProcess priority:aPriority. |
2283 |
^ self |
|
1288 | 2284 |
]. |
2285 |
||
2286 |
p := |
|
2258 | 2287 |
[ |
2288 |
[ |
|
3742 | 2289 |
|myDelay timeOfLastGC doGC| |
2258 | 2290 |
|
2291 |
myDelay := Delay forSeconds:5. |
|
3733 | 2292 |
timeOfLastGC := AbsoluteTime now. |
2258 | 2293 |
|
2294 |
[true] whileTrue:[ |
|
3742 | 2295 |
doGC := self gcStepIfUseful. |
2296 |
doGC ifFalse:[ |
|
2297 |
(BackgroundCollectMaximumInterval notNil |
|
2298 |
and:[(AbsoluteTime now - timeOfLastGC) > BackgroundCollectMaximumInterval]) |
|
2299 |
ifTrue:[ |
|
3743 | 2300 |
"/ 'ObjectMemory [info]: start time-triggered background collect.' infoPrintCR. |
3742 | 2301 |
doGC := true. |
2302 |
] |
|
2303 |
]. |
|
2304 |
||
2305 |
doGC ifTrue:[ |
|
3761 | 2306 |
"/ |
2307 |
"/ perform a full cycle (finish cycle) |
|
2308 |
"/ |
|
3742 | 2309 |
[self gcStep] whileFalse:[]. |
3761 | 2310 |
"/ |
2311 |
"/ increase oldSpace, if freeSpace is below limits. |
|
2312 |
"/ |
|
2313 |
self moreOldSpaceIfUseful. |
|
3733 | 2314 |
timeOfLastGC := AbsoluteTime now. |
2258 | 2315 |
]. |
3761 | 2316 |
"/ |
2317 |
"/ wait a bit |
|
2318 |
"/ |
|
3733 | 2319 |
myDelay wait. |
2258 | 2320 |
] |
2321 |
] valueOnUnwindDo:[ |
|
2322 |
BackgroundCollectProcess := nil |
|
2323 |
] |
|
2324 |
] newProcess. |
|
1288 | 2325 |
p name:'background collector'. |
2326 |
p priority:aPriority. |
|
2327 |
p restartable:true. |
|
3733 | 2328 |
p beGroupLeader. |
1288 | 2329 |
p resume. |
2330 |
BackgroundCollectProcess := p |
|
2331 |
||
2332 |
" |
|
2333 |
the following lets the backgroundCollector run at prio 5 |
|
2334 |
whenever 100000 bytes have been allocated, OR freeSpace drops |
|
2335 |
below 1meg. Having the system keep 1meg as reserve for peak allocation. |
|
2336 |
||
2337 |
Doing this may reduce pauses due to inevitable collects when running |
|
2338 |
out of freeSpace, if the collector can keep up with allocation rate. |
|
2339 |
" |
|
2340 |
||
2341 |
" |
|
2258 | 2342 |
ObjectMemory stopBackgroundCollector. |
2343 |
||
1288 | 2344 |
ObjectMemory incrementalGCLimit:100000. |
2345 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
2258 | 2346 |
ObjectMemory startBackgroundCollectorAt:5. |
211 | 2347 |
" |
2258 | 2348 |
|
3761 | 2349 |
"Modified: / 14.8.1998 / 13:09:19 / cg" |
207 | 2350 |
! |
2351 |
||
1288 | 2352 |
stopBackgroundCollector |
2353 |
"stop the background collector" |
|
2354 |
||
2355 |
BackgroundCollectProcess notNil ifTrue:[ |
|
2356 |
BackgroundCollectProcess terminate. |
|
2357 |
BackgroundCollectProcess := nil |
|
207 | 2358 |
] |
293 | 2359 |
|
211 | 2360 |
" |
2361 |
ObjectMemory stopBackgroundCollector |
|
2362 |
" |
|
362 | 2363 |
! |
2364 |
||
1288 | 2365 |
tenure |
2366 |
"force all living new stuff into old-space - effectively making |
|
2367 |
all living young objects become old objects immediately. |
|
2368 |
This is relatively fast (compared to oldspace collect). |
|
2369 |
||
2370 |
This method should only be used in very special situations: |
|
2371 |
for example, when building up some long-living data structure |
|
2372 |
in a time critical application. |
|
2373 |
To do so, you have to do a scavenge followed by a tenure after the |
|
2374 |
objects are created. Be careful, to not reference any other chunk- |
|
2375 |
data when calling for a tenure (this will lead to lots of garbage in |
|
2376 |
the oldspace). |
|
2377 |
In normal situations, explicit tenures are not needed." |
|
2378 |
%{ |
|
2379 |
__tenure(__context); |
|
2380 |
%} |
|
2381 |
||
2382 |
" |
|
2383 |
ObjectMemory tenure |
|
2384 |
" |
|
2385 |
" |
|
2386 |
... build up long living objects ... |
|
2387 |
ObjectMemory scavenge. |
|
2388 |
ObjectMemory tenure |
|
615 | 2389 |
... continue - objects created above are now in oldSpace ... |
2390 |
" |
|
2391 |
! |
|
2392 |
||
1288 | 2393 |
tenuringScavenge |
2394 |
"collect newspace stuff, with aging (i.e. objects old enough |
|
2395 |
will be moved into the oldSpace). |
|
2396 |
Use this for debugging and testing only - the system performs |
|
2397 |
this automatically when the newspace fills up. |
|
2398 |
This is relatively fast (compared to oldspace collect)" |
|
615 | 2399 |
%{ |
2400 |
__scavenge(__context); |
|
2401 |
%} |
|
2402 |
||
2403 |
" |
|
2404 |
ObjectMemory tenuringScavenge |
|
2405 |
" |
|
1288 | 2406 |
! |
2407 |
||
2403 | 2408 |
verboseCompactingGC |
2409 |
"ST80 compatibility; same as verboseGarbageCollect" |
|
2410 |
||
2411 |
self verboseGarbageCollect |
|
2412 |
! |
|
2413 |
||
1288 | 2414 |
verboseGarbageCollect |
2415 |
"perform a compressing garbage collect and show some informational |
|
2416 |
output on the Transcript" |
|
2417 |
||
2418 |
|nBytesBefore nReclaimed value unit| |
|
2419 |
||
2420 |
nBytesBefore := self oldSpaceUsed. |
|
3648
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2421 |
|
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2422 |
"/ try 1pass baker collect first. |
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2423 |
"/ this will fail if oldSpace size is above compressLimit |
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2424 |
(self compressingGarbageCollect) ifFalse:[ |
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2425 |
"/ fallBack - use 2pass inplace compress |
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2426 |
self compressOldSpace |
a6da5ea8a7df
fallBack to 2pass compress in #verboseGarbageCollect.
Claus Gittinger <cg@exept.de>
parents:
3647
diff
changeset
|
2427 |
]. |
3649 | 2428 |
|
2429 |
"/ show what we reclaimed |
|
1288 | 2430 |
nReclaimed := nBytesBefore - self oldSpaceUsed. |
2431 |
nReclaimed > 0 ifTrue:[ |
|
1418 | 2432 |
nReclaimed > 1024 ifTrue:[ |
2433 |
nReclaimed > (1024 * 1024) ifTrue:[ |
|
3649 | 2434 |
value := nReclaimed * 10 // (1024 * 1024) / 10.0. |
1418 | 2435 |
unit := ' Mb.' |
2436 |
] ifFalse:[ |
|
2437 |
value := nReclaimed // 1024. |
|
2438 |
unit := ' Kb.' |
|
2439 |
] |
|
2440 |
] ifFalse:[ |
|
2441 |
value := nReclaimed. |
|
2442 |
unit := ' bytes.' |
|
2443 |
]. |
|
3649 | 2444 |
Transcript show:'reclaimed '; show:value. |
1418 | 2445 |
Transcript showCR:unit |
1288 | 2446 |
] |
2447 |
||
2448 |
" |
|
2449 |
ObjectMemory verboseGarbageCollect |
|
2450 |
" |
|
1418 | 2451 |
|
3649 | 2452 |
"Modified: / 15.7.1998 / 13:28:05 / cg" |
2403 | 2453 |
! |
2454 |
||
2455 |
verboseGlobalCompactingGC |
|
2456 |
"ST80 compatibility; same as verboseGarbageCollect" |
|
2457 |
||
2458 |
self verboseGarbageCollect |
|
178 | 2459 |
! ! |
2460 |
||
1767 | 2461 |
!ObjectMemory class methodsFor:'garbage collector control'! |
133 | 2462 |
|
1288 | 2463 |
announceOldSpaceNeed:howMuch |
2464 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
2465 |
soon, which is going to live longer (whatever that means). |
|
2466 |
It first checks if the memory can be allocated without forcing a compressing |
|
2467 |
GC. If not, the oldSpace is increased. This may also lead to a slow compressing |
|
2468 |
collect. However, many smaller increases are avoided afterwards. Calling this |
|
2469 |
method before allocating huge chunks of data may provide better overall performance. |
|
2470 |
Notice: this is a nonstandard interface - use only in special situations." |
|
2471 |
||
2472 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2473 |
self incrementalGC. |
|
2474 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2475 |
self moreOldSpace:howMuch |
|
615 | 2476 |
] |
2477 |
] |
|
310 | 2478 |
|
2479 |
" |
|
615 | 2480 |
ObjectMemory announceOldSpaceNeed:1000000 |
133 | 2481 |
" |
2482 |
! |
|
2483 |
||
1288 | 2484 |
announceSpaceNeed:howMuch |
2485 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
2486 |
soon. The VM tries to prepare itself for this allocation to be performed |
|
2487 |
with less overhead. For example, it could preallocate some memory in one |
|
2488 |
big chunk (instead of doing many smaller reallocations later). |
|
2489 |
Notice: this is a nonstandard interface - use only in special situations. |
|
2490 |
Also, this does a background collect before the big chunk of memory is |
|
2491 |
allocated, not locking other processes while doing so." |
|
2492 |
||
2493 |
(howMuch < (self newSpaceSize // 2)) ifTrue:[ |
|
2494 |
self scavenge. |
|
2495 |
]. |
|
2496 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2497 |
(howMuch > (self newSpaceSize // 2)) ifFalse:[ |
|
2498 |
self scavenge. |
|
2499 |
]. |
|
2500 |
self incrementalGC. |
|
2501 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
2502 |
self moreOldSpace:howMuch |
|
202 | 2503 |
] |
2504 |
] |
|
2505 |
||
2506 |
" |
|
2507 |
ObjectMemory announceSpaceNeed:100000 |
|
2508 |
" |
|
2509 |
! |
|
2510 |
||
1288 | 2511 |
avoidTenure:flag |
2512 |
"set/clear the avoidTenure flag. If set, aging of newSpace is turned off |
|
2513 |
as long as the newSpace fill-grade stays below some magic high-water mark. |
|
2514 |
If off (the default), aging is done as usual. |
|
2515 |
If the flag is turned on, scavenge may be a bit slower, due to more |
|
2516 |
objects being copied around. However, chances are high that in an idle |
|
2517 |
or (almost idle) system, less objects are moved into oldSpace. |
|
2518 |
Therefore, this helps to avoid oldSpace colelcts, in systems which go into |
|
2519 |
some standby mode and are reactivated by some external event. |
|
2520 |
(the avoid-flag should be turned off there, and set again once the idle loop |
|
2521 |
is reentered). |
|
2522 |
||
2523 |
This is an EXPERIMENTAL interface." |
|
178 | 2524 |
|
2525 |
%{ /* NOCONTEXT */ |
|
615 | 2526 |
__avoidTenure(flag == true ? 1 : 0); |
133 | 2527 |
%} |
2528 |
! |
|
2529 |
||
1288 | 2530 |
checkForFastNew:amount |
2531 |
"this method returns true, if amount bytes could be allocated |
|
2532 |
quickly (i.e. without forcing a full GC or compress). |
|
2533 |
This can be used for smart background processes, which want to |
|
2534 |
allocate big chunks of data without disturbing foreground processes |
|
2535 |
too much. Such a process would check for fast-allocation, and perform |
|
2536 |
incremental GC-steps if required. Thus, avoiding the long blocking pause |
|
2537 |
due to a forced (non-incremental) GC. |
|
2538 |
Especially: doing so will not block higher priority foreground processes. |
|
2539 |
See an example use in Behavior>>niceBasicNew:. |
|
2540 |
This is experimental and not guaranteed to be in future versions." |
|
2541 |
||
2542 |
%{ /* NOCONTEXT */ |
|
2543 |
extern int __checkForFastNew(); |
|
2544 |
||
2545 |
if (__isSmallInteger(amount)) { |
|
2546 |
if (! __checkForFastNew(__intVal(amount))) { |
|
2547 |
RETURN (false); |
|
2548 |
} |
|
2549 |
} |
|
2550 |
||
2551 |
%}. |
|
2552 |
^ true |
|
178 | 2553 |
! |
2554 |
||
1768 | 2555 |
dynamicCodeGCTrigger |
2556 |
"return the dynamic code trigger limit for incremental GC activation. |
|
2557 |
The system will start doing incremental background GC, whenever this amount |
|
2558 |
of code was dynamically generated. |
|
2559 |
The default is nil; which disables this trigger" |
|
2560 |
||
2561 |
^ DynamicCodeGCTrigger |
|
2562 |
||
2563 |
" |
|
2564 |
ObjectMemory dynamicCodeGCTrigger |
|
2565 |
" |
|
2566 |
||
2567 |
"Created: 16.10.1996 / 17:42:01 / cg" |
|
2568 |
! |
|
2569 |
||
2570 |
dynamicCodeGCTrigger:numberOfBytesOrNil |
|
2571 |
"set the dynamic code trigger limit for incremental GC activation. |
|
2572 |
The system will start doing incremental background GC, whenever this amount |
|
2573 |
of code was dynamically generated. |
|
2574 |
The default is nil; which disables this trigger" |
|
2575 |
||
2576 |
DynamicCodeGCTrigger := numberOfBytesOrNil |
|
2577 |
||
2578 |
" |
|
2579 |
ObjectMemory dynamicCodeGCTrigger:50000 |
|
2580 |
" |
|
2581 |
||
2582 |
"Created: 16.10.1996 / 17:42:29 / cg" |
|
2583 |
! |
|
2584 |
||
2585 |
dynamicCodeLimit |
|
2586 |
"return the dynamic code limit. |
|
2587 |
The system will start doing incremental background GC, whenever this amount |
|
2588 |
of code has been generated (overall), and start to flush the code cache, |
|
2589 |
if (after the GC), more code is still allocated. |
|
2590 |
The default is nil; which disables this trigger" |
|
2591 |
||
1781 | 2592 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 2593 |
^ DynamicCodeLimit |
2594 |
||
2595 |
" |
|
2596 |
ObjectMemory dynamicCodeLimit |
|
2597 |
" |
|
2598 |
||
2599 |
"Created: 16.10.1996 / 17:43:37 / cg" |
|
2600 |
! |
|
2601 |
||
2602 |
dynamicCodeLimit:nBytesOrNil |
|
2603 |
"set the dynamic code limit. |
|
2604 |
The system will start doing incremental background GC, whenever this amount |
|
2605 |
of code has been generated (overall), and start to flush the code cache, |
|
2606 |
if (after the GC), more code is still allocated. |
|
2607 |
The default is nil; which disables this trigger" |
|
2608 |
||
1770 | 2609 |
DynamicCodeLimit := nBytesOrNil. |
2610 |
self setCompiledCodeLimit:nBytesOrNil. |
|
1768 | 2611 |
|
2612 |
" |
|
2613 |
ObjectMemory dynamicCodeLimit:100000 |
|
2614 |
" |
|
2615 |
||
2616 |
"Created: 16.10.1996 / 17:43:58 / cg" |
|
1770 | 2617 |
"Modified: 16.10.1996 / 19:30:46 / cg" |
1768 | 2618 |
! |
2619 |
||
1288 | 2620 |
fastMoreOldSpaceAllocation:aBoolean |
2621 |
"this method turns on/off fastMoreOldSpace allocation. |
|
2622 |
By default, this is turned off (false), which means that in case of |
|
2623 |
a filled-up oldSpace, a GC is tried first before more oldSpace is allocated. |
|
2624 |
This strategy is ok for the normal operation of the system, |
|
2625 |
but behaves badly, if the program allocates huge data structures (say a |
|
2626 |
game tree of 30Mb in size) which survives and therefore will not be reclaimed |
|
2627 |
by a GC. |
|
2628 |
Of course while building this tree, and the memory becomes full, the system |
|
2629 |
would not know in advance, that the GC will not reclaim anything. |
|
2630 |
||
2631 |
Setting fastOldSpaceIncrement to true will avoid this, by forcing the |
|
2632 |
memory system to allocate more memory right away, without doing a GC first. |
|
2633 |
||
2634 |
WARNING: make certain that this flag is turned off, after your huge data |
|
2635 |
is allocated, since otherwise the system may continue to increase its |
|
2636 |
virtual memory without ever checking for garbage. |
|
2637 |
This method returns the previous value of the flag; typically this return |
|
2638 |
value should be used to switch back." |
|
2639 |
||
2640 |
%{ /* NOCONTEXT */ |
|
2641 |
extern int __fastMoreOldSpaceAllocation(); |
|
2642 |
||
2643 |
RETURN (__fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false); |
|
2644 |
%} |
|
2645 |
" |
|
2646 |
|previousSetting| |
|
2647 |
||
2648 |
previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
2649 |
[ |
|
2650 |
... |
|
2651 |
allocate your huge data |
|
2652 |
... |
|
2653 |
] valueNoOrOnUnwindDo:[ |
|
2654 |
ObjectMemory fastMoreOldSpaceAllocation:previousSetting |
|
2655 |
] |
|
2656 |
" |
|
2657 |
||
2658 |
" |
|
2659 |
|prev this| |
|
2660 |
||
2661 |
prev := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
370 | 2662 |
ObjectMemory fastMoreOldSpaceAllocation:prev. |
2663 |
^ prev |
|
2664 |
" |
|
2665 |
! |
|
2666 |
||
1288 | 2667 |
fastMoreOldSpaceLimit:aNumber |
2668 |
"this method sets and returns the fastMoreOldSpace limit. |
|
2669 |
If fastMoreOldSpaceAllocation is true, and the current oldSpace size is |
|
2670 |
below this limit, the memory manager will NOT do a GC when running out of |
|
2671 |
oldSpace, but instead quickly go ahead increasing the size of the oldSpace. |
|
2672 |
Setting the limit to 0 turns off any limit (i.e. it will continue to |
|
2673 |
increase the oldSpace forwever - actually, until the OS refuses to give us |
|
2674 |
more memory). The returned value is the previous setting of the limit." |
|
2675 |
||
2676 |
%{ /* NOCONTEXT */ |
|
2677 |
extern int __fastMoreOldSpaceLimit(); |
|
2678 |
||
2679 |
if (__isSmallInteger(aNumber)) { |
|
2680 |
RETURN ( __MKSMALLINT( __fastMoreOldSpaceLimit(__intVal(aNumber)))); |
|
2681 |
} |
|
2682 |
%}. |
|
2683 |
self primitiveFailed |
|
2684 |
||
2685 |
" |
|
2686 |
|prev this| |
|
2687 |
||
2688 |
prev := ObjectMemory fastMoreOldSpaceLimit:10*1024*1024. |
|
370 | 2689 |
ObjectMemory fastMoreOldSpaceLimit:prev. |
2690 |
^ prev |
|
2691 |
" |
|
133 | 2692 |
! |
2693 |
||
1288 | 2694 |
freeSpaceGCAmount |
2695 |
"return the amount to be allocated if, after an incrementalGC, |
|
2696 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2697 |
The default is nil, which lets the system compute an abbpropriate value" |
|
615 | 2698 |
|
2699 |
^ FreeSpaceGCAmount |
|
2700 |
||
2701 |
" |
|
2702 |
ObjectMemory freeSpaceGCAmount |
|
2703 |
" |
|
2704 |
! |
|
2705 |
||
1288 | 2706 |
freeSpaceGCAmount:aNumber |
2707 |
"set the amount to be allocated if, after an incrementalGC, |
|
2708 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
2709 |
The amount should be greater than the limit, otherwise the incremental |
|
2710 |
GC may try over and over to get the memory (actually waisting time)." |
|
2711 |
||
2712 |
FreeSpaceGCAmount := aNumber |
|
2713 |
||
2714 |
" |
|
2715 |
the following will try to always keep at least 1meg of free space |
|
2716 |
(in the background) and start to do so, whenever the freeSpace drops |
|
2717 |
below 250k. |
|
2718 |
" |
|
2719 |
" |
|
2720 |
ObjectMemory freeSpaceGCLimit:250000. |
|
2721 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
2722 |
" |
|
2723 |
||
2724 |
" |
|
2725 |
turn it off (i.e. let the system compute an appropriate amount ...) |
|
615 | 2726 |
" |
2727 |
" |
|
2728 |
ObjectMemory freeSpaceGCAmount:nil. |
|
2729 |
" |
|
2730 |
! |
|
2731 |
||
1288 | 2732 |
freeSpaceGCLimit |
2733 |
"return the freeSpace limit for incremental GC activation. |
|
2734 |
The system will start doing incremental background GC, once less than this number |
|
2735 |
of bytes are available in the compact free space. |
|
2736 |
The default is 100000; setting it to nil will turn this trigger off." |
|
615 | 2737 |
|
2738 |
^ FreeSpaceGCLimit |
|
2739 |
||
2740 |
" |
|
2741 |
ObjectMemory freeSpaceGCLimit |
|
2742 |
" |
|
133 | 2743 |
! |
2744 |
||
1288 | 2745 |
freeSpaceGCLimit:aNumber |
2746 |
"set the freeSpace limit for incremental GC activation. |
|
2747 |
The system will start doing incremental background GC, once less than this number |
|
2748 |
of bytes are available for allocation. |
|
2749 |
The default is nil; setting it to nil will turn this trigger off." |
|
2750 |
||
2751 |
FreeSpaceGCLimit := aNumber |
|
2752 |
||
2753 |
" |
|
2754 |
the following will start the incrementalGC (in the background) |
|
2755 |
whenever the freeSpace drops below 1meg of free space |
|
2756 |
" |
|
2757 |
" |
|
2758 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
2759 |
" |
|
2760 |
||
2761 |
" |
|
2762 |
turn it off (i.e. let the system hit the wall ...) |
|
615 | 2763 |
" |
2764 |
" |
|
2765 |
ObjectMemory freeSpaceGCLimit:nil. |
|
2766 |
" |
|
1 | 2767 |
! |
2768 |
||
1288 | 2769 |
incrementalGCLimit |
2770 |
"return the allocatedSinceLastGC limit for incremental GC activation. |
|
2771 |
The system will start doing incremental background GC, once more than this number |
|
2772 |
of bytes have been allocated since the last GC. |
|
2773 |
The default is 500000; setting it to nil will turn this trigger off." |
|
615 | 2774 |
|
2775 |
^ IncrementalGCLimit |
|
2776 |
||
2777 |
" |
|
2778 |
ObjectMemory incrementalGCLimit |
|
2779 |
" |
|
178 | 2780 |
! |
85 | 2781 |
|
1288 | 2782 |
incrementalGCLimit:aNumber |
2783 |
"set the allocatedSinceLastGC limit for incremental GC activation. |
|
2784 |
The system will start doing incremental background GC, once more than this number |
|
2785 |
of bytes have been allocated since the last GC. |
|
2786 |
The default is 500000; setting it to nil will turn this trigger off." |
|
2787 |
||
2788 |
IncrementalGCLimit := aNumber |
|
2789 |
||
2790 |
" |
|
2791 |
ObjectMemory incrementalGCLimit:500000. 'do incr. GC very seldom' |
|
2792 |
ObjectMemory incrementalGCLimit:100000. 'medium' |
|
2793 |
ObjectMemory incrementalGCLimit:10000. 'do incr. GC very often' |
|
615 | 2794 |
ObjectMemory incrementalGCLimit:nil. 'never' |
2795 |
" |
|
370 | 2796 |
! |
2797 |
||
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2798 |
incrementalSweeping:aBoolean |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2799 |
"ineable/disable incremental sweeps during background GC. |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2800 |
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
|
2801 |
used by applications - it may vanish without notice" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2802 |
|
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2803 |
%{ |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2804 |
int rslt; |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2805 |
|
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2806 |
rslt = __incrementalSweeping((aBoolean == true) ? 1 : 0); |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2807 |
RETURN (rslt ? true : false); |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2808 |
%} |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2809 |
" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2810 |
ObjectMemory incrementalSweeping:false. |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2811 |
ObjectMemory incrementalSweeping:true |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2812 |
" |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2813 |
! |
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
2814 |
|
1288 | 2815 |
lockTenure:flag |
2816 |
"set/clear the tenureLock. If the lock is set, the system |
|
2817 |
completely turns off tenuring, and objects remain in newSpace (forever). |
|
2818 |
Once this lock is set, the system operates only in the newSpace and no memory |
|
2819 |
allocations from oldSpace are allowed (except for explicit tenure calls). |
|
2820 |
If any allocation request cannot be resoved, the VM raises a memory interrupt, |
|
2821 |
clears the lockTenure-flag and returns nil. Thus, it automatically falls back into |
|
2822 |
the normal mode of operation, to avoid big trouble |
|
2823 |
(fail to allocate memory when handling the exception). |
|
2824 |
||
2825 |
This interface can be used in applications, which are guaranteed to have their |
|
2826 |
working set completely in the newSpace AND want to limit the worst case |
|
2827 |
pause times to the worst case scavenge time |
|
2828 |
(which itself is limitd by the size of the newSpace). |
|
2829 |
I.e. systems which go into some event loop after initial startup, |
|
2830 |
may turn on the tenureLock to make certain that no oldSpace memory is |
|
2831 |
allocated in the future; thereby limiting any GC activity to newSpace scavenges only. |
|
2832 |
||
2833 |
This is an EXPERIMENTAL interface. |
|
2834 |
" |
|
2835 |
||
2836 |
%{ |
|
2837 |
if (flag == true) { |
|
370 | 2838 |
__tenure(__context); |
2839 |
} |
|
379 | 2840 |
__lockTenure(flag == true ? 1 : 0); |
2841 |
%} |
|
2842 |
! |
|
2843 |
||
1288 | 2844 |
makeOld:anObject |
2845 |
"move anObject into oldSpace. |
|
2846 |
This method is for internal & debugging purposes only - |
|
2847 |
it may vanish. Dont use it." |
|
2848 |
%{ |
|
2849 |
if (__moveToOldSpace(anObject, __context) < 0) { |
|
615 | 2850 |
RETURN (false); |
2851 |
} |
|
2852 |
%}. |
|
2853 |
^ true |
|
2854 |
! |
|
2855 |
||
2337 | 2856 |
maxOldSpace |
2339 | 2857 |
"return the maxOldSpace value. If non-zero, thats the limit for which the |
2858 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 2859 |
If zero, it will allocate forever (until the OS wont hand out more). |
2860 |
The default is zero." |
|
2861 |
||
2862 |
%{ /* NOCONTEXT */ |
|
2863 |
extern unsigned __maxOldSpace(); |
|
2864 |
||
2865 |
RETURN (__MKSMALLINT( __maxOldSpace(-1) )); |
|
2866 |
%} |
|
2867 |
" |
|
2868 |
ObjectMemory maxOldSpace |
|
2869 |
" |
|
2870 |
! |
|
2871 |
||
2872 |
maxOldSpace:amount |
|
2339 | 2873 |
"set the maxOldSpace value. If non-zero, thats the limit for which the |
2874 |
VM will try hard to not allocate more oldSpace memory. (its not a hard limit) |
|
2337 | 2875 |
If zero, it will allocate forever (until the OS wont hand out more). |
2338 | 2876 |
The default is zero. |
2877 |
WARNING: |
|
2339 | 2878 |
an oldSpace limit may lead to trashing due to exorbitant GC activity; |
2879 |
its usually better to let it allocate more and page in/page out. |
|
2880 |
Usually, the background GC will catch up sooner or later and reclaim |
|
2881 |
the memory without blocking the system" |
|
2337 | 2882 |
|
2883 |
%{ /* NOCONTEXT */ |
|
2884 |
extern unsigned __maxOldSpace(); |
|
2885 |
||
2886 |
if (__isSmallInteger(amount)) { |
|
2887 |
RETURN (__MKSMALLINT( __maxOldSpace(__intVal(amount)) )); |
|
2888 |
} |
|
2889 |
%} |
|
2890 |
"to change maximum to 4Megs:" |
|
2891 |
" |
|
2892 |
ObjectMemory maxOldSpace:4*1024*1024 |
|
2893 |
" |
|
2894 |
! |
|
2895 |
||
1288 | 2896 |
moreOldSpace:howMuch |
2897 |
"allocate howMuch bytes more for old objects; return true if this worked, |
|
2898 |
false if that failed. |
|
2899 |
This is done automatically, when running out of space, but makes |
|
2900 |
sense, if its known in advance that a lot of memory is needed to |
|
2901 |
avoid multiple reallocations and compresses. |
|
2902 |
On systems which do not support the mmap (or equivalent) system call, |
|
2903 |
this (currently) implies a compressing garbage collect - so its slow. |
|
2904 |
Notice: this is a nonstandard interface - use only in special situations." |
|
2905 |
||
2906 |
%{ |
|
2907 |
if (__isSmallInteger(howMuch)) { |
|
2908 |
RETURN( __moreOldSpace(__context, __intVal(howMuch)) ? true : false ); |
|
615 | 2909 |
} |
2910 |
RETURN (false); |
|
379 | 2911 |
%} |
615 | 2912 |
" |
2913 |
ObjectMemory moreOldSpace:1000000 |
|
2914 |
" |
|
379 | 2915 |
! |
2916 |
||
1288 | 2917 |
moreOldSpaceIfUseful |
2918 |
"to be called after an incremental GC cycle; |
|
2919 |
if freeSpace is still below limit, allocate more oldSpace" |
|
2920 |
||
2921 |
|limit free amount| |
|
2922 |
||
2923 |
limit := FreeSpaceGCLimit. |
|
2924 |
limit notNil ifTrue:[ |
|
2122 | 2925 |
"/ if reclaimed space is below limit, we have to allocate more |
2926 |
"/ oldSpace, to avoid excessive gcSteps (due to freeSpaceLimit |
|
2927 |
"/ still not reached) |
|
2928 |
"/ |
|
2929 |
free := self freeSpace + self freeListSpace. |
|
2930 |
free < (limit * 3 // 2) ifTrue:[ |
|
2931 |
amount := FreeSpaceGCAmount. |
|
2932 |
amount isNil ifTrue:[ |
|
2933 |
amount := limit * 3 // 2. |
|
2934 |
]. |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
2935 |
'ObjectMemory [info]: moreOldSpace to satisfy free-limit' infoPrintCR. |
2122 | 2936 |
(self moreOldSpace:(amount - free + (64*1024))) ifFalse:[ |
2937 |
"/ |
|
2938 |
"/ could not increase oldspace; reset FreeSpaceGCLimit to avoid |
|
2939 |
"/ useless retries |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
2940 |
'ObjectMemory [warning]: could not increase oldSpace - reset limit' errorPrintCR. |
2122 | 2941 |
FreeSpaceGCLimit := nil |
2942 |
] |
|
2943 |
]. |
|
615 | 2944 |
]. |
2122 | 2945 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
2946 |
"Modified: 10.1.1997 / 17:59:48 / cg" |
370 | 2947 |
! |
2948 |
||
1288 | 2949 |
newSpaceSize:newSize |
2950 |
"change the size of the newSpace. To do this, the current contents |
|
2951 |
of the newSpace may have to be tenured (if size is smaller). |
|
2952 |
Returns false, if it failed for any reason. |
|
2953 |
Experimental: this interface may valish without notice. |
|
2954 |
||
2955 |
DANGER ALERT: |
|
2956 |
be careful too big of a size may lead to longer scavenge pauses. |
|
2957 |
Too small of a newSpace may lead to more CPU overhead, due to |
|
2958 |
excessive scavenges. You have been warned." |
|
2959 |
||
2960 |
%{ |
|
2961 |
extern int __setNewSpaceSize(); |
|
2962 |
||
2963 |
if (__isSmallInteger(newSize)) { |
|
2964 |
RETURN (__setNewSpaceSize(__intVal(newSize)) ? true : false); |
|
2965 |
} |
|
2966 |
%}. |
|
2967 |
self primitiveFailed |
|
2968 |
||
2969 |
" less absolute CPU overhead (but longer pauses): |
|
2970 |
||
2971 |
ObjectMemory newSpaceSize:800*1024 |
|
2972 |
" |
|
2973 |
||
2974 |
" smaller pauses, but more overall CPU overhead: |
|
2975 |
||
2976 |
ObjectMemory newSpaceSize:200*1024 |
|
370 | 2977 |
" |
2978 |
||
2979 |
" the default: |
|
2980 |
||
2981 |
ObjectMemory newSpaceSize:400*1024 |
|
2982 |
" |
|
615 | 2983 |
! |
2984 |
||
1288 | 2985 |
oldSpaceCompressLimit |
2986 |
"return the limit for oldSpace compression. If more memory than this |
|
2987 |
limit is in use, the system will not perform compresses on the oldspace, |
|
2988 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
2989 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
2990 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
2991 |
you may want to increase this limit." |
|
2992 |
||
2993 |
%{ /* NOCONTEXT */ |
|
2994 |
extern unsigned __compressingGCLimit(); |
|
2995 |
||
2996 |
RETURN (__MKSMALLINT( __compressingGCLimit(-1) )); |
|
1105
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2997 |
%} |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2998 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2999 |
ObjectMemory oldSpaceCompressLimit |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3000 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3001 |
! |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
3002 |
|
1288 | 3003 |
oldSpaceCompressLimit:amount |
3004 |
"set the limit for oldSpace compression. If more memory than this |
|
3005 |
limit is in use, the system will not perform compresses on the oldspace, |
|
3006 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
3007 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
3008 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
3009 |
you may want to increase this limit. |
|
3010 |
This method returns the previous increment value." |
|
3011 |
||
3012 |
%{ /* NOCONTEXT */ |
|
3013 |
extern unsigned __compressingGCLimit(); |
|
3014 |
||
3015 |
if (__isSmallInteger(amount)) { |
|
3016 |
RETURN (__MKSMALLINT( __compressingGCLimit(__intVal(amount)) )); |
|
3017 |
} |
|
3018 |
%} |
|
3019 |
"to change the limit to 12Mb:" |
|
615 | 3020 |
" |
3021 |
ObjectMemory oldSpaceCompressLimit:12*1024*1024 |
|
3022 |
" |
|
3023 |
! |
|
3024 |
||
1288 | 3025 |
oldSpaceIncrement |
3026 |
"return the oldSpaceIncrement value. Thats the amount by which |
|
3027 |
more memory is allocated in case the oldSpace gets filled up. |
|
3028 |
In normal situations, the default value used in the VM is fine |
|
3029 |
and there is no need to change it." |
|
3030 |
||
3031 |
%{ /* NOCONTEXT */ |
|
3032 |
extern unsigned __oldSpaceIncrement(); |
|
3033 |
||
3034 |
RETURN (__MKSMALLINT( __oldSpaceIncrement(-1) )); |
|
615 | 3035 |
%} |
3036 |
" |
|
3037 |
ObjectMemory oldSpaceIncrement |
|
3038 |
" |
|
3039 |
! |
|
3040 |
||
1288 | 3041 |
oldSpaceIncrement:amount |
3042 |
"set the oldSpaceIncrement value. Thats the amount by which |
|
3043 |
more memory is allocated in case the oldSpace gets filled up. |
|
3044 |
In normal situations, the default value used in the VM is fine |
|
3045 |
and there is no need to change it. This method returns the |
|
3046 |
previous increment value." |
|
3047 |
||
3048 |
%{ /* NOCONTEXT */ |
|
3049 |
extern unsigned __oldSpaceIncrement(); |
|
3050 |
||
3051 |
if (__isSmallInteger(amount)) { |
|
3052 |
RETURN (__MKSMALLINT( __oldSpaceIncrement(__intVal(amount)) )); |
|
3053 |
} |
|
3054 |
%} |
|
3055 |
"to change increment to 1Meg:" |
|
615 | 3056 |
" |
3057 |
ObjectMemory oldSpaceIncrement:1024*1024 |
|
3058 |
" |
|
3059 |
! |
|
3060 |
||
1288 | 3061 |
tenureParameters:magic |
3062 |
"this is pure magic and not for public eyes ... |
|
3063 |
This method allows fine tuning the scavenger internals, |
|
3064 |
in cooperation to some statistic & test programs. |
|
3065 |
It is undocumented, secret and may vanish. |
|
3066 |
If you play around here, the system may behave very strange." |
|
615 | 3067 |
|
3068 |
%{ /* NOCONTEXT */ |
|
3069 |
__tenureParams(magic); |
|
3070 |
%}. |
|
3071 |
! |
|
3072 |
||
1288 | 3073 |
turnGarbageCollectorOff |
3074 |
"turn off the generational garbage collector by forcing new objects to be |
|
3075 |
allocated directly in oldSpace (instead of newSpace) |
|
3076 |
WARNING: |
|
3077 |
This is somewhat dangerous: if collector is turned off, |
|
3078 |
and too many objects are created, the system may run into trouble |
|
3079 |
(i.e. oldSpace becomes full) and be forced to perform a full mark&sweep |
|
3080 |
or even a compressing collect - making the overall realtime behavior worse. |
|
3081 |
Use this only for special purposes or when realtime behavior |
|
3082 |
is required for a limited time period. |
|
3083 |
||
3084 |
OBSOLETE: this is no longer supported |
|
3085 |
- it may be a no-operation by the time you read this." |
|
615 | 3086 |
|
3087 |
%{ /* NOCONTEXT */ |
|
3088 |
__allocForceSpace(OLDSPACE); |
|
3089 |
%} |
|
3090 |
! |
|
3091 |
||
1288 | 3092 |
turnGarbageCollectorOn |
3093 |
"turn garbage collector on again (see ObjectMemory>>turnGarbageCollectorOff)" |
|
615 | 3094 |
|
3095 |
%{ /* NOCONTEXT */ |
|
3096 |
__allocForceSpace(9999); |
|
3097 |
%} |
|
1288 | 3098 |
! |
3099 |
||
3100 |
watchTenure:flag |
|
3101 |
"set/clear the tenureWatch. If set, an internalError exception will be raised, |
|
3102 |
whenever objects are tenured from newSpace into oldSpace |
|
3103 |
(except for an explicit tenure request). |
|
3104 |
This can be used to validate that no oldSpace objects are created |
|
3105 |
(i.e. the system operates fully in newSpace). |
|
3106 |
Be careful, if the avoidTenure flag is not set, |
|
3107 |
there will almost always be a tenure sooner or later. |
|
3108 |
||
3109 |
EXPERIMENTAL - no warranty" |
|
3110 |
||
3111 |
%{ /* NOCONTEXT */ |
|
3112 |
__watchTenure(flag == true ? 1 : 0); |
|
3113 |
%} |
|
178 | 3114 |
! ! |
3115 |
||
1767 | 3116 |
!ObjectMemory class methodsFor:'interrupt handler access'! |
615 | 3117 |
|
1288 | 3118 |
childSignalInterruptHandler |
3119 |
"return the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
615 | 3120 |
|
3121 |
^ ChildSignalInterruptHandler |
|
3122 |
! |
|
3123 |
||
1288 | 3124 |
childSignalInterruptHandler:aHandler |
3125 |
"set the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
3126 |
||
3127 |
ChildSignalInterruptHandler := aHandler |
|
3128 |
||
3129 |
"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
|
3130 |
"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
|
3131 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
3132 |
|
1288 | 3133 |
customInterruptHandler |
615 | 3134 |
"return the handler for custom interrupts" |
3135 |
||
3136 |
^ CustomInterruptHandler |
|
3137 |
! |
|
3138 |
||
1288 | 3139 |
customInterruptHandler:aHandler |
615 | 3140 |
"set the handler for custom interrupts" |
3141 |
||
3142 |
CustomInterruptHandler := aHandler |
|
3143 |
! |
|
3144 |
||
1288 | 3145 |
disposeInterruptHandler |
3146 |
"return the handler for object disposal interrupts" |
|
615 | 3147 |
|
3148 |
^ DisposeInterruptHandler |
|
3149 |
! |
|
3150 |
||
1288 | 3151 |
disposeInterruptHandler:aHandler |
3152 |
"set the handler for object disposal interrupts" |
|
615 | 3153 |
|
3154 |
DisposeInterruptHandler := aHandler |
|
3155 |
! |
|
3156 |
||
1288 | 3157 |
errorInterruptHandler |
615 | 3158 |
"return the handler for display error interrupts" |
3159 |
||
3160 |
^ ErrorInterruptHandler |
|
3161 |
! |
|
3162 |
||
1288 | 3163 |
errorInterruptHandler:aHandler |
3164 |
"set the handler for display error interrupts" |
|
615 | 3165 |
|
3166 |
ErrorInterruptHandler := aHandler |
|
3167 |
! |
|
3168 |
||
1288 | 3169 |
exceptionInterruptHandler |
3170 |
"return the handler for floating point exception interrupts" |
|
615 | 3171 |
|
3172 |
^ ExceptionInterruptHandler |
|
3173 |
! |
|
3174 |
||
1288 | 3175 |
internalErrorHandler |
3176 |
"return the handler for ST/X internal errors. |
|
3177 |
An internal error is reported for example when a methods |
|
3178 |
bytecode is not a ByteArray, the selector table is not an Array |
|
3179 |
etc. |
|
615 | 3180 |
Those should not occur in normal circumstances." |
3181 |
||
3182 |
^ InternalErrorHandler |
|
3183 |
! |
|
3184 |
||
1288 | 3185 |
ioInterruptHandler |
3186 |
"return the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3187 |
|
3188 |
^ IOInterruptHandler |
|
3189 |
! |
|
3190 |
||
1288 | 3191 |
ioInterruptHandler:aHandler |
3192 |
"set the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 3193 |
|
3194 |
IOInterruptHandler := aHandler |
|
3195 |
! |
|
3196 |
||
1288 | 3197 |
recursionInterruptHandler |
3198 |
"return the handler for recursion/stack overflow interrupts" |
|
615 | 3199 |
|
3200 |
^ RecursionInterruptHandler |
|
3201 |
! |
|
3202 |
||
1288 | 3203 |
recursionInterruptHandler:aHandler |
3204 |
"set the handler for recursion/stack overflow interrupts" |
|
615 | 3205 |
|
3206 |
RecursionInterruptHandler := aHandler |
|
3207 |
! |
|
3208 |
||
1288 | 3209 |
registerErrorInterruptHandler:aHandler forID:errorIDSymbol |
3210 |
"register a handler" |
|
3211 |
||
3212 |
RegisteredErrorInterruptHandlers isNil ifTrue:[ |
|
3213 |
RegisteredErrorInterruptHandlers := IdentityDictionary new |
|
615 | 3214 |
]. |
3215 |
RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler |
|
3216 |
! |
|
3217 |
||
1288 | 3218 |
registeredErrorInterruptHandlers |
615 | 3219 |
"return registered handlers" |
3220 |
||
3221 |
^ RegisteredErrorInterruptHandlers |
|
3222 |
! |
|
3223 |
||
1288 | 3224 |
signalInterruptHandler |
615 | 3225 |
"return the handler for UNIX-signal interrupts" |
3226 |
||
3227 |
^ SignalInterruptHandler |
|
3228 |
! |
|
3229 |
||
1288 | 3230 |
signalInterruptHandler:aHandler |
3231 |
"set the handler for UNIX-signal interrupts" |
|
615 | 3232 |
|
3233 |
SignalInterruptHandler := aHandler |
|
3234 |
! |
|
3235 |
||
1288 | 3236 |
spyInterruptHandler |
615 | 3237 |
"return the handler for spy-timer interrupts" |
3238 |
||
3239 |
^ SpyInterruptHandler |
|
3240 |
! |
|
3241 |
||
1288 | 3242 |
spyInterruptHandler:aHandler |
615 | 3243 |
"set the handler for spy-timer interrupts" |
3244 |
||
3245 |
SpyInterruptHandler := aHandler |
|
3246 |
! |
|
3247 |
||
1288 | 3248 |
stepInterruptHandler |
615 | 3249 |
"return the handler for single step interrupts" |
3250 |
||
3251 |
^ StepInterruptHandler |
|
3252 |
! |
|
3253 |
||
1288 | 3254 |
stepInterruptHandler:aHandler |
3255 |
"set the handler for single step interrupts" |
|
615 | 3256 |
|
3257 |
StepInterruptHandler := aHandler |
|
3258 |
! |
|
3259 |
||
1288 | 3260 |
timerInterruptHandler |
615 | 3261 |
"return the handler for timer interrupts" |
3262 |
||
3263 |
^ TimerInterruptHandler |
|
3264 |
! |
|
3265 |
||
1288 | 3266 |
timerInterruptHandler:aHandler |
615 | 3267 |
"set the handler for timer interrupts" |
3268 |
||
3269 |
TimerInterruptHandler := aHandler |
|
3270 |
! |
|
3271 |
||
1288 | 3272 |
userInterruptHandler |
615 | 3273 |
"return the handler for CNTL-C interrupt handling" |
3274 |
||
3275 |
^ UserInterruptHandler |
|
1288 | 3276 |
! |
3277 |
||
3278 |
userInterruptHandler:aHandler |
|
3279 |
"set the handler for CNTL-C interrupt handling" |
|
3280 |
||
3281 |
UserInterruptHandler := aHandler |
|
615 | 3282 |
! ! |
3283 |
||
1767 | 3284 |
!ObjectMemory class methodsFor:'interrupt statistics'! |
615 | 3285 |
|
1288 | 3286 |
interruptLatency:ms receiver:rec class:cls selector:sel vmActivity:vmActivity id:pid |
3287 |
"example implementation of latencyTime monitoring: |
|
3288 |
This method simply measures the max-latency time. |
|
3289 |
You may want to use some other handler (see #interruptLatencyMonitor:) |
|
3290 |
and extract more information (blocking context). |
|
3291 |
DEMO Example." |
|
3292 |
||
3293 |
ms > MaxInterruptLatency ifTrue:[ |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
3294 |
MaxInterruptLatency := ms. |
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3295 |
'IRQ-LATENCY: ' infoPrint. cls infoPrint. ' ' infoPrint. sel infoPrint. '(' infoPrint. vmActivity infoPrint . ') ---> ' infoPrint. ms infoPrintCR. |
1288 | 3296 |
]. |
3297 |
(InterruptLatencyGoal notNil and:[ms > InterruptLatencyGoal]) ifTrue:[ |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
3298 |
'*** IRQ REALTIME-DEADLINE MISSED: ' errorPrint. |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
3299 |
cls errorPrint. |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
3300 |
' ' errorPrint. sel errorPrint. '(' errorPrint. vmActivity errorPrint . ') ---> ' errorPrint. |
2138 | 3301 |
ms errorPrintCR. |
1288 | 3302 |
]. |
3303 |
||
3304 |
"to enable the demo handler: |
|
3305 |
||
3306 |
ObjectMemory resetMaxInterruptLatency. |
|
3307 |
ObjectMemory interruptLatencyMonitor:ObjectMemory. |
|
3308 |
" |
|
3309 |
"to disable timing statistics: |
|
3310 |
||
3311 |
ObjectMemory interruptLatencyMonitor:nil. |
|
3312 |
ObjectMemory maxInterruptLatency printNL. |
|
3313 |
" |
|
615 | 3314 |
|
3315 |
"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
|
3316 |
"Modified: 18.6.1996 / 14:15:52 / stefan" |
2138 | 3317 |
"Modified: 10.1.1997 / 19:09:53 / cg" |
615 | 3318 |
! |
3319 |
||
1288 | 3320 |
interruptLatencyGoal:millis |
3321 |
"setup to report an error message, whenever a realtime goal could not be |
|
3322 |
met due to blocked interrupts or long primitives or GC activity. |
|
3323 |
An argument of nil clears the check. |
|
3324 |
DEMO Example." |
|
3325 |
||
3326 |
InterruptLatencyGoal := millis. |
|
3327 |
millis isNil ifTrue:[ |
|
3328 |
InterruptLatencyMonitor := nil. |
|
3329 |
] ifFalse:[ |
|
3330 |
MaxInterruptLatency := 0. |
|
3331 |
InterruptLatencyMonitor := self. |
|
615 | 3332 |
] |
3333 |
||
3334 |
" |
|
3335 |
ObjectMemory interruptLatencyGoal:50 |
|
3336 |
" |
|
3337 |
! |
|
3338 |
||
1288 | 3339 |
interruptLatencyMonitor |
3340 |
"return the interrupt-latency-monitor if any. |
|
3341 |
See comment in #interruptLatencyMonitor:. |
|
3342 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3343 |
|
3344 |
^ InterruptLatencyMonitor |
|
3345 |
! |
|
3346 |
||
1288 | 3347 |
interruptLatencyMonitor:aHandler |
3348 |
"set the interrupt latency monitor. If non-nil, this one will be sent |
|
3349 |
an interruptLatency: message with the millisecond delay between |
|
3350 |
the interrupt and its handling. |
|
3351 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 3352 |
|
3353 |
InterruptLatencyMonitor := aHandler |
|
3354 |
! |
|
3355 |
||
1288 | 3356 |
maxInterruptLatency |
3357 |
"return the maximum accumulated interrupt latency in millis. |
|
615 | 3358 |
DEMO Example." |
3359 |
||
3360 |
^ MaxInterruptLatency |
|
1288 | 3361 |
! |
3362 |
||
3363 |
resetMaxInterruptLatency |
|
3364 |
"reset the maximum accumulated interrupt latency probe time. |
|
3365 |
DEMO Example." |
|
3366 |
||
3367 |
MaxInterruptLatency := 0 |
|
615 | 3368 |
! ! |
3369 |
||
1767 | 3370 |
!ObjectMemory class methodsFor:'just in time compilation'! |
3371 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3372 |
byteCodeSizeLimitForDynamicCompilation:aNumber |
2526 | 3373 |
"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
|
3374 |
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
|
3375 |
if its bytecode size is larger than the given number. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3376 |
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
|
3377 |
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
|
3378 |
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
|
3379 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3380 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3381 |
extern int __byteCodeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3382 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3383 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3384 |
prev = __byteCodeSizeLimitForDynamicCompilation( |
2526 | 3385 |
__isSmallInteger(aNumber) |
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3386 |
? __intVal(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3387 |
: -1); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3388 |
RETURN (__MKSMALLINT(prev)); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3389 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3390 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3391 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3392 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3393 |
ObjectMemory byteCodeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3394 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3395 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3396 |
|
2638 | 3397 |
codeForCPU:aCPUSymbol |
3398 |
"instruct the just in time compiler that some specific CPU |
|
3399 |
is present (forcing it to generate code for that). |
|
3400 |
The default is set correct for the architecture, and the |
|
3401 |
runTime system tries to figure out the cpu - but who knows ... |
|
3402 |
The valid symbols depend on the architecture: |
|
3403 |
i386: #i486 / #i586 (affects code ordering) |
|
3404 |
sparc: #sparcV8 / #sparcV8 (affects instruction set) |
|
3405 |
mips: #rs2000 / #rs4000 (affects delay slot generation) |
|
3406 |
||
3407 |
This is a nonstandard entry and may be removed without notice - |
|
3408 |
not for the general user." |
|
3409 |
||
3410 |
%{ /* NOCONTEXT */ |
|
3411 |
__codeForCPU(aCPUSymbol); |
|
3412 |
%}. |
|
3413 |
||
3414 |
" |
|
3415 |
ObjectMemory codeForCPU:#i486 |
|
3416 |
ObjectMemory codeForCPU:#i586 |
|
3417 |
" |
|
3418 |
! |
|
3419 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3420 |
codeSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3421 |
"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
|
3422 |
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
|
3423 |
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
|
3424 |
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
|
3425 |
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
|
3426 |
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
|
3427 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3428 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3429 |
extern int __codeSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3430 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3431 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3432 |
prev = __codeSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3433 |
? __intVal(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3434 |
: -1); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3435 |
RETURN (__MKSMALLINT(prev)); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3436 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3437 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3438 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3439 |
ObjectMemory codeSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3440 |
ObjectMemory codeSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3441 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3442 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3443 |
|
1767 | 3444 |
compiledCodeCounter |
3445 |
"return the number of additional code-bytes which |
|
3446 |
were generated since the counter was last reset" |
|
3447 |
||
3448 |
%{ /* NOCONTEXT */ |
|
3449 |
||
3450 |
extern __compiledCodeCounter(); |
|
3451 |
int nBytes; |
|
3452 |
||
3453 |
nBytes = __compiledCodeCounter(); |
|
3454 |
RETURN (__MKSMALLINT(nBytes)); |
|
3455 |
%} |
|
3456 |
" |
|
3457 |
ObjectMemory compiledCodeCounter |
|
3458 |
" |
|
3459 |
! |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3460 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3461 |
compiledCodeSpaceUsed |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3462 |
"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
|
3463 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3464 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3465 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3466 |
extern __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3467 |
int nBytes; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3468 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3469 |
nBytes = __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3470 |
RETURN (__MKSMALLINT(nBytes)); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3471 |
%} |
1767 | 3472 |
" |
3473 |
ObjectMemory compiledCodeSpaceUsed |
|
3474 |
" |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3475 |
! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3476 |
|
1948
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3477 |
fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3478 |
"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
|
3479 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3480 |
%{ /* NOCONTEXT */ |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3481 |
extern int __fullSingleStep(); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3482 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3483 |
RETURN (__fullSingleStep(-1) ? true : false); |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3484 |
%} |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3485 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3486 |
ObjectMemory fullSingleStepSupport |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3487 |
" |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3488 |
|
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3489 |
! |
ca8c3f2f5374
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1947
diff
changeset
|
3490 |
|
1795 | 3491 |
fullSingleStepSupport:aBoolean |
3492 |
"enable/disable full single step support for the just-in-time-compiled code. |
|
3493 |
If off, things like simple increment/decrement, additions and variable- |
|
3494 |
stores are not steppable, but treated like atomar invisible operations. |
|
3495 |
If on, single step halts at those operations. |
|
3496 |
Execution is a bit slower if enabled." |
|
3497 |
||
3498 |
%{ /* NOCONTEXT */ |
|
3499 |
extern int __fullSingleStep(); |
|
3500 |
int prev; |
|
3501 |
||
3502 |
prev = __fullSingleStep(aBoolean == true |
|
3503 |
? 1 |
|
3504 |
: (aBoolean == false) |
|
3505 |
? 0 |
|
3506 |
: -1); |
|
3507 |
RETURN (prev ? true : false); |
|
3508 |
%} |
|
3509 |
" |
|
3510 |
ObjectMemory fullSingleStepSupport:true |
|
3511 |
ObjectMemory fullSingleStepSupport:false |
|
3512 |
" |
|
3513 |
||
3514 |
! |
|
3515 |
||
3516 |
getCompiledCodeLimit |
|
3517 |
"get the codeLimit from the VM" |
|
3518 |
||
3519 |
%{ /* NOCONTEXT */ |
|
3520 |
extern int __dynamicCodeLimit(); |
|
3521 |
int limit; |
|
3522 |
||
3523 |
limit = __dynamicCodeLimit(); |
|
3524 |
if (limit) { |
|
3525 |
RETURN (__MKSMALLINT(limit)); |
|
3526 |
} |
|
3527 |
RETURN (nil); |
|
3528 |
%} |
|
3529 |
! |
|
3530 |
||
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3531 |
insnSizeLimitForDynamicCompilation:aNumber |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3532 |
"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
|
3533 |
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
|
3534 |
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
|
3535 |
internal insns are generated. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3536 |
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
|
3537 |
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
|
3538 |
systems. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3539 |
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
|
3540 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3541 |
%{ /* NOCONTEXT */ |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3542 |
extern int __insnSizeLimitForDynamicCompilation(); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3543 |
int prev; |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3544 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3545 |
prev = __insnSizeLimitForDynamicCompilation( __isSmallInteger(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3546 |
? __intVal(aNumber) |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3547 |
: -1); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3548 |
RETURN (__MKSMALLINT(prev)); |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3549 |
%}. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3550 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3551 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3552 |
ObjectMemory insnSizeLimitForDynamicCompilation:nil |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3553 |
ObjectMemory insnSizeLimitForDynamicCompilation:8000 |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3554 |
" |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3555 |
! |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3556 |
|
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3557 |
justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3558 |
"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
|
3559 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3560 |
%{ /* NOCONTEXT */ |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3561 |
extern int __justInTimeCompilation(); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3562 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3563 |
RETURN (__justInTimeCompilation(-1) ? true : false); |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3564 |
%} |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3565 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3566 |
ObjectMemory justInTimeCompilation |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3567 |
" |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3568 |
|
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3569 |
! |
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3570 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3571 |
justInTimeCompilation:aBoolean |
1947
7ef53563e2f9
added a separate query for justInTimeCompilation
Claus Gittinger <cg@exept.de>
parents:
1940
diff
changeset
|
3572 |
"enable/disable just-in-time-compilation." |
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3573 |
|
1939
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3574 |
aBoolean notNil ifTrue:[ |
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3575 |
JustInTimeCompilationEnabled := aBoolean. |
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3576 |
]. |
214f42e29868
remember just-in-time state in image
Claus Gittinger <cg@exept.de>
parents:
1926
diff
changeset
|
3577 |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3578 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3579 |
extern int __justInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3580 |
int prev; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3581 |
|
1657 | 3582 |
prev = __justInTimeCompilation(aBoolean == true |
1767 | 3583 |
? 1 |
3584 |
: (aBoolean == false) |
|
3585 |
? 0 |
|
3586 |
: -1); |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3587 |
RETURN (prev ? true : false); |
2017 | 3588 |
%}. |
1767 | 3589 |
" |
3590 |
ObjectMemory justInTimeCompilation:true |
|
3591 |
ObjectMemory justInTimeCompilation:false |
|
3592 |
" |
|
2017 | 3593 |
! |
3594 |
||
1940 | 3595 |
reEnableJustInTimeCompilation |
3596 |
"to be called after a snapshot restart; if justInTimeCompiler |
|
3597 |
was enabled before, do it again. |
|
3598 |
For now, this is not done automatically, to allow restarting |
|
3599 |
a system with the dynamic compiler turned off (its still experimental). |
|
3600 |
Therefore, this reenabling is done in the smalltalk_r.rc file." |
|
3601 |
||
3602 |
JustInTimeCompilationEnabled == true ifTrue:[ |
|
3603 |
self justInTimeCompilation:true |
|
3604 |
] |
|
3605 |
! |
|
3606 |
||
1770 | 3607 |
resetCompiledCodeCounter |
3608 |
"reset the counter of additional code-bytes" |
|
3609 |
||
3610 |
%{ /* NOCONTEXT */ |
|
3611 |
||
3612 |
extern void __resetDynamicCodeGeneratedCounter(); |
|
3613 |
||
3614 |
__resetDynamicCodeGeneratedCounter(); |
|
3615 |
%} |
|
3616 |
" |
|
3617 |
ObjectMemory resetCompiledCodeCounter |
|
3618 |
" |
|
3619 |
||
3620 |
! |
|
3621 |
||
1769 | 3622 |
setCompiledCodeLimit:newLimit |
3623 |
"set the VM's limit" |
|
3624 |
||
3625 |
%{ /* NOCONTEXT */ |
|
3626 |
extern __setDynamicCodeLimit(); |
|
3627 |
||
3628 |
if (__isSmallInteger(newLimit)) { |
|
3629 |
__setDynamicCodeLimit(__intVal(newLimit)); |
|
3630 |
} else if (newLimit == nil) { |
|
3631 |
__setDynamicCodeLimit(0); |
|
3632 |
} |
|
3633 |
%} |
|
3634 |
! |
|
3635 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3636 |
supportsJustInTimeCompilation |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3637 |
"return true, if this system supports just-in-time-compilation of |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3638 |
bytecode to machine code. Dont confuse this with stc-compilation." |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3639 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3640 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3641 |
extern int __canDoJustInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3642 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3643 |
RETURN (__canDoJustInTimeCompilation() ? true : false); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3644 |
%} |
1767 | 3645 |
" |
3646 |
ObjectMemory supportsJustInTimeCompilation |
|
3647 |
" |
|
3648 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3649 |
! ! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
3650 |
|
1767 | 3651 |
!ObjectMemory class methodsFor:'low memory handling'! |
615 | 3652 |
|
3781 | 3653 |
allocationFailed |
3654 |
"memory allocation has failed in the VM |
|
3655 |
This is triggered by the runtime system (or possibly by |
|
3656 |
a user primitive)" |
|
3657 |
||
3658 |
^ AllocationFailureSignal raise |
|
3659 |
! |
|
3660 |
||
1288 | 3661 |
memoryInterrupt |
3662 |
"when a low-memory condition arises, ask all classes to |
|
3663 |
remove possibly cached data. You may help the system a bit, |
|
3664 |
in providing a lowSpaceCleanup method in your classes which have |
|
3665 |
lots of data kept somewhere (usually, cached data). |
|
3666 |
- this may or may not help." |
|
3667 |
||
3668 |
self performLowSpaceCleanup. |
|
3669 |
"/ self error:'almost out of memory' |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3670 |
'ObjectMemory [warning]: almost out of memory' errorPrintCR. |
615 | 3671 |
|
3672 |
LowSpaceSemaphore signalIf. |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
3673 |
|
2131
1eeb310e109a
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
2122
diff
changeset
|
3674 |
"Modified: 10.1.1997 / 17:59:31 / cg" |
1288 | 3675 |
! |
3676 |
||
3677 |
performLowSpaceCleanup |
|
3678 |
"ask all classes to remove possibly cached data. |
|
3679 |
You may help the system a bit, in providing a lowSpaceCleanup method |
|
3680 |
in your classes which have lots of data kept somewhere (usually, cached data)." |
|
3681 |
||
3682 |
Smalltalk allBehaviorsDo:[:aClass | |
|
3683 |
aClass lowSpaceCleanup |
|
3684 |
]. |
|
3685 |
||
3686 |
"Created: 12.4.1996 / 14:57:28 / cg" |
|
362 | 3687 |
! ! |
3688 |
||
1767 | 3689 |
!ObjectMemory class methodsFor:'object finalization'! |
290 | 3690 |
|
1288 | 3691 |
allChangedShadowObjectsDo:aBlock |
3692 |
"evaluate the argument, aBlock for all known shadow objects which have |
|
3693 |
lost a pointer recently." |
|
290 | 3694 |
%{ |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
3695 |
__allChangedShadowObjectsDo(&aBlock); |
290 | 3696 |
%} |
3697 |
! |
|
3698 |
||
3733 | 3699 |
backgroundFinalizationProcess |
3700 |
"return the backgroundFinalizationProcess (or nil, if noone is running)" |
|
3701 |
||
3702 |
^ BackgroundFinalizationProcess |
|
3703 |
||
3704 |
"Created: / 4.8.1998 / 02:00:13 / cg" |
|
3705 |
! |
|
3706 |
||
1288 | 3707 |
disposeInterrupt |
3708 |
"this is triggered by the garbage collector, |
|
3709 |
whenever any shadowArray looses a pointer." |
|
3710 |
||
3711 |
FinalizationSemaphore notNil ifTrue:[ |
|
2160
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3712 |
"/ |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3713 |
"/ background finalizer is waiting ... |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3714 |
"/ |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3715 |
FinalizationSemaphore signalOnce |
290 | 3716 |
] ifFalse:[ |
2160
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3717 |
"/ |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3718 |
"/ do it right here |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3719 |
"/ |
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3720 |
self finalize |
290 | 3721 |
] |
2160
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3722 |
|
ae0c0525ff2d
only signal finalizationSema once
Claus Gittinger <cg@exept.de>
parents:
2138
diff
changeset
|
3723 |
"Modified: 13.1.1997 / 17:26:16 / cg" |
290 | 3724 |
! |
3725 |
||
1288 | 3726 |
finalize |
3727 |
"tell all weak objects that something happened." |
|
3728 |
||
3729 |
self allChangedShadowObjectsDo:[:aShadowArray | |
|
2099
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3730 |
aShadowArray lostPointer. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3731 |
]. |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3732 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3733 |
"/ we should change the setup, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3734 |
"/ to make the Dependencies collection a dependent |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3735 |
"/ of all the WeakArrays and WeakIDSets there, |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3736 |
"/ and send a changed message when any of them looses |
2100 | 3737 |
"/ a pointer. |
3738 |
"/ This would automize the send below. |
|
3739 |
"/ |
|
3740 |
"/ WARNING: |
|
3741 |
"/ this can only be done, if the WeakIDSet holds its |
|
3742 |
"/ dependends itself (like a WeakArray), |
|
3743 |
"/ otherwise we might get trouble. |
|
3744 |
"/ 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
|
3745 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3746 |
Dependencies removeEmptyDependencyValues |
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3747 |
|
dd8e237f87e5
clean up weakArrays in the Dependency collection
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
3748 |
"Modified: 9.1.1997 / 01:00:44 / cg" |
615 | 3749 |
! |
3750 |
||
1288 | 3751 |
startBackgroundFinalizationAt:aPriority |
3752 |
"start a process doing finalization work in the background. |
|
3753 |
Can be used to reduce the pauses created by finalization. |
|
3754 |
Normally, these pauses are not noticed; however if you have (say) |
|
3755 |
ten thousands of weak objects, these could become long enough to |
|
3756 |
make background finalization usefull. |
|
3757 |
WARNING: background finalization may lead to much delayed freeing of |
|
3758 |
system resources. Especially, you may temporarily run out of free |
|
3759 |
color table entries or fileDescriptors etc. Use at your own risk (if at all)" |
|
3760 |
||
3761 |
|p| |
|
3762 |
||
3763 |
"/ |
|
3764 |
"/ its not useful, to run it more than once |
|
3765 |
"/ |
|
3766 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
3733 | 3767 |
BackgroundFinalizationProcess priority:aPriority. |
3768 |
^ self |
|
1288 | 3769 |
]. |
3770 |
||
2262 | 3771 |
FinalizationSemaphore := Semaphore new name:'FinalizationSemaphore'. |
1288 | 3772 |
|
3773 |
p := |
|
3733 | 3774 |
[ |
3775 |
[ |
|
3776 |
[true] whileTrue:[ |
|
3777 |
" |
|
3778 |
wait till something to do ... |
|
3779 |
" |
|
3780 |
FinalizationSemaphore wait. |
|
3781 |
" |
|
3782 |
... and do it |
|
3783 |
" |
|
3784 |
self finalize |
|
3785 |
] |
|
3786 |
] valueOnUnwindDo:[ |
|
3787 |
BackgroundFinalizationProcess := nil. |
|
3788 |
FinalizationSemaphore := nil |
|
3789 |
] |
|
3790 |
] newProcess. |
|
1288 | 3791 |
p name:'background finalizer'. |
3792 |
p priority:aPriority. |
|
3793 |
p restartable:true. |
|
3733 | 3794 |
p beGroupLeader. |
1288 | 3795 |
p resume. |
3796 |
BackgroundFinalizationProcess := p |
|
290 | 3797 |
|
3798 |
" |
|
3799 |
ObjectMemory startBackgroundFinalizationAt:5 |
|
3800 |
" |
|
3733 | 3801 |
|
3802 |
"Modified: / 5.8.1998 / 14:53:27 / cg" |
|
1288 | 3803 |
! |
3804 |
||
3805 |
stopBackgroundFinalization |
|
3806 |
"stop the background finalizer" |
|
3807 |
||
3808 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
3809 |
BackgroundFinalizationProcess terminate. |
|
3810 |
BackgroundFinalizationProcess := nil |
|
3811 |
]. |
|
3812 |
||
3813 |
" |
|
3814 |
ObjectMemory stopBackgroundFinalization |
|
3815 |
" |
|
290 | 3816 |
! ! |
3817 |
||
1767 | 3818 |
!ObjectMemory class methodsFor:'physical memory access'! |
93 | 3819 |
|
1288 | 3820 |
collectedOldSpacePagesDo:aBlock |
3821 |
"evaluates aBlock for all pages in the prev. oldSpace, passing |
|
3822 |
the pages address as argument. |
|
3823 |
For internal & debugging use only." |
|
3824 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
3825 |
if (__collectedOldSpacePagesDo(&aBlock) < 0) { |
615 | 3826 |
RETURN (false); |
3827 |
} |
|
3828 |
%}. |
|
3829 |
^ true |
|
3830 |
! |
|
3831 |
||
1288 | 3832 |
newSpacePagesDo:aBlock |
3833 |
"evaluates aBlock for all pages in the newSpace, passing |
|
3834 |
the pages address as argument. |
|
3835 |
For internal & debugging use only." |
|
3836 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
3837 |
if (__newSpacePagesDo(&aBlock) < 0) { |
159 | 3838 |
RETURN (false); |
85 | 3839 |
} |
3840 |
%}. |
|
3841 |
^ true |
|
3842 |
! |
|
3843 |
||
1288 | 3844 |
oldSpacePagesDo:aBlock |
3845 |
"evaluates aBlock for all pages in the oldSpace, passing |
|
3846 |
the pages address as argument. |
|
3847 |
For internal & debugging use only." |
|
3848 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
3849 |
if (__oldSpacePagesDo(&aBlock) < 0) { |
1286 | 3850 |
RETURN (false); |
85 | 3851 |
} |
3852 |
%}. |
|
3853 |
^ true |
|
1288 | 3854 |
! |
3855 |
||
3856 |
pageIsInCore:aPageNumber |
|
3857 |
"return true, if the page (as enumerated via oldSpacePagesDo:) |
|
3858 |
is in memory; false, if currently paged out. For internal |
|
3859 |
use / monitors only; may vanish. |
|
3860 |
NOTICE: not all systems provide this information; on those that |
|
3861 |
do not, true is returned for all pages." |
|
3862 |
%{ |
|
3863 |
#ifdef HAS_MINCORE |
|
3864 |
int pageSize = getpagesize(); |
|
3865 |
char result[10]; |
|
3866 |
INT addr; |
|
3867 |
||
3868 |
if (__isSmallInteger(aPageNumber)) { |
|
3869 |
addr = __intVal(aPageNumber) & ~(pageSize - 1); |
|
3870 |
} else { |
|
3871 |
addr = ((INT)aPageNumber) & ~(pageSize - 1); |
|
3872 |
} |
|
3873 |
if (mincore(addr, pageSize-1, result) < 0) { |
|
3874 |
RETURN (true); |
|
3875 |
} |
|
3876 |
RETURN ((result[0] & 1) ? true : false); |
|
3877 |
#endif |
|
3878 |
%}. |
|
3879 |
"OS does not supply this info - assume yes" |
|
3880 |
^ true |
|
85 | 3881 |
! ! |
3882 |
||
1767 | 3883 |
!ObjectMemory class methodsFor:'queries'! |
615 | 3884 |
|
1288 | 3885 |
bytesUsed |
3886 |
"return the number of bytes allocated for objects - |
|
3887 |
this number is not exact, since some objects may already be dead |
|
3888 |
(i.e. not yet reclaimed by the garbage collector). |
|
3889 |
If you need the exact number, you have to loop over all |
|
3890 |
objects and ask for the bytesize using ObjectMemory>>sizeOf:." |
|
3891 |
||
3892 |
%{ /* NOCONTEXT */ |
|
3893 |
extern unsigned __oldSpaceUsed(), __newSpaceUsed(), __freeListSpace(); |
|
3894 |
||
3895 |
RETURN ( __MKSMALLINT(__oldSpaceUsed() + __newSpaceUsed() - __freeListSpace()) ); |
|
615 | 3896 |
%} |
3897 |
" |
|
3898 |
ObjectMemory bytesUsed |
|
3899 |
" |
|
3900 |
! |
|
3901 |
||
1288 | 3902 |
collectObjectsWhich:aBlock |
3903 |
"helper for the whoReferences queries. Returns a collection |
|
3904 |
of objects for which aBlock returns true." |
|
3905 |
||
3906 |
|aCollection| |
|
3907 |
||
3908 |
aCollection := IdentitySet new. |
|
3909 |
self allObjectsDo:[:o | |
|
3910 |
(aBlock value:o) ifTrue:[ |
|
3911 |
aCollection add:o |
|
3912 |
] |
|
3913 |
]. |
|
3914 |
(aCollection size == 0) ifTrue:[ |
|
615 | 3915 |
"actually this cannot happen - there is always one" |
3916 |
^ nil |
|
3917 |
]. |
|
3918 |
^ aCollection |
|
3919 |
! |
|
3920 |
||
1288 | 3921 |
fixSpaceSize |
3922 |
"return the total size of the fix space." |
|
3923 |
||
3924 |
%{ /* NOCONTEXT */ |
|
3925 |
extern unsigned __fixSpaceSize(); |
|
3926 |
||
3927 |
RETURN ( __MKSMALLINT(__fixSpaceSize()) ); |
|
615 | 3928 |
%} |
3929 |
" |
|
3930 |
ObjectMemory fixSpaceSize |
|
3931 |
" |
|
3932 |
! |
|
3933 |
||
1288 | 3934 |
fixSpaceUsed |
3935 |
"return the number of bytes allocated for old objects in fix space." |
|
3936 |
||
3937 |
%{ /* NOCONTEXT */ |
|
3938 |
extern unsigned __fixSpaceUsed(); |
|
3939 |
||
3940 |
RETURN ( __MKSMALLINT(__fixSpaceUsed()) ); |
|
615 | 3941 |
%} |
3942 |
" |
|
3943 |
ObjectMemory fixSpaceUsed |
|
3944 |
" |
|
3945 |
! |
|
3946 |
||
1288 | 3947 |
freeListSpace |
3948 |
"return the number of bytes in the free lists. |
|
3949 |
(which is included in oldSpaceUsed)" |
|
3950 |
||
3951 |
%{ /* NOCONTEXT */ |
|
3952 |
extern unsigned __freeListSpace(); |
|
3953 |
||
3954 |
RETURN ( __MKSMALLINT(__freeListSpace()) ); |
|
615 | 3955 |
%} |
3956 |
" |
|
3957 |
ObjectMemory freeListSpace |
|
3958 |
" |
|
3959 |
! |
|
3960 |
||
1288 | 3961 |
freeSpace |
3962 |
"return the number of bytes in the compact free area. |
|
3963 |
(oldSpaceUsed + freeSpaceSize = oldSpaceSize)" |
|
3964 |
||
3965 |
%{ /* NOCONTEXT */ |
|
3966 |
extern unsigned __oldSpaceSize(), __oldSpaceUsed(); |
|
3967 |
||
3968 |
RETURN ( __MKSMALLINT(__oldSpaceSize() - __oldSpaceUsed()) ); |
|
615 | 3969 |
%} |
3970 |
" |
|
3971 |
ObjectMemory freeSpace |
|
3972 |
" |
|
3973 |
! |
|
3974 |
||
1288 | 3975 |
garbageCollectCount |
3976 |
"return the number of compressing collects that occurred since startup" |
|
3977 |
||
3978 |
%{ /* NOCONTEXT */ |
|
3979 |
extern int __garbageCollectCount(); |
|
3980 |
||
3981 |
RETURN (__MKSMALLINT(__garbageCollectCount())); |
|
615 | 3982 |
%} |
3983 |
" |
|
3984 |
ObjectMemory garbageCollectCount |
|
3985 |
" |
|
3986 |
! |
|
3987 |
||
1288 | 3988 |
incrementalGCCount |
3989 |
"return the number of incremental collects that occurred since startup" |
|
3990 |
||
3991 |
%{ /* NOCONTEXT */ |
|
3992 |
extern int __incrementalGCCount(); |
|
3993 |
||
3994 |
RETURN (__MKSMALLINT(__incrementalGCCount())); |
|
615 | 3995 |
%} |
3996 |
" |
|
3997 |
ObjectMemory incrementalGCCount |
|
3998 |
" |
|
3999 |
! |
|
4000 |
||
1288 | 4001 |
incrementalGCPhase |
4002 |
"returns the internal state of the incremental GC. |
|
4003 |
The meaning of those numbers is a secret :-). |
|
4004 |
(for the curious: (currently) |
|
4005 |
2 is idle, 3..11 are various mark phases, |
|
4006 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4007 |
incr. GC gets interrupted by a full GC). |
|
4008 |
Do not depend on the values - there may be additional phases in |
|
4009 |
future versions (incremental compact ;-). |
|
4010 |
This is for debugging and monitoring only - and may change or vanish" |
|
4011 |
||
4012 |
%{ /* NOCONTEXT */ |
|
615 | 4013 |
extern int __incrGCphase(); |
4014 |
||
1133 | 4015 |
RETURN (__MKSMALLINT(__incrGCphase())); |
615 | 4016 |
%} |
4017 |
! |
|
4018 |
||
3742 | 4019 |
incrementalGCPhaseSymbolic |
4020 |
"returns the internal state of the incremental GC |
|
4021 |
in a symbolic form. |
|
4022 |
(for the curious: (currently) |
|
4023 |
2 is idle, 3..11 are various mark phases, |
|
4024 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
4025 |
incr. GC gets interrupted by a full GC). |
|
4026 |
Do not depend on the values - there may be additional phases in |
|
4027 |
future versions (incremental compact ;-). |
|
4028 |
This is for debugging and monitoring only - and may change or vanish" |
|
4029 |
||
4030 |
|phase| |
|
4031 |
||
4032 |
phase := self incrementalGCPhase. |
|
4033 |
phase < 2 ifTrue:[^ #cleanup]. |
|
4034 |
phase == 2 ifTrue:[^ #idle]. |
|
4035 |
phase < 12 ifTrue:[^ #marking]. |
|
4036 |
^ #sweeping |
|
4037 |
||
4038 |
"Created: / 10.8.1998 / 15:02:52 / cg" |
|
4039 |
! |
|
4040 |
||
1288 | 4041 |
lastScavengeReclamation |
4042 |
"returns the number of bytes replacimed by the last scavenge. |
|
4043 |
For statistic only - this may vanish." |
|
4044 |
||
4045 |
%{ /* NOCONTEXT */ |
|
4046 |
extern int __newSpaceReclaimed(); |
|
4047 |
||
4048 |
RETURN ( __MKSMALLINT(__newSpaceReclaimed()) ); |
|
4049 |
%} |
|
4050 |
"percentage of reclaimed objects is returned by: |
|
4051 |
||
4052 |
((ObjectMemory lastScavengeReclamation) |
|
615 | 4053 |
/ (ObjectMemory newSpaceSize)) * 100.0 |
4054 |
" |
|
4055 |
! |
|
4056 |
||
1288 | 4057 |
lifoRememberedSet |
4058 |
"return the lifoRemSet. |
|
4059 |
This is pure VM debugging and will vanish without notice." |
|
4060 |
||
4061 |
%{ /* NOCONTEXT */ |
|
4062 |
extern OBJ __lifoRememberedSet(); |
|
4063 |
||
4064 |
RETURN ( __lifoRememberedSet() ); |
|
615 | 4065 |
%} |
4066 |
" |
|
4067 |
ObjectMemory lifoRememberedSet |
|
4068 |
" |
|
4069 |
! |
|
4070 |
||
1288 | 4071 |
lifoRememberedSetSize |
4072 |
"return the size of the lifoRemSet. |
|
4073 |
This is a VM debugging interface and may vanish without notice." |
|
4074 |
||
4075 |
%{ /* NOCONTEXT */ |
|
4076 |
extern int __lifoRememberedSetSize(); |
|
4077 |
||
4078 |
RETURN (__MKSMALLINT(__lifoRememberedSetSize())); |
|
615 | 4079 |
%} |
4080 |
" |
|
4081 |
ObjectMemory lifoRememberedSetSize |
|
4082 |
" |
|
4083 |
! |
|
4084 |
||
1288 | 4085 |
markAndSweepCount |
4086 |
"return the number of mark&sweep collects that occurred since startup" |
|
4087 |
||
4088 |
%{ /* NOCONTEXT */ |
|
4089 |
extern int __markAndSweepCount(); |
|
4090 |
||
4091 |
RETURN (__MKSMALLINT(__markAndSweepCount())); |
|
615 | 4092 |
%} |
4093 |
" |
|
4094 |
ObjectMemory markAndSweepCount |
|
4095 |
" |
|
4096 |
! |
|
4097 |
||
1288 | 4098 |
maximumIdentityHashValue |
4099 |
"for ST-80 compatibility: return the maximum value |
|
4100 |
a hashKey as returned by identityHash can get. |
|
4101 |
Since ST/X uses direct pointers, a field in the objectHeader |
|
4102 |
is used, which is currently 11 bits in size." |
|
4103 |
||
4104 |
%{ /* NOCONTEXT */ |
|
4105 |
RETURN ( __MKSMALLINT( __MAX_HASH__ << __HASH_SHIFT__) ); |
|
615 | 4106 |
%} |
4107 |
" |
|
4108 |
ObjectMemory maximumIdentityHashValue |
|
4109 |
" |
|
4110 |
! |
|
4111 |
||
1288 | 4112 |
minScavengeReclamation |
4113 |
"returns the number of bytes replacimed by the least effective scavenge. |
|
4114 |
For statistic only - this may vanish." |
|
4115 |
||
4116 |
%{ /* NOCONTEXT */ |
|
4117 |
extern int __newSpaceReclaimedMin(); |
|
4118 |
||
4119 |
RETURN ( __MKSMALLINT(__newSpaceReclaimedMin()) ); |
|
615 | 4120 |
%} |
4121 |
" |
|
4122 |
ObjectMemory minScavengeReclamation |
|
4123 |
" |
|
4124 |
! |
|
4125 |
||
1288 | 4126 |
newSpaceSize |
4127 |
"return the total size of the new space - this is usually fix" |
|
4128 |
||
4129 |
%{ /* NOCONTEXT */ |
|
4130 |
extern unsigned __newSpaceSize(); |
|
4131 |
||
4132 |
RETURN ( __MKSMALLINT(__newSpaceSize()) ); |
|
615 | 4133 |
%} |
4134 |
" |
|
4135 |
ObjectMemory newSpaceSize |
|
4136 |
" |
|
4137 |
! |
|
4138 |
||
1288 | 4139 |
newSpaceUsed |
4140 |
"return the number of bytes allocated for new objects. |
|
4141 |
The returned value is usually obsolete as soon as you do |
|
4142 |
something with it ..." |
|
4143 |
||
4144 |
%{ /* NOCONTEXT */ |
|
4145 |
extern unsigned __newSpaceUsed(); |
|
4146 |
||
4147 |
RETURN ( __MKSMALLINT(__newSpaceUsed()) ); |
|
615 | 4148 |
%} |
4149 |
" |
|
4150 |
ObjectMemory newSpaceUsed |
|
4151 |
" |
|
4152 |
! |
|
4153 |
||
1288 | 4154 |
numberOfObjects |
4155 |
"return the number of objects in the system." |
|
4156 |
||
4157 |
|tally "{ Class: SmallInteger }"| |
|
4158 |
||
4159 |
tally := 0. |
|
4160 |
self allObjectsDo:[:obj | tally := tally + 1]. |
|
615 | 4161 |
^ tally |
4162 |
||
4163 |
" |
|
4164 |
ObjectMemory numberOfObjects |
|
4165 |
" |
|
4166 |
! |
|
4167 |
||
1288 | 4168 |
numberOfWeakObjects |
4169 |
"return the number of weak objects in the system" |
|
4170 |
||
4171 |
%{ /* NOCONTEXT */ |
|
4172 |
extern int __weakListSize(); |
|
4173 |
||
4174 |
RETURN ( __MKSMALLINT(__weakListSize()) ); |
|
615 | 4175 |
%} |
4176 |
" |
|
4177 |
ObjectMemory numberOfWeakObjects |
|
4178 |
" |
|
4179 |
! |
|
4180 |
||
1288 | 4181 |
oldSpaceAllocatedSinceLastGC |
4182 |
"return the number of bytes allocated for old objects since the |
|
4183 |
last oldspace garbage collect occured. This information is used |
|
4184 |
by ProcessorScheduler to decide when to start the incremental |
|
4185 |
background GC." |
|
4186 |
||
4187 |
%{ /* NOCONTEXT */ |
|
4188 |
extern unsigned __oldSpaceAllocatedSinceLastGC(); |
|
4189 |
||
4190 |
RETURN ( __MKSMALLINT(__oldSpaceAllocatedSinceLastGC()) ); |
|
615 | 4191 |
%} |
4192 |
" |
|
4193 |
ObjectMemory oldSpaceAllocatedSinceLastGC |
|
4194 |
" |
|
4195 |
! |
|
4196 |
||
1288 | 4197 |
oldSpaceSize |
4198 |
"return the total size of the old space. - may grow slowly" |
|
4199 |
||
4200 |
%{ /* NOCONTEXT */ |
|
4201 |
extern unsigned __oldSpaceSize(); |
|
4202 |
||
4203 |
RETURN ( __MKSMALLINT(__oldSpaceSize()) ); |
|
615 | 4204 |
%} |
4205 |
" |
|
4206 |
ObjectMemory oldSpaceSize |
|
4207 |
" |
|
4208 |
! |
|
4209 |
||
1288 | 4210 |
oldSpaceUsed |
4211 |
"return the number of bytes allocated for old objects. |
|
4212 |
(This includes the free lists)" |
|
4213 |
||
4214 |
%{ /* NOCONTEXT */ |
|
4215 |
extern unsigned __oldSpaceUsed(); |
|
4216 |
||
4217 |
RETURN ( __MKSMALLINT(__oldSpaceUsed()) ); |
|
615 | 4218 |
%} |
4219 |
" |
|
4220 |
ObjectMemory oldSpaceUsed |
|
4221 |
" |
|
4222 |
! |
|
4223 |
||
1288 | 4224 |
rememberedSetSize |
4225 |
"return the number of old objects referencing new ones. |
|
4226 |
This is a VM debugging interface and may vanish without notice." |
|
4227 |
||
4228 |
%{ /* NOCONTEXT */ |
|
4229 |
extern int __rememberedSetSize(); |
|
4230 |
||
4231 |
RETURN (__MKSMALLINT(__rememberedSetSize())); |
|
615 | 4232 |
%} |
4233 |
" |
|
4234 |
ObjectMemory rememberedSetSize |
|
4235 |
" |
|
4236 |
! |
|
4237 |
||
1288 | 4238 |
resetMinScavengeReclamation |
4239 |
"resets the number of bytes replacimed by the least effective scavenge. |
|
4240 |
For statistic only - this may vanish." |
|
4241 |
||
4242 |
%{ /* NOCONTEXT */ |
|
4243 |
extern int __resetNewSpaceReclaimedMin(); |
|
4244 |
||
4245 |
__resetNewSpaceReclaimedMin(); |
|
4246 |
%}. |
|
4247 |
^ self |
|
4248 |
" |
|
4249 |
ObjectMemory resetMinScavengeReclamation. |
|
615 | 4250 |
ObjectMemory minScavengeReclamation |
4251 |
" |
|
4252 |
! |
|
4253 |
||
1288 | 4254 |
runsSingleOldSpace |
4255 |
"return true, if the system runs in a single oldSpace or |
|
4256 |
false if not. |
|
4257 |
The memory system will always drop the second semispace when |
|
4258 |
running out of virtual memory, or the baker-limit is reached. |
|
4259 |
OBSOLETE: |
|
4260 |
the system may now decide at any time to switch between |
|
4261 |
single and double-space algorithms, depending on the overall memory |
|
4262 |
size. You will now almost always get false as result, since the |
|
4263 |
second semispace is only allocated when needed, and released |
|
4264 |
immediately afterwards. |
|
4265 |
" |
|
4266 |
||
4267 |
%{ /* NOCONTEXT */ |
|
4268 |
extern int __runsSingleOldSpace(); |
|
4269 |
||
4270 |
RETURN ( (__runsSingleOldSpace() ? true : false) ); |
|
615 | 4271 |
%} |
4272 |
" |
|
4273 |
ObjectMemory runsSingleOldSpace |
|
4274 |
" |
|
4275 |
! |
|
4276 |
||
1288 | 4277 |
scavengeCount |
4278 |
"return the number of scavenges that occurred since startup" |
|
4279 |
||
4280 |
%{ /* NOCONTEXT */ |
|
4281 |
extern int __scavengeCount(); |
|
4282 |
||
4283 |
RETURN (__MKSMALLINT(__scavengeCount())); |
|
615 | 4284 |
%} |
4285 |
" |
|
4286 |
ObjectMemory scavengeCount |
|
4287 |
" |
|
4288 |
! |
|
4289 |
||
1288 | 4290 |
symSpaceSize |
4291 |
"return the total size of the sym space." |
|
4292 |
||
4293 |
%{ /* NOCONTEXT */ |
|
4294 |
extern unsigned __symSpaceSize(); |
|
4295 |
||
4296 |
RETURN ( __MKSMALLINT(__symSpaceSize()) ); |
|
615 | 4297 |
%} |
4298 |
" |
|
4299 |
ObjectMemory symSpaceSize |
|
4300 |
" |
|
4301 |
! |
|
4302 |
||
1288 | 4303 |
symSpaceUsed |
4304 |
"return the number of bytes allocated for old objects in sym space." |
|
4305 |
||
4306 |
%{ /* NOCONTEXT */ |
|
4307 |
extern unsigned __symSpaceUsed(); |
|
4308 |
||
4309 |
RETURN ( __MKSMALLINT(__symSpaceUsed()) ); |
|
615 | 4310 |
%} |
4311 |
" |
|
4312 |
ObjectMemory symSpaceUsed |
|
4313 |
" |
|
4314 |
! |
|
4315 |
||
1288 | 4316 |
tenureAge |
4317 |
"return the current tenure age - thats the number of times |
|
4318 |
an object has to survive scavenges to be moved into oldSpace. |
|
4319 |
For statistic/debugging only - this method may vanish" |
|
4320 |
||
4321 |
%{ /* NOCONTEXT */ |
|
615 | 4322 |
extern unsigned __tenureAge(); |
4323 |
||
1133 | 4324 |
RETURN ( __MKSMALLINT(__tenureAge()) ); |
615 | 4325 |
%} |
4326 |
! |
|
4327 |
||
3181
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4328 |
vmSymbols |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4329 |
"return a collection of symbols used by the VM" |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4330 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4331 |
"/ DO NOT REMOVE THIS METHOD. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4332 |
"/ 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
|
4333 |
"/ in fixed (non-moving) memory. |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4334 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4335 |
^ #( |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4336 |
"/ interpreter stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4337 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4338 |
"/ JavaVM stuff |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4339 |
|
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4340 |
nativeMethodInvokation |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4341 |
newCleared |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4342 |
monitorEnter: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4343 |
monitorExit: |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4344 |
classInit |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4345 |
javaClass |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4346 |
resolve |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4347 |
resolveStatic |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4348 |
) |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4349 |
! |
c7041542f8b8
added vmSymbols (needed for Java)
Claus Gittinger <cg@exept.de>
parents:
3108
diff
changeset
|
4350 |
|
1288 | 4351 |
whoReferences:anObject |
4352 |
"return a collection of objects referencing the argument, anObject" |
|
4353 |
||
4354 |
^ self collectObjectsWhich:[:o | o references:anObject] |
|
615 | 4355 |
|
4356 |
" |
|
4357 |
(ObjectMemory whoReferences:Transcript) printNL |
|
4358 |
" |
|
4359 |
! |
|
4360 |
||
3262
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4361 |
whoReferencesAny:aCollection |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4362 |
"return a collection of objects referencing any object from |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4363 |
the argument, aCollection" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4364 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4365 |
^ self collectObjectsWhich:[:o | o referencesAny:aCollection] |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4366 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4367 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4368 |
ObjectMemory whoReferencesAny:(Array with:Transcript with:Smalltalk) |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4369 |
" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4370 |
|
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4371 |
"Modified: / 2.2.1998 / 16:08:18 / cg" |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4372 |
! |
5a9d609d8b25
added #displayRefChainTo: - for debugging
Claus Gittinger <cg@exept.de>
parents:
3223
diff
changeset
|
4373 |
|
1288 | 4374 |
whoReferencesDerivedInstancesOf:aClass |
4375 |
"return a collection of objects refering to instances |
|
4376 |
of the argument, aClass or a subclass of it." |
|
4377 |
||
4378 |
^ self collectObjectsWhich:[:o | o referencesDerivedInstanceOf:aClass] |
|
615 | 4379 |
|
4380 |
" |
|
4381 |
(ObjectMemory whoReferencesDerivedInstancesOf:View) printNL |
|
4382 |
" |
|
1288 | 4383 |
! |
4384 |
||
4385 |
whoReferencesInstancesOf:aClass |
|
4386 |
"return a collection of objects refering to instances |
|
4387 |
of the argument, aClass" |
|
4388 |
||
4389 |
^ self collectObjectsWhich:[:o | o referencesInstanceOf:aClass] |
|
4390 |
||
4391 |
" |
|
4392 |
(ObjectMemory whoReferencesInstancesOf:SystemBrowser) printNL |
|
4393 |
" |
|
615 | 4394 |
! ! |
4395 |
||
1767 | 4396 |
!ObjectMemory class methodsFor:'semaphore access'! |
615 | 4397 |
|
1288 | 4398 |
lowSpaceSemaphore |
4399 |
"return the semaphore that is signalled when the system detects a |
|
4400 |
low space condition. Usually, some time after this, an allocationFailure |
|
4401 |
will happen. You can have a cleanup process sitting in that semaphore and |
|
4402 |
start to release object." |
|
379 | 4403 |
|
1286 | 4404 |
^ LowSpaceSemaphore |
379 | 4405 |
! ! |
4406 |
||
1767 | 4407 |
!ObjectMemory class methodsFor:'statistics'! |
1288 | 4408 |
|
4409 |
ageStatistic |
|
2524 | 4410 |
"for ST/X developers only: |
4411 |
dump contents of newSpace with objects age information. |
|
4412 |
This method may be removed without notice" |
|
4413 |
||
1288 | 4414 |
%{ /* NOCONTEXT */ |
1286 | 4415 |
|
4416 |
__ageStatistics(); |
|
4417 |
%} |
|
2524 | 4418 |
" |
4419 |
ObjectMemory ageStatistic |
|
4420 |
" |
|
4421 |
! |
|
4422 |
||
4423 |
codeCacheInfo |
|
4424 |
"for ST/X developers only: |
|
4425 |
dump contents of dynamic code cache LRU lists. |
|
4426 |
This method may be removed without notice" |
|
4427 |
||
4428 |
%{ /* NOCONTEXT */ |
|
2525 | 4429 |
OBJ __codeCacheInfo(); |
2524 | 4430 |
|
4431 |
RETURN (__codeCacheInfo()); |
|
4432 |
%} |
|
4433 |
" |
|
4434 |
ObjectMemory codeCacheInfo do:[:item | |
|
4435 |
|n nMethods nBytes| |
|
4436 |
||
4437 |
n := item at:1. |
|
4438 |
nMethods := item at:2. |
|
4439 |
nBytes := item at:3. |
|
4440 |
||
4441 |
n isNil ifTrue:[ |
|
4442 |
||
4443 |
] ifFalse:[ |
|
4444 |
(n printStringLeftPaddedTo:2) print. |
|
4445 |
]. |
|
4446 |
' ' print. |
|
4447 |
(nMethods printStringLeftPaddedTo:4) print. |
|
4448 |
' ' print. |
|
4449 |
(nBytes printStringLeftPaddedTo:6) printCR. |
|
4450 |
] |
|
4451 |
" |
|
4452 |
||
1288 | 4453 |
! ! |
4454 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4455 |
!ObjectMemory class methodsFor:'system configuration queries'! |
1288 | 4456 |
|
4457 |
allBinaryModulesDo:aBlock |
|
4458 |
"internal private method - walk over all known binary |
|
4459 |
modules and evaluate aBlock for each entry. |
|
4460 |
Do not depend on the information returned for each - this may |
|
418 | 4461 |
change without notice." |
4462 |
||
4463 |
%{ |
|
4464 |
__REGISTRATION_DO_BLOCK(&aBlock COMMA_SND); |
|
4465 |
%} |
|
4466 |
! |
|
4467 |
||
1288 | 4468 |
binaryModuleInfo |
4469 |
"return a collection of moduleInfo entries. |
|
4470 |
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
|
4471 |
with one entry for each binary package (module)." |
1288 | 4472 |
|
4473 |
|modules| |
|
4474 |
||
4475 |
modules := IdentityDictionary new. |
|
4476 |
self allBinaryModulesDo:[:entry | |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4477 |
|id name type libName subModuleName module dynamic infoRec pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4478 |
typeName nameString| |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4479 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4480 |
id := entry at:1. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4481 |
subModuleName := (entry at:2) asSymbol. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4482 |
libName := (entry at:4). |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4483 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4484 |
id > 0 ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4485 |
pathName := ObjectFileLoader pathNameFromID:id. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4486 |
dynamic := true. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4487 |
typeName := 'dynamic '. |
2580
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4488 |
pathName isNil ifTrue:[ |
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4489 |
name := '?' |
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4490 |
] ifFalse:[ |
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4491 |
name := pathName asFilename baseName |
d649a490f236
care for nil pathName in moduleEntry
Claus Gittinger <cg@exept.de>
parents:
2526
diff
changeset
|
4492 |
] |
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4493 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4494 |
dynamic := false. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4495 |
typeName := 'builtIn '. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4496 |
pathName := nil. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4497 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4498 |
name := subModuleName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4499 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4500 |
name := libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4501 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4502 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4503 |
nameString := typeName. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4504 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4505 |
nameString := nameString, 'module ' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4506 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4507 |
nameString := nameString, 'classLib ' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4508 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4509 |
nameString := nameString , name. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4510 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4511 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4512 |
type := #classObject |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4513 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4514 |
type := #classLibrary |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4515 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4516 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4517 |
infoRec := modules at:id ifAbsent:nil. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4518 |
infoRec notNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4519 |
infoRec classNames add:subModuleName. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4520 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4521 |
infoRec := BinaryModuleDescriptor |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4522 |
name:nameString |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4523 |
type:type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4524 |
id:id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4525 |
dynamic:dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4526 |
classNames:(Set with:subModuleName) |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4527 |
pathName:pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4528 |
libraryName:libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4529 |
timeStamp:nil. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4530 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4531 |
modules at:id put:infoRec. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4532 |
]. |
1288 | 4533 |
]. |
4534 |
^ modules |
|
4535 |
||
4536 |
" |
|
4537 |
ObjectMemory binaryModuleInfo |
|
418 | 4538 |
" |
4539 |
||
438 | 4540 |
"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
|
4541 |
"Modified: 22.4.1997 / 23:42:59 / cg" |
418 | 4542 |
! |
4543 |
||
1288 | 4544 |
fullBinaryModuleInfo |
4545 |
"return a full collection of moduleInfo entries. |
|
4546 |
This returns a dictionary (keys are component names) |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4547 |
with one entry for each sub-component in all binary packages." |
1288 | 4548 |
|
4549 |
|modules| |
|
4550 |
||
4551 |
modules := IdentityDictionary new. |
|
4552 |
self allBinaryModulesDo:[:entry | |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4553 |
|infoEntry |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4554 |
id name type libName subModuleName module dynamic pathName t| |
1503
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4555 |
|
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4556 |
id := entry at:1. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4557 |
subModuleName := (entry at:2) asSymbol. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4558 |
libName := (entry at:4). |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4559 |
t := AbsoluteTime fromOSTime:((entry at:5) * 1000). |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4560 |
|
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4561 |
id > 0 ifTrue:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4562 |
dynamic := true. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4563 |
] ifFalse:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4564 |
dynamic := false. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4565 |
]. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4566 |
libName isNil ifTrue:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4567 |
type := #classObject |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4568 |
] ifFalse:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4569 |
type := #classLibrary |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
4570 |
]. |
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4571 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4572 |
"/ ... new: |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4573 |
infoEntry := BinaryModuleDescriptor |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4574 |
name:nil |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4575 |
type:type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4576 |
id:id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4577 |
dynamic:dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4578 |
classNames:(Array with:subModuleName) |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4579 |
pathName:nil |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4580 |
libraryName:libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4581 |
timeStamp:t. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4582 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4583 |
modules at:subModuleName put:infoEntry. |
1288 | 4584 |
]. |
4585 |
^ modules |
|
4586 |
||
4587 |
" |
|
4588 |
ObjectMemory fullBinaryModuleInfo |
|
418 | 4589 |
" |
4590 |
||
4591 |
"Modified: 30.8.1995 / 17:29:30 / claus" |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4592 |
"Modified: 31.10.1996 / 13:58:44 / cg" |
615 | 4593 |
! |
4594 |
||
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4595 |
getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4596 |
"return a collection of release strings giving information |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4597 |
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
|
4598 |
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
|
4599 |
change or vanish without notice." |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4600 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4601 |
%{ |
3729
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
4602 |
extern OBJ __getVMReleaseStrings(); |
dfb4670c8b1f
need ext decl for getVMReleaseStrings
Claus Gittinger <cg@exept.de>
parents:
3725
diff
changeset
|
4603 |
|
3699
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4604 |
RETURN (__getVMReleaseStrings()); |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4605 |
%} |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4606 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4607 |
ObjectMemory getVMIdentificationStrings |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4608 |
" |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4609 |
! ! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4610 |
|
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4611 |
!ObjectMemory class methodsFor:'system management'! |
6d315f76aa33
moved some debugging methods from Smalltalk.
Claus Gittinger <cg@exept.de>
parents:
3652
diff
changeset
|
4612 |
|
1288 | 4613 |
imageBaseName |
4614 |
"return a reasonable filename to use as baseName (i.e. without extension). |
|
4615 |
This is the filename of the current image (without '.img') or, |
|
4616 |
if not running from an image, the default name 'st'" |
|
4617 |
||
4618 |
|nm| |
|
4619 |
||
4620 |
nm := ImageName. |
|
4621 |
(nm isNil or:[nm isBlank]) ifTrue:[ |
|
4622 |
^ 'st' |
|
4623 |
]. |
|
4624 |
(nm endsWith:'.sav') ifTrue:[ |
|
4625 |
nm := nm copyWithoutLast:4 |
|
4626 |
]. |
|
4627 |
(nm endsWith:'.img') ifTrue:[ |
|
4628 |
^ nm copyWithoutLast:4 |
|
615 | 4629 |
]. |
4630 |
^ nm |
|
4631 |
||
4632 |
" |
|
4633 |
ObjectMemory imageBaseName |
|
4634 |
" |
|
4635 |
! |
|
4636 |
||
1288 | 4637 |
imageName |
4638 |
"return the filename of the current image, or nil |
|
4639 |
if not running from an image." |
|
615 | 4640 |
|
4641 |
^ ImageName |
|
335 | 4642 |
|
4643 |
" |
|
615 | 4644 |
ObjectMemory imageName |
335 | 4645 |
" |
1 | 4646 |
! |
4647 |
||
1288 | 4648 |
imageSaveTime |
4649 |
"return a timestamp for when the running image was saved. |
|
1096 | 4650 |
Return nil if not running from an image." |
4651 |
||
4652 |
^ ImageSaveTime |
|
4653 |
! |
|
4654 |
||
1288 | 4655 |
loadClassBinary:aClassName |
4656 |
"find the object file for aClassName and -if found - load it; |
|
4657 |
this one loads precompiled object files" |
|
4658 |
||
4659 |
|fName newClass| |
|
4660 |
||
4661 |
fName := self fileNameForClass:aClassName. |
|
4662 |
fName notNil ifTrue:[ |
|
4663 |
Class withoutUpdatingChangesDo: |
|
4664 |
[ |
|
4665 |
self loadBinary:(fName , '.o') |
|
4666 |
]. |
|
4667 |
newClass := self at:(aClassName asSymbol). |
|
4668 |
(newClass notNil and:[newClass implements:#initialize]) ifTrue:[ |
|
615 | 4669 |
newClass initialize |
159 | 4670 |
] |
615 | 4671 |
] |
4672 |
! |
|
4673 |
||
1288 | 4674 |
nameForChanges |
4675 |
"return a reasonable filename to store the changes into. |
|
4676 |
Currently, this is defined in a classVariable and defaults to 'changes'. |
|
4677 |
In future versions, this will be the basename of the current image with '.img' replaced |
|
4678 |
by '.chg', or, if not running from an image, the default name 'st.chg'." |
|
4679 |
||
4680 |
ChangeFileName notNil ifTrue:[^ ChangeFileName]. |
|
4681 |
^ 'changes'. |
|
4682 |
||
4683 |
"/ future versions will have: |
|
4684 |
"/ (requires some additionas at other places) |
|
4685 |
"/ |
|
615 | 4686 |
"/ ^ self imageBaseName , '.chg' |
1 | 4687 |
|
335 | 4688 |
" |
615 | 4689 |
ObjectMemory nameForChanges |
4690 |
" |
|
4691 |
! |
|
4692 |
||
1288 | 4693 |
nameForChanges:aFilename |
4694 |
"set the name of the file where changes are stored into." |
|
4695 |
||
4696 |
ChangeFileName := aFilename |
|
615 | 4697 |
|
4698 |
" |
|
4699 |
ObjectMemory nameForChanges:'myChanges' |
|
4700 |
" |
|
4701 |
! |
|
4702 |
||
1288 | 4703 |
nameForSnapshot |
4704 |
"return a reasonable filename to store the snapshot image into. |
|
4705 |
This is the filename of the current image or, |
|
4706 |
if not running from an image, the default name 'st.img'" |
|
4707 |
||
4708 |
^ self imageBaseName , '.img' |
|
615 | 4709 |
|
4710 |
" |
|
4711 |
ObjectMemory nameForSnapshot |
|
335 | 4712 |
" |
1 | 4713 |
! |
4714 |
||
1288 | 4715 |
nameForSources |
4716 |
"return a reasonable filename to store the sources into. |
|
4717 |
This is the basename of the current image with '.img' replaced |
|
4718 |
by '.src', or, if not running from an image, the default name 'st.src'" |
|
615 | 4719 |
|
4720 |
^ self imageBaseName , '.src' |
|
362 | 4721 |
|
4722 |
" |
|
615 | 4723 |
ObjectMemory nameForSources |
4724 |
" |
|
4725 |
! |
|
4726 |
||
1288 | 4727 |
primSnapShotOn:aFileName |
4728 |
"create a snapshot in the given file. |
|
4729 |
Low level entry. Does not notify classes or write an entry to |
|
1704 | 4730 |
the changes file. Also, no image backup is created. |
4731 |
Returns true if the snapshot worked, false if it failed for some reason. |
|
1288 | 4732 |
This method should not be used in normal cases." |
4733 |
||
1704 | 4734 |
|ok oldImageName oldImageTime| |
4735 |
||
4736 |
" |
|
4737 |
save the name and time with it ... |
|
4738 |
" |
|
4739 |
oldImageName := ImageName. |
|
4740 |
oldImageTime := ImageSaveTime. |
|
4741 |
||
4742 |
ImageName := aFileName. |
|
4743 |
ImageSaveTime := AbsoluteTime now. |
|
4744 |
||
4745 |
%{ /* CALLSSTACK:32000 */ |
|
1288 | 4746 |
|
4747 |
OBJ __snapShotOn(); |
|
4748 |
OBJ funny = @symbol(funnySnapshotSymbol); |
|
4749 |
||
4750 |
if (__isString(aFileName)) { |
|
4751 |
__BLOCKINTERRUPTS(); |
|
4752 |
ok = __snapShotOn(__context, _stringVal(aFileName), funny); |
|
615 | 4753 |
__UNBLOCKINTERRUPTS(); |
4754 |
} |
|
4755 |
%}. |
|
1704 | 4756 |
|
4757 |
ImageName := oldImageName. |
|
4758 |
ImageSaveTime := oldImageTime. |
|
4759 |
||
615 | 4760 |
^ ok |
4761 |
! |
|
4762 |
||
1288 | 4763 |
snapShot |
4764 |
"create a snapshot file containing all of the current state." |
|
615 | 4765 |
|
4766 |
self snapShotOn:(self nameForSnapshot) |
|
4767 |
||
4768 |
" |
|
4769 |
ObjectMemory snapShot |
|
362 | 4770 |
" |
1288 | 4771 |
! |
4772 |
||
4773 |
snapShotOn:aFileName |
|
4774 |
"create a snapshot in the given file. |
|
4775 |
If the file exists, save it for backup. |
|
4776 |
Return true if the snapshot worked, false if it failed for some reason. |
|
4777 |
Notify dependents before and after the snapshot operation." |
|
4778 |
||
2924 | 4779 |
|ok fn| |
1288 | 4780 |
|
4781 |
" |
|
4782 |
keep a save version - just in case something |
|
4783 |
bad happens while writing the image. |
|
4784 |
(could be st/x internal error or file-system errors etc) |
|
4785 |
" |
|
2924 | 4786 |
fn := aFileName asFilename. |
4787 |
fn exists ifTrue:[ |
|
4788 |
fn renameTo:(fn withSuffix:'sav') |
|
1288 | 4789 |
]. |
4790 |
||
4791 |
" |
|
4792 |
give others a chance to fix things |
|
4793 |
" |
|
4794 |
self changed:#save. "/ will vanish ... |
|
4795 |
self changed:#aboutToSnapshot. "/ ... for ST-80 compatibility |
|
4796 |
||
4797 |
" |
|
4798 |
ST-80 compatibility; send #preSnapshot to all classes |
|
4799 |
" |
|
4800 |
Smalltalk allBehaviorsDo:[:aClass | |
|
4801 |
aClass preSnapshot |
|
4802 |
]. |
|
4803 |
||
4804 |
ok := self primSnapShotOn:aFileName. |
|
4805 |
||
4806 |
ok ifTrue:[ |
|
4807 |
Class addChangeRecordForSnapshot:aFileName. |
|
4808 |
]. |
|
4809 |
||
4810 |
||
4811 |
" |
|
4812 |
ST-80 compatibility; send #postSnapshot to all classes |
|
4813 |
" |
|
4814 |
Smalltalk allBehaviorsDo:[:aClass | |
|
4815 |
aClass postSnapshot |
|
4816 |
]. |
|
4817 |
self changed:#finishedSnapshot. "/ ST-80 compatibility |
|
4818 |
^ ok |
|
4819 |
||
4820 |
" |
|
4821 |
ObjectMemory snapShotOn:'myimage.img' |
|
4822 |
" |
|
362 | 4823 |
! ! |
615 | 4824 |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4825 |
!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
|
4826 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4827 |
name:n type:t id:i dynamic:d classNames:c pathName:p libraryName:l timeStamp:ts |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4828 |
^ (self basicNew) name:n type:t id:i dynamic:d classNames:c pathName:p libraryName:l timeStamp:ts |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4829 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4830 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4831 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4832 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4833 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'accessing'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4834 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4835 |
classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4836 |
"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
|
4837 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4838 |
^ classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4839 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4840 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4841 |
dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4842 |
"return true, if this module was loaded dynamically |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4843 |
(as opposed to a module which was linked into the system right from |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4844 |
the start. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4845 |
Do not cofuse this with shared libraries - these may be dynamic or not)." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4846 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4847 |
^ dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4848 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4849 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4850 |
id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4851 |
"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
|
4852 |
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
|
4853 |
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
|
4854 |
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
|
4855 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4856 |
^ id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4857 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4858 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4859 |
libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4860 |
"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
|
4861 |
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
|
4862 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4863 |
^ libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4864 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4865 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4866 |
name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4867 |
"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
|
4868 |
libraryName." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4869 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4870 |
^ name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4871 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4872 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4873 |
pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4874 |
"return the modules pathName" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4875 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4876 |
^ pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4877 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4878 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4879 |
timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4880 |
"return the modules timeStamp" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4881 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4882 |
^ timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4883 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4884 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4885 |
type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4886 |
"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
|
4887 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4888 |
^ type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4889 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4890 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4891 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'backward compatibility'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4892 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4893 |
at:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4894 |
"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
|
4895 |
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
|
4896 |
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
|
4897 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4898 |
^ self perform:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4899 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4900 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4901 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'private access'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4902 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4903 |
name:n type:t id:i dynamic:d classNames:c pathName:p libraryName:l timeStamp:ts |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4904 |
name := n. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4905 |
type := t. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4906 |
id := i. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4907 |
dynamic := d. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4908 |
classNames := c. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4909 |
libraryName := l. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4910 |
timeStamp := ts. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4911 |
pathName := p. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4912 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
4913 |
|
1767 | 4914 |
!ObjectMemory class methodsFor:'documentation'! |
630 | 4915 |
|
1288 | 4916 |
version |
3858
4be800f88b8e
added interface to incrementalSweeping()
Claus Gittinger <cg@exept.de>
parents:
3781
diff
changeset
|
4917 |
^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.172 1998-09-29 10:44:05 cg Exp $' |
630 | 4918 |
! ! |
615 | 4919 |
ObjectMemory initialize! |