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