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