author | Claus Gittinger <cg@exept.de> |
Thu, 07 Nov 1996 19:54:49 +0100 | |
changeset 1926 | eda492a4e179 |
parent 1848 | 5aa378aa47a9 |
child 1939 | 214f42e29868 |
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 |
28 |
DynamicCodeLimit' |
|
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 |
||
619 |
LowSpaceSemaphore := Semaphore new. |
|
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 |
|
643 |
^ self freeSpace + self freeListSpace |
|
644 |
||
645 |
" |
|
646 |
ObjectMemory availableFreeBytes |
|
647 |
" |
|
648 |
! |
|
649 |
||
650 |
bytesPerOOP |
|
651 |
"return the number of bytes an object reference (for example: an instvar) |
|
652 |
takes" |
|
653 |
||
654 |
%{ /* NOCONTEXT */ |
|
655 |
RETURN(__MKSMALLINT(sizeof(OBJ))); |
|
656 |
%} |
|
657 |
||
658 |
" |
|
659 |
ObjectMemory bytesPerOOP |
|
660 |
" |
|
661 |
! |
|
662 |
||
663 |
bytesPerOTE |
|
664 |
"return the number of overhead bytes of an object. |
|
665 |
i.e. the number of bytes in every objects header." |
|
666 |
||
667 |
%{ /* NOCONTEXT */ |
|
668 |
RETURN(__MKSMALLINT(OHDR_SIZE)); |
|
669 |
%} |
|
670 |
||
671 |
" |
|
672 |
ObjectMemory bytesPerOTE |
|
673 |
" |
|
674 |
! |
|
675 |
||
676 |
compactingGC |
|
677 |
self garbageCollect |
|
678 |
! |
|
679 |
||
680 |
current |
|
681 |
^ self |
|
682 |
! |
|
683 |
||
684 |
globalCompactingGC |
|
685 |
self garbageCollect |
|
686 |
! |
|
687 |
||
688 |
growMemoryBy:numberOfBytes |
|
689 |
^ self moreOldSpace:numberOfBytes |
|
690 |
! |
|
691 |
||
692 |
numOopsNumBytes |
|
693 |
^ Array with:(self numberOfObjects) |
|
694 |
with:(self bytesUsed) |
|
695 |
||
696 |
" |
|
697 |
ObjectMemory numOopsNumBytes |
|
698 |
" |
|
699 |
! ! |
|
700 |
||
1767 | 701 |
!ObjectMemory class methodsFor:'Signal constants'! |
2 | 702 |
|
703 |
allocationFailureSignal |
|
13 | 704 |
"return the signal raised when an object allocation failed" |
705 |
||
2 | 706 |
^ AllocationFailureSignal |
464
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
707 |
! |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
708 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
709 |
mallocFailureSignal |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
710 |
"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
|
711 |
(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
|
712 |
non-Object storage)" |
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
713 |
|
83af924c8cff
differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents:
458
diff
changeset
|
714 |
^ MallocFailureSignal |
2 | 715 |
! ! |
1 | 716 |
|
1767 | 717 |
!ObjectMemory class methodsFor:'VM messages'! |
375 | 718 |
|
615 | 719 |
debugPrinting |
720 |
"return true, if various debug printouts in the VM |
|
375 | 721 |
are turned on, false of off." |
722 |
||
723 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
724 |
extern int __getDebugPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
725 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
726 |
RETURN (__getDebugPrinting() ? true : false); |
375 | 727 |
%} |
728 |
! |
|
729 |
||
730 |
debugPrinting:aBoolean |
|
731 |
"turn on/off various debug printouts in the VM |
|
732 |
in case of an error. For example, a double-notUnderstood |
|
733 |
leads to a VM context dump if debugPrinting is on. |
|
734 |
If off, those messages are suppressed. |
|
735 |
The default is on, since these messages are only printed for |
|
736 |
severe errors." |
|
737 |
||
738 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
739 |
__setDebugPrinting( (aBoolean == true) ); |
375 | 740 |
%} |
741 |
! |
|
742 |
||
615 | 743 |
infoPrinting |
744 |
"return true, if various informational printouts in the VM |
|
375 | 745 |
are turned on, false of off." |
746 |
||
747 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
748 |
extern int __getInfoPrinting(); |
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
749 |
|
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
750 |
RETURN (__getInfoPrinting() ? true : false); |
615 | 751 |
%} |
752 |
! |
|
753 |
||
754 |
infoPrinting:aBoolean |
|
755 |
"turn on/off various informational printouts in the VM. |
|
756 |
For example, the GC activity messages are controlled by |
|
757 |
this flags setting. |
|
758 |
The default is true, since (currently) those messages |
|
759 |
are useful for ST/X developers." |
|
760 |
||
761 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
762 |
__setInfoPrinting( (aBoolean == true) ); |
615 | 763 |
%} |
764 |
! ! |
|
765 |
||
1767 | 766 |
!ObjectMemory class methodsFor:'access debugging'! |
703 | 767 |
|
768 |
setTrapOnAccessFor:anObject |
|
769 |
"install an access trap for anObject; |
|
770 |
An accessSignal will be raised, whenever any instvar of anObject is either read or written. |
|
771 |
This is not supported on all architectures, therefore the return value |
|
772 |
(true of trap was installed ok, false if failed) should be checked." |
|
773 |
||
774 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
775 |
RETURN (__addTrapOnAccess(anObject, 2) ? true : false); |
703 | 776 |
%} |
777 |
! |
|
778 |
||
779 |
setTrapOnReadFor:anObject |
|
780 |
"install a read trap for anObject; |
|
781 |
An accessSignal will be raised, whenever any access into anObject occurrs. |
|
782 |
This is not supported on all architectures, therefore the return value |
|
783 |
(true of trap was installed ok, false if failed) should be checked." |
|
784 |
||
785 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
786 |
RETURN (__addTrapOnAccess(anObject, 0) ? true : false); |
703 | 787 |
%} |
788 |
! |
|
789 |
||
790 |
setTrapOnWriteFor:anObject |
|
791 |
"install a write trap for anObject; |
|
792 |
An accessSignal will be raised, whenever any instvar of anObject is written to. |
|
793 |
This is not supported on all architectures, therefore the return value |
|
794 |
(true of trap was installed ok, false if failed) should be checked." |
|
795 |
||
796 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
797 |
RETURN (__addTrapOnAccess(anObject, 1) ? true : false); |
703 | 798 |
%} |
799 |
! |
|
800 |
||
801 |
unsetAllTraps |
|
802 |
"remove all access traps" |
|
803 |
||
804 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
805 |
__removeAllAccessTraps(); |
703 | 806 |
%} |
807 |
! |
|
808 |
||
809 |
unsetTrapFor:anObject |
|
810 |
"remove any access trap for anObject." |
|
811 |
||
812 |
%{ /* NOCONTEXT */ |
|
829
fc386319f41c
removed external function defs (soon no longer allowed)
Claus Gittinger <cg@exept.de>
parents:
827
diff
changeset
|
813 |
__removeTrapOnAccess(anObject); |
703 | 814 |
%} |
815 |
! ! |
|
816 |
||
1767 | 817 |
!ObjectMemory class methodsFor:'cache management'! |
615 | 818 |
|
819 |
flushCaches |
|
820 |
"flush method and inline caches for all classes" |
|
821 |
||
822 |
%{ /* NOCONTEXT */ |
|
823 |
__flushMethodCache(); |
|
824 |
__flushAllInlineCaches(); |
|
825 |
%} |
|
826 |
! |
|
827 |
||
828 |
flushCachesFor:aClass |
|
829 |
"flush method and inline caches for aClass" |
|
830 |
||
831 |
%{ /* NOCONTEXT */ |
|
832 |
__flushMethodCacheFor(aClass); |
|
833 |
__flushInlineCachesFor(aClass); |
|
834 |
%} |
|
835 |
! |
|
836 |
||
837 |
flushCachesForSelector:aSelector |
|
838 |
"flush method and inline caches for aSelector" |
|
839 |
||
840 |
%{ /* NOCONTEXT */ |
|
841 |
__flushMethodCacheForSelector(aSelector); |
|
842 |
__flushInlineCachesForSelector(aSelector); |
|
843 |
%} |
|
844 |
! |
|
845 |
||
846 |
flushInlineCaches |
|
847 |
"flush all inlinecaches" |
|
848 |
||
849 |
%{ /* NOCONTEXT */ |
|
850 |
__flushAllInlineCaches(); |
|
851 |
%} |
|
852 |
! |
|
853 |
||
854 |
flushInlineCachesFor:aClass withArgs:nargs |
|
855 |
"flush inlinecaches for calls to aClass with nargs arguments" |
|
856 |
||
857 |
%{ /* NOCONTEXT */ |
|
1133 | 858 |
__flushInlineCachesForAndNargs(aClass, __intVal(nargs)); |
615 | 859 |
%} |
860 |
! |
|
861 |
||
862 |
flushInlineCachesForClass:aClass |
|
863 |
"flush inlinecaches for calls to aClass." |
|
864 |
||
865 |
%{ /* NOCONTEXT */ |
|
866 |
__flushInlineCachesFor(aClass); |
|
867 |
%} |
|
868 |
! |
|
869 |
||
870 |
flushInlineCachesForSelector:aSelector |
|
871 |
"flush inlinecaches for sends of aSelector" |
|
872 |
||
873 |
%{ /* NOCONTEXT */ |
|
874 |
__flushInlineCachesForSelector(aSelector); |
|
875 |
%} |
|
876 |
! |
|
877 |
||
878 |
flushInlineCachesWithArgs:nargs |
|
879 |
"flush inlinecaches for calls with nargs arguments" |
|
880 |
||
881 |
%{ /* NOCONTEXT */ |
|
1133 | 882 |
__flushInlineCaches(__intVal(nargs)); |
615 | 883 |
%} |
884 |
! |
|
885 |
||
886 |
flushMethodCache |
|
887 |
"flush the method cache" |
|
888 |
||
889 |
%{ /* NOCONTEXT */ |
|
890 |
__flushMethodCache(); |
|
891 |
%} |
|
892 |
! |
|
893 |
||
894 |
flushMethodCacheFor:aClass |
|
895 |
"flush the method cache for sends to aClass" |
|
896 |
||
897 |
%{ /* NOCONTEXT */ |
|
898 |
__flushMethodCacheFor(aClass); |
|
899 |
%} |
|
900 |
! |
|
901 |
||
902 |
flushMethodCacheForSelector:aSelector |
|
903 |
"flush the method cache for sends of aSelector" |
|
904 |
||
905 |
%{ /* NOCONTEXT */ |
|
906 |
__flushMethodCacheForSelector(aSelector); |
|
907 |
%} |
|
908 |
! |
|
909 |
||
1108 | 910 |
incrementSnapshotID |
911 |
%{ /* NOCONTEXT */ |
|
912 |
__bumpSnapshotID(); |
|
913 |
%} |
|
914 |
! |
|
915 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
916 |
snapshotID |
918 | 917 |
"return the internal snapshotID number. |
918 |
This is incremented when an image is restarted, and |
|
919 |
stored with the image. |
|
920 |
Not for normal users, this is used by the VM to invalidate |
|
921 |
caches which are stored with the image" |
|
922 |
||
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
923 |
%{ /* NOCONTEXT */ |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
924 |
RETURN ( __MKSMALLINT( __snapshotID() )); |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
925 |
%} |
918 | 926 |
" |
927 |
ObjectMemory snapshotID |
|
928 |
" |
|
876
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
929 |
! |
2fb0b80d8731
added entries to manipulate snapshotIDs
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
930 |
|
615 | 931 |
trapRestrictedMethods:trap |
932 |
"Allow/Deny execution of restricted Methods (see Method>>>restricted:) |
|
933 |
||
934 |
Notice: method restriction is a nonstandard feature, not supported |
|
935 |
by other smalltalk implementations and not specified in the ANSI spec. |
|
936 |
This is EXPERIMENTAL - and being evaluated for usability. |
|
937 |
It may change or even vanish (if it shows to be not useful)." |
|
938 |
||
939 |
|oldTrap| |
|
940 |
||
941 |
%{ |
|
942 |
if (__setTrapRestrictedMethods(trap == true)) |
|
943 |
oldTrap = true; |
|
944 |
else |
|
945 |
oldTrap = false; |
|
946 |
%}. |
|
947 |
||
948 |
(trap and:[oldTrap not]) ifTrue:[ |
|
949 |
self flushCaches |
|
950 |
]. |
|
951 |
^ oldTrap |
|
952 |
||
953 |
" |
|
954 |
ObjectMemory trapRestrictedMethods:true |
|
955 |
ObjectMemory trapRestrictedMethods:false |
|
956 |
" |
|
957 |
! ! |
|
958 |
||
1767 | 959 |
!ObjectMemory class methodsFor:'debug queries'! |
615 | 960 |
|
961 |
addressOf:anObject |
|
962 |
"return the core address of anObject as an integer |
|
963 |
- since objects may move around, the returned value is invalid after the |
|
964 |
next scavenge/collect. |
|
965 |
WARNING: this method is for ST/X debugging only |
|
966 |
it will be removed without notice" |
|
967 |
||
968 |
%{ /* NOCONTEXT */ |
|
969 |
||
970 |
if (! __isNonNilObject(anObject)) { |
|
971 |
RETURN ( nil ); |
|
972 |
} |
|
646
b0a2e25461cb
object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
973 |
if ((unsigned)anObject <= _MAX_INT) { |
1133 | 974 |
RETURN ( __MKSMALLINT((int)anObject) ); |
615 | 975 |
} |
646
b0a2e25461cb
object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
976 |
RETURN ( __MKUINT((int)anObject) ); |
615 | 977 |
%} |
978 |
" |
|
979 |
|p| |
|
980 |
p := Point new. |
|
981 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
982 |
ObjectMemory scavenge. |
|
983 |
((ObjectMemory addressOf:p) printStringRadix:16) printNL. |
|
984 |
" |
|
985 |
! |
|
986 |
||
987 |
ageOf:anObject |
|
988 |
"return the number of scavenges, an object has survived |
|
989 |
in new space. |
|
990 |
For old objects and living contexts, the returned number is invalid. |
|
991 |
WARNING: this method is for ST/X debugging only |
|
992 |
it will be removed without notice" |
|
993 |
||
994 |
%{ /* NOCONTEXT */ |
|
995 |
||
996 |
if (! __isNonNilObject(anObject)) { |
|
997 |
RETURN ( 0 ); |
|
998 |
} |
|
1133 | 999 |
RETURN ( __MKSMALLINT( _GET_AGE(anObject) ) ); |
615 | 1000 |
%} |
1001 |
" |
|
1002 |
|p| |
|
1003 |
p := Point new. |
|
1004 |
(ObjectMemory ageOf:p) printNL. |
|
1005 |
ObjectMemory tenuringScavenge. |
|
1006 |
(ObjectMemory spaceOf:p) printNL. |
|
1007 |
ObjectMemory tenuringScavenge. |
|
1008 |
(ObjectMemory spaceOf:p) printNL. |
|
1009 |
ObjectMemory tenuringScavenge. |
|
1010 |
(ObjectMemory spaceOf:p) printNL. |
|
1011 |
ObjectMemory tenuringScavenge. |
|
1012 |
(ObjectMemory spaceOf:p) printNL. |
|
1013 |
" |
|
1014 |
! |
|
1015 |
||
1016 |
dumpObject:someObject |
|
1017 |
"low level dump an object. |
|
1018 |
WARNING: this method is for ST/X debugging only |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1019 |
it may be removed (or replaced by a noop) without notice" |
615 | 1020 |
|
1021 |
%{ |
|
794
d713b6c04379
more __xx__ renames (dumpObject)
Claus Gittinger <cg@exept.de>
parents:
759
diff
changeset
|
1022 |
__dumpObject__(someObject); |
615 | 1023 |
%} |
1024 |
" |
|
1025 |
ObjectMemory dumpObject:true |
|
1026 |
ObjectMemory dumpObject:(Array new:10) |
|
1027 |
ObjectMemory dumpObject:(10@20 corner:30@40) |
|
1028 |
" |
|
1029 |
! |
|
1030 |
||
1031 |
flagsOf:anObject |
|
1032 |
"For debugging only. |
|
1033 |
WARNING: this method is for ST/X debugging only |
|
1034 |
it will be removed without notice" |
|
1035 |
||
1036 |
%{ /* NOCONTEXT */ |
|
1037 |
||
1038 |
if (! __isNonNilObject(anObject)) { |
|
1039 |
RETURN ( nil ); |
|
1040 |
} |
|
1133 | 1041 |
RETURN ( __MKSMALLINT( anObject->o_flags ) ); |
615 | 1042 |
%} |
1043 |
" |
|
1044 |
F_ISREMEMBERED 1 /* a new-space thing being refd by some oldSpace thing */ |
|
1045 |
F_ISFORWARDED 2 /* a forwarded object (you will never see this here) */ |
|
1046 |
F_DEREFERENCED 4 /* a collection after grow (not currently used) */ |
|
1047 |
F_ISONLIFOLIST 8 /* a non-lifo-context-referencing-obj already on list */ |
|
1048 |
F_MARK 16 /* mark bit for background collector */ |
|
1049 |
" |
|
1050 |
||
1051 |
" |
|
1052 |
|arr| |
|
1053 |
||
1054 |
arr := Array new. |
|
1055 |
arr at:1 put:([thisContext] value). |
|
1056 |
(ObjectMemory flagsOf:anObject) printNL |
|
1057 |
" |
|
1058 |
! |
|
1059 |
||
1108 | 1060 |
globalRefChainTo:anObject |
1669 | 1061 |
|levels objects setOfOwners| |
1108 | 1062 |
|
1063 |
levels := OrderedCollection new. |
|
1064 |
objects := WeakIdentitySet with:anObject. |
|
1065 |
||
1066 |
[objects includes:Smalltalk] whileFalse:[ |
|
1067 |
setOfOwners := WeakIdentitySet new. |
|
1068 |
||
1069 |
objects do:[:o | |
|
1070 |
|owners| |
|
1071 |
||
1072 |
owners := o allOwners. |
|
1150
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1073 |
owners notNil ifTrue:[ |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1074 |
owners := owners select:[:el | (el isMemberOf:WeakArray) not]. |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1075 |
setOfOwners addAll:owners. |
c3fddb156331
added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents:
1133
diff
changeset
|
1076 |
]. |
1108 | 1077 |
|
1078 |
"/ (no instVarNamed:#keyArray) atAllPut:nil. |
|
1079 |
"/ no := nil. |
|
1080 |
"/ (owners instVarNamed:#keyArray) atAllPut:nil. |
|
1081 |
"/ owners := nil. |
|
1082 |
]. |
|
1083 |
||
1084 |
levels add:objects. |
|
1427 | 1085 |
'done with level: ' print. levels size print. ' found ' print. objects size print. ' refs' printCR. |
1108 | 1086 |
|
1087 |
levels do:[:alreadyFound | |
|
1088 |
setOfOwners remove:(alreadyFound instVarNamed:#keyArray) ifAbsent:nil. |
|
1089 |
alreadyFound do:[:o | |
|
1090 |
setOfOwners remove:o ifAbsent:nil |
|
1091 |
] |
|
1092 |
]. |
|
1093 |
||
1094 |
setOfOwners remove:(objects instVarNamed:#keyArray) ifAbsent:nil. |
|
1095 |
"/ setOfOwners printNL. |
|
1096 |
||
1097 |
objects := setOfOwners. |
|
1098 |
objects isEmpty ifTrue:[ |
|
1099 |
"/ 'none found' printNL. |
|
1100 |
^ nil |
|
1101 |
]. |
|
1102 |
]. |
|
1103 |
||
1104 |
"/ '' printNL. |
|
1105 |
||
1106 |
^ self |
|
1107 |
refChainFrom:Smalltalk |
|
1108 |
to:anObject |
|
1109 |
inRefSets:levels reverse |
|
1110 |
startingAt:1 |
|
1111 |
||
1112 |
" |
|
1113 |
self globalRefChainTo:Point new |
|
1114 |
" |
|
1115 |
" |
|
1116 |
Smalltalk at:#foo put:Point new. |
|
1117 |
self globalRefChainTo:(Smalltalk at:#foo) |
|
1118 |
" |
|
1119 |
" |
|
1120 |
|p| |
|
1121 |
p := Point new. |
|
1122 |
Smalltalk at:#foo put:(#x -> p). |
|
1123 |
self globalRefChainTo:p |
|
1124 |
" |
|
1125 |
" |
|
1126 |
|a| |
|
1127 |
a := Array new:1. a at:1 put:a. |
|
1128 |
Smalltalk at:#foo put:(#x -> a). |
|
1129 |
self globalRefChainTo:a |
|
1130 |
" |
|
1131 |
" |
|
1132 |
|a| |
|
1133 |
a := Array new:1. a at:1 put:a. |
|
1134 |
Smalltalk at:#foo put:(#x -> (Array with:a)). |
|
1135 |
self globalRefChainTo:a |
|
1136 |
" |
|
1137 |
" |
|
1138 |
|a| |
|
1139 |
a := Array new:1. a at:1 put:a. |
|
1140 |
Smalltalk at:#foo put:(#x -> (Array with:a with:(#y -> a))). |
|
1141 |
self globalRefChainTo:a |
|
1142 |
" |
|
1143 |
" |
|
1144 |
|p| |
|
1145 |
p := Point new. |
|
1146 |
Smalltalk at:#foo put:(WeakArray with:(#x -> (#y -> p))). |
|
1147 |
self globalRefChainTo:p |
|
1148 |
" |
|
1149 |
" |
|
1150 |
self globalRefChainTo:Transcript topView |
|
1151 |
" |
|
1152 |
||
1427 | 1153 |
"Modified: 20.5.1996 / 10:28:58 / cg" |
1108 | 1154 |
! |
1155 |
||
615 | 1156 |
objectAt:anAddress |
1157 |
"return whatever anAddress points to as object. |
|
1158 |
BIG BIG DANGER ALERT: |
|
1159 |
this method is only to be used for debugging ST/X itself |
|
1160 |
- you can easily (and badly) crash the system. |
|
1161 |
WARNING: this method is for ST/X debugging only |
|
1162 |
it will be removed without notice" |
|
1163 |
||
1288 | 1164 |
%{ /* NOCONTEXT */ |
1165 |
int addr = __longIntVal(anAddress); |
|
1166 |
||
1167 |
if (addr) { |
|
1168 |
RETURN ((OBJ)(addr)); |
|
615 | 1169 |
} |
1288 | 1170 |
RETURN (nil); |
615 | 1171 |
%} |
1172 |
! |
|
1173 |
||
1288 | 1174 |
printReferences:anObject |
1175 |
"for debugging: print referents to anObject. |
|
1176 |
WARNING: this method is for ST/X debugging only |
|
1177 |
it will be removed without notice |
|
1178 |
use ObjectMemory>>whoReferences: or anObject>>allOwners." |
|
615 | 1179 |
|
1180 |
%{ |
|
1181 |
__printRefChain(__context, anObject); |
|
1182 |
%} |
|
1183 |
! |
|
1184 |
||
1288 | 1185 |
refChainFrom:start to:anObject inRefSets:levels startingAt:index |
1186 |
|chain names oClass| |
|
1187 |
||
1188 |
index > levels size ifTrue:[ |
|
1189 |
^ OrderedCollection with:start |
|
1190 |
]. |
|
1191 |
||
1192 |
"/'set: ' print. (levels at:index) displayString printNL. |
|
1193 |
"/'start: ' print. start printNL. |
|
1194 |
(levels at:index) do:[:el | |
|
1195 |
"/'trying: ' print. el printNL. |
|
1196 |
(start references:el) ifTrue:[ |
|
1197 |
"/'yes' printNL. |
|
1198 |
chain := self |
|
1199 |
refChainFrom:el |
|
1200 |
to:anObject |
|
1201 |
inRefSets:levels |
|
1202 |
startingAt:(index+1). |
|
1203 |
||
1204 |
chain notNil ifTrue:[ |
|
1205 |
start == Smalltalk ifTrue:[ |
|
1206 |
start keysAndValuesDo:[:key :val | |
|
1207 |
(val == el) ifTrue:[ |
|
1208 |
chain addFirst:'Smalltalk:' , key. |
|
1209 |
^ chain |
|
1210 |
] |
|
1211 |
] |
|
1212 |
] ifFalse:[ |
|
1213 |
names := start class allInstVarNames. |
|
1214 |
oClass := start class. |
|
1215 |
1 to:oClass instSize do:[:i | |
|
1216 |
((start instVarAt:i) == el) ifTrue:[ |
|
1217 |
chain addFirst:(start -> ('[' , (names at:i) , ']')). |
|
1218 |
^ chain |
|
1219 |
]. |
|
1220 |
]. |
|
1221 |
oClass isVariable ifTrue:[ |
|
1222 |
oClass isPointers ifTrue:[ |
|
1223 |
1 to:start basicSize do:[:i | |
|
1224 |
((start basicAt:i) == el) ifTrue:[ |
|
1225 |
chain addFirst:(start -> ('[' , i printString , ']')). |
|
1226 |
^ chain |
|
1227 |
] |
|
1228 |
] |
|
1229 |
] |
|
1230 |
]. |
|
1231 |
]. |
|
1232 |
||
1233 |
chain addFirst:start. |
|
1234 |
||
1235 |
^ chain |
|
1236 |
] |
|
1237 |
]. |
|
1238 |
]. |
|
1239 |
^ nil |
|
1240 |
||
1241 |
||
1242 |
" |
|
1243 |
|o a1 a2| |
|
1244 |
||
1245 |
o := Object new. |
|
1246 |
a1 := Array with:o with:nil with:nil. |
|
1247 |
a2 := Array with:a1 with:nil with:nil. |
|
1248 |
a2 references:a1 |
|
1249 |
" |
|
1250 |
||
1251 |
" |
|
1252 |
|o a1 a2 a3 a4 levels| |
|
1253 |
||
1254 |
o := Object new. |
|
1255 |
a1 := Array with:o. |
|
1256 |
a2 := Array with:a1. |
|
1257 |
a3 := Array with:a2. |
|
1258 |
a4 := Array with:a3. |
|
1259 |
levels := Array with:(Array with:a3) |
|
1260 |
with:(Array with:a2) |
|
1261 |
with:(Array with:a1). |
|
1262 |
||
1263 |
self refChainFrom:a4 to:o inRefSets:levels startingAt:1. |
|
1108 | 1264 |
" |
1265 |
||
1266 |
"Modified: 19.3.1996 / 23:22:41 / cg" |
|
1267 |
! |
|
1268 |
||
1288 | 1269 |
sizeOf:anObject |
1270 |
"return the size of anObject in bytes. |
|
1271 |
(this is not the same as 'anObject size'). |
|
1272 |
WARNING: this method is for ST/X debugging only |
|
1273 |
it will be removed without notice" |
|
1274 |
||
1275 |
%{ /* NOCONTEXT */ |
|
1276 |
||
1277 |
RETURN ( __isNonNilObject(anObject) ? __MKSMALLINT(__qSize(anObject)) : __MKSMALLINT(0) ) |
|
1278 |
%} |
|
1279 |
" |
|
1280 |
|hist big nw| |
|
1281 |
||
1282 |
hist := Array new:100 withAll:0. |
|
1283 |
big := 0. |
|
1284 |
ObjectMemory allObjectsDo:[:o | |
|
1285 |
nw := (ObjectMemory sizeOf:o) // 4 + 1. |
|
1286 |
nw > 100 ifTrue:[ |
|
1287 |
big := big + 1 |
|
1288 |
] ifFalse:[ |
|
1289 |
hist at:nw put:(hist at:nw) + 1 |
|
615 | 1290 |
]. |
1291 |
]. |
|
1292 |
hist printNL. |
|
1293 |
big printNL |
|
1294 |
" |
|
1288 | 1295 |
! |
1296 |
||
1297 |
spaceOf:anObject |
|
1298 |
"return the memory space, in which anObject is. |
|
1299 |
- since objects may move between spaces, |
|
1300 |
the returned value may be invalid after the next scavenge/collect. |
|
1301 |
WARNING: this method is for ST/X debugging only |
|
1302 |
it will be removed without notice" |
|
1303 |
||
1304 |
%{ /* NOCONTEXT */ |
|
1305 |
||
1306 |
if (! __isNonNilObject(anObject)) { |
|
1307 |
RETURN ( nil ); |
|
1308 |
} |
|
1309 |
RETURN ( __MKSMALLINT( __qSpace(anObject) ) ); |
|
1310 |
%} |
|
375 | 1311 |
! ! |
1312 |
||
1767 | 1313 |
!ObjectMemory class methodsFor:'dependents access'! |
10 | 1314 |
|
1288 | 1315 |
dependents |
1316 |
"return the colleciton of my dependents" |
|
1317 |
||
1318 |
^ Dependents |
|
10 | 1319 |
! |
1320 |
||
1288 | 1321 |
dependents:aCollection |
10 | 1322 |
"set the dependents collection" |
1323 |
||
1324 |
Dependents := aCollection |
|
1288 | 1325 |
! |
1326 |
||
1327 |
dependentsDo:aBlock |
|
1328 |
"evaluate aBlock for all of my dependents. |
|
1329 |
Since this is performed at startup time (under the scheduler), |
|
1330 |
this is redefined here to catch abort signals. |
|
1331 |
Thus, if any error occurs in a #returnFromSnapshot, |
|
1332 |
the user can press abort to continue." |
|
1333 |
||
1334 |
|deps| |
|
1335 |
||
1336 |
deps := Dependents. |
|
1337 |
deps notNil ifTrue:[ |
|
1338 |
deps do:[:each | |
|
1339 |
AbortSignal handle:[:ex | |
|
1340 |
ex return |
|
1341 |
] do:[ |
|
282 | 1342 |
aBlock value:each |
1343 |
] |
|
1344 |
] |
|
1345 |
] |
|
1288 | 1346 |
! ! |
1347 |
||
1767 | 1348 |
!ObjectMemory class methodsFor:'enumerating'! |
1288 | 1349 |
|
1350 |
allInstancesOf:aClass do:aBlock |
|
1351 |
"evaluate the argument, aBlock for all instances of aClass in the system. |
|
1352 |
There is one caveat: if a compressing oldSpace collect |
|
1353 |
occurs while looping over the objects, the loop cannot be |
|
1354 |
continued (for some internal reasons). In this case, false |
|
1355 |
is returned." |
|
1356 |
||
1357 |
|work| |
|
1358 |
||
1359 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1360 |
__nonTenuringScavenge(__context); |
|
1361 |
/* |
|
1362 |
* allInstancesDo needs a temporary to hold newSpace objects |
|
1363 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1364 |
if (__allInstancesOfDo(&aClass, &aBlock, &work) < 0) { |
159 | 1365 |
RETURN (false); |
85 | 1366 |
} |
1367 |
%}. |
|
1368 |
^ true |
|
2 | 1369 |
! |
1370 |
||
1288 | 1371 |
allObjectsDo:aBlock |
1372 |
"evaluate the argument, aBlock for all objects in the system. |
|
1373 |
There is one caveat: if a compressing oldSpace collect |
|
1374 |
occurs while looping over the objects, the loop cannot be |
|
1375 |
continued (for some internal reasons). In this case, false |
|
1376 |
is returned." |
|
1377 |
||
1378 |
|work| |
|
1379 |
||
1380 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1381 |
__nonTenuringScavenge(__context); |
|
1382 |
/* |
|
1383 |
* allObjectsDo needs a temporary to hold newSpace objects |
|
1384 |
*/ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1385 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, &work) < 0) { |
615 | 1386 |
RETURN (false); |
1387 |
} |
|
1388 |
%}. |
|
1389 |
^ true |
|
1288 | 1390 |
! |
1391 |
||
1392 |
allOldObjectsDo:aBlock |
|
1393 |
"evaluate the argument, aBlock for all old objects in the system. |
|
1394 |
For debugging and tests only - do not use" |
|
1395 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
1396 |
if (__allInstancesOfDo((OBJ *)0, &aBlock, (OBJ *)0) < 0) { |
1288 | 1397 |
RETURN (false); |
1398 |
} |
|
1399 |
%}. |
|
1400 |
^ true |
|
1 | 1401 |
! ! |
1402 |
||
1767 | 1403 |
!ObjectMemory class methodsFor:'garbage collection'! |
615 | 1404 |
|
1288 | 1405 |
backgroundCollectorRunning |
1406 |
"return true, if a backgroundCollector is running" |
|
1407 |
||
1408 |
^ BackgroundCollectProcess notNil |
|
500 | 1409 |
|
1410 |
" |
|
615 | 1411 |
ObjectMemory backgroundCollectorRunning |
375 | 1412 |
" |
1413 |
! |
|
1414 |
||
1288 | 1415 |
compressingGarbageCollect |
1416 |
"search for and free garbage in the oldSpace (newSpace is cleaned automatically) |
|
1417 |
performing a COMPRESSING garbage collect. |
|
1418 |
This can take a long time - especially, if paging is involved |
|
1419 |
(when no paging is involved, its faster than I thought :-). |
|
1420 |
If no memory is available for the compress, or the system has been started with |
|
1421 |
the -Msingle option, this does a non-COMPRESSING collect." |
|
1422 |
%{ |
|
1423 |
if (! __garbageCollect(__context)) { |
|
1424 |
__markAndSweep(__context); |
|
178 | 1425 |
} |
1 | 1426 |
%} |
1427 |
||
93 | 1428 |
" |
375 | 1429 |
ObjectMemory compressingGarbageCollect |
93 | 1430 |
" |
1431 |
! |
|
1432 |
||
1288 | 1433 |
garbageCollect |
1434 |
"search for and free garbage in the oldSpace. |
|
1435 |
This can take a long time - especially, if paging is involved." |
|
1436 |
||
1437 |
"/ used to be |
|
1438 |
"/ self compressingGarbageCollect |
|
1439 |
"/ here; changed to default to markAndSweep |
|
615 | 1440 |
|
1441 |
self markAndSweep |
|
1 | 1442 |
|
93 | 1443 |
" |
615 | 1444 |
ObjectMemory garbageCollect |
375 | 1445 |
" |
1446 |
! |
|
1447 |
||
1288 | 1448 |
gcStep |
1449 |
"one incremental garbage collect step. |
|
1450 |
Mark or sweep some small number of objects. This |
|
1451 |
method will return after a reasonable (short) time. |
|
1452 |
This is used by the ProcessorScheduler at idle times. |
|
1453 |
Returns true, if an incremental GC cycle has finished." |
|
1454 |
%{ |
|
1455 |
extern int __incrGCstep(); |
|
133 | 1456 |
|
1457 |
RETURN (__incrGCstep(__context) ? true : false); |
|
1 | 1458 |
%} |
1459 |
! |
|
1460 |
||
1288 | 1461 |
gcStepIfUseful |
1462 |
"If either the IncrementalGCLimit or the FreeSpaceGCLimits have been |
|
1463 |
reached, perform one incremental garbage collect step. |
|
1464 |
Return true, if more gcSteps are required to finish the cycle, |
|
1465 |
false if done with a gc round. |
|
1466 |
If no limit has been reached yet, do nothing and return false. |
|
1467 |
This is called by the ProcessorScheduler at idle times or by the |
|
1468 |
backgroundCollector." |
|
1469 |
||
1470 |
|done limit| |
|
1471 |
||
1472 |
AbortSignal handle:[:ex | |
|
1768 | 1473 |
"/ in case of abort (from the debugger), |
1474 |
"/ disable gcSteps. |
|
1475 |
done := true. |
|
1476 |
IncrementalGCLimit := FreeSpaceGCLimit := nil. |
|
1477 |
'OBJMEM: IGC aborted; turning off incremental GC' errorPrintNL |
|
1288 | 1478 |
] do:[ |
1768 | 1479 |
limit := IncrementalGCLimit. |
1480 |
(limit notNil and:[self oldSpaceAllocatedSinceLastGC > limit]) ifTrue:[ |
|
1481 |
done := ObjectMemory gcStep |
|
1482 |
] ifFalse:[ |
|
1483 |
limit := FreeSpaceGCLimit. |
|
1484 |
(limit notNil and:[(self freeSpace + self freeListSpace) < limit]) ifTrue:[ |
|
1485 |
done := ObjectMemory gcStep. |
|
1486 |
done ifTrue:[ |
|
1487 |
self moreOldSpaceIfUseful |
|
1488 |
]. |
|
1489 |
] ifFalse:[ |
|
1490 |
limit := DynamicCodeGCTrigger. |
|
1491 |
(limit notNil and:[self compiledCodeCounter > limit]) ifTrue:[ |
|
1492 |
done := ObjectMemory gcStep. |
|
1493 |
] ifFalse:[ |
|
1494 |
limit := DynamicCodeLimit. |
|
1495 |
(limit notNil and:[self compiledCodeSpaceUsed > limit]) ifTrue:[ |
|
1496 |
done := ObjectMemory gcStep. |
|
1497 |
] ifFalse:[ |
|
1498 |
done := true |
|
1499 |
] |
|
1500 |
] |
|
1501 |
] |
|
1502 |
]. |
|
615 | 1503 |
]. |
1504 |
^ done not |
|
1768 | 1505 |
|
1506 |
"Modified: 16.10.1996 / 17:40:09 / cg" |
|
615 | 1507 |
! |
1508 |
||
1288 | 1509 |
incrementalGC |
1510 |
"perform one round of incremental GC steps. |
|
1511 |
The overall effect of this method is (almost) the same as calling |
|
1512 |
markAndSweep. However, #incrementalGC is interruptable while #markAndSweep |
|
1513 |
is atomic and blocks for a while. The code here performs incremental |
|
1514 |
GC steps, until one complete gc-cycle is completed. If running at a higher |
|
1515 |
than userBackground priority, it will give up the CPU after every such |
|
1516 |
step for a while. |
|
1517 |
Thus this method can be called either from a low prio (background) process |
|
1518 |
or from a high prio process. |
|
1519 |
(however, if you have nothing else to do, its better to call for markAndSweep, |
|
1520 |
since it is faster) |
|
1521 |
For example, someone allocating huge amounts of memory could |
|
1522 |
ask for the possibility of a quick allocation using |
|
1523 |
#checkForFastNew: and try a #incrementalGC if not. In many |
|
1524 |
cases, this can avoid a pause (in the higher prio processes) due to |
|
1525 |
a blocking GC." |
|
1526 |
||
1669 | 1527 |
|delay| |
1288 | 1528 |
|
1529 |
Processor activeProcess priority > Processor userBackgroundPriority ifTrue:[ |
|
1530 |
delay := Delay forMilliseconds:1 |
|
1531 |
]. |
|
1532 |
||
1533 |
[self gcStep] whileFalse:[ |
|
1534 |
delay notNil ifTrue:[delay wait] |
|
1535 |
]. |
|
1536 |
self moreOldSpaceIfUseful |
|
1537 |
||
1538 |
" |
|
1539 |
ObjectMemory incrementalGC |
|
1540 |
[ObjectMemory incrementalGC] forkAt:3 |
|
403 | 1541 |
[ObjectMemory incrementalGC] forkAt:9 |
133 | 1542 |
" |
194 | 1543 |
! |
1544 |
||
1288 | 1545 |
markAndSweep |
1546 |
"mark/sweep garbage collector. |
|
1547 |
perform a full mark&sweep collect. |
|
1548 |
Warning: this may take some time and it is NOT interruptable. |
|
1549 |
If you want to do a collect from a background process, or have |
|
1550 |
other things to do, better use #incrementalGC which is interruptable." |
|
615 | 1551 |
%{ |
1552 |
__markAndSweep(__context); |
|
1553 |
%} |
|
194 | 1554 |
|
1555 |
" |
|
615 | 1556 |
ObjectMemory markAndSweep |
1557 |
" |
|
1558 |
! |
|
1559 |
||
1288 | 1560 |
reclaimSymbols |
1561 |
"reclaim unused symbols; |
|
1562 |
Unused symbols are (currently) not reclaimed automatically, |
|
1563 |
but only upon request with this method. |
|
1564 |
It takes some time to do this ... and it is NOT interruptable. |
|
1565 |
Future versions may do this automatically, while garbage collecting." |
|
615 | 1566 |
%{ |
1567 |
__reclaimSymbols(__context); |
|
1568 |
%} |
|
1569 |
" |
|
1570 |
ObjectMemory reclaimSymbols |
|
1571 |
" |
|
1572 |
! |
|
1573 |
||
1288 | 1574 |
scavenge |
1575 |
"collect young objects, without aging (i.e. no tenure). |
|
1576 |
Can be used to quickly get rid of shortly before allocated |
|
1577 |
stuff. This is relatively fast (compared to oldspace collect). |
|
1578 |
||
1579 |
An example where a non-tenuring scavenge makes sense is when |
|
1580 |
allocating some OperatingSystem resource (a Color, File or View) |
|
1581 |
and the OS runs out of resources. In this case, the scavenge may |
|
1582 |
free some ST-objects and therefore (by signalling the WeakArrays |
|
1583 |
or Registries) free the OS resources too. |
|
1584 |
Of course, only recently allocated resources will be freed this |
|
1585 |
way. If none was freed, a full collect will be needed." |
|
615 | 1586 |
%{ |
1587 |
__nonTenuringScavenge(__context); |
|
1588 |
%} |
|
1589 |
||
1590 |
" |
|
1591 |
ObjectMemory scavenge |
|
194 | 1592 |
" |
207 | 1593 |
! |
1594 |
||
1288 | 1595 |
startBackgroundCollectorAt:aPriority |
1596 |
"start a process doing incremental GC in the background. |
|
1597 |
Use this, if you have suspendable background processes which |
|
1598 |
run all the time, and therefore would prevent the idle-collector |
|
1599 |
from running. See documentation in this class for more details." |
|
1600 |
||
1601 |
|p| |
|
1602 |
||
1603 |
"/ |
|
1604 |
"/ its not useful, to run it more than once |
|
1605 |
"/ |
|
1606 |
BackgroundCollectProcess notNil ifTrue:[ |
|
1607 |
BackgroundCollectProcess priority:aPriority. |
|
1608 |
^ self |
|
1609 |
]. |
|
1610 |
||
1611 |
p := |
|
1612 |
[ |
|
1613 |
[ |
|
1614 |
[true] whileTrue:[ |
|
1615 |
self gcStepIfUseful ifTrue:[ |
|
1616 |
" |
|
1617 |
perform a full cycle |
|
1618 |
" |
|
1619 |
self incrementalGC |
|
1620 |
]. |
|
1621 |
" |
|
1622 |
wait a bit |
|
1623 |
" |
|
1624 |
(Delay forSeconds:5) wait |
|
1625 |
] |
|
1626 |
] valueOnUnwindDo:[ |
|
1627 |
BackgroundCollectProcess := nil |
|
1628 |
] |
|
1629 |
] newProcess. |
|
1630 |
p name:'background collector'. |
|
1631 |
p priority:aPriority. |
|
1632 |
p restartable:true. |
|
1633 |
p resume. |
|
1634 |
BackgroundCollectProcess := p |
|
1635 |
||
1636 |
" |
|
1637 |
the following lets the backgroundCollector run at prio 5 |
|
1638 |
whenever 100000 bytes have been allocated, OR freeSpace drops |
|
1639 |
below 1meg. Having the system keep 1meg as reserve for peak allocation. |
|
1640 |
||
1641 |
Doing this may reduce pauses due to inevitable collects when running |
|
1642 |
out of freeSpace, if the collector can keep up with allocation rate. |
|
1643 |
" |
|
1644 |
||
1645 |
" |
|
1646 |
ObjectMemory incrementalGCLimit:100000. |
|
1647 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
211 | 1648 |
ObjectMemory startBackgroundCollectorAt:5 |
1649 |
" |
|
207 | 1650 |
! |
1651 |
||
1288 | 1652 |
stopBackgroundCollector |
1653 |
"stop the background collector" |
|
1654 |
||
1655 |
BackgroundCollectProcess notNil ifTrue:[ |
|
1656 |
BackgroundCollectProcess terminate. |
|
1657 |
BackgroundCollectProcess := nil |
|
207 | 1658 |
] |
293 | 1659 |
|
211 | 1660 |
" |
1661 |
ObjectMemory stopBackgroundCollector |
|
1662 |
" |
|
362 | 1663 |
! |
1664 |
||
1288 | 1665 |
tenure |
1666 |
"force all living new stuff into old-space - effectively making |
|
1667 |
all living young objects become old objects immediately. |
|
1668 |
This is relatively fast (compared to oldspace collect). |
|
1669 |
||
1670 |
This method should only be used in very special situations: |
|
1671 |
for example, when building up some long-living data structure |
|
1672 |
in a time critical application. |
|
1673 |
To do so, you have to do a scavenge followed by a tenure after the |
|
1674 |
objects are created. Be careful, to not reference any other chunk- |
|
1675 |
data when calling for a tenure (this will lead to lots of garbage in |
|
1676 |
the oldspace). |
|
1677 |
In normal situations, explicit tenures are not needed." |
|
1678 |
%{ |
|
1679 |
__tenure(__context); |
|
1680 |
%} |
|
1681 |
||
1682 |
" |
|
1683 |
ObjectMemory tenure |
|
1684 |
" |
|
1685 |
" |
|
1686 |
... build up long living objects ... |
|
1687 |
ObjectMemory scavenge. |
|
1688 |
ObjectMemory tenure |
|
615 | 1689 |
... continue - objects created above are now in oldSpace ... |
1690 |
" |
|
1691 |
! |
|
1692 |
||
1288 | 1693 |
tenuringScavenge |
1694 |
"collect newspace stuff, with aging (i.e. objects old enough |
|
1695 |
will be moved into the oldSpace). |
|
1696 |
Use this for debugging and testing only - the system performs |
|
1697 |
this automatically when the newspace fills up. |
|
1698 |
This is relatively fast (compared to oldspace collect)" |
|
615 | 1699 |
%{ |
1700 |
__scavenge(__context); |
|
1701 |
%} |
|
1702 |
||
1703 |
" |
|
1704 |
ObjectMemory tenuringScavenge |
|
1705 |
" |
|
1288 | 1706 |
! |
1707 |
||
1708 |
verboseGarbageCollect |
|
1709 |
"perform a compressing garbage collect and show some informational |
|
1710 |
output on the Transcript" |
|
1711 |
||
1712 |
|nBytesBefore nReclaimed value unit| |
|
1713 |
||
1714 |
nBytesBefore := self oldSpaceUsed. |
|
1715 |
self compressingGarbageCollect. |
|
1716 |
nReclaimed := nBytesBefore - self oldSpaceUsed. |
|
1717 |
nReclaimed > 0 ifTrue:[ |
|
1418 | 1718 |
nReclaimed > 1024 ifTrue:[ |
1719 |
nReclaimed > (1024 * 1024) ifTrue:[ |
|
1720 |
value := nReclaimed // (1024 * 1024). |
|
1721 |
unit := ' Mb.' |
|
1722 |
] ifFalse:[ |
|
1723 |
value := nReclaimed // 1024. |
|
1724 |
unit := ' Kb.' |
|
1725 |
] |
|
1726 |
] ifFalse:[ |
|
1727 |
value := nReclaimed. |
|
1728 |
unit := ' bytes.' |
|
1729 |
]. |
|
1730 |
Transcript show:'reclaimed '; show:value printString. |
|
1731 |
Transcript showCR:unit |
|
1288 | 1732 |
] |
1733 |
||
1734 |
" |
|
1735 |
ObjectMemory verboseGarbageCollect |
|
1736 |
" |
|
1418 | 1737 |
|
1738 |
"Modified: 18.5.1996 / 15:44:13 / cg" |
|
178 | 1739 |
! ! |
1740 |
||
1767 | 1741 |
!ObjectMemory class methodsFor:'garbage collector control'! |
133 | 1742 |
|
1288 | 1743 |
announceOldSpaceNeed:howMuch |
1744 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
1745 |
soon, which is going to live longer (whatever that means). |
|
1746 |
It first checks if the memory can be allocated without forcing a compressing |
|
1747 |
GC. If not, the oldSpace is increased. This may also lead to a slow compressing |
|
1748 |
collect. However, many smaller increases are avoided afterwards. Calling this |
|
1749 |
method before allocating huge chunks of data may provide better overall performance. |
|
1750 |
Notice: this is a nonstandard interface - use only in special situations." |
|
1751 |
||
1752 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
1753 |
self incrementalGC. |
|
1754 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
1755 |
self moreOldSpace:howMuch |
|
615 | 1756 |
] |
1757 |
] |
|
310 | 1758 |
|
1759 |
" |
|
615 | 1760 |
ObjectMemory announceOldSpaceNeed:1000000 |
133 | 1761 |
" |
1762 |
! |
|
1763 |
||
1288 | 1764 |
announceSpaceNeed:howMuch |
1765 |
"announce to the memory system, that howMuch bytes of memory will be needed |
|
1766 |
soon. The VM tries to prepare itself for this allocation to be performed |
|
1767 |
with less overhead. For example, it could preallocate some memory in one |
|
1768 |
big chunk (instead of doing many smaller reallocations later). |
|
1769 |
Notice: this is a nonstandard interface - use only in special situations. |
|
1770 |
Also, this does a background collect before the big chunk of memory is |
|
1771 |
allocated, not locking other processes while doing so." |
|
1772 |
||
1773 |
(howMuch < (self newSpaceSize // 2)) ifTrue:[ |
|
1774 |
self scavenge. |
|
1775 |
]. |
|
1776 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
1777 |
(howMuch > (self newSpaceSize // 2)) ifFalse:[ |
|
1778 |
self scavenge. |
|
1779 |
]. |
|
1780 |
self incrementalGC. |
|
1781 |
(self checkForFastNew:howMuch) ifFalse:[ |
|
1782 |
self moreOldSpace:howMuch |
|
202 | 1783 |
] |
1784 |
] |
|
1785 |
||
1786 |
" |
|
1787 |
ObjectMemory announceSpaceNeed:100000 |
|
1788 |
" |
|
1789 |
! |
|
1790 |
||
1288 | 1791 |
avoidTenure:flag |
1792 |
"set/clear the avoidTenure flag. If set, aging of newSpace is turned off |
|
1793 |
as long as the newSpace fill-grade stays below some magic high-water mark. |
|
1794 |
If off (the default), aging is done as usual. |
|
1795 |
If the flag is turned on, scavenge may be a bit slower, due to more |
|
1796 |
objects being copied around. However, chances are high that in an idle |
|
1797 |
or (almost idle) system, less objects are moved into oldSpace. |
|
1798 |
Therefore, this helps to avoid oldSpace colelcts, in systems which go into |
|
1799 |
some standby mode and are reactivated by some external event. |
|
1800 |
(the avoid-flag should be turned off there, and set again once the idle loop |
|
1801 |
is reentered). |
|
1802 |
||
1803 |
This is an EXPERIMENTAL interface." |
|
178 | 1804 |
|
1805 |
%{ /* NOCONTEXT */ |
|
615 | 1806 |
__avoidTenure(flag == true ? 1 : 0); |
133 | 1807 |
%} |
1808 |
! |
|
1809 |
||
1288 | 1810 |
checkForFastNew:amount |
1811 |
"this method returns true, if amount bytes could be allocated |
|
1812 |
quickly (i.e. without forcing a full GC or compress). |
|
1813 |
This can be used for smart background processes, which want to |
|
1814 |
allocate big chunks of data without disturbing foreground processes |
|
1815 |
too much. Such a process would check for fast-allocation, and perform |
|
1816 |
incremental GC-steps if required. Thus, avoiding the long blocking pause |
|
1817 |
due to a forced (non-incremental) GC. |
|
1818 |
Especially: doing so will not block higher priority foreground processes. |
|
1819 |
See an example use in Behavior>>niceBasicNew:. |
|
1820 |
This is experimental and not guaranteed to be in future versions." |
|
1821 |
||
1822 |
%{ /* NOCONTEXT */ |
|
1823 |
extern int __checkForFastNew(); |
|
1824 |
||
1825 |
if (__isSmallInteger(amount)) { |
|
1826 |
if (! __checkForFastNew(__intVal(amount))) { |
|
1827 |
RETURN (false); |
|
1828 |
} |
|
1829 |
} |
|
1830 |
||
1831 |
%}. |
|
1832 |
^ true |
|
178 | 1833 |
! |
1834 |
||
1768 | 1835 |
dynamicCodeGCTrigger |
1836 |
"return the dynamic code trigger limit for incremental GC activation. |
|
1837 |
The system will start doing incremental background GC, whenever this amount |
|
1838 |
of code was dynamically generated. |
|
1839 |
The default is nil; which disables this trigger" |
|
1840 |
||
1841 |
^ DynamicCodeGCTrigger |
|
1842 |
||
1843 |
" |
|
1844 |
ObjectMemory dynamicCodeGCTrigger |
|
1845 |
" |
|
1846 |
||
1847 |
"Created: 16.10.1996 / 17:42:01 / cg" |
|
1848 |
! |
|
1849 |
||
1850 |
dynamicCodeGCTrigger:numberOfBytesOrNil |
|
1851 |
"set the dynamic code trigger limit for incremental GC activation. |
|
1852 |
The system will start doing incremental background GC, whenever this amount |
|
1853 |
of code was dynamically generated. |
|
1854 |
The default is nil; which disables this trigger" |
|
1855 |
||
1856 |
DynamicCodeGCTrigger := numberOfBytesOrNil |
|
1857 |
||
1858 |
" |
|
1859 |
ObjectMemory dynamicCodeGCTrigger:50000 |
|
1860 |
" |
|
1861 |
||
1862 |
"Created: 16.10.1996 / 17:42:29 / cg" |
|
1863 |
! |
|
1864 |
||
1865 |
dynamicCodeLimit |
|
1866 |
"return the dynamic code limit. |
|
1867 |
The system will start doing incremental background GC, whenever this amount |
|
1868 |
of code has been generated (overall), and start to flush the code cache, |
|
1869 |
if (after the GC), more code is still allocated. |
|
1870 |
The default is nil; which disables this trigger" |
|
1871 |
||
1781 | 1872 |
DynamicCodeLimit := self getCompiledCodeLimit. |
1768 | 1873 |
^ DynamicCodeLimit |
1874 |
||
1875 |
" |
|
1876 |
ObjectMemory dynamicCodeLimit |
|
1877 |
" |
|
1878 |
||
1879 |
"Created: 16.10.1996 / 17:43:37 / cg" |
|
1880 |
! |
|
1881 |
||
1882 |
dynamicCodeLimit:nBytesOrNil |
|
1883 |
"set the dynamic code limit. |
|
1884 |
The system will start doing incremental background GC, whenever this amount |
|
1885 |
of code has been generated (overall), and start to flush the code cache, |
|
1886 |
if (after the GC), more code is still allocated. |
|
1887 |
The default is nil; which disables this trigger" |
|
1888 |
||
1770 | 1889 |
DynamicCodeLimit := nBytesOrNil. |
1890 |
self setCompiledCodeLimit:nBytesOrNil. |
|
1768 | 1891 |
|
1892 |
" |
|
1893 |
ObjectMemory dynamicCodeLimit:100000 |
|
1894 |
" |
|
1895 |
||
1896 |
"Created: 16.10.1996 / 17:43:58 / cg" |
|
1770 | 1897 |
"Modified: 16.10.1996 / 19:30:46 / cg" |
1768 | 1898 |
! |
1899 |
||
1288 | 1900 |
fastMoreOldSpaceAllocation:aBoolean |
1901 |
"this method turns on/off fastMoreOldSpace allocation. |
|
1902 |
By default, this is turned off (false), which means that in case of |
|
1903 |
a filled-up oldSpace, a GC is tried first before more oldSpace is allocated. |
|
1904 |
This strategy is ok for the normal operation of the system, |
|
1905 |
but behaves badly, if the program allocates huge data structures (say a |
|
1906 |
game tree of 30Mb in size) which survives and therefore will not be reclaimed |
|
1907 |
by a GC. |
|
1908 |
Of course while building this tree, and the memory becomes full, the system |
|
1909 |
would not know in advance, that the GC will not reclaim anything. |
|
1910 |
||
1911 |
Setting fastOldSpaceIncrement to true will avoid this, by forcing the |
|
1912 |
memory system to allocate more memory right away, without doing a GC first. |
|
1913 |
||
1914 |
WARNING: make certain that this flag is turned off, after your huge data |
|
1915 |
is allocated, since otherwise the system may continue to increase its |
|
1916 |
virtual memory without ever checking for garbage. |
|
1917 |
This method returns the previous value of the flag; typically this return |
|
1918 |
value should be used to switch back." |
|
1919 |
||
1920 |
%{ /* NOCONTEXT */ |
|
1921 |
extern int __fastMoreOldSpaceAllocation(); |
|
1922 |
||
1923 |
RETURN (__fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false); |
|
1924 |
%} |
|
1925 |
" |
|
1926 |
|previousSetting| |
|
1927 |
||
1928 |
previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
1929 |
[ |
|
1930 |
... |
|
1931 |
allocate your huge data |
|
1932 |
... |
|
1933 |
] valueNoOrOnUnwindDo:[ |
|
1934 |
ObjectMemory fastMoreOldSpaceAllocation:previousSetting |
|
1935 |
] |
|
1936 |
" |
|
1937 |
||
1938 |
" |
|
1939 |
|prev this| |
|
1940 |
||
1941 |
prev := ObjectMemory fastMoreOldSpaceAllocation:true. |
|
370 | 1942 |
ObjectMemory fastMoreOldSpaceAllocation:prev. |
1943 |
^ prev |
|
1944 |
" |
|
1945 |
! |
|
1946 |
||
1288 | 1947 |
fastMoreOldSpaceLimit:aNumber |
1948 |
"this method sets and returns the fastMoreOldSpace limit. |
|
1949 |
If fastMoreOldSpaceAllocation is true, and the current oldSpace size is |
|
1950 |
below this limit, the memory manager will NOT do a GC when running out of |
|
1951 |
oldSpace, but instead quickly go ahead increasing the size of the oldSpace. |
|
1952 |
Setting the limit to 0 turns off any limit (i.e. it will continue to |
|
1953 |
increase the oldSpace forwever - actually, until the OS refuses to give us |
|
1954 |
more memory). The returned value is the previous setting of the limit." |
|
1955 |
||
1956 |
%{ /* NOCONTEXT */ |
|
1957 |
extern int __fastMoreOldSpaceLimit(); |
|
1958 |
||
1959 |
if (__isSmallInteger(aNumber)) { |
|
1960 |
RETURN ( __MKSMALLINT( __fastMoreOldSpaceLimit(__intVal(aNumber)))); |
|
1961 |
} |
|
1962 |
%}. |
|
1963 |
self primitiveFailed |
|
1964 |
||
1965 |
" |
|
1966 |
|prev this| |
|
1967 |
||
1968 |
prev := ObjectMemory fastMoreOldSpaceLimit:10*1024*1024. |
|
370 | 1969 |
ObjectMemory fastMoreOldSpaceLimit:prev. |
1970 |
^ prev |
|
1971 |
" |
|
133 | 1972 |
! |
1973 |
||
1288 | 1974 |
freeSpaceGCAmount |
1975 |
"return the amount to be allocated if, after an incrementalGC, |
|
1976 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
1977 |
The default is nil, which lets the system compute an abbpropriate value" |
|
615 | 1978 |
|
1979 |
^ FreeSpaceGCAmount |
|
1980 |
||
1981 |
" |
|
1982 |
ObjectMemory freeSpaceGCAmount |
|
1983 |
" |
|
1984 |
! |
|
1985 |
||
1288 | 1986 |
freeSpaceGCAmount:aNumber |
1987 |
"set the amount to be allocated if, after an incrementalGC, |
|
1988 |
not at least FreeSpaceGCLimit bytes are available for allocation. |
|
1989 |
The amount should be greater than the limit, otherwise the incremental |
|
1990 |
GC may try over and over to get the memory (actually waisting time)." |
|
1991 |
||
1992 |
FreeSpaceGCAmount := aNumber |
|
1993 |
||
1994 |
" |
|
1995 |
the following will try to always keep at least 1meg of free space |
|
1996 |
(in the background) and start to do so, whenever the freeSpace drops |
|
1997 |
below 250k. |
|
1998 |
" |
|
1999 |
" |
|
2000 |
ObjectMemory freeSpaceGCLimit:250000. |
|
2001 |
ObjectMemory freeSpaceGCAmount:1000000. |
|
2002 |
" |
|
2003 |
||
2004 |
" |
|
2005 |
turn it off (i.e. let the system compute an appropriate amount ...) |
|
615 | 2006 |
" |
2007 |
" |
|
2008 |
ObjectMemory freeSpaceGCAmount:nil. |
|
2009 |
" |
|
2010 |
! |
|
2011 |
||
1288 | 2012 |
freeSpaceGCLimit |
2013 |
"return the freeSpace limit for incremental GC activation. |
|
2014 |
The system will start doing incremental background GC, once less than this number |
|
2015 |
of bytes are available in the compact free space. |
|
2016 |
The default is 100000; setting it to nil will turn this trigger off." |
|
615 | 2017 |
|
2018 |
^ FreeSpaceGCLimit |
|
2019 |
||
2020 |
" |
|
2021 |
ObjectMemory freeSpaceGCLimit |
|
2022 |
" |
|
133 | 2023 |
! |
2024 |
||
1288 | 2025 |
freeSpaceGCLimit:aNumber |
2026 |
"set the freeSpace limit for incremental GC activation. |
|
2027 |
The system will start doing incremental background GC, once less than this number |
|
2028 |
of bytes are available for allocation. |
|
2029 |
The default is nil; setting it to nil will turn this trigger off." |
|
2030 |
||
2031 |
FreeSpaceGCLimit := aNumber |
|
2032 |
||
2033 |
" |
|
2034 |
the following will start the incrementalGC (in the background) |
|
2035 |
whenever the freeSpace drops below 1meg of free space |
|
2036 |
" |
|
2037 |
" |
|
2038 |
ObjectMemory freeSpaceGCLimit:1000000. |
|
2039 |
" |
|
2040 |
||
2041 |
" |
|
2042 |
turn it off (i.e. let the system hit the wall ...) |
|
615 | 2043 |
" |
2044 |
" |
|
2045 |
ObjectMemory freeSpaceGCLimit:nil. |
|
2046 |
" |
|
1 | 2047 |
! |
2048 |
||
1288 | 2049 |
incrementalGCLimit |
2050 |
"return the allocatedSinceLastGC limit for incremental GC activation. |
|
2051 |
The system will start doing incremental background GC, once more than this number |
|
2052 |
of bytes have been allocated since the last GC. |
|
2053 |
The default is 500000; setting it to nil will turn this trigger off." |
|
615 | 2054 |
|
2055 |
^ IncrementalGCLimit |
|
2056 |
||
2057 |
" |
|
2058 |
ObjectMemory incrementalGCLimit |
|
2059 |
" |
|
178 | 2060 |
! |
85 | 2061 |
|
1288 | 2062 |
incrementalGCLimit:aNumber |
2063 |
"set the allocatedSinceLastGC limit for incremental GC activation. |
|
2064 |
The system will start doing incremental background GC, once more than this number |
|
2065 |
of bytes have been allocated since the last GC. |
|
2066 |
The default is 500000; setting it to nil will turn this trigger off." |
|
2067 |
||
2068 |
IncrementalGCLimit := aNumber |
|
2069 |
||
2070 |
" |
|
2071 |
ObjectMemory incrementalGCLimit:500000. 'do incr. GC very seldom' |
|
2072 |
ObjectMemory incrementalGCLimit:100000. 'medium' |
|
2073 |
ObjectMemory incrementalGCLimit:10000. 'do incr. GC very often' |
|
615 | 2074 |
ObjectMemory incrementalGCLimit:nil. 'never' |
2075 |
" |
|
370 | 2076 |
! |
2077 |
||
1288 | 2078 |
lockTenure:flag |
2079 |
"set/clear the tenureLock. If the lock is set, the system |
|
2080 |
completely turns off tenuring, and objects remain in newSpace (forever). |
|
2081 |
Once this lock is set, the system operates only in the newSpace and no memory |
|
2082 |
allocations from oldSpace are allowed (except for explicit tenure calls). |
|
2083 |
If any allocation request cannot be resoved, the VM raises a memory interrupt, |
|
2084 |
clears the lockTenure-flag and returns nil. Thus, it automatically falls back into |
|
2085 |
the normal mode of operation, to avoid big trouble |
|
2086 |
(fail to allocate memory when handling the exception). |
|
2087 |
||
2088 |
This interface can be used in applications, which are guaranteed to have their |
|
2089 |
working set completely in the newSpace AND want to limit the worst case |
|
2090 |
pause times to the worst case scavenge time |
|
2091 |
(which itself is limitd by the size of the newSpace). |
|
2092 |
I.e. systems which go into some event loop after initial startup, |
|
2093 |
may turn on the tenureLock to make certain that no oldSpace memory is |
|
2094 |
allocated in the future; thereby limiting any GC activity to newSpace scavenges only. |
|
2095 |
||
2096 |
This is an EXPERIMENTAL interface. |
|
2097 |
" |
|
2098 |
||
2099 |
%{ |
|
2100 |
if (flag == true) { |
|
370 | 2101 |
__tenure(__context); |
2102 |
} |
|
379 | 2103 |
__lockTenure(flag == true ? 1 : 0); |
2104 |
%} |
|
2105 |
! |
|
2106 |
||
1288 | 2107 |
makeOld:anObject |
2108 |
"move anObject into oldSpace. |
|
2109 |
This method is for internal & debugging purposes only - |
|
2110 |
it may vanish. Dont use it." |
|
2111 |
%{ |
|
2112 |
if (__moveToOldSpace(anObject, __context) < 0) { |
|
615 | 2113 |
RETURN (false); |
2114 |
} |
|
2115 |
%}. |
|
2116 |
^ true |
|
2117 |
! |
|
2118 |
||
1288 | 2119 |
moreOldSpace:howMuch |
2120 |
"allocate howMuch bytes more for old objects; return true if this worked, |
|
2121 |
false if that failed. |
|
2122 |
This is done automatically, when running out of space, but makes |
|
2123 |
sense, if its known in advance that a lot of memory is needed to |
|
2124 |
avoid multiple reallocations and compresses. |
|
2125 |
On systems which do not support the mmap (or equivalent) system call, |
|
2126 |
this (currently) implies a compressing garbage collect - so its slow. |
|
2127 |
Notice: this is a nonstandard interface - use only in special situations." |
|
2128 |
||
2129 |
%{ |
|
2130 |
if (__isSmallInteger(howMuch)) { |
|
2131 |
RETURN( __moreOldSpace(__context, __intVal(howMuch)) ? true : false ); |
|
615 | 2132 |
} |
2133 |
RETURN (false); |
|
379 | 2134 |
%} |
615 | 2135 |
" |
2136 |
ObjectMemory moreOldSpace:1000000 |
|
2137 |
" |
|
379 | 2138 |
! |
2139 |
||
1288 | 2140 |
moreOldSpaceIfUseful |
2141 |
"to be called after an incremental GC cycle; |
|
2142 |
if freeSpace is still below limit, allocate more oldSpace" |
|
2143 |
||
2144 |
|limit free amount| |
|
2145 |
||
2146 |
limit := FreeSpaceGCLimit. |
|
2147 |
limit notNil ifTrue:[ |
|
2148 |
"/ if reclaimed space is below limit, we have to allocate more |
|
2149 |
"/ oldSpace, to avoid excessive gcSteps (due to freeSpaceLimit |
|
2150 |
"/ still not reached) |
|
2151 |
"/ |
|
2152 |
free := self freeSpace + self freeListSpace. |
|
2153 |
free < (limit * 3 // 2) ifTrue:[ |
|
2154 |
amount := FreeSpaceGCAmount. |
|
2155 |
amount isNil ifTrue:[ |
|
2156 |
amount := limit * 3 // 2. |
|
2157 |
]. |
|
2158 |
'OBJECTMEMORY: moreOldSpace to satisfy free-limit' infoPrintNL. |
|
2159 |
(self moreOldSpace:(amount - free + (64*1024))) ifFalse:[ |
|
2160 |
"/ |
|
2161 |
"/ could not increase oldspace; reset FreeSpaceGCLimit to avoid |
|
2162 |
"/ useless retries |
|
2163 |
'OBJECTMEMORY: could not increase oldSpace - reset limit' errorPrintNL. |
|
615 | 2164 |
FreeSpaceGCLimit := nil |
2165 |
] |
|
2166 |
]. |
|
2167 |
]. |
|
370 | 2168 |
! |
2169 |
||
1288 | 2170 |
newSpaceSize:newSize |
2171 |
"change the size of the newSpace. To do this, the current contents |
|
2172 |
of the newSpace may have to be tenured (if size is smaller). |
|
2173 |
Returns false, if it failed for any reason. |
|
2174 |
Experimental: this interface may valish without notice. |
|
2175 |
||
2176 |
DANGER ALERT: |
|
2177 |
be careful too big of a size may lead to longer scavenge pauses. |
|
2178 |
Too small of a newSpace may lead to more CPU overhead, due to |
|
2179 |
excessive scavenges. You have been warned." |
|
2180 |
||
2181 |
%{ |
|
2182 |
extern int __setNewSpaceSize(); |
|
2183 |
||
2184 |
if (__isSmallInteger(newSize)) { |
|
2185 |
RETURN (__setNewSpaceSize(__intVal(newSize)) ? true : false); |
|
2186 |
} |
|
2187 |
%}. |
|
2188 |
self primitiveFailed |
|
2189 |
||
2190 |
" less absolute CPU overhead (but longer pauses): |
|
2191 |
||
2192 |
ObjectMemory newSpaceSize:800*1024 |
|
2193 |
" |
|
2194 |
||
2195 |
" smaller pauses, but more overall CPU overhead: |
|
2196 |
||
2197 |
ObjectMemory newSpaceSize:200*1024 |
|
370 | 2198 |
" |
2199 |
||
2200 |
" the default: |
|
2201 |
||
2202 |
ObjectMemory newSpaceSize:400*1024 |
|
2203 |
" |
|
615 | 2204 |
! |
2205 |
||
1288 | 2206 |
oldSpaceCompressLimit |
2207 |
"return the limit for oldSpace compression. If more memory than this |
|
2208 |
limit is in use, the system will not perform compresses on the oldspace, |
|
2209 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
2210 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
2211 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
2212 |
you may want to increase this limit." |
|
2213 |
||
2214 |
%{ /* NOCONTEXT */ |
|
2215 |
extern unsigned __compressingGCLimit(); |
|
2216 |
||
2217 |
RETURN (__MKSMALLINT( __compressingGCLimit(-1) )); |
|
1105
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2218 |
%} |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2219 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2220 |
ObjectMemory oldSpaceCompressLimit |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2221 |
" |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2222 |
! |
fe3a6359e13b
added access to oldSpaceCompressLimit
Claus Gittinger <cg@exept.de>
parents:
1096
diff
changeset
|
2223 |
|
1288 | 2224 |
oldSpaceCompressLimit:amount |
2225 |
"set the limit for oldSpace compression. If more memory than this |
|
2226 |
limit is in use, the system will not perform compresses on the oldspace, |
|
2227 |
but instead do a mark&sweep GC followed by an oldSpace increase if not enough |
|
2228 |
could be reclaimed. The default is currently some 8Mb, which is ok for workstations |
|
2229 |
with 16..32Mb of physical memory. If your system has much more physical RAM, |
|
2230 |
you may want to increase this limit. |
|
2231 |
This method returns the previous increment value." |
|
2232 |
||
2233 |
%{ /* NOCONTEXT */ |
|
2234 |
extern unsigned __compressingGCLimit(); |
|
2235 |
||
2236 |
if (__isSmallInteger(amount)) { |
|
2237 |
RETURN (__MKSMALLINT( __compressingGCLimit(__intVal(amount)) )); |
|
2238 |
} |
|
2239 |
%} |
|
2240 |
"to change the limit to 12Mb:" |
|
615 | 2241 |
" |
2242 |
ObjectMemory oldSpaceCompressLimit:12*1024*1024 |
|
2243 |
" |
|
2244 |
! |
|
2245 |
||
1288 | 2246 |
oldSpaceIncrement |
2247 |
"return the oldSpaceIncrement value. Thats the amount by which |
|
2248 |
more memory is allocated in case the oldSpace gets filled up. |
|
2249 |
In normal situations, the default value used in the VM is fine |
|
2250 |
and there is no need to change it." |
|
2251 |
||
2252 |
%{ /* NOCONTEXT */ |
|
2253 |
extern unsigned __oldSpaceIncrement(); |
|
2254 |
||
2255 |
RETURN (__MKSMALLINT( __oldSpaceIncrement(-1) )); |
|
615 | 2256 |
%} |
2257 |
" |
|
2258 |
ObjectMemory oldSpaceIncrement |
|
2259 |
" |
|
2260 |
! |
|
2261 |
||
1288 | 2262 |
oldSpaceIncrement:amount |
2263 |
"set the oldSpaceIncrement value. Thats the amount by which |
|
2264 |
more memory is allocated in case the oldSpace gets filled up. |
|
2265 |
In normal situations, the default value used in the VM is fine |
|
2266 |
and there is no need to change it. This method returns the |
|
2267 |
previous increment value." |
|
2268 |
||
2269 |
%{ /* NOCONTEXT */ |
|
2270 |
extern unsigned __oldSpaceIncrement(); |
|
2271 |
||
2272 |
if (__isSmallInteger(amount)) { |
|
2273 |
RETURN (__MKSMALLINT( __oldSpaceIncrement(__intVal(amount)) )); |
|
2274 |
} |
|
2275 |
%} |
|
2276 |
"to change increment to 1Meg:" |
|
615 | 2277 |
" |
2278 |
ObjectMemory oldSpaceIncrement:1024*1024 |
|
2279 |
" |
|
2280 |
! |
|
2281 |
||
1288 | 2282 |
tenureParameters:magic |
2283 |
"this is pure magic and not for public eyes ... |
|
2284 |
This method allows fine tuning the scavenger internals, |
|
2285 |
in cooperation to some statistic & test programs. |
|
2286 |
It is undocumented, secret and may vanish. |
|
2287 |
If you play around here, the system may behave very strange." |
|
615 | 2288 |
|
2289 |
%{ /* NOCONTEXT */ |
|
2290 |
__tenureParams(magic); |
|
2291 |
%}. |
|
2292 |
! |
|
2293 |
||
1288 | 2294 |
turnGarbageCollectorOff |
2295 |
"turn off the generational garbage collector by forcing new objects to be |
|
2296 |
allocated directly in oldSpace (instead of newSpace) |
|
2297 |
WARNING: |
|
2298 |
This is somewhat dangerous: if collector is turned off, |
|
2299 |
and too many objects are created, the system may run into trouble |
|
2300 |
(i.e. oldSpace becomes full) and be forced to perform a full mark&sweep |
|
2301 |
or even a compressing collect - making the overall realtime behavior worse. |
|
2302 |
Use this only for special purposes or when realtime behavior |
|
2303 |
is required for a limited time period. |
|
2304 |
||
2305 |
OBSOLETE: this is no longer supported |
|
2306 |
- it may be a no-operation by the time you read this." |
|
615 | 2307 |
|
2308 |
%{ /* NOCONTEXT */ |
|
2309 |
__allocForceSpace(OLDSPACE); |
|
2310 |
%} |
|
2311 |
! |
|
2312 |
||
1288 | 2313 |
turnGarbageCollectorOn |
2314 |
"turn garbage collector on again (see ObjectMemory>>turnGarbageCollectorOff)" |
|
615 | 2315 |
|
2316 |
%{ /* NOCONTEXT */ |
|
2317 |
__allocForceSpace(9999); |
|
2318 |
%} |
|
1288 | 2319 |
! |
2320 |
||
2321 |
watchTenure:flag |
|
2322 |
"set/clear the tenureWatch. If set, an internalError exception will be raised, |
|
2323 |
whenever objects are tenured from newSpace into oldSpace |
|
2324 |
(except for an explicit tenure request). |
|
2325 |
This can be used to validate that no oldSpace objects are created |
|
2326 |
(i.e. the system operates fully in newSpace). |
|
2327 |
Be careful, if the avoidTenure flag is not set, |
|
2328 |
there will almost always be a tenure sooner or later. |
|
2329 |
||
2330 |
EXPERIMENTAL - no warranty" |
|
2331 |
||
2332 |
%{ /* NOCONTEXT */ |
|
2333 |
__watchTenure(flag == true ? 1 : 0); |
|
2334 |
%} |
|
178 | 2335 |
! ! |
2336 |
||
1767 | 2337 |
!ObjectMemory class methodsFor:'interrupt handler access'! |
615 | 2338 |
|
1288 | 2339 |
childSignalInterruptHandler |
2340 |
"return the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
615 | 2341 |
|
2342 |
^ ChildSignalInterruptHandler |
|
2343 |
! |
|
2344 |
||
1288 | 2345 |
childSignalInterruptHandler:aHandler |
2346 |
"set the handler for UNIX-death-of-a-childprocess-signal interrupts" |
|
2347 |
||
2348 |
ChildSignalInterruptHandler := aHandler |
|
2349 |
||
2350 |
"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
|
2351 |
"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
|
2352 |
! |
3eb3911cb63e
Support of SIGCHL interrupt handling and OS-independent proces status
Stefan Vogel <sv@exept.de>
parents:
797
diff
changeset
|
2353 |
|
1288 | 2354 |
customInterruptHandler |
615 | 2355 |
"return the handler for custom interrupts" |
2356 |
||
2357 |
^ CustomInterruptHandler |
|
2358 |
! |
|
2359 |
||
1288 | 2360 |
customInterruptHandler:aHandler |
615 | 2361 |
"set the handler for custom interrupts" |
2362 |
||
2363 |
CustomInterruptHandler := aHandler |
|
2364 |
! |
|
2365 |
||
1288 | 2366 |
disposeInterruptHandler |
2367 |
"return the handler for object disposal interrupts" |
|
615 | 2368 |
|
2369 |
^ DisposeInterruptHandler |
|
2370 |
! |
|
2371 |
||
1288 | 2372 |
disposeInterruptHandler:aHandler |
2373 |
"set the handler for object disposal interrupts" |
|
615 | 2374 |
|
2375 |
DisposeInterruptHandler := aHandler |
|
2376 |
! |
|
2377 |
||
1288 | 2378 |
errorInterruptHandler |
615 | 2379 |
"return the handler for display error interrupts" |
2380 |
||
2381 |
^ ErrorInterruptHandler |
|
2382 |
! |
|
2383 |
||
1288 | 2384 |
errorInterruptHandler:aHandler |
2385 |
"set the handler for display error interrupts" |
|
615 | 2386 |
|
2387 |
ErrorInterruptHandler := aHandler |
|
2388 |
! |
|
2389 |
||
1288 | 2390 |
exceptionInterruptHandler |
2391 |
"return the handler for floating point exception interrupts" |
|
615 | 2392 |
|
2393 |
^ ExceptionInterruptHandler |
|
2394 |
! |
|
2395 |
||
1288 | 2396 |
internalErrorHandler |
2397 |
"return the handler for ST/X internal errors. |
|
2398 |
An internal error is reported for example when a methods |
|
2399 |
bytecode is not a ByteArray, the selector table is not an Array |
|
2400 |
etc. |
|
615 | 2401 |
Those should not occur in normal circumstances." |
2402 |
||
2403 |
^ InternalErrorHandler |
|
2404 |
! |
|
2405 |
||
1288 | 2406 |
ioInterruptHandler |
2407 |
"return the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 2408 |
|
2409 |
^ IOInterruptHandler |
|
2410 |
! |
|
2411 |
||
1288 | 2412 |
ioInterruptHandler:aHandler |
2413 |
"set the handler for I/O available signal interrupts (SIGIO/SIGPOLL)" |
|
615 | 2414 |
|
2415 |
IOInterruptHandler := aHandler |
|
2416 |
! |
|
2417 |
||
1288 | 2418 |
recursionInterruptHandler |
2419 |
"return the handler for recursion/stack overflow interrupts" |
|
615 | 2420 |
|
2421 |
^ RecursionInterruptHandler |
|
2422 |
! |
|
2423 |
||
1288 | 2424 |
recursionInterruptHandler:aHandler |
2425 |
"set the handler for recursion/stack overflow interrupts" |
|
615 | 2426 |
|
2427 |
RecursionInterruptHandler := aHandler |
|
2428 |
! |
|
2429 |
||
1288 | 2430 |
registerErrorInterruptHandler:aHandler forID:errorIDSymbol |
2431 |
"register a handler" |
|
2432 |
||
2433 |
RegisteredErrorInterruptHandlers isNil ifTrue:[ |
|
2434 |
RegisteredErrorInterruptHandlers := IdentityDictionary new |
|
615 | 2435 |
]. |
2436 |
RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler |
|
2437 |
! |
|
2438 |
||
1288 | 2439 |
registeredErrorInterruptHandlers |
615 | 2440 |
"return registered handlers" |
2441 |
||
2442 |
^ RegisteredErrorInterruptHandlers |
|
2443 |
! |
|
2444 |
||
1288 | 2445 |
signalInterruptHandler |
615 | 2446 |
"return the handler for UNIX-signal interrupts" |
2447 |
||
2448 |
^ SignalInterruptHandler |
|
2449 |
! |
|
2450 |
||
1288 | 2451 |
signalInterruptHandler:aHandler |
2452 |
"set the handler for UNIX-signal interrupts" |
|
615 | 2453 |
|
2454 |
SignalInterruptHandler := aHandler |
|
2455 |
! |
|
2456 |
||
1288 | 2457 |
spyInterruptHandler |
615 | 2458 |
"return the handler for spy-timer interrupts" |
2459 |
||
2460 |
^ SpyInterruptHandler |
|
2461 |
! |
|
2462 |
||
1288 | 2463 |
spyInterruptHandler:aHandler |
615 | 2464 |
"set the handler for spy-timer interrupts" |
2465 |
||
2466 |
SpyInterruptHandler := aHandler |
|
2467 |
! |
|
2468 |
||
1288 | 2469 |
stepInterruptHandler |
615 | 2470 |
"return the handler for single step interrupts" |
2471 |
||
2472 |
^ StepInterruptHandler |
|
2473 |
! |
|
2474 |
||
1288 | 2475 |
stepInterruptHandler:aHandler |
2476 |
"set the handler for single step interrupts" |
|
615 | 2477 |
|
2478 |
StepInterruptHandler := aHandler |
|
2479 |
! |
|
2480 |
||
1288 | 2481 |
timerInterruptHandler |
615 | 2482 |
"return the handler for timer interrupts" |
2483 |
||
2484 |
^ TimerInterruptHandler |
|
2485 |
! |
|
2486 |
||
1288 | 2487 |
timerInterruptHandler:aHandler |
615 | 2488 |
"set the handler for timer interrupts" |
2489 |
||
2490 |
TimerInterruptHandler := aHandler |
|
2491 |
! |
|
2492 |
||
1288 | 2493 |
userInterruptHandler |
615 | 2494 |
"return the handler for CNTL-C interrupt handling" |
2495 |
||
2496 |
^ UserInterruptHandler |
|
1288 | 2497 |
! |
2498 |
||
2499 |
userInterruptHandler:aHandler |
|
2500 |
"set the handler for CNTL-C interrupt handling" |
|
2501 |
||
2502 |
UserInterruptHandler := aHandler |
|
615 | 2503 |
! ! |
2504 |
||
1767 | 2505 |
!ObjectMemory class methodsFor:'interrupt statistics'! |
615 | 2506 |
|
1288 | 2507 |
interruptLatency:ms receiver:rec class:cls selector:sel vmActivity:vmActivity id:pid |
2508 |
"example implementation of latencyTime monitoring: |
|
2509 |
This method simply measures the max-latency time. |
|
2510 |
You may want to use some other handler (see #interruptLatencyMonitor:) |
|
2511 |
and extract more information (blocking context). |
|
2512 |
DEMO Example." |
|
2513 |
||
2514 |
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
|
2515 |
MaxInterruptLatency := ms. |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
2516 |
'IRQ-LATENCY: ' infoPrint. cls infoPrint. ' ' infoPrint. sel infoPrint. '(' infoPrint. vmActivity infoPrint . ') ---> ' infoPrint. ms infoPrintNL. |
1288 | 2517 |
]. |
2518 |
(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
|
2519 |
'*** 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
|
2520 |
cls errorPrint. |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
2521 |
' ' errorPrint. sel errorPrint. '(' errorPrint. vmActivity errorPrint . ') ---> ' errorPrint. |
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
2522 |
ms errorPrintNL. |
1288 | 2523 |
]. |
2524 |
||
2525 |
"to enable the demo handler: |
|
2526 |
||
2527 |
ObjectMemory resetMaxInterruptLatency. |
|
2528 |
ObjectMemory interruptLatencyMonitor:ObjectMemory. |
|
2529 |
" |
|
2530 |
"to disable timing statistics: |
|
2531 |
||
2532 |
ObjectMemory interruptLatencyMonitor:nil. |
|
2533 |
ObjectMemory maxInterruptLatency printNL. |
|
2534 |
" |
|
615 | 2535 |
|
2536 |
"Created: 7.11.1995 / 21:05:50 / cg" |
|
2537 |
"Modified: 7.11.1995 / 21:13:33 / cg" |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1427
diff
changeset
|
2538 |
"Modified: 18.6.1996 / 14:15:52 / stefan" |
615 | 2539 |
! |
2540 |
||
1288 | 2541 |
interruptLatencyGoal:millis |
2542 |
"setup to report an error message, whenever a realtime goal could not be |
|
2543 |
met due to blocked interrupts or long primitives or GC activity. |
|
2544 |
An argument of nil clears the check. |
|
2545 |
DEMO Example." |
|
2546 |
||
2547 |
InterruptLatencyGoal := millis. |
|
2548 |
millis isNil ifTrue:[ |
|
2549 |
InterruptLatencyMonitor := nil. |
|
2550 |
] ifFalse:[ |
|
2551 |
MaxInterruptLatency := 0. |
|
2552 |
InterruptLatencyMonitor := self. |
|
615 | 2553 |
] |
2554 |
||
2555 |
" |
|
2556 |
ObjectMemory interruptLatencyGoal:50 |
|
2557 |
" |
|
2558 |
! |
|
2559 |
||
1288 | 2560 |
interruptLatencyMonitor |
2561 |
"return the interrupt-latency-monitor if any. |
|
2562 |
See comment in #interruptLatencyMonitor:. |
|
2563 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 2564 |
|
2565 |
^ InterruptLatencyMonitor |
|
2566 |
! |
|
2567 |
||
1288 | 2568 |
interruptLatencyMonitor:aHandler |
2569 |
"set the interrupt latency monitor. If non-nil, this one will be sent |
|
2570 |
an interruptLatency: message with the millisecond delay between |
|
2571 |
the interrupt and its handling. |
|
2572 |
This is a non-standard debugging/realtime instrumentation entry." |
|
615 | 2573 |
|
2574 |
InterruptLatencyMonitor := aHandler |
|
2575 |
! |
|
2576 |
||
1288 | 2577 |
maxInterruptLatency |
2578 |
"return the maximum accumulated interrupt latency in millis. |
|
615 | 2579 |
DEMO Example." |
2580 |
||
2581 |
^ MaxInterruptLatency |
|
1288 | 2582 |
! |
2583 |
||
2584 |
resetMaxInterruptLatency |
|
2585 |
"reset the maximum accumulated interrupt latency probe time. |
|
2586 |
DEMO Example." |
|
2587 |
||
2588 |
MaxInterruptLatency := 0 |
|
615 | 2589 |
! ! |
2590 |
||
1767 | 2591 |
!ObjectMemory class methodsFor:'just in time compilation'! |
2592 |
||
2593 |
compiledCodeCounter |
|
2594 |
"return the number of additional code-bytes which |
|
2595 |
were generated since the counter was last reset" |
|
2596 |
||
2597 |
%{ /* NOCONTEXT */ |
|
2598 |
||
2599 |
extern __compiledCodeCounter(); |
|
2600 |
int nBytes; |
|
2601 |
||
2602 |
nBytes = __compiledCodeCounter(); |
|
2603 |
RETURN (__MKSMALLINT(nBytes)); |
|
2604 |
%} |
|
2605 |
" |
|
2606 |
ObjectMemory compiledCodeCounter |
|
2607 |
" |
|
2608 |
! |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2609 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2610 |
compiledCodeSpaceUsed |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2611 |
"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
|
2612 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2613 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2614 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2615 |
extern __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2616 |
int nBytes; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2617 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2618 |
nBytes = __compiledCodeSpaceUsed(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2619 |
RETURN (__MKSMALLINT(nBytes)); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2620 |
%} |
1767 | 2621 |
" |
2622 |
ObjectMemory compiledCodeSpaceUsed |
|
2623 |
" |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2624 |
! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2625 |
|
1795 | 2626 |
fullSingleStepSupport:aBoolean |
2627 |
"enable/disable full single step support for the just-in-time-compiled code. |
|
2628 |
If off, things like simple increment/decrement, additions and variable- |
|
2629 |
stores are not steppable, but treated like atomar invisible operations. |
|
2630 |
If on, single step halts at those operations. |
|
2631 |
Execution is a bit slower if enabled." |
|
2632 |
||
2633 |
%{ /* NOCONTEXT */ |
|
2634 |
extern int __fullSingleStep(); |
|
2635 |
int prev; |
|
2636 |
||
2637 |
prev = __fullSingleStep(aBoolean == true |
|
2638 |
? 1 |
|
2639 |
: (aBoolean == false) |
|
2640 |
? 0 |
|
2641 |
: -1); |
|
2642 |
RETURN (prev ? true : false); |
|
2643 |
%} |
|
2644 |
" |
|
2645 |
ObjectMemory fullSingleStepSupport:true |
|
2646 |
ObjectMemory fullSingleStepSupport:false |
|
2647 |
ObjectMemory fullSingleStepSupport:nil |
|
2648 |
" |
|
2649 |
||
2650 |
! |
|
2651 |
||
2652 |
getCompiledCodeLimit |
|
2653 |
"get the codeLimit from the VM" |
|
2654 |
||
2655 |
%{ /* NOCONTEXT */ |
|
2656 |
extern int __dynamicCodeLimit(); |
|
2657 |
int limit; |
|
2658 |
||
2659 |
limit = __dynamicCodeLimit(); |
|
2660 |
if (limit) { |
|
2661 |
RETURN (__MKSMALLINT(limit)); |
|
2662 |
} |
|
2663 |
RETURN (nil); |
|
2664 |
%} |
|
2665 |
! |
|
2666 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2667 |
justInTimeCompilation:aBoolean |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2668 |
"enable/disable just-in-time-compilation. Returns the previous setting." |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2669 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2670 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2671 |
extern int __justInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2672 |
int prev; |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2673 |
|
1657 | 2674 |
prev = __justInTimeCompilation(aBoolean == true |
1767 | 2675 |
? 1 |
2676 |
: (aBoolean == false) |
|
2677 |
? 0 |
|
2678 |
: -1); |
|
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2679 |
RETURN (prev ? true : false); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2680 |
%} |
1767 | 2681 |
" |
2682 |
ObjectMemory justInTimeCompilation:true |
|
2683 |
ObjectMemory justInTimeCompilation:false |
|
2684 |
ObjectMemory justInTimeCompilation:nil |
|
2685 |
" |
|
2686 |
||
2687 |
! |
|
2688 |
||
1770 | 2689 |
resetCompiledCodeCounter |
2690 |
"reset the counter of additional code-bytes" |
|
2691 |
||
2692 |
%{ /* NOCONTEXT */ |
|
2693 |
||
2694 |
extern void __resetDynamicCodeGeneratedCounter(); |
|
2695 |
||
2696 |
__resetDynamicCodeGeneratedCounter(); |
|
2697 |
%} |
|
2698 |
" |
|
2699 |
ObjectMemory resetCompiledCodeCounter |
|
2700 |
" |
|
2701 |
||
2702 |
! |
|
2703 |
||
1769 | 2704 |
setCompiledCodeLimit:newLimit |
2705 |
"set the VM's limit" |
|
2706 |
||
2707 |
%{ /* NOCONTEXT */ |
|
2708 |
extern __setDynamicCodeLimit(); |
|
2709 |
||
2710 |
if (__isSmallInteger(newLimit)) { |
|
2711 |
__setDynamicCodeLimit(__intVal(newLimit)); |
|
2712 |
} else if (newLimit == nil) { |
|
2713 |
__setDynamicCodeLimit(0); |
|
2714 |
} |
|
2715 |
%} |
|
2716 |
! |
|
2717 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2718 |
supportsJustInTimeCompilation |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2719 |
"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
|
2720 |
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
|
2721 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2722 |
%{ /* NOCONTEXT */ |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2723 |
extern int __canDoJustInTimeCompilation(); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2724 |
|
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2725 |
RETURN (__canDoJustInTimeCompilation() ? true : false); |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2726 |
%} |
1767 | 2727 |
" |
2728 |
ObjectMemory supportsJustInTimeCompilation |
|
2729 |
" |
|
2730 |
||
1637
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2731 |
! ! |
0548117601bd
more queries for just-in-time compiler
Claus Gittinger <cg@exept.de>
parents:
1503
diff
changeset
|
2732 |
|
1767 | 2733 |
!ObjectMemory class methodsFor:'low memory handling'! |
615 | 2734 |
|
1288 | 2735 |
memoryInterrupt |
2736 |
"when a low-memory condition arises, ask all classes to |
|
2737 |
remove possibly cached data. You may help the system a bit, |
|
2738 |
in providing a lowSpaceCleanup method in your classes which have |
|
2739 |
lots of data kept somewhere (usually, cached data). |
|
2740 |
- this may or may not help." |
|
2741 |
||
2742 |
self performLowSpaceCleanup. |
|
2743 |
"/ self error:'almost out of memory' |
|
2744 |
'almost out of memory' errorPrintNL. |
|
615 | 2745 |
|
2746 |
LowSpaceSemaphore signalIf. |
|
1160
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
2747 |
|
1a30ffb90937
separated #performLowSpaceCleanup
Claus Gittinger <cg@exept.de>
parents:
1152
diff
changeset
|
2748 |
"Modified: 12.4.1996 / 14:57:55 / cg" |
1288 | 2749 |
! |
2750 |
||
2751 |
performLowSpaceCleanup |
|
2752 |
"ask all classes to remove possibly cached data. |
|
2753 |
You may help the system a bit, in providing a lowSpaceCleanup method |
|
2754 |
in your classes which have lots of data kept somewhere (usually, cached data)." |
|
2755 |
||
2756 |
Smalltalk allBehaviorsDo:[:aClass | |
|
2757 |
aClass lowSpaceCleanup |
|
2758 |
]. |
|
2759 |
||
2760 |
"Created: 12.4.1996 / 14:57:28 / cg" |
|
362 | 2761 |
! ! |
2762 |
||
1767 | 2763 |
!ObjectMemory class methodsFor:'object finalization'! |
290 | 2764 |
|
1288 | 2765 |
allChangedShadowObjectsDo:aBlock |
2766 |
"evaluate the argument, aBlock for all known shadow objects which have |
|
2767 |
lost a pointer recently." |
|
290 | 2768 |
%{ |
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2769 |
__allChangedShadowObjectsDo(&aBlock); |
290 | 2770 |
%} |
2771 |
! |
|
2772 |
||
1288 | 2773 |
disposeInterrupt |
2774 |
"this is triggered by the garbage collector, |
|
2775 |
whenever any shadowArray looses a pointer." |
|
2776 |
||
2777 |
FinalizationSemaphore notNil ifTrue:[ |
|
2778 |
"/ |
|
2779 |
"/ background finalizer is waiting ... |
|
2780 |
"/ |
|
2781 |
FinalizationSemaphore signal |
|
290 | 2782 |
] ifFalse:[ |
2783 |
"/ |
|
2784 |
"/ do it right here |
|
2785 |
"/ |
|
291 | 2786 |
self finalize |
290 | 2787 |
] |
2788 |
! |
|
2789 |
||
1288 | 2790 |
finalize |
2791 |
"tell all weak objects that something happened." |
|
2792 |
||
2793 |
self allChangedShadowObjectsDo:[:aShadowArray | |
|
615 | 2794 |
aShadowArray lostPointer. |
2795 |
] |
|
2796 |
! |
|
2797 |
||
1288 | 2798 |
startBackgroundFinalizationAt:aPriority |
2799 |
"start a process doing finalization work in the background. |
|
2800 |
Can be used to reduce the pauses created by finalization. |
|
2801 |
Normally, these pauses are not noticed; however if you have (say) |
|
2802 |
ten thousands of weak objects, these could become long enough to |
|
2803 |
make background finalization usefull. |
|
2804 |
WARNING: background finalization may lead to much delayed freeing of |
|
2805 |
system resources. Especially, you may temporarily run out of free |
|
2806 |
color table entries or fileDescriptors etc. Use at your own risk (if at all)" |
|
2807 |
||
2808 |
|p| |
|
2809 |
||
2810 |
"/ |
|
2811 |
"/ its not useful, to run it more than once |
|
2812 |
"/ |
|
2813 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
2814 |
BackgroundFinalizationProcess priority:aPriority. |
|
2815 |
^ self |
|
2816 |
]. |
|
2817 |
||
2818 |
FinalizationSemaphore := Semaphore new. |
|
2819 |
||
2820 |
p := |
|
2821 |
[ |
|
2822 |
[ |
|
2823 |
[true] whileTrue:[ |
|
2824 |
" |
|
2825 |
wait till something to do ... |
|
2826 |
" |
|
2827 |
FinalizationSemaphore wait. |
|
2828 |
" |
|
2829 |
... and do it |
|
2830 |
" |
|
2831 |
self finalize |
|
2832 |
] |
|
2833 |
] valueOnUnwindDo:[ |
|
2834 |
BackgroundFinalizationProcess := nil. |
|
2835 |
FinalizationSemaphore := nil |
|
2836 |
] |
|
2837 |
] newProcess. |
|
2838 |
p name:'background finalizer'. |
|
2839 |
p priority:aPriority. |
|
2840 |
p restartable:true. |
|
2841 |
p resume. |
|
2842 |
BackgroundFinalizationProcess := p |
|
290 | 2843 |
|
2844 |
" |
|
2845 |
ObjectMemory startBackgroundFinalizationAt:5 |
|
2846 |
" |
|
1288 | 2847 |
! |
2848 |
||
2849 |
stopBackgroundFinalization |
|
2850 |
"stop the background finalizer" |
|
2851 |
||
2852 |
BackgroundFinalizationProcess notNil ifTrue:[ |
|
2853 |
BackgroundFinalizationProcess terminate. |
|
2854 |
BackgroundFinalizationProcess := nil |
|
2855 |
]. |
|
2856 |
||
2857 |
" |
|
2858 |
ObjectMemory stopBackgroundFinalization |
|
2859 |
" |
|
290 | 2860 |
! ! |
2861 |
||
1767 | 2862 |
!ObjectMemory class methodsFor:'physical memory access'! |
93 | 2863 |
|
1288 | 2864 |
collectedOldSpacePagesDo:aBlock |
2865 |
"evaluates aBlock for all pages in the prev. oldSpace, passing |
|
2866 |
the pages address as argument. |
|
2867 |
For internal & debugging use only." |
|
2868 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2869 |
if (__collectedOldSpacePagesDo(&aBlock) < 0) { |
615 | 2870 |
RETURN (false); |
2871 |
} |
|
2872 |
%}. |
|
2873 |
^ true |
|
2874 |
! |
|
2875 |
||
1288 | 2876 |
newSpacePagesDo:aBlock |
2877 |
"evaluates aBlock for all pages in the newSpace, passing |
|
2878 |
the pages address as argument. |
|
2879 |
For internal & debugging use only." |
|
2880 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2881 |
if (__newSpacePagesDo(&aBlock) < 0) { |
159 | 2882 |
RETURN (false); |
85 | 2883 |
} |
2884 |
%}. |
|
2885 |
^ true |
|
2886 |
! |
|
2887 |
||
1288 | 2888 |
oldSpacePagesDo:aBlock |
2889 |
"evaluates aBlock for all pages in the oldSpace, passing |
|
2890 |
the pages address as argument. |
|
2891 |
For internal & debugging use only." |
|
2892 |
%{ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1669
diff
changeset
|
2893 |
if (__oldSpacePagesDo(&aBlock) < 0) { |
1286 | 2894 |
RETURN (false); |
85 | 2895 |
} |
2896 |
%}. |
|
2897 |
^ true |
|
1288 | 2898 |
! |
2899 |
||
2900 |
pageIsInCore:aPageNumber |
|
2901 |
"return true, if the page (as enumerated via oldSpacePagesDo:) |
|
2902 |
is in memory; false, if currently paged out. For internal |
|
2903 |
use / monitors only; may vanish. |
|
2904 |
NOTICE: not all systems provide this information; on those that |
|
2905 |
do not, true is returned for all pages." |
|
2906 |
%{ |
|
2907 |
#ifdef HAS_MINCORE |
|
2908 |
int pageSize = getpagesize(); |
|
2909 |
char result[10]; |
|
2910 |
INT addr; |
|
2911 |
||
2912 |
if (__isSmallInteger(aPageNumber)) { |
|
2913 |
addr = __intVal(aPageNumber) & ~(pageSize - 1); |
|
2914 |
} else { |
|
2915 |
addr = ((INT)aPageNumber) & ~(pageSize - 1); |
|
2916 |
} |
|
2917 |
if (mincore(addr, pageSize-1, result) < 0) { |
|
2918 |
RETURN (true); |
|
2919 |
} |
|
2920 |
RETURN ((result[0] & 1) ? true : false); |
|
2921 |
#endif |
|
2922 |
%}. |
|
2923 |
"OS does not supply this info - assume yes" |
|
2924 |
^ true |
|
85 | 2925 |
! ! |
2926 |
||
1767 | 2927 |
!ObjectMemory class methodsFor:'queries'! |
615 | 2928 |
|
1288 | 2929 |
bytesUsed |
2930 |
"return the number of bytes allocated for objects - |
|
2931 |
this number is not exact, since some objects may already be dead |
|
2932 |
(i.e. not yet reclaimed by the garbage collector). |
|
2933 |
If you need the exact number, you have to loop over all |
|
2934 |
objects and ask for the bytesize using ObjectMemory>>sizeOf:." |
|
2935 |
||
2936 |
%{ /* NOCONTEXT */ |
|
2937 |
extern unsigned __oldSpaceUsed(), __newSpaceUsed(), __freeListSpace(); |
|
2938 |
||
2939 |
RETURN ( __MKSMALLINT(__oldSpaceUsed() + __newSpaceUsed() - __freeListSpace()) ); |
|
615 | 2940 |
%} |
2941 |
" |
|
2942 |
ObjectMemory bytesUsed |
|
2943 |
" |
|
2944 |
! |
|
2945 |
||
1288 | 2946 |
collectObjectsWhich:aBlock |
2947 |
"helper for the whoReferences queries. Returns a collection |
|
2948 |
of objects for which aBlock returns true." |
|
2949 |
||
2950 |
|aCollection| |
|
2951 |
||
2952 |
aCollection := IdentitySet new. |
|
2953 |
self allObjectsDo:[:o | |
|
2954 |
(aBlock value:o) ifTrue:[ |
|
2955 |
aCollection add:o |
|
2956 |
] |
|
2957 |
]. |
|
2958 |
(aCollection size == 0) ifTrue:[ |
|
615 | 2959 |
"actually this cannot happen - there is always one" |
2960 |
^ nil |
|
2961 |
]. |
|
2962 |
^ aCollection |
|
2963 |
! |
|
2964 |
||
1288 | 2965 |
fixSpaceSize |
2966 |
"return the total size of the fix space." |
|
2967 |
||
2968 |
%{ /* NOCONTEXT */ |
|
2969 |
extern unsigned __fixSpaceSize(); |
|
2970 |
||
2971 |
RETURN ( __MKSMALLINT(__fixSpaceSize()) ); |
|
615 | 2972 |
%} |
2973 |
" |
|
2974 |
ObjectMemory fixSpaceSize |
|
2975 |
" |
|
2976 |
! |
|
2977 |
||
1288 | 2978 |
fixSpaceUsed |
2979 |
"return the number of bytes allocated for old objects in fix space." |
|
2980 |
||
2981 |
%{ /* NOCONTEXT */ |
|
2982 |
extern unsigned __fixSpaceUsed(); |
|
2983 |
||
2984 |
RETURN ( __MKSMALLINT(__fixSpaceUsed()) ); |
|
615 | 2985 |
%} |
2986 |
" |
|
2987 |
ObjectMemory fixSpaceUsed |
|
2988 |
" |
|
2989 |
! |
|
2990 |
||
1288 | 2991 |
freeListSpace |
2992 |
"return the number of bytes in the free lists. |
|
2993 |
(which is included in oldSpaceUsed)" |
|
2994 |
||
2995 |
%{ /* NOCONTEXT */ |
|
2996 |
extern unsigned __freeListSpace(); |
|
2997 |
||
2998 |
RETURN ( __MKSMALLINT(__freeListSpace()) ); |
|
615 | 2999 |
%} |
3000 |
" |
|
3001 |
ObjectMemory freeListSpace |
|
3002 |
" |
|
3003 |
! |
|
3004 |
||
1288 | 3005 |
freeSpace |
3006 |
"return the number of bytes in the compact free area. |
|
3007 |
(oldSpaceUsed + freeSpaceSize = oldSpaceSize)" |
|
3008 |
||
3009 |
%{ /* NOCONTEXT */ |
|
3010 |
extern unsigned __oldSpaceSize(), __oldSpaceUsed(); |
|
3011 |
||
3012 |
RETURN ( __MKSMALLINT(__oldSpaceSize() - __oldSpaceUsed()) ); |
|
615 | 3013 |
%} |
3014 |
" |
|
3015 |
ObjectMemory freeSpace |
|
3016 |
" |
|
3017 |
! |
|
3018 |
||
1288 | 3019 |
garbageCollectCount |
3020 |
"return the number of compressing collects that occurred since startup" |
|
3021 |
||
3022 |
%{ /* NOCONTEXT */ |
|
3023 |
extern int __garbageCollectCount(); |
|
3024 |
||
3025 |
RETURN (__MKSMALLINT(__garbageCollectCount())); |
|
615 | 3026 |
%} |
3027 |
" |
|
3028 |
ObjectMemory garbageCollectCount |
|
3029 |
" |
|
3030 |
! |
|
3031 |
||
1288 | 3032 |
incrementalGCCount |
3033 |
"return the number of incremental collects that occurred since startup" |
|
3034 |
||
3035 |
%{ /* NOCONTEXT */ |
|
3036 |
extern int __incrementalGCCount(); |
|
3037 |
||
3038 |
RETURN (__MKSMALLINT(__incrementalGCCount())); |
|
615 | 3039 |
%} |
3040 |
" |
|
3041 |
ObjectMemory incrementalGCCount |
|
3042 |
" |
|
3043 |
! |
|
3044 |
||
1288 | 3045 |
incrementalGCPhase |
3046 |
"returns the internal state of the incremental GC. |
|
3047 |
The meaning of those numbers is a secret :-). |
|
3048 |
(for the curious: (currently) |
|
3049 |
2 is idle, 3..11 are various mark phases, |
|
3050 |
12 is the sweep phase. 0 and 1 are cleanup phases when the |
|
3051 |
incr. GC gets interrupted by a full GC). |
|
3052 |
Do not depend on the values - there may be additional phases in |
|
3053 |
future versions (incremental compact ;-). |
|
3054 |
This is for debugging and monitoring only - and may change or vanish" |
|
3055 |
||
3056 |
%{ /* NOCONTEXT */ |
|
615 | 3057 |
extern int __incrGCphase(); |
3058 |
||
1133 | 3059 |
RETURN (__MKSMALLINT(__incrGCphase())); |
615 | 3060 |
%} |
3061 |
! |
|
3062 |
||
1288 | 3063 |
lastScavengeReclamation |
3064 |
"returns the number of bytes replacimed by the last scavenge. |
|
3065 |
For statistic only - this may vanish." |
|
3066 |
||
3067 |
%{ /* NOCONTEXT */ |
|
3068 |
extern int __newSpaceReclaimed(); |
|
3069 |
||
3070 |
RETURN ( __MKSMALLINT(__newSpaceReclaimed()) ); |
|
3071 |
%} |
|
3072 |
"percentage of reclaimed objects is returned by: |
|
3073 |
||
3074 |
((ObjectMemory lastScavengeReclamation) |
|
615 | 3075 |
/ (ObjectMemory newSpaceSize)) * 100.0 |
3076 |
" |
|
3077 |
! |
|
3078 |
||
1288 | 3079 |
lifoRememberedSet |
3080 |
"return the lifoRemSet. |
|
3081 |
This is pure VM debugging and will vanish without notice." |
|
3082 |
||
3083 |
%{ /* NOCONTEXT */ |
|
3084 |
extern OBJ __lifoRememberedSet(); |
|
3085 |
||
3086 |
RETURN ( __lifoRememberedSet() ); |
|
615 | 3087 |
%} |
3088 |
" |
|
3089 |
ObjectMemory lifoRememberedSet |
|
3090 |
" |
|
3091 |
! |
|
3092 |
||
1288 | 3093 |
lifoRememberedSetSize |
3094 |
"return the size of the lifoRemSet. |
|
3095 |
This is a VM debugging interface and may vanish without notice." |
|
3096 |
||
3097 |
%{ /* NOCONTEXT */ |
|
3098 |
extern int __lifoRememberedSetSize(); |
|
3099 |
||
3100 |
RETURN (__MKSMALLINT(__lifoRememberedSetSize())); |
|
615 | 3101 |
%} |
3102 |
" |
|
3103 |
ObjectMemory lifoRememberedSetSize |
|
3104 |
" |
|
3105 |
! |
|
3106 |
||
1288 | 3107 |
markAndSweepCount |
3108 |
"return the number of mark&sweep collects that occurred since startup" |
|
3109 |
||
3110 |
%{ /* NOCONTEXT */ |
|
3111 |
extern int __markAndSweepCount(); |
|
3112 |
||
3113 |
RETURN (__MKSMALLINT(__markAndSweepCount())); |
|
615 | 3114 |
%} |
3115 |
" |
|
3116 |
ObjectMemory markAndSweepCount |
|
3117 |
" |
|
3118 |
! |
|
3119 |
||
1288 | 3120 |
maximumIdentityHashValue |
3121 |
"for ST-80 compatibility: return the maximum value |
|
3122 |
a hashKey as returned by identityHash can get. |
|
3123 |
Since ST/X uses direct pointers, a field in the objectHeader |
|
3124 |
is used, which is currently 11 bits in size." |
|
3125 |
||
3126 |
%{ /* NOCONTEXT */ |
|
3127 |
RETURN ( __MKSMALLINT( __MAX_HASH__ << __HASH_SHIFT__) ); |
|
615 | 3128 |
%} |
3129 |
" |
|
3130 |
ObjectMemory maximumIdentityHashValue |
|
3131 |
" |
|
3132 |
! |
|
3133 |
||
1288 | 3134 |
minScavengeReclamation |
3135 |
"returns the number of bytes replacimed by the least effective scavenge. |
|
3136 |
For statistic only - this may vanish." |
|
3137 |
||
3138 |
%{ /* NOCONTEXT */ |
|
3139 |
extern int __newSpaceReclaimedMin(); |
|
3140 |
||
3141 |
RETURN ( __MKSMALLINT(__newSpaceReclaimedMin()) ); |
|
615 | 3142 |
%} |
3143 |
" |
|
3144 |
ObjectMemory minScavengeReclamation |
|
3145 |
" |
|
3146 |
! |
|
3147 |
||
1288 | 3148 |
newSpaceSize |
3149 |
"return the total size of the new space - this is usually fix" |
|
3150 |
||
3151 |
%{ /* NOCONTEXT */ |
|
3152 |
extern unsigned __newSpaceSize(); |
|
3153 |
||
3154 |
RETURN ( __MKSMALLINT(__newSpaceSize()) ); |
|
615 | 3155 |
%} |
3156 |
" |
|
3157 |
ObjectMemory newSpaceSize |
|
3158 |
" |
|
3159 |
! |
|
3160 |
||
1288 | 3161 |
newSpaceUsed |
3162 |
"return the number of bytes allocated for new objects. |
|
3163 |
The returned value is usually obsolete as soon as you do |
|
3164 |
something with it ..." |
|
3165 |
||
3166 |
%{ /* NOCONTEXT */ |
|
3167 |
extern unsigned __newSpaceUsed(); |
|
3168 |
||
3169 |
RETURN ( __MKSMALLINT(__newSpaceUsed()) ); |
|
615 | 3170 |
%} |
3171 |
" |
|
3172 |
ObjectMemory newSpaceUsed |
|
3173 |
" |
|
3174 |
! |
|
3175 |
||
1288 | 3176 |
numberOfObjects |
3177 |
"return the number of objects in the system." |
|
3178 |
||
3179 |
|tally "{ Class: SmallInteger }"| |
|
3180 |
||
3181 |
tally := 0. |
|
3182 |
self allObjectsDo:[:obj | tally := tally + 1]. |
|
615 | 3183 |
^ tally |
3184 |
||
3185 |
" |
|
3186 |
ObjectMemory numberOfObjects |
|
3187 |
" |
|
3188 |
! |
|
3189 |
||
1288 | 3190 |
numberOfWeakObjects |
3191 |
"return the number of weak objects in the system" |
|
3192 |
||
3193 |
%{ /* NOCONTEXT */ |
|
3194 |
extern int __weakListSize(); |
|
3195 |
||
3196 |
RETURN ( __MKSMALLINT(__weakListSize()) ); |
|
615 | 3197 |
%} |
3198 |
" |
|
3199 |
ObjectMemory numberOfWeakObjects |
|
3200 |
" |
|
3201 |
! |
|
3202 |
||
1288 | 3203 |
oldSpaceAllocatedSinceLastGC |
3204 |
"return the number of bytes allocated for old objects since the |
|
3205 |
last oldspace garbage collect occured. This information is used |
|
3206 |
by ProcessorScheduler to decide when to start the incremental |
|
3207 |
background GC." |
|
3208 |
||
3209 |
%{ /* NOCONTEXT */ |
|
3210 |
extern unsigned __oldSpaceAllocatedSinceLastGC(); |
|
3211 |
||
3212 |
RETURN ( __MKSMALLINT(__oldSpaceAllocatedSinceLastGC()) ); |
|
615 | 3213 |
%} |
3214 |
" |
|
3215 |
ObjectMemory oldSpaceAllocatedSinceLastGC |
|
3216 |
" |
|
3217 |
! |
|
3218 |
||
1288 | 3219 |
oldSpaceSize |
3220 |
"return the total size of the old space. - may grow slowly" |
|
3221 |
||
3222 |
%{ /* NOCONTEXT */ |
|
3223 |
extern unsigned __oldSpaceSize(); |
|
3224 |
||
3225 |
RETURN ( __MKSMALLINT(__oldSpaceSize()) ); |
|
615 | 3226 |
%} |
3227 |
" |
|
3228 |
ObjectMemory oldSpaceSize |
|
3229 |
" |
|
3230 |
! |
|
3231 |
||
1288 | 3232 |
oldSpaceUsed |
3233 |
"return the number of bytes allocated for old objects. |
|
3234 |
(This includes the free lists)" |
|
3235 |
||
3236 |
%{ /* NOCONTEXT */ |
|
3237 |
extern unsigned __oldSpaceUsed(); |
|
3238 |
||
3239 |
RETURN ( __MKSMALLINT(__oldSpaceUsed()) ); |
|
615 | 3240 |
%} |
3241 |
" |
|
3242 |
ObjectMemory oldSpaceUsed |
|
3243 |
" |
|
3244 |
! |
|
3245 |
||
1288 | 3246 |
rememberedSetSize |
3247 |
"return the number of old objects referencing new ones. |
|
3248 |
This is a VM debugging interface and may vanish without notice." |
|
3249 |
||
3250 |
%{ /* NOCONTEXT */ |
|
3251 |
extern int __rememberedSetSize(); |
|
3252 |
||
3253 |
RETURN (__MKSMALLINT(__rememberedSetSize())); |
|
615 | 3254 |
%} |
3255 |
" |
|
3256 |
ObjectMemory rememberedSetSize |
|
3257 |
" |
|
3258 |
! |
|
3259 |
||
1288 | 3260 |
resetMinScavengeReclamation |
3261 |
"resets the number of bytes replacimed by the least effective scavenge. |
|
3262 |
For statistic only - this may vanish." |
|
3263 |
||
3264 |
%{ /* NOCONTEXT */ |
|
3265 |
extern int __resetNewSpaceReclaimedMin(); |
|
3266 |
||
3267 |
__resetNewSpaceReclaimedMin(); |
|
3268 |
%}. |
|
3269 |
^ self |
|
3270 |
" |
|
3271 |
ObjectMemory resetMinScavengeReclamation. |
|
615 | 3272 |
ObjectMemory minScavengeReclamation |
3273 |
" |
|
3274 |
! |
|
3275 |
||
1288 | 3276 |
runsSingleOldSpace |
3277 |
"return true, if the system runs in a single oldSpace or |
|
3278 |
false if not. |
|
3279 |
The memory system will always drop the second semispace when |
|
3280 |
running out of virtual memory, or the baker-limit is reached. |
|
3281 |
OBSOLETE: |
|
3282 |
the system may now decide at any time to switch between |
|
3283 |
single and double-space algorithms, depending on the overall memory |
|
3284 |
size. You will now almost always get false as result, since the |
|
3285 |
second semispace is only allocated when needed, and released |
|
3286 |
immediately afterwards. |
|
3287 |
" |
|
3288 |
||
3289 |
%{ /* NOCONTEXT */ |
|
3290 |
extern int __runsSingleOldSpace(); |
|
3291 |
||
3292 |
RETURN ( (__runsSingleOldSpace() ? true : false) ); |
|
615 | 3293 |
%} |
3294 |
" |
|
3295 |
ObjectMemory runsSingleOldSpace |
|
3296 |
" |
|
3297 |
! |
|
3298 |
||
1288 | 3299 |
scavengeCount |
3300 |
"return the number of scavenges that occurred since startup" |
|
3301 |
||
3302 |
%{ /* NOCONTEXT */ |
|
3303 |
extern int __scavengeCount(); |
|
3304 |
||
3305 |
RETURN (__MKSMALLINT(__scavengeCount())); |
|
615 | 3306 |
%} |
3307 |
" |
|
3308 |
ObjectMemory scavengeCount |
|
3309 |
" |
|
3310 |
! |
|
3311 |
||
1288 | 3312 |
symSpaceSize |
3313 |
"return the total size of the sym space." |
|
3314 |
||
3315 |
%{ /* NOCONTEXT */ |
|
3316 |
extern unsigned __symSpaceSize(); |
|
3317 |
||
3318 |
RETURN ( __MKSMALLINT(__symSpaceSize()) ); |
|
615 | 3319 |
%} |
3320 |
" |
|
3321 |
ObjectMemory symSpaceSize |
|
3322 |
" |
|
3323 |
! |
|
3324 |
||
1288 | 3325 |
symSpaceUsed |
3326 |
"return the number of bytes allocated for old objects in sym space." |
|
3327 |
||
3328 |
%{ /* NOCONTEXT */ |
|
3329 |
extern unsigned __symSpaceUsed(); |
|
3330 |
||
3331 |
RETURN ( __MKSMALLINT(__symSpaceUsed()) ); |
|
615 | 3332 |
%} |
3333 |
" |
|
3334 |
ObjectMemory symSpaceUsed |
|
3335 |
" |
|
3336 |
! |
|
3337 |
||
1288 | 3338 |
tenureAge |
3339 |
"return the current tenure age - thats the number of times |
|
3340 |
an object has to survive scavenges to be moved into oldSpace. |
|
3341 |
For statistic/debugging only - this method may vanish" |
|
3342 |
||
3343 |
%{ /* NOCONTEXT */ |
|
615 | 3344 |
extern unsigned __tenureAge(); |
3345 |
||
1133 | 3346 |
RETURN ( __MKSMALLINT(__tenureAge()) ); |
615 | 3347 |
%} |
3348 |
! |
|
3349 |
||
1288 | 3350 |
whoReferences:anObject |
3351 |
"return a collection of objects referencing the argument, anObject" |
|
3352 |
||
3353 |
^ self collectObjectsWhich:[:o | o references:anObject] |
|
615 | 3354 |
|
3355 |
" |
|
3356 |
(ObjectMemory whoReferences:Transcript) printNL |
|
3357 |
" |
|
3358 |
! |
|
3359 |
||
1288 | 3360 |
whoReferencesDerivedInstancesOf:aClass |
3361 |
"return a collection of objects refering to instances |
|
3362 |
of the argument, aClass or a subclass of it." |
|
3363 |
||
3364 |
^ self collectObjectsWhich:[:o | o referencesDerivedInstanceOf:aClass] |
|
615 | 3365 |
|
3366 |
" |
|
3367 |
(ObjectMemory whoReferencesDerivedInstancesOf:View) printNL |
|
3368 |
" |
|
1288 | 3369 |
! |
3370 |
||
3371 |
whoReferencesInstancesOf:aClass |
|
3372 |
"return a collection of objects refering to instances |
|
3373 |
of the argument, aClass" |
|
3374 |
||
3375 |
^ self collectObjectsWhich:[:o | o referencesInstanceOf:aClass] |
|
3376 |
||
3377 |
" |
|
3378 |
(ObjectMemory whoReferencesInstancesOf:SystemBrowser) printNL |
|
3379 |
" |
|
615 | 3380 |
! ! |
3381 |
||
1767 | 3382 |
!ObjectMemory class methodsFor:'semaphore access'! |
615 | 3383 |
|
1288 | 3384 |
lowSpaceSemaphore |
3385 |
"return the semaphore that is signalled when the system detects a |
|
3386 |
low space condition. Usually, some time after this, an allocationFailure |
|
3387 |
will happen. You can have a cleanup process sitting in that semaphore and |
|
3388 |
start to release object." |
|
379 | 3389 |
|
1286 | 3390 |
^ LowSpaceSemaphore |
379 | 3391 |
! ! |
3392 |
||
1767 | 3393 |
!ObjectMemory class methodsFor:'statistics'! |
1288 | 3394 |
|
3395 |
ageStatistic |
|
3396 |
%{ /* NOCONTEXT */ |
|
1286 | 3397 |
|
3398 |
__ageStatistics(); |
|
3399 |
%} |
|
1288 | 3400 |
! ! |
3401 |
||
1767 | 3402 |
!ObjectMemory class methodsFor:'system management'! |
1288 | 3403 |
|
3404 |
allBinaryModulesDo:aBlock |
|
3405 |
"internal private method - walk over all known binary |
|
3406 |
modules and evaluate aBlock for each entry. |
|
3407 |
Do not depend on the information returned for each - this may |
|
418 | 3408 |
change without notice." |
3409 |
||
3410 |
%{ |
|
3411 |
__REGISTRATION_DO_BLOCK(&aBlock COMMA_SND); |
|
3412 |
%} |
|
3413 |
! |
|
3414 |
||
1288 | 3415 |
binaryModuleInfo |
3416 |
"return a collection of moduleInfo entries. |
|
3417 |
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
|
3418 |
with one entry for each binary package (module)." |
1288 | 3419 |
|
3420 |
|modules| |
|
3421 |
||
3422 |
modules := IdentityDictionary new. |
|
3423 |
self allBinaryModulesDo:[:entry | |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3424 |
|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
|
3425 |
typeName nameString| |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3426 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3427 |
id := entry at:1. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3428 |
subModuleName := (entry at:2) asSymbol. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3429 |
libName := (entry at:4). |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3430 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3431 |
id > 0 ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3432 |
pathName := ObjectFileLoader pathNameFromID:id. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3433 |
dynamic := true. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3434 |
typeName := 'dynamic '. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3435 |
name := pathName asFilename baseName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3436 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3437 |
dynamic := false. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3438 |
typeName := 'builtIn '. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3439 |
pathName := nil. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3440 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3441 |
name := subModuleName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3442 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3443 |
name := libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3444 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3445 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3446 |
nameString := typeName. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3447 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3448 |
nameString := nameString, 'module ' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3449 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3450 |
nameString := nameString, 'classLib ' |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3451 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3452 |
nameString := nameString , name. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3453 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3454 |
libName isNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3455 |
type := #classObject |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3456 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3457 |
type := #classLibrary |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3458 |
]. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3459 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3460 |
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
|
3461 |
infoRec notNil ifTrue:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3462 |
infoRec classNames add:subModuleName. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3463 |
] ifFalse:[ |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3464 |
infoRec := BinaryModuleDescriptor |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3465 |
name:nameString |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3466 |
type:type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3467 |
id:id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3468 |
dynamic:dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3469 |
classNames:(Set with:subModuleName) |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3470 |
pathName:pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3471 |
libraryName:libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3472 |
timeStamp:nil. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3473 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3474 |
modules at:id put:infoRec. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3475 |
]. |
1288 | 3476 |
]. |
3477 |
^ modules |
|
3478 |
||
3479 |
" |
|
3480 |
ObjectMemory binaryModuleInfo |
|
418 | 3481 |
" |
3482 |
||
438 | 3483 |
"Modified: 17.9.1995 / 16:33:02 / claus" |
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3484 |
"Modified: 31.10.1996 / 13:59:02 / cg" |
418 | 3485 |
! |
3486 |
||
1288 | 3487 |
fullBinaryModuleInfo |
3488 |
"return a full collection of moduleInfo entries. |
|
3489 |
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
|
3490 |
with one entry for each sub-component in all binary packages." |
1288 | 3491 |
|
3492 |
|modules| |
|
3493 |
||
3494 |
modules := IdentityDictionary new. |
|
3495 |
self allBinaryModulesDo:[:entry | |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3496 |
|infoEntry |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3497 |
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
|
3498 |
|
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3499 |
id := entry at:1. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3500 |
subModuleName := (entry at:2) asSymbol. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3501 |
libName := (entry at:4). |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3502 |
t := AbsoluteTime fromOSTime:((entry at:5) * 1000). |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3503 |
|
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3504 |
id > 0 ifTrue:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3505 |
dynamic := true. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3506 |
] ifFalse:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3507 |
dynamic := false. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3508 |
]. |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3509 |
libName isNil ifTrue:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3510 |
type := #classObject |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3511 |
] ifFalse:[ |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3512 |
type := #classLibrary |
b73090986d9b
time changes (include milliseconds in osTime)
Claus Gittinger <cg@exept.de>
parents:
1480
diff
changeset
|
3513 |
]. |
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3514 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3515 |
"/ ... new: |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3516 |
infoEntry := BinaryModuleDescriptor |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3517 |
name:nil |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3518 |
type:type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3519 |
id:id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3520 |
dynamic:dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3521 |
classNames:(Array with:subModuleName) |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3522 |
pathName:nil |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3523 |
libraryName:libName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3524 |
timeStamp:t. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3525 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3526 |
modules at:subModuleName put:infoEntry. |
1288 | 3527 |
]. |
3528 |
^ modules |
|
3529 |
||
3530 |
" |
|
3531 |
ObjectMemory fullBinaryModuleInfo |
|
418 | 3532 |
" |
3533 |
||
3534 |
"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
|
3535 |
"Modified: 31.10.1996 / 13:58:44 / cg" |
615 | 3536 |
! |
3537 |
||
1288 | 3538 |
imageBaseName |
3539 |
"return a reasonable filename to use as baseName (i.e. without extension). |
|
3540 |
This is the filename of the current image (without '.img') or, |
|
3541 |
if not running from an image, the default name 'st'" |
|
3542 |
||
3543 |
|nm| |
|
3544 |
||
3545 |
nm := ImageName. |
|
3546 |
(nm isNil or:[nm isBlank]) ifTrue:[ |
|
3547 |
^ 'st' |
|
3548 |
]. |
|
3549 |
(nm endsWith:'.sav') ifTrue:[ |
|
3550 |
nm := nm copyWithoutLast:4 |
|
3551 |
]. |
|
3552 |
(nm endsWith:'.img') ifTrue:[ |
|
3553 |
^ nm copyWithoutLast:4 |
|
615 | 3554 |
]. |
3555 |
^ nm |
|
3556 |
||
3557 |
" |
|
3558 |
ObjectMemory imageBaseName |
|
3559 |
" |
|
3560 |
! |
|
3561 |
||
1288 | 3562 |
imageName |
3563 |
"return the filename of the current image, or nil |
|
3564 |
if not running from an image." |
|
615 | 3565 |
|
3566 |
^ ImageName |
|
335 | 3567 |
|
3568 |
" |
|
615 | 3569 |
ObjectMemory imageName |
335 | 3570 |
" |
1 | 3571 |
! |
3572 |
||
1288 | 3573 |
imageSaveTime |
3574 |
"return a timestamp for when the running image was saved. |
|
1096 | 3575 |
Return nil if not running from an image." |
3576 |
||
3577 |
^ ImageSaveTime |
|
3578 |
! |
|
3579 |
||
1288 | 3580 |
loadClassBinary:aClassName |
3581 |
"find the object file for aClassName and -if found - load it; |
|
3582 |
this one loads precompiled object files" |
|
3583 |
||
3584 |
|fName newClass| |
|
3585 |
||
3586 |
fName := self fileNameForClass:aClassName. |
|
3587 |
fName notNil ifTrue:[ |
|
3588 |
Class withoutUpdatingChangesDo: |
|
3589 |
[ |
|
3590 |
self loadBinary:(fName , '.o') |
|
3591 |
]. |
|
3592 |
newClass := self at:(aClassName asSymbol). |
|
3593 |
(newClass notNil and:[newClass implements:#initialize]) ifTrue:[ |
|
615 | 3594 |
newClass initialize |
159 | 3595 |
] |
615 | 3596 |
] |
3597 |
! |
|
3598 |
||
1288 | 3599 |
nameForChanges |
3600 |
"return a reasonable filename to store the changes into. |
|
3601 |
Currently, this is defined in a classVariable and defaults to 'changes'. |
|
3602 |
In future versions, this will be the basename of the current image with '.img' replaced |
|
3603 |
by '.chg', or, if not running from an image, the default name 'st.chg'." |
|
3604 |
||
3605 |
ChangeFileName notNil ifTrue:[^ ChangeFileName]. |
|
3606 |
^ 'changes'. |
|
3607 |
||
3608 |
"/ future versions will have: |
|
3609 |
"/ (requires some additionas at other places) |
|
3610 |
"/ |
|
615 | 3611 |
"/ ^ self imageBaseName , '.chg' |
1 | 3612 |
|
335 | 3613 |
" |
615 | 3614 |
ObjectMemory nameForChanges |
3615 |
" |
|
3616 |
! |
|
3617 |
||
1288 | 3618 |
nameForChanges:aFilename |
3619 |
"set the name of the file where changes are stored into." |
|
3620 |
||
3621 |
ChangeFileName := aFilename |
|
615 | 3622 |
|
3623 |
" |
|
3624 |
ObjectMemory nameForChanges:'myChanges' |
|
3625 |
" |
|
3626 |
! |
|
3627 |
||
1288 | 3628 |
nameForSnapshot |
3629 |
"return a reasonable filename to store the snapshot image into. |
|
3630 |
This is the filename of the current image or, |
|
3631 |
if not running from an image, the default name 'st.img'" |
|
3632 |
||
3633 |
^ self imageBaseName , '.img' |
|
615 | 3634 |
|
3635 |
" |
|
3636 |
ObjectMemory nameForSnapshot |
|
335 | 3637 |
" |
1 | 3638 |
! |
3639 |
||
1288 | 3640 |
nameForSources |
3641 |
"return a reasonable filename to store the sources into. |
|
3642 |
This is the basename of the current image with '.img' replaced |
|
3643 |
by '.src', or, if not running from an image, the default name 'st.src'" |
|
615 | 3644 |
|
3645 |
^ self imageBaseName , '.src' |
|
362 | 3646 |
|
3647 |
" |
|
615 | 3648 |
ObjectMemory nameForSources |
3649 |
" |
|
3650 |
! |
|
3651 |
||
1288 | 3652 |
primSnapShotOn:aFileName |
3653 |
"create a snapshot in the given file. |
|
3654 |
Low level entry. Does not notify classes or write an entry to |
|
1704 | 3655 |
the changes file. Also, no image backup is created. |
3656 |
Returns true if the snapshot worked, false if it failed for some reason. |
|
1288 | 3657 |
This method should not be used in normal cases." |
3658 |
||
1704 | 3659 |
|ok oldImageName oldImageTime| |
3660 |
||
3661 |
" |
|
3662 |
save the name and time with it ... |
|
3663 |
" |
|
3664 |
oldImageName := ImageName. |
|
3665 |
oldImageTime := ImageSaveTime. |
|
3666 |
||
3667 |
ImageName := aFileName. |
|
3668 |
ImageSaveTime := AbsoluteTime now. |
|
3669 |
||
3670 |
%{ /* CALLSSTACK:32000 */ |
|
1288 | 3671 |
|
3672 |
OBJ __snapShotOn(); |
|
3673 |
OBJ funny = @symbol(funnySnapshotSymbol); |
|
3674 |
||
3675 |
if (__isString(aFileName)) { |
|
3676 |
__BLOCKINTERRUPTS(); |
|
3677 |
ok = __snapShotOn(__context, _stringVal(aFileName), funny); |
|
615 | 3678 |
__UNBLOCKINTERRUPTS(); |
3679 |
} |
|
3680 |
%}. |
|
1704 | 3681 |
|
3682 |
ImageName := oldImageName. |
|
3683 |
ImageSaveTime := oldImageTime. |
|
3684 |
||
615 | 3685 |
^ ok |
3686 |
! |
|
3687 |
||
1288 | 3688 |
snapShot |
3689 |
"create a snapshot file containing all of the current state." |
|
615 | 3690 |
|
3691 |
self snapShotOn:(self nameForSnapshot) |
|
3692 |
||
3693 |
" |
|
3694 |
ObjectMemory snapShot |
|
362 | 3695 |
" |
1288 | 3696 |
! |
3697 |
||
3698 |
snapShotOn:aFileName |
|
3699 |
"create a snapshot in the given file. |
|
3700 |
If the file exists, save it for backup. |
|
3701 |
Return true if the snapshot worked, false if it failed for some reason. |
|
3702 |
Notify dependents before and after the snapshot operation." |
|
3703 |
||
1704 | 3704 |
|ok| |
1288 | 3705 |
|
3706 |
" |
|
3707 |
keep a save version - just in case something |
|
3708 |
bad happens while writing the image. |
|
3709 |
(could be st/x internal error or file-system errors etc) |
|
3710 |
" |
|
3711 |
(OperatingSystem isValidPath:aFileName) ifTrue:[ |
|
3712 |
OperatingSystem renameFile:aFileName to:(aFileName , '.sav'). |
|
3713 |
]. |
|
3714 |
||
3715 |
" |
|
3716 |
give others a chance to fix things |
|
3717 |
" |
|
3718 |
self changed:#save. "/ will vanish ... |
|
3719 |
self changed:#aboutToSnapshot. "/ ... for ST-80 compatibility |
|
3720 |
||
3721 |
" |
|
3722 |
ST-80 compatibility; send #preSnapshot to all classes |
|
3723 |
" |
|
3724 |
Smalltalk allBehaviorsDo:[:aClass | |
|
3725 |
aClass preSnapshot |
|
3726 |
]. |
|
3727 |
||
3728 |
ok := self primSnapShotOn:aFileName. |
|
3729 |
||
3730 |
ok ifTrue:[ |
|
3731 |
Class addChangeRecordForSnapshot:aFileName. |
|
3732 |
]. |
|
3733 |
||
3734 |
||
3735 |
" |
|
3736 |
ST-80 compatibility; send #postSnapshot to all classes |
|
3737 |
" |
|
3738 |
Smalltalk allBehaviorsDo:[:aClass | |
|
3739 |
aClass postSnapshot |
|
3740 |
]. |
|
3741 |
self changed:#finishedSnapshot. "/ ST-80 compatibility |
|
3742 |
^ ok |
|
3743 |
||
3744 |
" |
|
3745 |
ObjectMemory snapShotOn:'myimage.img' |
|
3746 |
" |
|
362 | 3747 |
! ! |
615 | 3748 |
|
1848
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3749 |
!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
|
3750 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3751 |
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
|
3752 |
^ (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
|
3753 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3754 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3755 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3756 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3757 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'accessing'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3758 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3759 |
classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3760 |
"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
|
3761 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3762 |
^ classNames |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3763 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3764 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3765 |
dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3766 |
"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
|
3767 |
(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
|
3768 |
the start. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3769 |
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
|
3770 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3771 |
^ dynamic |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3772 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3773 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3774 |
id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3775 |
"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
|
3776 |
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
|
3777 |
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
|
3778 |
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
|
3779 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3780 |
^ id |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3781 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3782 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3783 |
libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3784 |
"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
|
3785 |
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
|
3786 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3787 |
^ libraryName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3788 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3789 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3790 |
name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3791 |
"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
|
3792 |
libraryName." |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3793 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3794 |
^ name |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3795 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3796 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3797 |
pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3798 |
"return the modules pathName" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3799 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3800 |
^ pathName |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3801 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3802 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3803 |
timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3804 |
"return the modules timeStamp" |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3805 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3806 |
^ timeStamp |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3807 |
! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3808 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3809 |
type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3810 |
"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
|
3811 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3812 |
^ type |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3813 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3814 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3815 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'backward compatibility'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3816 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3817 |
at:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3818 |
"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
|
3819 |
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
|
3820 |
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
|
3821 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3822 |
^ self perform:key |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3823 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3824 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3825 |
!ObjectMemory::BinaryModuleDescriptor methodsFor:'private access'! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3826 |
|
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3827 |
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
|
3828 |
name := n. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3829 |
type := t. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3830 |
id := i. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3831 |
dynamic := d. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3832 |
classNames := c. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3833 |
libraryName := l. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3834 |
timeStamp := ts. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3835 |
pathName := p. |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3836 |
! ! |
5aa378aa47a9
make use of private classes in the moduleInfo record
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3837 |
|
1767 | 3838 |
!ObjectMemory class methodsFor:'documentation'! |
630 | 3839 |
|
1288 | 3840 |
version |
1926 | 3841 |
^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.120 1996-11-07 18:54:49 cg Exp $' |
630 | 3842 |
! ! |
615 | 3843 |
ObjectMemory initialize! |