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