ObjectMemory.st
author Claus Gittinger <cg@exept.de>
Sat, 16 Dec 1995 14:04:33 +0100
changeset 778 afbb3ebde874
parent 759 908363ce8a32
child 794 d713b6c04379
permissions -rw-r--r--
commentary
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
a27a279701f8 Initial revision
claus
parents:
diff changeset
    13
Object subclass:#ObjectMemory
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    14
	 instanceVariableNames:''
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    15
	 classVariableNames:'InternalErrorHandler UserInterruptHandler TimerInterruptHandler
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    16
		SpyInterruptHandler StepInterruptHandler
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    17
		ExceptionInterruptHandler ErrorInterruptHandler
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    18
		MemoryInterruptHandler SignalInterruptHandler
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    19
		ChildSignalInterruptHandler DisposeInterruptHandler
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    20
		RecursionInterruptHandler IOInterruptHandler
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    21
		CustomInterruptHandler RegisteredErrorInterruptHandlers
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    22
		InterruptLatencyMonitor AllocationFailureSignal
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    23
		MallocFailureSignal LowSpaceSemaphore IncrementalGCLimit
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    24
		FreeSpaceGCLimit FreeSpaceGCAmount BackgroundCollectProcess
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    25
		BackgroundFinalizationProcess FinalizationSemaphore Dependents
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
    26
		ImageName ChangeFileName MaxInterruptLatency InterruptLatencyGoal'
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    27
	 poolDictionaries:''
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    28
	 category:'System-Support'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    29
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    30
2
claus
parents: 1
diff changeset
    31
!ObjectMemory class methodsFor:'documentation'!
claus
parents: 1
diff changeset
    32
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    33
caching
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    34
"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    35
    The system uses various caches to speed up method-lookup.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    36
    Currently, there is a three-level cache hierarchy:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    37
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    38
	inline-cache            keeps the target of the last send at the caller-
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    39
				side (i.e. every send goes through its private 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    40
				1-slot inline-cache, where the address of the last
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    41
				called function at this call location is kept.)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    42
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    43
	polymorph-inline-cache  keeps a limited list of all targets ever reached 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    44
				at this call location. The list is automatically 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    45
				flushed if it grows too large, or the overall number
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    46
				of poly-chache entries exceeds a limit.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    47
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    48
	method-lookup-cache     a global cache. Hashes on class-selector pairs,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    49
				returning the target method.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    50
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    51
    Whenever methods are added or removed from the system, or the inheritance 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    52
    hierarchy changes, some or all caches have to be flushed.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    53
    The flushXXX methods perform the task of flushing various caches.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    54
    All standard methods in Behavior call for cache flushing, when things change;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    55
    however, if you use the low level access methods in Behavior
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    56
    (for example: #setSuperclass:) special care has to be taken.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    57
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    58
    In some situations, not all caches need flushing, for example a change
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    59
    in an interpreted method (currently) needs no flushing of the inline caches.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    60
    Also, flushing can be limited to entries for a specific class for most changes.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    61
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    62
    To be 'on the brigth side of live', use ObjectMemory>>flushCaches (which
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    63
    flushes all of them), when in doubt of which caches should be flushed. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    64
    It is better flush too much - otherwise you may end up in a wrong method after 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    65
    a send.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    66
"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    67
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
    68
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    69
copyright
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    70
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    71
 COPYRIGHT (c) 1992 by Claus Gittinger
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
    72
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    73
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    74
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    75
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    76
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    77
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    78
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    79
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    80
"
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    81
!
81dacba7a63a *** empty log message ***
claus
parents: 85
diff changeset
    82
2
claus
parents: 1
diff changeset
    83
documentation
claus
parents: 1
diff changeset
    84
"
403
claus
parents: 384
diff changeset
    85
    This class contains access methods to the system memory and the VM.
claus
parents: 384
diff changeset
    86
claus
parents: 384
diff changeset
    87
    In previous ST/X versions, this stuff used to be in the Smalltalk class.
claus
parents: 384
diff changeset
    88
    It has been separated for better overall class structure and modularisation.
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
    89
    There are no instances of ObjectMemory - all is done in class methods.
403
claus
parents: 384
diff changeset
    90
    (this is a functional interface).
claus
parents: 384
diff changeset
    91
claus
parents: 384
diff changeset
    92
    Many methods here are for debuging purposes, for developers
claus
parents: 384
diff changeset
    93
    or experimental, and therefore not standard.
68
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    94
    Do not depend on them being there - some may vanish ...
59faa75185ba *** empty log message ***
claus
parents: 56
diff changeset
    95
    (especially those, that depend on a specific GC implementation)
403
claus
parents: 384
diff changeset
    96
    Most of the stuff found here is not available, or different or called
claus
parents: 384
diff changeset
    97
    different in other smalltalk implementations. Be aware, that using these
claus
parents: 384
diff changeset
    98
    interfaces (especially: depending on them) may make your application
claus
parents: 384
diff changeset
    99
    non portable.
claus
parents: 384
diff changeset
   100
claus
parents: 384
diff changeset
   101
    See more documentation in -> caching
claus
parents: 384
diff changeset
   102
			      -> interrupts
claus
parents: 384
diff changeset
   103
			      -> garbageCollection
2
claus
parents: 1
diff changeset
   104
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   105
    Class variables:
2
claus
parents: 1
diff changeset
   106
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   107
	InternalErrorHandler            gets informed (by VM), when some runtime
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   108
					error occurs (usually fatal)
2
claus
parents: 1
diff changeset
   109
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   110
	UserInterruptHandler            gets informed (by VM) when CNTL-C is pressed
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   111
	TimerInterruptHandler           gets alarm timer interrupts (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   112
	SpyInterruptHandler             another alarm timer (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   113
	StepInterruptHandler            gets single step interrupts (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   114
	ExceptionInterruptHandler       gets floating point exceptions (from VM)
345
claus
parents: 339
diff changeset
   115
	ErrorInterruptHandler           gets primitive errors (from VM)
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   116
	MemoryInterruptHandler          gets soon-out-of-memory conditions (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   117
	SignalInterruptHandler          gets unix signals (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   118
	ChildSignalInterruptHandler     gets child death signals (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   119
	DisposeInterruptHandler         gets informed, when an object is disposed from 
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   120
					a shadowArray (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   121
	RecursionInterruptHandler       gets recursion limit violations (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   122
	IOInterruptHandler              gets SIGIO unix signals (from VM)
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   123
	CustomInterruptHandler          gets custom interrupts (from VM)
2
claus
parents: 1
diff changeset
   124
504
ac74e0dfe630 typo fixed
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   125
	InterruptLatencyMonitor         if nonNil, that one will be notified (by the VM)
ac74e0dfe630 typo fixed
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   126
					with an interruptLatency:millis message for every 
493
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   127
					interrupt and gets the delay time
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   128
					(between the time when the signal arrived and
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   129
					 when it was really delivered) as argument.
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   130
					This can be used to create a statistic for
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   131
					realtime systems.
2a2b3d5c0dbc irq latency statistic hook added
Claus Gittinger <cg@exept.de>
parents: 472
diff changeset
   132
345
claus
parents: 339
diff changeset
   133
	RegisteredErrorInterruptHandlers
claus
parents: 339
diff changeset
   134
					associates errorID (as passed from primitive
claus
parents: 339
diff changeset
   135
					to the __errorInterruptWithID() function)
claus
parents: 339
diff changeset
   136
					with handlers.
claus
parents: 339
diff changeset
   137
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   138
	IncrementalGCLimit              number of bytes, that must be allocated since
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   139
					last full garbage collect to turn the incremental
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   140
					collector on (at idle time).
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   141
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   142
	FreeSpaceGCLimit                low limit on freeSpace at which incremental
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   143
					gc starts to run at idle time.
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   144
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   145
	FreeSpaceGCAmount               amount to allocate once freeSpace drops
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   146
					below FreeSpaceGCLimit
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   147
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   148
	Dependents                      keep my dependents locally (its faster) for
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   149
					all those registries
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   150
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   151
	LowSpaceSemaphore               a semaphore signalled whenever the system is
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   152
					running in low memory (i.e. the memory manager
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   153
					ran into memory shortage and feels that it
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   154
					may soon be no longer grant allocation requests).
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   155
					You can have a process waiting on this semaphore
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   156
					which starts to remove (i.e. nil-out) objects
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   157
					or preform other cleanup actions.
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   158
                                        
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   159
	AllocationFailureSignal         signal raised when a new fails (see Behavior)
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   160
					When this signal is raised, the meomory manager
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   161
					is really in trouble (i.e. above feelings where
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   162
					correct)
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   163
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   164
	BackgroundCollectProcess        created by startBackgroundCollectorAt:
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   165
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   166
	BackgroundFinalizationProcess   created by startBackgroundFinalizationAt:
403
claus
parents: 384
diff changeset
   167
claus
parents: 384
diff changeset
   168
    Warning:
claus
parents: 384
diff changeset
   169
      The InterruptHandler variables are known by the runtime system -
claus
parents: 384
diff changeset
   170
      they are the objects that get an interrupt message when the event
claus
parents: 384
diff changeset
   171
      occurs. You may not remove any of them.
2
claus
parents: 1
diff changeset
   172
"
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   173
!
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   174
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   175
garbageCollection
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   176
"
403
claus
parents: 384
diff changeset
   177
    Currently, Smalltalk/X uses a two-level memory hierachy (actually, there
claus
parents: 384
diff changeset
   178
    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
   179
    but for the following discussion, these are not of interest).
403
claus
parents: 384
diff changeset
   180
claus
parents: 384
diff changeset
   181
  newSpace:
claus
parents: 384
diff changeset
   182
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   183
    Objects are created in a so-called newSpace, which is relatively small.
403
claus
parents: 384
diff changeset
   184
    This newSpace is cleaned by a so called ``scavenge''-operation, whenever 
claus
parents: 384
diff changeset
   185
    becoming full. Scavenging means, that all still-live objects (i.e. referenced
claus
parents: 384
diff changeset
   186
    by some other) are copied over to another memory area, leaving all unreachable
claus
parents: 384
diff changeset
   187
    objects as garbage behind. Thus, the newSpace actually consists of two semispaces,
claus
parents: 384
diff changeset
   188
    of whih only one is active - the other being used only while objects are
claus
parents: 384
diff changeset
   189
    copied.
claus
parents: 384
diff changeset
   190
    After this copying, these two semispaces exchange their roles - i.e. reachable
claus
parents: 384
diff changeset
   191
    objects are copied ping-pong like between these semispaces.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   192
    Once an object survives enough of these copying operations, the next scavenge 
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   193
    will move it into the so called oldSpace, which is much larger, and not
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   194
    processed by the scavenger. 
403
claus
parents: 384
diff changeset
   195
    This movement of an object from newSpace to oldSpace is called ``tenure''.
claus
parents: 384
diff changeset
   196
    (this avoids objects being copied around forever).
claus
parents: 384
diff changeset
   197
    Once tenured, an object is no longer contained in the newSpace, and
claus
parents: 384
diff changeset
   198
    thus ceases to create any scavenging overhead after that.
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   199
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   200
    Scavenging occurs automatically, and is usually done fast enough to go 
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   201
    unnoticed (typically, it takes some 5 to 50ms to perform a scavenge, 
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   202
    depending on how many live objects are in the newspace).
403
claus
parents: 384
diff changeset
   203
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
   204
    Interestingly, the scavenger performs better, if many garbage objects
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   205
    are to be reclaimed, since less object-copying has to be done. Therefore,
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   206
    the best-case scavenge time is almost zero, if there is only garbage in
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   207
    the newSpace. In contrast, the worst-case is when all newSpace objects are still
403
claus
parents: 384
diff changeset
   208
    living. Thus, from a newSpace collectors viewPoint, it makes sense to get
claus
parents: 384
diff changeset
   209
    objects out of the way as fast as possible. However the oldSpace is
claus
parents: 384
diff changeset
   210
    collected much less frequently and the cost to reclaim an oldspace object
claus
parents: 384
diff changeset
   211
    is much higher (actually, the cost to reclaim a newspace object is zero -
claus
parents: 384
diff changeset
   212
    its the survival of objects which we have to pay for).
claus
parents: 384
diff changeset
   213
    Therefore, from an oldSpace collectors point of view, its preferable to
claus
parents: 384
diff changeset
   214
    keep objects in the newSpace as long as possible.
claus
parents: 384
diff changeset
   215
claus
parents: 384
diff changeset
   216
    To honor this conflicting situation, the system uses an adaptive tenure-count,
207
claus
parents: 202
diff changeset
   217
    which adjusts the number of scavenges required for tenure (the so called 
claus
parents: 202
diff changeset
   218
    'tenureAge') according to the fill-grade of the newSpace.
403
claus
parents: 384
diff changeset
   219
    If the newSpace is relatively empty, it tries to keep objects longer there.
claus
parents: 384
diff changeset
   220
    The controlling parameters of the tenure age can be changed dynamically,
claus
parents: 384
diff changeset
   221
    detailed information is available upon request.
claus
parents: 384
diff changeset
   222
claus
parents: 384
diff changeset
   223
    The exact speed of the scavenger depends mostly on the speed of your memory
claus
parents: 384
diff changeset
   224
    interface (and, since most of todays memories have access times in the order
claus
parents: 384
diff changeset
   225
    of 50-100ns, the raw CPU speed does not correlate linear with the GC speed).
claus
parents: 384
diff changeset
   226
    Measurements give roughly 40-70ms for a full 400k newSpace 
claus
parents: 384
diff changeset
   227
    (i.e. all objects survive).
claus
parents: 384
diff changeset
   228
    The upper bounds of the scavenge blocking time can be controlled by changing
claus
parents: 384
diff changeset
   229
    the size of the newSpace - ether via acommand line argument, or even dynamically
claus
parents: 384
diff changeset
   230
    by Objectmemory>>newSpaceSize:. Smaller sizes lead to shorter blocking periods,
claus
parents: 384
diff changeset
   231
    but greater absolute GC overhead. The default (400k) seems to be a good compromise.
claus
parents: 384
diff changeset
   232
    (if you are not happy with it, try playing around with the settings)
claus
parents: 384
diff changeset
   233
claus
parents: 384
diff changeset
   234
  oldSpace:
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   235
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   236
    To reclaim oldspace, the system uses three algorithms: mark&sweep, a copying
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   237
    (and compressing) baker-type collector and an incremental mark&sweep.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   238
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   239
    The mark&sweep runs whenever the oldspace becomes full, putting dead objects
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   240
    onto a free list. If a memory request cannot be served from this freelist,
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   241
    and the total size of objects on the freelist exceeds a threshold, the system
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   242
    will compress the oldspace to make the free-space into one big area.
207
claus
parents: 202
diff changeset
   243
    This compress is done by copying all live objects into a newly allocated
claus
parents: 202
diff changeset
   244
    area, and freeing the previous memory afterwards (baker collector).
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   245
    Since a compressing oldspace collect leads to a noticable pause of the system,
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   246
    the memory manager tries hard to avoid oldspace compression.
207
claus
parents: 202
diff changeset
   247
    (actually, if enough real memory is available to hold both spaces in physical
claus
parents: 202
diff changeset
   248
     memory, the compress is pretty fast).
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   249
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   250
    The incremental mark&sweep runs in the background, whenever the system is idle
403
claus
parents: 384
diff changeset
   251
    (see ProcessorSceduler>>waitForEventOrTimeout), or alternatively as a low or high
claus
parents: 384
diff changeset
   252
    priority background process (see ObjectMemory>>startBackgroundCollector). 
362
claus
parents: 360
diff changeset
   253
    Like the normal mark&sweep, this incremental collector follows object references 
claus
parents: 360
diff changeset
   254
    and marks reachable objects on its way. However, this is done 'a few objects-at-a-time',
claus
parents: 360
diff changeset
   255
    to not disrupt the system noticably. Currently, there are some (theoretical) and in
403
claus
parents: 384
diff changeset
   256
    practice never occurring situations, in which the incremental GC still creates noticable
claus
parents: 384
diff changeset
   257
    delays. A current project is involved with this and a future versions of ST/X (ST/X-RT)
claus
parents: 384
diff changeset
   258
    will be available which shows deterministic worst case behavior in its GC pauses 
claus
parents: 384
diff changeset
   259
    (this will be provided as an additional add-on option - certainly not for free ;-).
claus
parents: 384
diff changeset
   260
    Currently, incremental GC blockings are in the order of 10-70ms.
claus
parents: 384
diff changeset
   261
    There is one catch with low priority background IGC: if there is never any idle
claus
parents: 384
diff changeset
   262
    time available (i.e. all processes run all the time), it would never get a chance
claus
parents: 384
diff changeset
   263
    to do any collection work. To handle this case, a background IGC can also be started
claus
parents: 384
diff changeset
   264
    as a high priority process, which gives up the cpu (by delaying on the time) after
claus
parents: 384
diff changeset
   265
    every IGC step. A high priority background collector will always make progress
claus
parents: 384
diff changeset
   266
    and eventually finish a GC cycle. However, it may have more of an influence on 
claus
parents: 384
diff changeset
   267
    the other processes. So, its up to you, to decide ...
362
claus
parents: 360
diff changeset
   268
claus
parents: 360
diff changeset
   269
    Incremental garbage collection is controlled by the variables 
claus
parents: 360
diff changeset
   270
    'IncrementalGCLimit', 'FreeSpaceGCLimit' and 'FreeSpaceGCAmount':
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   271
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   272
      the ProcessorScheduler will perform incremental GC steps at idle time, 
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   273
      if the total space allocated since the last full collect exceeds 
362
claus
parents: 360
diff changeset
   274
      'IncrementalGCLimit',
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   275
      or if there are less than 'FreeSpaceGCLimit' bytes available in free store.
362
claus
parents: 360
diff changeset
   276
      If after the incrementalGC, less than 'FreeSpaceGCLimi't bytes are available,
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   277
      'FreeSpaceGCAmount' more bytes are requested from the memory manager.
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   278
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   279
    The defaults are set in ObjectMemory>>initialize and can be changed in your 
403
claus
parents: 384
diff changeset
   280
    startup 'smalltalk.rc'-file. Setting them to nil turns incremental GC off.
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   281
362
claus
parents: 360
diff changeset
   282
    For example, setting 'IncrementalGCLimit' to 500000 will start the background collector
207
claus
parents: 202
diff changeset
   283
    whenever 500k bytes have been allocated - usually very seldom. Setting it to some
claus
parents: 202
diff changeset
   284
    small number (say 10000) will have it run very often.
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   285
362
claus
parents: 360
diff changeset
   286
    Setting 'FreeSpaceGCAmount' to (say) 1meg lets the system try to always keep
403
claus
parents: 384
diff changeset
   287
    1meg of freeSpace. If less memory is available, more oldSpace will be allocated.
claus
parents: 384
diff changeset
   288
    Keeping some memory in the pocket may prevent the system from running into a blocking
claus
parents: 384
diff changeset
   289
    GC if memory is allocated in peaks (but only, if the incremental GC can keep up with 
claus
parents: 384
diff changeset
   290
    allocation rate). The trigger level 'FreeSpaceGCLimit' should be below that amount;
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   291
    to avoid excessive incremental GC activity (say 1/4 if the amount).
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   292
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   293
    Having the background GC running often should not hurt the performance of your 
362
claus
parents: 360
diff changeset
   294
    smalltalk processes, since the IGC only runs at times when no ST processes are runnable. 
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   295
    (there are some short delays in event processing, since the IGC's steps may take 
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   296
    some XX ms.) 
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   297
    However, if you are not alone on your machine (i.e. a timesharing system) or 
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
   298
    you have other Unix processes to run, you should not run the IGC too often, 
362
claus
parents: 360
diff changeset
   299
    since it may hurt OTHER users/unix processes.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   300
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   301
    Since this collector only runs at idle times, even a low priority background 
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   302
    process will prevent it from doing its work. You may want to start a somewhat
207
claus
parents: 202
diff changeset
   303
    higher priority background collect (say at prio 4), which also preempts these
claus
parents: 202
diff changeset
   304
    background processes. (see ObjectMemory>>startBackgroundCollectorAt:).
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   305
325
claus
parents: 324
diff changeset
   306
    Beginning with 2.10.4, a third space, called symSpace has been added.
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   307
    Objects in this space are never moved or garbage collected.
325
claus
parents: 324
diff changeset
   308
    This space is used for (some) symbols only.
claus
parents: 324
diff changeset
   309
claus
parents: 324
diff changeset
   310
    Beginning with 2.10.5, a fourth space, called fixSpace has been added.
claus
parents: 324
diff changeset
   311
    Objects in this space are never moved or garbage collected.
claus
parents: 324
diff changeset
   312
    This space is used for constant objects (true, false, some basic classes etc.).
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   313
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   314
    A plan for 2.11 is to offer an arbitrary number of spaces, which can be
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   315
    attached and detached at runtime. This will allow easy share of object
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   316
    with remote systems and separating objects into a per application/package
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   317
    space. (be prepared for changes in the future and make your application
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   318
    independ of the VM internals)
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   319
403
claus
parents: 384
diff changeset
   320
  default setup:
claus
parents: 384
diff changeset
   321
claus
parents: 384
diff changeset
   322
    The following table lists some default settings and means for changing them:
claus
parents: 384
diff changeset
   323
claus
parents: 384
diff changeset
   324
	    what        default     change by           
claus
parents: 384
diff changeset
   325
				    command line arg    dynamically
claus
parents: 384
diff changeset
   326
    -----------------------------------------------------------------------
claus
parents: 384
diff changeset
   327
	newSpace size     400k      -Mnew nnn           newSpaceSize:nnn
claus
parents: 384
diff changeset
   328
claus
parents: 384
diff changeset
   329
	oldSpace size    3000k      -Mold nnn           moreOldSpace:
claus
parents: 384
diff changeset
   330
							announceSpaceNeed:
claus
parents: 384
diff changeset
   331
							collectGarbage
claus
parents: 384
diff changeset
   332
claus
parents: 384
diff changeset
   333
	max tenure age     29                           lockTenure:
claus
parents: 384
diff changeset
   334
							avoidTenure:
claus
parents: 384
diff changeset
   335
							(sets it to infinity)
claus
parents: 384
diff changeset
   336
        
claus
parents: 384
diff changeset
   337
	adaptive tenure                                 tenureParameters
claus
parents: 384
diff changeset
   338
claus
parents: 384
diff changeset
   339
	oldSpace
claus
parents: 384
diff changeset
   340
	compressor      enabled     -Msingle            -
claus
parents: 384
diff changeset
   341
claus
parents: 384
diff changeset
   342
	limit for
claus
parents: 384
diff changeset
   343
	old-compress     8000k      -                   oldSpaceCompressLimit:
claus
parents: 384
diff changeset
   344
claus
parents: 384
diff changeset
   345
	chunk size
claus
parents: 384
diff changeset
   346
	to increase
claus
parents: 384
diff changeset
   347
	oldpPace          256k      -                   oldSpaceIncrement:
claus
parents: 384
diff changeset
   348
        
claus
parents: 384
diff changeset
   349
	prefer moreOld
claus
parents: 384
diff changeset
   350
	to doing GC      false      -                   fastMoreOldSpaceAllocation:
claus
parents: 384
diff changeset
   351
claus
parents: 384
diff changeset
   352
	limit for
claus
parents: 384
diff changeset
   353
	above                -      -                   fastMoreOldSpaceLimit:
claus
parents: 384
diff changeset
   354
claus
parents: 384
diff changeset
   355
	keep size for        -      -                   freeSpaceGCAmount:
claus
parents: 384
diff changeset
   356
	IGC
claus
parents: 384
diff changeset
   357
claus
parents: 384
diff changeset
   358
	low water
claus
parents: 384
diff changeset
   359
	trigger for IGC      -      -                   freeSpaceGCLimit:
claus
parents: 384
diff changeset
   360
claus
parents: 384
diff changeset
   361
	allocated
claus
parents: 384
diff changeset
   362
	trigger for IGC   500k      -                   incrementalGCLimit
claus
parents: 384
diff changeset
   363
claus
parents: 384
diff changeset
   364
        
claus
parents: 384
diff changeset
   365
    By default, no incremental GC activity is started.
claus
parents: 384
diff changeset
   366
    You have to change your startup files to do this. A suggested configuration
claus
parents: 384
diff changeset
   367
    (used by the author) is:
claus
parents: 384
diff changeset
   368
claus
parents: 384
diff changeset
   369
	' keep 1meg in the pocket '
claus
parents: 384
diff changeset
   370
claus
parents: 384
diff changeset
   371
	ObjectMemory freeSpaceGCAmount:1000000. 
claus
parents: 384
diff changeset
   372
claus
parents: 384
diff changeset
   373
	' start incrementalGC when freespace drops below 250k '
claus
parents: 384
diff changeset
   374
	' or 500k of oldSpace has been allocated              '
claus
parents: 384
diff changeset
   375
claus
parents: 384
diff changeset
   376
	ObjectMemory freeSpaceGCLimit:250000.                 '
claus
parents: 384
diff changeset
   377
	ObjectMemory incrementalGCLimit:500000.               '
claus
parents: 384
diff changeset
   378
claus
parents: 384
diff changeset
   379
	' collect as a background process (the default is: at idle times)
claus
parents: 384
diff changeset
   380
	' this means that running cubes or other demo processes are suspended
claus
parents: 384
diff changeset
   381
	' for the collect; change the prio to below 4 if you want them to continue
claus
parents: 384
diff changeset
   382
claus
parents: 384
diff changeset
   383
	ObjectMemory startBackgroundCollectorAt:5.            '
claus
parents: 384
diff changeset
   384
	ObjectMemory startBackgroundFinalizationAt:5.         '
claus
parents: 384
diff changeset
   385
claus
parents: 384
diff changeset
   386
	' quickly allocate more space (i.e. avoid blocking collects)
claus
parents: 384
diff changeset
   387
	' up to 8meg - then start to collect if more memory is needed.
claus
parents: 384
diff changeset
   388
claus
parents: 384
diff changeset
   389
	ObjectMemory fastMoreOldSpaceLimit:8*1024*1024.       '
claus
parents: 384
diff changeset
   390
	ObjectMemory fastMoreOldSpaceAllocation:true.         '
claus
parents: 384
diff changeset
   391
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   392
  hints & tricks:
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   393
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   394
    normally, there is no need to call for an explicit garbage collection, or
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   395
    modify the default parameters.
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   396
    The memory system should adapt reasonable and provide good performance 
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   397
    for a wide range of allocation patterns (see Example3 below for an exception).
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   398
207
claus
parents: 202
diff changeset
   399
    However, there may be situations, in which hints and/or explicit
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   400
    control over allocation can speedup your programs; but please:
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   401
207
claus
parents: 202
diff changeset
   402
      - if you think you have to play around with the memory policies,
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   403
	first check your program - you may find useless allocations
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   404
	or bad uses of collections. A typical error that is made is to
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   405
	create large collections using the #, (comma) concatenation method,
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   406
	which shows square behavior, since it allocates many, many temporary
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   407
	collections. Also, watch out for #copyWith:, #add: etc.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   408
	All of these create a new collection. Remember, that most collections
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   409
	offer methods to preallocate some space; for example, 'Set new:' creates
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   410
	an empty set, but preallocates space to avoid resizing over and over.
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   411
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   412
	An especially bad performace dog is to use #add: on fix-size collection
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   413
	objects (such as Strings or Arrays), since in addition to allocating
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   414
	lots of garbage, a #become: operation is required for EACH element
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
   415
	added. NEVER use Arrays for growing/shrinking data - use OrderedCollection
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   416
	instead. (if you really need an array, use asArray afterwards)
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   417
207
claus
parents: 202
diff changeset
   418
      - if you are going to allocate huge data structures, think about
claus
parents: 202
diff changeset
   419
	optimizing space. For example, if you allocate a million instances of
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   420
	some object, each added instance variable makes up 4Mb of additional 
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   421
	memory need.
207
claus
parents: 202
diff changeset
   422
	Also, for Byte-valued, Integer-valued and Float like objects, special
claus
parents: 202
diff changeset
   423
	collections are provided, which store their values directly inside (instead
claus
parents: 202
diff changeset
   424
	of a reference to the object). A FloatArray consisting of 1 million floats
213
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   425
	requires about 4mb of memory, while an Array of Floats requires 4mb for the
3b56a17534fd *** empty log message ***
claus
parents: 211
diff changeset
   426
	references to the floats, PLUS 20Mb for the floats themself.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   427
207
claus
parents: 202
diff changeset
   428
      - check if you really need fast access to all of these objects; you may
claus
parents: 202
diff changeset
   429
	try to only keep some subset in memory, and use binary storage or
claus
parents: 202
diff changeset
   430
	(if this is too slow) optimized store/retrieve methods and keep the bigger
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   431
	part in a file. 
362
claus
parents: 360
diff changeset
   432
	(How about a DiskArray class, which does this transparently ?
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   433
	 See the FileText class for some ideas and something to start with ...)
207
claus
parents: 202
diff changeset
   434
claus
parents: 202
diff changeset
   435
claus
parents: 202
diff changeset
   436
    Hint / Example 1: 
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   437
      you are about to allocate a huge data structure, which is known to
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   438
      survive long. In this case, it is better to have these objects move into the
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   439
      oldspace sooner, to avoid the copying overhead during scavenges.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   440
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   441
      To do this, you can call ObjectMemory>>tenure after allocation, which
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   442
      forces all new-objects immediately into the oldspace. 
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   443
      Make certain, that not to many (ideally no) short-living objects are in the
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   444
      newspace when doing this.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   445
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   446
      Another alternative is to tell the system that all allocation should be
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   447
      done directly in the oldspace. This completely avoids the scavenging overhead
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   448
      for these objects. To do so, use ObjectMemory>>turnGarbageCollectorOff
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   449
      before the allocation, and ObjectMemory>>turnGarbageCollectorOn afterwards.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   450
      Keep in mind, that do-loops may allocate block-objects and other temporaries,
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   451
      so there is a danger of making things worse due to having all those temporaries
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   452
      in the oldspace afterwards. (which is not a fatal situation, but will
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   453
      force the system to do an oldspace collect earlier, which may not be your
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   454
      intention).
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   455
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   456
207
claus
parents: 202
diff changeset
   457
   Hint / Example 2:
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   458
      you know in advance, that a certain (big) amount of memory will be needed.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   459
      For example, the fileBrowser wants to show a huge file in its text-view.
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   460
      In this case, it is better to tell the memory system in advance, how much
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   461
      memory will be needed, since otherwise many compresses and reallocations will
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   462
      occur (the memory system will allocate additional memory in chunks of smaller
433d44af1630 more GC control
claus
parents: 93
diff changeset
   463
      256k pieces, if a compress failes. Thus, if you are going to allocate (say) 1Mb of 
433d44af1630 more GC control
claus
parents: 93
diff changeset
   464
      strings, it will perform 5 compressing GC's).
433d44af1630 more GC control
claus
parents: 93
diff changeset
   465
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   466
      This is done using ObjectMemory>>moreOldSpace: or ObjectMemory announceSpaceNeed:.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
   467
      In the above example, you would do 'ObjectMemory announceSpaceNeed:500000', which 
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   468
      avoids those annoying 5 compressing GC's.
207
claus
parents: 202
diff changeset
   469
      BTW: if you have other smalltalk processes (threads) running which should not be
claus
parents: 202
diff changeset
   470
      paused if possible, it is better to use #announceSpaceNeed. This tries to avoid 
claus
parents: 202
diff changeset
   471
      pausing in other processes and sometimes succeeds, while moreOldSpace will always 
claus
parents: 202
diff changeset
   472
      block the whole system for a while. However, there is no 'no-pause' guarantee.
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   473
433d44af1630 more GC control
claus
parents: 93
diff changeset
   474
      The amount of automatic increase (in case the oldSpace becomes full) is 256k by
433d44af1630 more GC control
claus
parents: 93
diff changeset
   475
      default. This number can be changed with ObjectMemory>>oldSpaceIncrement:.
433d44af1630 more GC control
claus
parents: 93
diff changeset
   476
207
claus
parents: 202
diff changeset
   477
claus
parents: 202
diff changeset
   478
    Hint / Example3:
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   479
      There are rare cases, when an explicit GC makes a difference: since
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   480
      object finalization is done at GC time, objects which keep operatingSystem
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   481
      resources may be finalized late. This is normally no problem, except if
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   482
      the system is running out of resources. For example, allocating new colors
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   483
      may fail if many colors have already been allocated in the past - even
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   484
      though these colors are actually free. The Depth8Image calls for an
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   485
      explicit GC, whenever it fails to allocate a color for a bitmap, to force
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   486
      finalization of free, but not yet finalized colors.
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   487
207
claus
parents: 202
diff changeset
   488
claus
parents: 202
diff changeset
   489
    Hint 4:
claus
parents: 202
diff changeset
   490
      If you run in too small of physical memory, the incremental GC may have a
claus
parents: 202
diff changeset
   491
      bad effect on your working set: since it touches pages (which may otherwise
claus
parents: 202
diff changeset
   492
      not be needed at the moment, the operating system is forced to steal other
claus
parents: 202
diff changeset
   493
      (possibly more useful) pages from your set of incore pages.
claus
parents: 202
diff changeset
   494
      You may get better performance, if you turn off the incremental GC while
claus
parents: 202
diff changeset
   495
      processing a big data structure.
claus
parents: 202
diff changeset
   496
claus
parents: 202
diff changeset
   497
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   498
    Warning: many of the methods found here are not standard and may not even be available in
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
   499
    future versions of ST/X. Use them only in very special situations or experiments.
229
210ee6865aa3 commenting
claus
parents: 216
diff changeset
   500
207
claus
parents: 202
diff changeset
   501
    Let me know about additional special features you think are useful, and about
claus
parents: 202
diff changeset
   502
    special features you are using - this provides the feedback required to decide
403
claus
parents: 384
diff changeset
   503
    which methods are to be removed, kept or enhanced in future versions.
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
   504
"
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   505
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   506
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   507
interrupts
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   508
"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   509
    Handling of interrupts (i.e. unix-signals) is done via handler objects, which
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   510
    get a #XXXInterrupt-message sent. This is more flexible than (say) signalling
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   511
    a semaphore, since the handler-object may do anything to react on the signal
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   512
    (of course, it can also signal a semaphore to emulate the above behavior).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   513
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   514
    Another reason for having handler objects is that they allow interrupt handling
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   515
    without any context switch, for high speed interrupt response.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   516
    However, if you do this, special care is needed, since it is not defined, 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   517
    which process gets the interrupt and will do the processing (therefore,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   518
    the default setup installs handlers which simply signal a semaphore and
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   519
    continue the running process).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   520
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   521
    Typically, the handlers are set during early initialization of the system
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   522
    by sending 'ObjectMemory XXXInterruptHandler:aHandler' and not changed later.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   523
    (see Smalltalk>>initialize or ProcessorScheduler>>initialize).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   524
    To setup your own handler, create some object which responds to #xxxInterrupt,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   525
    and make it the handler using the above method.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   526
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   527
    Interrupt messages sent to handlers are:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   528
	internalError:<someString>      - internal interpreter/GC errors
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   529
	userInterrupt                   - ^C interrupt
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   530
	customInterrupt                 - custom interrupt
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   531
	ioInterrupt                     - SIGIO interrupt
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   532
	timerInterrupt                  - alarm timer (SIGALRM)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   533
	errorInterrupt:<id>             - errors from other primitives/subsystems
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   534
					  (DisplayError)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   535
	spyInterrupt                    - spy timer interrupt (SIGVTALARM)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   536
	stepInterrupt                   - single step interrupt
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   537
	disposeInterrupt                - finalization required
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   538
	recursionInterrupt              - recursion (stack) overflow
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   539
	memoryInterrupt                 - soon running out of memory
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   540
	fpExceptionInterrupt            - floating point exception (SIGFPE)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   541
	childSignalInterrupt            - death of a child process (SIGCHILD)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   542
	signalInterrupt:<number>        - unix signal (if other than above signals)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   543
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   544
    To avoid frustration in case of badly set handlers, these messages
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   545
    are also implemented in the Object class - thus anything can be defined
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   546
    as interrupt handler. However, the VM will not send any
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   547
    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
   548
    (which means that nil is a bad choice, if you are interested in the event).
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   549
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   550
    Interrupt processing is not immediately after the event arrives: there
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   551
    are certain ``save-places'' at which this handling is performed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   552
    (message send, method return and loop-heads).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   553
    If not explicitely enabled, primitive code is never interrupted.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   554
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   555
    Interrupts may be disabled (OperatingSystem blockInterrupts) and reenabled
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   556
    (unblockInterrupts) to allow for critical data to be manipulated.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   557
    Every process has its own interrupt-enable state which is switched
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   558
    when processes switch control (i.e. you cannot block interrupts across
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   559
    a suspend, delay etc.). However, the state will be restored after a resume.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   560
"
2
claus
parents: 1
diff changeset
   561
! !
claus
parents: 1
diff changeset
   562
claus
parents: 1
diff changeset
   563
!ObjectMemory class methodsFor:'initialization'!
claus
parents: 1
diff changeset
   564
claus
parents: 1
diff changeset
   565
initialize
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   566
    "initialize the class"
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   567
2
claus
parents: 1
diff changeset
   568
    AllocationFailureSignal isNil ifTrue:[
302
1f76060d58a4 *** empty log message ***
claus
parents: 293
diff changeset
   569
	AllocationFailureSignal := ErrorSignal newSignalMayProceed:true.
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   570
	AllocationFailureSignal nameClass:self message:#allocationFailureSignal.
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
   571
	AllocationFailureSignal notifierString:'allocation failure'.
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   572
465
fdc81f5887a1 made mallocFailureSignal a child of allocationFailureSignal
Claus Gittinger <cg@exept.de>
parents: 464
diff changeset
   573
	MallocFailureSignal := AllocationFailureSignal newSignalMayProceed:true.
464
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   574
	MallocFailureSignal nameClass:self message:#mallocFailureSignal.
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   575
	MallocFailureSignal notifierString:'(malloc) allocation failure'.
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   576
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
   577
	LowSpaceSemaphore := Semaphore new.
2
claus
parents: 1
diff changeset
   578
    ].
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
   579
    DisposeInterruptHandler := self.
2
claus
parents: 1
diff changeset
   580
    IncrementalGCLimit := 500000.
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
   581
    FreeSpaceGCLimit := FreeSpaceGCAmount := nil.
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   582
    MemoryInterruptHandler := self
2
claus
parents: 1
diff changeset
   583
! !
claus
parents: 1
diff changeset
   584
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   585
!ObjectMemory class methodsFor:'ST-80 compatibility'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   586
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   587
availableFreeBytes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   588
    ^ self freeSpace + self freeListSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   589
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   590
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   591
     ObjectMemory availableFreeBytes 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   592
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   593
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   594
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   595
bytesPerOOP
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   596
    "return the number of bytes an object reference (for example: an instvar)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   597
     takes"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   598
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   599
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   600
    RETURN(__MKSMALLINT(sizeof(OBJ)));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   601
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   602
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   603
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   604
     ObjectMemory bytesPerOOP 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   605
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   606
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   607
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   608
bytesPerOTE
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   609
    "return the number of overhead bytes of an object.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   610
     i.e. the number of bytes in every objects header."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   611
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   612
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   613
    RETURN(__MKSMALLINT(OHDR_SIZE));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   614
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   616
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   617
     ObjectMemory bytesPerOTE 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   618
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   619
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   620
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   621
compactingGC
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   622
    self garbageCollect
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   623
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   624
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   625
current
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   626
    ^ self
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   627
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   628
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   629
globalCompactingGC
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   630
    self garbageCollect
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   631
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   632
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   633
growMemoryBy:numberOfBytes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   634
    ^ self moreOldSpace:numberOfBytes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   635
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   636
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   637
numOopsNumBytes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   638
    ^ Array with:(self numberOfObjects)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   639
	    with:(self bytesUsed)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   640
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   641
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   642
     ObjectMemory numOopsNumBytes 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   643
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   644
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   645
345
claus
parents: 339
diff changeset
   646
!ObjectMemory class methodsFor:'Signal constants'!
2
claus
parents: 1
diff changeset
   647
claus
parents: 1
diff changeset
   648
allocationFailureSignal
13
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   649
    "return the signal raised when an object allocation failed"
62303f84ff5f *** empty log message ***
claus
parents: 10
diff changeset
   650
2
claus
parents: 1
diff changeset
   651
    ^ AllocationFailureSignal
464
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   652
!
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   653
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   654
mallocFailureSignal
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   655
    "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
   656
     (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
   657
      non-Object storage)"
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   658
83af924c8cff differenciate between object-allocation-failure and malloc-allocation-failure
Claus Gittinger <cg@exept.de>
parents: 458
diff changeset
   659
    ^ MallocFailureSignal
2
claus
parents: 1
diff changeset
   660
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   661
375
claus
parents: 370
diff changeset
   662
!ObjectMemory class methodsFor:'VM messages'!
claus
parents: 370
diff changeset
   663
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   664
debugPrinting
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   665
    "return true, if various debug printouts in the VM
375
claus
parents: 370
diff changeset
   666
     are turned on, false of off."
claus
parents: 370
diff changeset
   667
claus
parents: 370
diff changeset
   668
%{  /* NOCONTEXT */
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   669
    extern int __debugPrinting;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   670
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   671
    RETURN (__debugPrinting ? true : false);
375
claus
parents: 370
diff changeset
   672
%}
claus
parents: 370
diff changeset
   673
!
claus
parents: 370
diff changeset
   674
claus
parents: 370
diff changeset
   675
debugPrinting:aBoolean
claus
parents: 370
diff changeset
   676
    "turn on/off various debug printouts in the VM
claus
parents: 370
diff changeset
   677
     in case of an error. For example, a double-notUnderstood
claus
parents: 370
diff changeset
   678
     leads to a VM context dump if debugPrinting is on.
claus
parents: 370
diff changeset
   679
     If off, those messages are suppressed.
claus
parents: 370
diff changeset
   680
     The default is on, since these messages are only printed for
claus
parents: 370
diff changeset
   681
     severe errors."
claus
parents: 370
diff changeset
   682
claus
parents: 370
diff changeset
   683
%{  /* NOCONTEXT */
claus
parents: 370
diff changeset
   684
    extern int __debugPrinting;
claus
parents: 370
diff changeset
   685
claus
parents: 370
diff changeset
   686
    __debugPrinting = (aBoolean == true);
claus
parents: 370
diff changeset
   687
%}
claus
parents: 370
diff changeset
   688
!
claus
parents: 370
diff changeset
   689
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   690
infoPrinting
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   691
    "return true, if various informational printouts in the VM
375
claus
parents: 370
diff changeset
   692
     are turned on, false of off."
claus
parents: 370
diff changeset
   693
claus
parents: 370
diff changeset
   694
%{  /* NOCONTEXT */
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   695
    extern int __infoPrinting;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   696
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   697
    RETURN (__infoPrinting ? true : false);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   698
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   699
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   700
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   701
infoPrinting:aBoolean
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   702
    "turn on/off various informational printouts in the VM.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   703
     For example, the GC activity messages are controlled by
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   704
     this flags setting.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   705
     The default is true, since (currently) those messages
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   706
     are useful for ST/X developers."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   707
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   708
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   709
    extern int __infoPrinting;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   710
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   711
    __infoPrinting = (aBoolean == true);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   712
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   713
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   714
703
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   715
!ObjectMemory class methodsFor:'access debugging'!
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   716
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   717
setTrapOnAccessFor:anObject
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   718
    "install an access trap for anObject;
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   719
     An accessSignal will be raised, whenever any instvar of anObject is either read or written.
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   720
     This is not supported on all architectures, therefore the return value
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   721
     (true of trap was installed ok, false if failed) should be checked."
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   722
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   723
%{  /* NOCONTEXT */
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   724
    RETURN (__addTrapOnAccess__(anObject, 2) ? true : false);
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   725
%}
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   726
!
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   727
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   728
setTrapOnReadFor:anObject
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   729
    "install a read trap for anObject;
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   730
     An accessSignal will be raised, whenever any access into anObject occurrs.
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   731
     This is not supported on all architectures, therefore the return value
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   732
     (true of trap was installed ok, false if failed) should be checked."
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   733
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   734
%{  /* NOCONTEXT */
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   735
    RETURN (__addTrapOnAccess__(anObject, 0) ? true : false);
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   736
%}
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   737
!
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   738
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   739
setTrapOnWriteFor:anObject
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   740
    "install a write trap for anObject;
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   741
     An accessSignal will be raised, whenever any instvar of anObject is written to.
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   742
     This is not supported on all architectures, therefore the return value
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   743
     (true of trap was installed ok, false if failed) should be checked."
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   744
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   745
%{  /* NOCONTEXT */
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   746
    RETURN (__addTrapOnAccess__(anObject, 1) ? true : false);
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   747
%}
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   748
!
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   749
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   750
unsetAllTraps
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   751
    "remove all access traps"
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   752
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   753
%{  /* NOCONTEXT */
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   754
    __removeAllAccessTraps__();
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   755
%} 
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   756
!
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   757
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   758
unsetTrapFor:anObject
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   759
    "remove any access trap for anObject."
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   760
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   761
%{  /* NOCONTEXT */
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   762
    __removeTrapOnAccess__(anObject);
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   763
%}
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   764
! !
2d4202542a59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 683
diff changeset
   765
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   766
!ObjectMemory class methodsFor:'cache management'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   767
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   768
flushCaches
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   769
    "flush method and inline caches for all classes"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   770
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   771
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   772
    __flushMethodCache();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   773
    __flushAllInlineCaches();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   774
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   775
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   776
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   777
flushCachesFor:aClass
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   778
    "flush method and inline caches for aClass"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   779
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   780
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   781
    __flushMethodCacheFor(aClass);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   782
    __flushInlineCachesFor(aClass);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   783
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   784
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   785
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   786
flushCachesForSelector:aSelector
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   787
    "flush method and inline caches for aSelector"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   788
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   789
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   790
    __flushMethodCacheForSelector(aSelector);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   791
    __flushInlineCachesForSelector(aSelector);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   792
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   793
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   794
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   795
flushInlineCaches
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   796
    "flush all inlinecaches"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   797
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   798
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   799
    __flushAllInlineCaches();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   800
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   801
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   802
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   803
flushInlineCachesFor:aClass withArgs:nargs
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   804
    "flush inlinecaches for calls to aClass with nargs arguments"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   805
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   806
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   807
    __flushInlineCachesForAndNargs(aClass, _intVal(nargs));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   808
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   809
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   810
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   811
flushInlineCachesForClass:aClass
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   812
    "flush inlinecaches for calls to aClass."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   813
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   814
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   815
    __flushInlineCachesFor(aClass);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   816
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   817
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   818
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   819
flushInlineCachesForSelector:aSelector
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   820
    "flush inlinecaches for sends of aSelector"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   821
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   822
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   823
    __flushInlineCachesForSelector(aSelector);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   824
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   825
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   826
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   827
flushInlineCachesWithArgs:nargs
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   828
    "flush inlinecaches for calls with nargs arguments"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   829
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   830
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   831
    __flushInlineCaches(_intVal(nargs));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   832
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   833
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   834
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   835
flushMethodCache
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   836
    "flush the method cache"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   837
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   838
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   839
    __flushMethodCache();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   840
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   841
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   842
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   843
flushMethodCacheFor:aClass
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   844
    "flush the method cache for sends to aClass"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   845
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   846
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   847
    __flushMethodCacheFor(aClass);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   848
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   849
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   850
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   851
flushMethodCacheForSelector:aSelector
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   852
    "flush the method cache for sends of aSelector"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   853
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   854
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   855
    __flushMethodCacheForSelector(aSelector);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   856
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   857
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   858
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   859
trapRestrictedMethods:trap
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   860
    "Allow/Deny execution of restricted Methods (see Method>>>restricted:)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   861
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   862
     Notice: method restriction is a nonstandard feature, not supported
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   863
     by other smalltalk implementations and not specified in the ANSI spec.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   864
     This is EXPERIMENTAL - and being evaluated for usability.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   865
     It may change or even vanish (if it shows to be not useful)."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   866
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   867
    |oldTrap|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   868
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   869
%{ 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   870
	if (__setTrapRestrictedMethods(trap == true))
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   871
	    oldTrap = true;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   872
	else
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   873
	    oldTrap = false;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   874
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   875
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   876
    (trap and:[oldTrap not]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   877
	self flushCaches
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   878
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   879
    ^ oldTrap
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   880
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   881
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   882
	ObjectMemory trapRestrictedMethods:true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   883
	ObjectMemory trapRestrictedMethods:false
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   884
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   885
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   886
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   887
!ObjectMemory class methodsFor:'debug queries'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   888
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   889
addressOf:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   890
    "return the core address of anObject as an integer
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   891
     - since objects may move around, the returned value is invalid after the
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   892
     next scavenge/collect.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   893
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   894
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   895
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   896
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   897
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   898
    if (! __isNonNilObject(anObject)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   899
	RETURN ( nil );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   900
    }
646
b0a2e25461cb object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   901
    if ((unsigned)anObject <= _MAX_INT) {
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   902
	RETURN ( _MKSMALLINT((int)anObject) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   903
    }
646
b0a2e25461cb object addresses are unsigned (in addressOf:)
Claus Gittinger <cg@exept.de>
parents: 630
diff changeset
   904
    RETURN ( __MKUINT((int)anObject) );
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   905
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   906
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   907
    |p|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   908
    p := Point new.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   909
    ((ObjectMemory addressOf:p) printStringRadix:16) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   910
    ObjectMemory scavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   911
    ((ObjectMemory addressOf:p) printStringRadix:16) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   912
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   913
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   914
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   915
ageOf:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   916
    "return the number of scavenges, an object has survived
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   917
     in new space. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   918
     For old objects and living contexts, the returned number is invalid.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   919
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   920
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   921
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   922
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   923
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   924
    if (! __isNonNilObject(anObject)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   925
	RETURN ( 0 );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   926
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   927
    RETURN ( _MKSMALLINT( _GET_AGE(anObject) ) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   928
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   929
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   930
    |p|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   931
    p := Point new.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   932
    (ObjectMemory ageOf:p) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   933
    ObjectMemory tenuringScavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   934
    (ObjectMemory spaceOf:p) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   935
    ObjectMemory tenuringScavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   936
    (ObjectMemory spaceOf:p) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   937
    ObjectMemory tenuringScavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   938
    (ObjectMemory spaceOf:p) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   939
    ObjectMemory tenuringScavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   940
    (ObjectMemory spaceOf:p) printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   941
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   942
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   943
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   944
dumpObject:someObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   945
    "low level dump an object.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   946
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   947
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   948
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   949
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   950
    dumpObject(someObject);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   951
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   952
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   953
     ObjectMemory dumpObject:true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   954
     ObjectMemory dumpObject:(Array new:10) 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   955
     ObjectMemory dumpObject:(10@20 corner:30@40) 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   956
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   957
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   958
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   959
flagsOf:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   960
    "For debugging only.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   961
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   962
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   963
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   964
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   965
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   966
    if (! __isNonNilObject(anObject)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   967
	RETURN ( nil );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   968
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   969
    RETURN ( _MKSMALLINT( anObject->o_flags ) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   970
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   971
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   972
F_ISREMEMBERED  1       /* a new-space thing being refd by some oldSpace thing */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   973
F_ISFORWARDED   2       /* a forwarded object (you will never see this here) */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   974
F_DEREFERENCED  4       /* a collection after grow (not currently used) */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   975
F_ISONLIFOLIST  8       /* a non-lifo-context-referencing-obj already on list */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   976
F_MARK          16      /* mark bit for background collector */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   977
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   978
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   979
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   980
     |arr|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   981
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   982
     arr := Array new.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   983
     arr at:1 put:([thisContext] value).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   984
     (ObjectMemory flagsOf:anObject) printNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   985
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   986
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   987
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   988
objectAt:anAddress
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   989
    "return whatever anAddress points to as object.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   990
     BIG BIG DANGER ALERT: 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   991
	this method is only to be used for debugging ST/X itself 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   992
	- you can easily (and badly) crash the system.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   993
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   994
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   995
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   996
    |low high|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   997
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   998
    low := anAddress bitAnd:16rFFFF.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
   999
    high := (anAddress bitShift:16) bitAnd:16rFFFF.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1000
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1001
    if (__bothSmallInteger(low, high)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1002
	RETURN ((OBJ)((_intVal(high) << 16) | _intVal(low)));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1003
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1004
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1005
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1006
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1007
printReferences:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1008
    "for debugging: print referents to anObject.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1009
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1010
	      it will be removed without notice
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1011
	use ObjectMemory>>whoReferences: or anObject>>allOwners."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1012
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1013
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1014
    __printRefChain(__context, anObject);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1015
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1016
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1017
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1018
sizeOf:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1019
    "return the size of anObject in bytes.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1020
     (this is not the same as 'anObject size').
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1021
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1022
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1023
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1024
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1025
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1026
    RETURN ( __isNonNilObject(anObject) ? _MKSMALLINT(__qSize(anObject)) : _MKSMALLINT(0) )
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1027
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1028
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1029
     |hist big nw|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1030
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1031
     hist := Array new:100 withAll:0.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1032
     big := 0.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1033
     ObjectMemory allObjectsDo:[:o |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1034
	 nw := (ObjectMemory sizeOf:o) // 4 + 1.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1035
	 nw > 100 ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1036
	    big := big + 1
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1037
	 ] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1038
	    hist at:nw put:(hist at:nw) + 1
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1039
	 ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1040
     ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1041
     hist printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1042
     big printNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1043
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1044
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1045
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1046
spaceOf:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1047
    "return the memory space, in which anObject is.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1048
     - since objects may move between spaces, 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1049
       the returned value may be invalid after the next scavenge/collect.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1050
     WARNING: this method is for ST/X debugging only 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1051
	      it will be removed without notice"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1052
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1053
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1054
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1055
    if (! __isNonNilObject(anObject)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1056
	RETURN ( nil );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1057
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1058
    RETURN ( _MKSMALLINT( __qSpace(anObject) ) );
375
claus
parents: 370
diff changeset
  1059
%}
claus
parents: 370
diff changeset
  1060
! !
claus
parents: 370
diff changeset
  1061
10
claus
parents: 5
diff changeset
  1062
!ObjectMemory class methodsFor:'dependents access'!
claus
parents: 5
diff changeset
  1063
claus
parents: 5
diff changeset
  1064
dependents
claus
parents: 5
diff changeset
  1065
    "return the colleciton of my dependents"
claus
parents: 5
diff changeset
  1066
claus
parents: 5
diff changeset
  1067
    ^ Dependents
claus
parents: 5
diff changeset
  1068
!
claus
parents: 5
diff changeset
  1069
claus
parents: 5
diff changeset
  1070
dependents:aCollection
claus
parents: 5
diff changeset
  1071
    "set the dependents collection"
claus
parents: 5
diff changeset
  1072
claus
parents: 5
diff changeset
  1073
    Dependents := aCollection
282
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1074
!
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1075
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1076
dependentsDo:aBlock
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1077
    "evaluate aBlock for all of my dependents.
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1078
     Since this is performed at startup time (under the scheduler),
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1079
     this is redefined here to catch abort signals.
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1080
     Thus, if any error occurs in a #returnFromSnapshot,
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1081
     the user can press abort to continue."
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1082
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1083
    |deps|
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1084
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1085
    deps := Dependents.
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1086
    deps notNil ifTrue:[
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1087
	deps do:[:each |
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1088
	    AbortSignal handle:[:ex |
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1089
		ex return       
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1090
	    ] do:[
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1091
		aBlock value:each
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1092
	    ]
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1093
	]
94f5c3a6230d *** empty log message ***
claus
parents: 270
diff changeset
  1094
    ]
10
claus
parents: 5
diff changeset
  1095
! !
claus
parents: 5
diff changeset
  1096
216
a8abff749575 *** empty log message ***
claus
parents: 213
diff changeset
  1097
!ObjectMemory class methodsFor:'enumerating'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1098
369
claus
parents: 362
diff changeset
  1099
allInstancesOf:aClass do:aBlock
claus
parents: 362
diff changeset
  1100
    "evaluate the argument, aBlock for all instances of aClass in the system.
claus
parents: 362
diff changeset
  1101
     There is one caveat: if a compressing oldSpace collect
claus
parents: 362
diff changeset
  1102
     occurs while looping over the objects, the loop cannot be
claus
parents: 362
diff changeset
  1103
     continued (for some internal reasons). In this case, false
claus
parents: 362
diff changeset
  1104
     is returned."
claus
parents: 362
diff changeset
  1105
claus
parents: 362
diff changeset
  1106
    |work|
claus
parents: 362
diff changeset
  1107
claus
parents: 362
diff changeset
  1108
%{  /* NOREGISTER - work may not be placed into a register here */
claus
parents: 362
diff changeset
  1109
    __nonTenuringScavenge(__context);
claus
parents: 362
diff changeset
  1110
    /*
claus
parents: 362
diff changeset
  1111
     * allInstancesDo needs a temporary to hold newSpace objects
claus
parents: 362
diff changeset
  1112
     */
claus
parents: 362
diff changeset
  1113
    if (__allInstancesOfDo(&aClass, &aBlock, &work COMMA_CON) < 0) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  1114
	RETURN (false);
85
claus
parents: 77
diff changeset
  1115
    }
claus
parents: 77
diff changeset
  1116
%}.
claus
parents: 77
diff changeset
  1117
    ^ true
2
claus
parents: 1
diff changeset
  1118
!
claus
parents: 1
diff changeset
  1119
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1120
allObjectsDo:aBlock
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1121
    "evaluate the argument, aBlock for all objects in the system.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1122
     There is one caveat: if a compressing oldSpace collect
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1123
     occurs while looping over the objects, the loop cannot be
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1124
     continued (for some internal reasons). In this case, false
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1125
     is returned."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1126
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1127
    |work|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1128
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1129
%{  /* NOREGISTER - work may not be placed into a register here */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1130
    __nonTenuringScavenge(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1131
    /*
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1132
     * allObjectsDo needs a temporary to hold newSpace objects
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1133
     */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1134
    if (__allInstancesOfDo((OBJ *)0, &aBlock, &work COMMA_CON) < 0) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1135
	RETURN (false);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1136
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1137
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1138
    ^ true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1139
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1140
2
claus
parents: 1
diff changeset
  1141
allOldObjectsDo:aBlock
claus
parents: 1
diff changeset
  1142
    "evaluate the argument, aBlock for all old objects in the system.
claus
parents: 1
diff changeset
  1143
     For debugging and tests only - do not use"
claus
parents: 1
diff changeset
  1144
%{
369
claus
parents: 362
diff changeset
  1145
    if (__allInstancesOfDo((OBJ *)0, &aBlock, (OBJ *)0 COMMA_CON) < 0) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  1146
	RETURN (false);
85
claus
parents: 77
diff changeset
  1147
    }
claus
parents: 77
diff changeset
  1148
%}. 
claus
parents: 77
diff changeset
  1149
    ^ true
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1150
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1151
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1152
!ObjectMemory class methodsFor:'garbage collection'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1153
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1154
backgroundCollectorRunning
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1155
    "return true, if a backgroundCollector is running"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1156
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1157
    ^ BackgroundCollectProcess notNil
500
e5fd4f3c9f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1158
e5fd4f3c9f37 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
  1159
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1160
     ObjectMemory backgroundCollectorRunning
375
claus
parents: 370
diff changeset
  1161
    "
claus
parents: 370
diff changeset
  1162
!
claus
parents: 370
diff changeset
  1163
claus
parents: 370
diff changeset
  1164
compressingGarbageCollect
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1165
    "search for and free garbage in the oldSpace (newSpace is cleaned automatically) 
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1166
     performing a COMPRESSING garbage collect.
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1167
     This can take a long time - especially, if paging is involved
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1168
     (when no paging is involved, its faster than I thought :-).
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1169
     If no memory is available for the compress, or the system has been started with
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1170
     the -Msingle option, this does a non-COMPRESSING collect."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1171
%{
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1172
    if (! __garbageCollect(__context)) {
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
  1173
	__markAndSweep(__context);
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1174
    }
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1175
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1176
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1177
    "
375
claus
parents: 370
diff changeset
  1178
     ObjectMemory compressingGarbageCollect
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1179
    "
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1180
!
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1181
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1182
garbageCollect
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1183
    "search for and free garbage in the oldSpace.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1184
     This can take a long time - especially, if paging is involved."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1185
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1186
    "/ used to be 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1187
    "/    self compressingGarbageCollect 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1188
    "/ here; changed to default to markAndSweep
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1189
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1190
    self markAndSweep
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1191
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  1192
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1193
     ObjectMemory garbageCollect
375
claus
parents: 370
diff changeset
  1194
    "
claus
parents: 370
diff changeset
  1195
!
claus
parents: 370
diff changeset
  1196
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1197
gcStep
77
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1198
    "one incremental garbage collect step.
6c38ca59927f *** empty log message ***
claus
parents: 68
diff changeset
  1199
     Mark or sweep some small number of objects. This
85
claus
parents: 77
diff changeset
  1200
     method will return after a reasonable (short) time.
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1201
     This is used by the ProcessorScheduler at idle times.
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1202
     Returns true, if an incremental GC cycle has finished."
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1203
%{
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1204
    extern int __incrGCstep();
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1205
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1206
    RETURN (__incrGCstep(__context) ? true : false);
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1207
%}
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1208
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1209
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1210
gcStepIfUseful
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1211
    "If either the IncrementalGCLimit or the FreeSpaceGCLimits have been
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1212
     reached, perform one incremental garbage collect step.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1213
     Return true, if more gcSteps are required to finish the cycle,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1214
     false if done with a gc round.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1215
     If no limit has been reached yet, do nothing and return false.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1216
     This is called by the ProcessorScheduler at idle times or by the 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1217
     backgroundCollector."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1218
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1219
    |done limit|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1220
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1221
    Object abortSignal handle:[:ex |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1222
	"/ in case of abort (from the debugger),
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1223
	"/ disable gcSteps.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1224
	done := true.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1225
	IncrementalGCLimit := FreeSpaceGCLimit := nil.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1226
	'OBJMEM: IGC aborted; turning off incremental GC' errorPrintNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1227
    ] do:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1228
	limit := IncrementalGCLimit.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1229
	(limit notNil and:[self oldSpaceAllocatedSinceLastGC > limit]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1230
	    done := ObjectMemory gcStep
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1231
	] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1232
	    limit := FreeSpaceGCLimit.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1233
	    (limit notNil and:[(self freeSpace + self freeListSpace) < limit]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1234
		done := ObjectMemory gcStep.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1235
		done ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1236
		    self moreOldSpaceIfUseful
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1237
		].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1238
	    ] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1239
		done := true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1240
	    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1241
	].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1242
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1243
    ^ done not
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1244
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1245
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1246
incrementalGC
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1247
    "perform one round of incremental GC steps.
403
claus
parents: 384
diff changeset
  1248
     The overall effect of this method is (almost) the same as calling 
claus
parents: 384
diff changeset
  1249
     markAndSweep. However, #incrementalGC is interruptable while #markAndSweep
claus
parents: 384
diff changeset
  1250
     is atomic and blocks for a while. The code here performs incremental
claus
parents: 384
diff changeset
  1251
     GC steps, until one complete gc-cycle is completed. If running at a higher
claus
parents: 384
diff changeset
  1252
     than userBackground priority, it will give up the CPU after every such
claus
parents: 384
diff changeset
  1253
     step for a while.
claus
parents: 384
diff changeset
  1254
     Thus this method can be called either from a low prio (background) process 
claus
parents: 384
diff changeset
  1255
     or from a high prio process.
369
claus
parents: 362
diff changeset
  1256
     (however, if you have nothing else to do, its better to call for markAndSweep,
claus
parents: 362
diff changeset
  1257
      since it is faster)
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  1258
     For example, someone allocating huge amounts of memory could
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  1259
     ask for the possibility of a quick allocation using
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  1260
     #checkForFastNew: and try a #incrementalGC if not. In many
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1261
     cases, this can avoid a pause (in the higher prio processes) due to 
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1262
     a blocking GC."
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1263
403
claus
parents: 384
diff changeset
  1264
    |p delay|
claus
parents: 384
diff changeset
  1265
claus
parents: 384
diff changeset
  1266
    Processor activeProcess priority > Processor userBackgroundPriority ifTrue:[
claus
parents: 384
diff changeset
  1267
	delay := Delay forMilliseconds:1
claus
parents: 384
diff changeset
  1268
    ].
claus
parents: 384
diff changeset
  1269
claus
parents: 384
diff changeset
  1270
    [self gcStep] whileFalse:[
claus
parents: 384
diff changeset
  1271
	delay notNil ifTrue:[delay wait]
claus
parents: 384
diff changeset
  1272
    ].
369
claus
parents: 362
diff changeset
  1273
    self moreOldSpaceIfUseful
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1274
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1275
    "
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1276
     ObjectMemory incrementalGC
356
claus
parents: 345
diff changeset
  1277
     [ObjectMemory incrementalGC] forkAt:3
403
claus
parents: 384
diff changeset
  1278
     [ObjectMemory incrementalGC] forkAt:9 
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1279
    "
194
197c209e61f4 fine tuning tenure
claus
parents: 178
diff changeset
  1280
!
197c209e61f4 fine tuning tenure
claus
parents: 178
diff changeset
  1281
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1282
markAndSweep
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1283
    "mark/sweep garbage collector.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1284
     perform a full mark&sweep collect.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1285
     Warning: this may take some time and it is NOT interruptable.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1286
     If you want to do a collect from a background process, or have
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1287
     other things to do, better use #incrementalGC which is interruptable."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1288
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1289
    __markAndSweep(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1290
%}
194
197c209e61f4 fine tuning tenure
claus
parents: 178
diff changeset
  1291
197c209e61f4 fine tuning tenure
claus
parents: 178
diff changeset
  1292
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1293
     ObjectMemory markAndSweep
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1294
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1295
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1296
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1297
reclaimSymbols
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1298
    "reclaim unused symbols;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1299
     Unused symbols are (currently) not reclaimed automatically,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1300
     but only upon request with this method. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1301
     It takes some time to do this ... and it is NOT interruptable.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1302
     Future versions may do this automatically, while garbage collecting."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1303
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1304
    __reclaimSymbols(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1305
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1306
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1307
     ObjectMemory reclaimSymbols
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1308
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1309
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1310
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1311
scavenge
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1312
    "collect young objects, without aging (i.e. no tenure).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1313
     Can be used to quickly get rid of shortly before allocated
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1314
     stuff. This is relatively fast (compared to oldspace collect).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1315
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1316
     An example where a non-tenuring scavenge makes sense is when
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1317
     allocating some OperatingSystem resource (a Color, File or View) 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1318
     and the OS runs out of resources. In this case, the scavenge may
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1319
     free some ST-objects and therefore (by signalling the WeakArrays
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1320
     or Registries) free the OS resources too.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1321
     Of course, only recently allocated resources will be freed this
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1322
     way. If none was freed, a full collect will be needed."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1323
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1324
    __nonTenuringScavenge(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1325
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1326
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1327
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1328
     ObjectMemory scavenge
194
197c209e61f4 fine tuning tenure
claus
parents: 178
diff changeset
  1329
    "
207
claus
parents: 202
diff changeset
  1330
!
claus
parents: 202
diff changeset
  1331
claus
parents: 202
diff changeset
  1332
startBackgroundCollectorAt:aPriority
claus
parents: 202
diff changeset
  1333
    "start a process doing incremental GC in the background.
claus
parents: 202
diff changeset
  1334
     Use this, if you have suspendable background processes which
claus
parents: 202
diff changeset
  1335
     run all the time, and therefore would prevent the idle-collector
claus
parents: 202
diff changeset
  1336
     from running. See documentation in this class for more details."
claus
parents: 202
diff changeset
  1337
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1338
    |p|
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1339
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1340
    "/
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1341
    "/ its not useful, to run it more than once
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1342
    "/
207
claus
parents: 202
diff changeset
  1343
    BackgroundCollectProcess notNil ifTrue:[
claus
parents: 202
diff changeset
  1344
	BackgroundCollectProcess priority:aPriority.
claus
parents: 202
diff changeset
  1345
	^ self
claus
parents: 202
diff changeset
  1346
    ].
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1347
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1348
    p :=
207
claus
parents: 202
diff changeset
  1349
	[
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1350
	    [
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1351
		[true] whileTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1352
		    self gcStepIfUseful ifTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1353
			"
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1354
			 perform a full cycle
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1355
			"
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1356
			self incrementalGC
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1357
		    ].
270
f036aaa9a836 *** empty log message ***
claus
parents: 253
diff changeset
  1358
		    "
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1359
		     wait a bit
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1360
		    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1361
		    (Delay forSeconds:5) wait
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1362
		]
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1363
	    ] valueOnUnwindDo:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1364
		BackgroundCollectProcess := nil
211
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1365
	    ]
207
claus
parents: 202
diff changeset
  1366
	] newProcess.
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1367
    p name:'background collector'.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1368
    p priority:aPriority.
339
claus
parents: 335
diff changeset
  1369
    p restartable:true.
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1370
    p resume.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  1371
    BackgroundCollectProcess := p
211
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1372
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1373
    "
293
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1374
     the following lets the backgroundCollector run at prio 5
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1375
     whenever 100000 bytes have been allocated, OR freeSpace drops
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1376
     below 1meg. Having the system keep 1meg as reserve for peak allocation.
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1377
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1378
     Doing this may reduce pauses due to inevitable collects when running
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1379
     out of freeSpace, if the collector can keep up with allocation rate.
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1380
    "
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1381
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1382
    "
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1383
     ObjectMemory incrementalGCLimit:100000.
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1384
     ObjectMemory freeSpaceGCLimit:1000000.
211
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1385
     ObjectMemory startBackgroundCollectorAt:5
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1386
    "
207
claus
parents: 202
diff changeset
  1387
!
claus
parents: 202
diff changeset
  1388
claus
parents: 202
diff changeset
  1389
stopBackgroundCollector
claus
parents: 202
diff changeset
  1390
    "stop the background collector"
claus
parents: 202
diff changeset
  1391
claus
parents: 202
diff changeset
  1392
    BackgroundCollectProcess notNil ifTrue:[
claus
parents: 202
diff changeset
  1393
	BackgroundCollectProcess terminate.
claus
parents: 202
diff changeset
  1394
	BackgroundCollectProcess := nil
claus
parents: 202
diff changeset
  1395
    ]
293
31df3850e98c *** empty log message ***
claus
parents: 291
diff changeset
  1396
211
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1397
    "
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1398
     ObjectMemory stopBackgroundCollector
58bb873aa83c *** empty log message ***
claus
parents: 207
diff changeset
  1399
    "
362
claus
parents: 360
diff changeset
  1400
!
claus
parents: 360
diff changeset
  1401
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1402
tenure
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1403
    "force all living new stuff into old-space - effectively making
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1404
     all living young objects become old objects immediately.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1405
     This is relatively fast (compared to oldspace collect).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1406
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1407
     This method should only be used in very special situations:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1408
     for example, when building up some long-living data structure
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1409
     in a time critical application.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1410
     To do so, you have to do a scavenge followed by a tenure after the
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1411
     objects are created. Be careful, to not reference any other chunk-
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1412
     data when calling for a tenure (this will lead to lots of garbage in
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1413
     the oldspace).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1414
     In normal situations, explicit tenures are not needed."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1415
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1416
    __tenure(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1417
%}
362
claus
parents: 360
diff changeset
  1418
claus
parents: 360
diff changeset
  1419
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1420
     ObjectMemory tenure
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1421
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1422
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1423
     ... build up long living objects ...
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1424
     ObjectMemory scavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1425
     ObjectMemory tenure
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1426
     ... continue - objects created above are now in oldSpace ...
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1427
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1428
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1429
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1430
tenuringScavenge
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1431
    "collect newspace stuff, with aging (i.e. objects old enough
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1432
     will be moved into the oldSpace).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1433
     Use this for debugging and testing only - the system performs
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1434
     this automatically when the newspace fills up.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1435
     This is relatively fast (compared to oldspace collect)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1436
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1437
    __scavenge(__context);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1438
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1439
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1440
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1441
     ObjectMemory tenuringScavenge
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1442
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1443
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1444
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1445
verboseGarbageCollect
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1446
    "perform a compressing garbage collect and show some informational
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1447
     output on the Transcript"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1448
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1449
    |nBytesBefore nReclaimed value unit|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1450
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1451
    nBytesBefore := self oldSpaceUsed.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1452
    self compressingGarbageCollect.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1453
    nReclaimed := nBytesBefore - self oldSpaceUsed.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1454
    nReclaimed > 0 ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1455
	nReclaimed > 1024 ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1456
	    nReclaimed > (1024 * 1024) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1457
		value := nReclaimed // (1024 * 1024).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1458
		unit := ' Mb.'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1459
	    ] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1460
		value := nReclaimed // 1024.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1461
		unit := ' Kb.'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1462
	    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1463
	] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1464
	    value := nReclaimed.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1465
	    unit := ' bytes.'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1466
	].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1467
	Transcript show:'reclaimed '; show:value printString.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1468
	Transcript showCr:unit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1469
    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1470
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1471
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1472
     ObjectMemory verboseGarbageCollect
362
claus
parents: 360
diff changeset
  1473
    "
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1474
! !
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1475
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1476
!ObjectMemory class methodsFor:'garbage collector control'!
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1477
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1478
announceOldSpaceNeed:howMuch
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1479
    "announce to the memory system, that howMuch bytes of memory will be needed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1480
     soon, which is going to live longer (whatever that means). 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1481
     It first checks if the memory can be allocated without forcing a compressing
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1482
     GC. If not, the oldSpace is increased. This may also lead to a slow compressing
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1483
     collect. However, many smaller increases are avoided afterwards. Calling this
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1484
     method before allocating huge chunks of data may provide better overall performance.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1485
     Notice: this is a nonstandard interface - use only in special situations."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1486
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1487
    (self checkForFastNew:howMuch) ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1488
	self incrementalGC.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1489
	(self checkForFastNew:howMuch) ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1490
	    self moreOldSpace:howMuch
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1491
	]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1492
    ]
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1493
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1494
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1495
     ObjectMemory announceOldSpaceNeed:1000000
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1496
    "
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1497
!
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1498
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1499
announceSpaceNeed:howMuch
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1500
    "announce to the memory system, that howMuch bytes of memory will be needed
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1501
     soon. The VM tries to prepare itself for this allocation to be performed
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1502
     with less overhead. For example, it could preallocate some memory in one
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1503
     big chunk (instead of doing many smaller reallocations later).
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1504
     Notice: this is a nonstandard interface - use only in special situations.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1505
     Also, this does a background collect before the big chunk of memory is
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1506
     allocated, not locking other processes while doing so."
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1507
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1508
    (howMuch < (self newSpaceSize // 2)) ifTrue:[
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1509
	self scavenge.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1510
    ].
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1511
    (self checkForFastNew:howMuch) ifFalse:[
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1512
	(howMuch > (self newSpaceSize // 2)) ifFalse:[
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1513
	    self scavenge.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1514
	].
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1515
	self incrementalGC.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1516
	(self checkForFastNew:howMuch) ifFalse:[
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1517
	    self moreOldSpace:howMuch
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1518
	]
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1519
    ]
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1520
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1521
    "
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1522
     ObjectMemory announceSpaceNeed:100000
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1523
    "
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1524
!
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1525
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1526
avoidTenure:flag
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1527
    "set/clear the avoidTenure flag. If set, aging of newSpace is turned off
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1528
     as long as the newSpace fill-grade stays below some magic high-water mark.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1529
     If off (the default), aging is done as usual.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1530
     If the flag is turned on, scavenge may be a bit slower, due to more
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1531
     objects being copied around. However, chances are high that in an idle
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1532
     or (almost idle) system, less objects are moved into oldSpace.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1533
     Therefore, this helps to avoid oldSpace colelcts, in systems which go into
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1534
     some standby mode and are reactivated by some external event.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1535
     (the avoid-flag should be turned off there, and set again once the idle loop
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1536
     is reentered).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1537
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1538
    This is an EXPERIMENTAL interface."
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1539
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1540
%{  /* NOCONTEXT */
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1541
    __avoidTenure(flag == true ? 1 : 0);
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1542
%}
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1543
!
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1544
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1545
checkForFastNew:amount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1546
    "this method returns true, if amount bytes could be allocated
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1547
     quickly (i.e. without forcing a full GC or compress).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1548
     This can be used for smart background processes, which want to
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1549
     allocate big chunks of data without disturbing foreground processes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1550
     too much. Such a process would check for fast-allocation, and perform
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1551
     incremental GC-steps if required. Thus, avoiding the long blocking pause 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1552
     due to a forced (non-incremental) GC. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1553
     Especially: doing so will not block higher priority foreground processes.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1554
     See an example use in Behavior>>niceBasicNew:.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1555
     This is experimental and not guaranteed to be in future versions."
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1556
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1557
%{  /* NOCONTEXT */
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1558
    extern int __checkForFastNew();
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1559
253
30daee717a53 *** empty log message ***
claus
parents: 229
diff changeset
  1560
    if (__isSmallInteger(amount)) {
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1561
	if (! __checkForFastNew(_intVal(amount))) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1562
	    RETURN (false);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1563
	}
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1564
    }
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1565
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1566
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1567
    ^ true
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1568
!
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1569
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1570
fastMoreOldSpaceAllocation:aBoolean
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1571
    "this method turns on/off fastMoreOldSpace allocation.
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1572
     By default, this is turned off (false), which means that in case of
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1573
     a filled-up oldSpace, a GC is tried first before more oldSpace is allocated. 
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1574
     This strategy is ok for the normal operation of the system,
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1575
     but behaves badly, if the program allocates huge data structures (say a
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1576
     game tree of 30Mb in size) which survives and therefore will not be reclaimed
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1577
     by a GC.
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1578
     Of course while building this tree, and the memory becomes full, the system 
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1579
     would not know in advance, that the GC will not reclaim anything.
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1580
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1581
     Setting fastOldSpaceIncrement to true will avoid this, by forcing the
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1582
     memory system to allocate more memory right away, without doing a GC first.
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1583
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1584
     WARNING: make certain that this flag is turned off, after your huge data
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1585
     is allocated, since otherwise the system may continue to increase its
202
40ca7cc6fb9c *** empty log message ***
claus
parents: 194
diff changeset
  1586
     virtual memory without ever checking for garbage.
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1587
     This method returns the previous value of the flag; typically this return
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1588
     value should be used to switch back."
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1589
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1590
%{   /* NOCONTEXT */
370
claus
parents: 369
diff changeset
  1591
     extern int __fastMoreOldSpaceAllocation();
claus
parents: 369
diff changeset
  1592
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1593
     RETURN (__fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false);
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1594
%}
310
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1595
    "
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1596
     |previousSetting|
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1597
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1598
     previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true.
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1599
     [
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1600
	...
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1601
	allocate your huge data
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1602
	...
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1603
     ] valueNoOrOnUnwindDo:[
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1604
	ObjectMemory fastMoreOldSpaceAllocation:previousSetting
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1605
     ]
fbfb977ae1bd *** empty log message ***
claus
parents: 308
diff changeset
  1606
    "
370
claus
parents: 369
diff changeset
  1607
claus
parents: 369
diff changeset
  1608
    "
claus
parents: 369
diff changeset
  1609
     |prev this|
claus
parents: 369
diff changeset
  1610
claus
parents: 369
diff changeset
  1611
     prev := ObjectMemory fastMoreOldSpaceAllocation:true.
claus
parents: 369
diff changeset
  1612
     ObjectMemory fastMoreOldSpaceAllocation:prev.
claus
parents: 369
diff changeset
  1613
     ^ prev
claus
parents: 369
diff changeset
  1614
    "
claus
parents: 369
diff changeset
  1615
!
claus
parents: 369
diff changeset
  1616
claus
parents: 369
diff changeset
  1617
fastMoreOldSpaceLimit:aNumber
claus
parents: 369
diff changeset
  1618
    "this method sets and returns the fastMoreOldSpace limit.
claus
parents: 369
diff changeset
  1619
     If fastMoreOldSpaceAllocation is true, and the current oldSpace size is
claus
parents: 369
diff changeset
  1620
     below this limit, the memory manager will NOT do a GC when running out of
claus
parents: 369
diff changeset
  1621
     oldSpace, but instead quickly go ahead increasing the size of the oldSpace.
claus
parents: 369
diff changeset
  1622
     Setting the limit to 0 turns off any limit (i.e. it will continue to
claus
parents: 369
diff changeset
  1623
     increase the oldSpace forwever - actually, until the OS refuses to give us
claus
parents: 369
diff changeset
  1624
     more memory). The returned value is the previous setting of the limit."
claus
parents: 369
diff changeset
  1625
claus
parents: 369
diff changeset
  1626
%{   /* NOCONTEXT */
claus
parents: 369
diff changeset
  1627
     extern int __fastMoreOldSpaceLimit();
claus
parents: 369
diff changeset
  1628
claus
parents: 369
diff changeset
  1629
     if (__isSmallInteger(aNumber)) {
claus
parents: 369
diff changeset
  1630
	 RETURN ( __MKSMALLINT( __fastMoreOldSpaceLimit(__intVal(aNumber))));
claus
parents: 369
diff changeset
  1631
     }
claus
parents: 369
diff changeset
  1632
%}.
claus
parents: 369
diff changeset
  1633
     self primitiveFailed
claus
parents: 369
diff changeset
  1634
    
claus
parents: 369
diff changeset
  1635
    "
claus
parents: 369
diff changeset
  1636
     |prev this|
claus
parents: 369
diff changeset
  1637
claus
parents: 369
diff changeset
  1638
     prev := ObjectMemory fastMoreOldSpaceLimit:10*1024*1024.
claus
parents: 369
diff changeset
  1639
     ObjectMemory fastMoreOldSpaceLimit:prev.
claus
parents: 369
diff changeset
  1640
     ^ prev
claus
parents: 369
diff changeset
  1641
    "
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1642
!
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1643
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1644
freeSpaceGCAmount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1645
    "return the amount to be allocated if, after an incrementalGC,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1646
     not at least FreeSpaceGCLimit bytes are available for allocation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1647
     The default is nil, which lets the system compute an abbpropriate value"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1648
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1649
    ^ FreeSpaceGCAmount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1650
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1651
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1652
     ObjectMemory freeSpaceGCAmount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1653
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1654
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1655
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1656
freeSpaceGCAmount:aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1657
    "set the amount to be allocated if, after an incrementalGC,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1658
     not at least FreeSpaceGCLimit bytes are available for allocation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1659
     The amount should be greater than the limit, otherwise the incremental
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1660
     GC may try over and over to get the memory (actually waisting time)."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1661
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1662
    FreeSpaceGCAmount := aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1663
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1664
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1665
     the following will try to always keep at least 1meg of free space
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1666
     (in the background) and start to do so, whenever the freeSpace drops
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1667
     below 250k.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1668
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1669
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1670
     ObjectMemory freeSpaceGCLimit:250000.  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1671
     ObjectMemory freeSpaceGCAmount:1000000.  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1672
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1673
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1674
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1675
     turn it off (i.e. let the system  compute an appropriate amount ...)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1676
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1677
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1678
     ObjectMemory freeSpaceGCAmount:nil.     
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1679
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1680
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1681
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1682
freeSpaceGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1683
    "return the freeSpace limit for incremental GC activation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1684
     The system will start doing incremental background GC, once less than this number 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1685
     of bytes are available in the compact free space.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1686
     The default is 100000; setting it to nil will turn this trigger off."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1687
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1688
    ^ FreeSpaceGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1689
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1690
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1691
     ObjectMemory freeSpaceGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1692
    "
133
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1693
!
433d44af1630 more GC control
claus
parents: 93
diff changeset
  1694
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1695
freeSpaceGCLimit:aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1696
    "set the freeSpace limit for incremental GC activation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1697
     The system will start doing incremental background GC, once less than this number 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1698
     of bytes are available for allocation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1699
     The default is nil; setting it to nil will turn this trigger off."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1700
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1701
    FreeSpaceGCLimit := aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1702
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1703
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1704
     the following will start the incrementalGC (in the background)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1705
     whenever the freeSpace drops below 1meg of free space
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1706
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1707
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1708
     ObjectMemory freeSpaceGCLimit:1000000.  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1709
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1710
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1711
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1712
     turn it off (i.e. let the system hit the wall ...)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1713
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1714
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1715
     ObjectMemory freeSpaceGCLimit:nil.     
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1716
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1717
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1718
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1719
incrementalGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1720
    "return the  allocatedSinceLastGC limit for incremental GC activation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1721
     The system will start doing incremental background GC, once more than this number 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1722
     of bytes have been allocated since the last GC. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1723
     The default is 500000; setting it to nil will turn this trigger off."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1724
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1725
    ^ IncrementalGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1726
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1727
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1728
     ObjectMemory incrementalGCLimit
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1729
    "
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1730
!
85
claus
parents: 77
diff changeset
  1731
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1732
incrementalGCLimit:aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1733
    "set the allocatedSinceLastGC limit for incremental GC activation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1734
     The system will start doing incremental background GC, once more than this number 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1735
     of bytes have been allocated since the last GC. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1736
     The default is 500000; setting it to nil will turn this trigger off."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1737
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1738
    IncrementalGCLimit := aNumber
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1739
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1740
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1741
     ObjectMemory incrementalGCLimit:500000.  'do incr. GC very seldom'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1742
     ObjectMemory incrementalGCLimit:100000.  'medium'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1743
     ObjectMemory incrementalGCLimit:10000.   'do incr. GC very often'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1744
     ObjectMemory incrementalGCLimit:nil.     'never'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1745
    "
370
claus
parents: 369
diff changeset
  1746
!
claus
parents: 369
diff changeset
  1747
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1748
lockTenure:flag
370
claus
parents: 369
diff changeset
  1749
    "set/clear the tenureLock. If the lock is set, the system
claus
parents: 369
diff changeset
  1750
     completely turns off tenuring, and objects remain in newSpace (forever).
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1751
     Once this lock is set, the system operates only in the newSpace and no memory 
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1752
     allocations from oldSpace are allowed (except for explicit tenure calls). 
370
claus
parents: 369
diff changeset
  1753
     If any allocation request cannot be resoved, the VM raises a memory interrupt,
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1754
     clears the lockTenure-flag and returns nil. Thus, it automatically falls back into
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1755
     the normal mode of operation, to avoid big trouble 
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1756
     (fail to allocate memory when handling the exception).
370
claus
parents: 369
diff changeset
  1757
claus
parents: 369
diff changeset
  1758
     This interface can be used in applications, which are guaranteed to have their
claus
parents: 369
diff changeset
  1759
     working set completely in the newSpace AND want to limit the worst case
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1760
     pause times to the worst case scavenge time 
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1761
     (which itself is limitd by the size of the newSpace). 
370
claus
parents: 369
diff changeset
  1762
     I.e. systems which go into some event loop after initial startup,
claus
parents: 369
diff changeset
  1763
     may turn on the tenureLock to make certain that no oldSpace memory is 
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1764
     allocated in the future; thereby limiting any GC activity to newSpace scavenges only.
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1765
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1766
     This is an EXPERIMENTAL interface.
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1767
    "
370
claus
parents: 369
diff changeset
  1768
claus
parents: 369
diff changeset
  1769
%{
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1770
    if (flag == true) {
370
claus
parents: 369
diff changeset
  1771
	__tenure(__context);
claus
parents: 369
diff changeset
  1772
    }
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1773
    __lockTenure(flag == true ? 1 : 0);
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1774
%}
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1775
!
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1776
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1777
makeOld:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1778
    "move anObject into oldSpace.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1779
     This method is for internal & debugging purposes only -
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1780
     it may vanish. Dont use it."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1781
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1782
    if (__moveToOldSpace(anObject, __context) < 0) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1783
	RETURN (false);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1784
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1785
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1786
    ^ true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1787
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1788
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1789
moreOldSpace:howMuch
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1790
    "allocate howMuch bytes more for old objects; return true if this worked,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1791
     false if that failed.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1792
     This is done automatically, when running out of space, but makes
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1793
     sense, if its known in advance that a lot of memory is needed to
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1794
     avoid multiple reallocations and compresses.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1795
     On systems which do not support the mmap (or equivalent) system call,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1796
     this (currently) implies a compressing garbage collect - so its slow.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1797
     Notice: this is a nonstandard interface - use only in special situations."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1798
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1799
%{  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1800
    if (__isSmallInteger(howMuch)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1801
	RETURN( __moreOldSpace(__context, _intVal(howMuch)) ? true : false );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1802
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1803
    RETURN (false);
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1804
%}
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1805
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1806
     ObjectMemory moreOldSpace:1000000
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1807
    "
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1808
!
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  1809
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1810
moreOldSpaceIfUseful
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1811
    "to be called after an incremental GC cycle;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1812
     if freeSpace is still below limit, allocate more oldSpace"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1813
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1814
    |limit free amount|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1815
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1816
    limit := FreeSpaceGCLimit.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1817
    limit notNil ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1818
	"/ if reclaimed space is below limit, we have to allocate more
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1819
	"/ oldSpace, to avoid excessive gcSteps (due to freeSpaceLimit 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1820
	"/ still not reached)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1821
	"/
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1822
	free := self freeSpace + self freeListSpace.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1823
	free < (limit * 3 // 2) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1824
	    amount := FreeSpaceGCAmount.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1825
	    amount isNil ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1826
		amount := limit * 3 // 2.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1827
	    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1828
	    'OBJECTMEMORY: moreOldSpace to satisfy free-limit' infoPrintNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1829
	    (self moreOldSpace:(amount - free + (64*1024))) ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1830
		"/
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1831
		"/ could not increase oldspace; reset FreeSpaceGCLimit to avoid
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1832
		"/ useless retries
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1833
		'OBJECTMEMORY: could not increase oldSpace - reset limit' errorPrintNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1834
		FreeSpaceGCLimit := nil
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1835
	    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1836
	].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1837
    ].
370
claus
parents: 369
diff changeset
  1838
!
claus
parents: 369
diff changeset
  1839
claus
parents: 369
diff changeset
  1840
newSpaceSize:newSize
claus
parents: 369
diff changeset
  1841
    "change the size of the newSpace. To do this, the current contents
claus
parents: 369
diff changeset
  1842
     of the newSpace may have to be tenured (if size is smaller).
claus
parents: 369
diff changeset
  1843
     Returns false, if it failed for any reason.
claus
parents: 369
diff changeset
  1844
     Experimental: this interface may valish without notice.
claus
parents: 369
diff changeset
  1845
claus
parents: 369
diff changeset
  1846
     DANGER ALERT:
claus
parents: 369
diff changeset
  1847
	be careful too big of a size may lead to longer scavenge pauses.
claus
parents: 369
diff changeset
  1848
	Too small of a newSpace may lead to more CPU overhead, due to
claus
parents: 369
diff changeset
  1849
	excessive scavenges. You have been warned."
claus
parents: 369
diff changeset
  1850
claus
parents: 369
diff changeset
  1851
%{  
claus
parents: 369
diff changeset
  1852
    extern int __setNewSpaceSize();
claus
parents: 369
diff changeset
  1853
claus
parents: 369
diff changeset
  1854
    if (__isSmallInteger(newSize)) {
claus
parents: 369
diff changeset
  1855
	RETURN (__setNewSpaceSize(__intVal(newSize)) ? true : false);
claus
parents: 369
diff changeset
  1856
    }
claus
parents: 369
diff changeset
  1857
%}.
claus
parents: 369
diff changeset
  1858
    self primitiveFailed
claus
parents: 369
diff changeset
  1859
claus
parents: 369
diff changeset
  1860
    " less absolute CPU overhead (but longer pauses):
claus
parents: 369
diff changeset
  1861
claus
parents: 369
diff changeset
  1862
     ObjectMemory newSpaceSize:800*1024
claus
parents: 369
diff changeset
  1863
    "
claus
parents: 369
diff changeset
  1864
claus
parents: 369
diff changeset
  1865
    " smaller pauses, but more overall CPU overhead:
claus
parents: 369
diff changeset
  1866
claus
parents: 369
diff changeset
  1867
     ObjectMemory newSpaceSize:200*1024
claus
parents: 369
diff changeset
  1868
    "
claus
parents: 369
diff changeset
  1869
claus
parents: 369
diff changeset
  1870
    " the default:
claus
parents: 369
diff changeset
  1871
claus
parents: 369
diff changeset
  1872
     ObjectMemory newSpaceSize:400*1024
claus
parents: 369
diff changeset
  1873
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1874
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1875
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1876
oldSpaceCompressLimit:amount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1877
    "set the limit for oldSpace compression. If more memory than this
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1878
     limit is in use, the system will not perform compresses on the oldspace,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1879
     but instead do a mark&sweep GC followed by an oldSpace increase if not enough
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1880
     could be reclaimed. The default is currently some 8Mb, which is ok for workstations
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1881
     with 16..32Mb of physical memory. If your system has much more physical RAM,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1882
     you may want to increase this limit.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1883
     This method returns the previous increment value."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1884
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1885
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1886
    extern unsigned __compressingGCLimit();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1887
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1888
    if (__isSmallInteger(amount)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1889
	RETURN (_MKSMALLINT( __compressingGCLimit(_intVal(amount)) ));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1890
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1891
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1892
    "to change the limit to 12Mb:"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1893
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1894
     ObjectMemory oldSpaceCompressLimit:12*1024*1024
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1895
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1896
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1897
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1898
oldSpaceIncrement
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1899
    "return the oldSpaceIncrement value. Thats the amount by which
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1900
     more memory is allocated in case the oldSpace gets filled up.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1901
     In normal situations, the default value used in the VM is fine
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1902
     and there is no need to change it."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1903
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1904
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1905
    extern unsigned __oldSpaceIncrement();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1906
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1907
    RETURN (_MKSMALLINT( __oldSpaceIncrement(-1) )); 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1908
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1909
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1910
     ObjectMemory oldSpaceIncrement
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1911
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1912
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1913
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1914
oldSpaceIncrement:amount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1915
    "set the oldSpaceIncrement value. Thats the amount by which
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1916
     more memory is allocated in case the oldSpace gets filled up.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1917
     In normal situations, the default value used in the VM is fine
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1918
     and there is no need to change it. This method returns the 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1919
     previous increment value."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1920
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1921
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1922
    extern unsigned __oldSpaceIncrement();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1923
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1924
    if (__isSmallInteger(amount)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1925
	RETURN (_MKSMALLINT( __oldSpaceIncrement(_intVal(amount)) )); 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1926
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1927
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1928
    "to change increment to 1Meg:"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1929
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1930
     ObjectMemory oldSpaceIncrement:1024*1024
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1931
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1932
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1933
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1934
tenureParameters:magic
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1935
    "this is pure magic and not for public eyes ...
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1936
     This method allows fine tuning the scavenger internals,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1937
     in cooperation to some statistic & test programs.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1938
     It is undocumented, secret and may vanish. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1939
     If you play around here, the system may behave very strange."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1940
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1941
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1942
    __tenureParams(magic);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1943
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1944
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1945
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1946
turnGarbageCollectorOff
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1947
    "turn off the generational garbage collector by forcing new objects to be
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1948
     allocated directly in oldSpace (instead of newSpace)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1949
     WARNING:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1950
     This is somewhat dangerous: if collector is turned off,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1951
     and too many objects are created, the system may run into trouble
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1952
     (i.e. oldSpace becomes full) and be forced to perform a full mark&sweep
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1953
     or even a compressing collect - making the overall realtime behavior worse.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1954
     Use this only for special purposes or when realtime behavior
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1955
     is required for a limited time period.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1956
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1957
     OBSOLETE: this is no longer supported 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1958
	       - it may be a no-operation by the time you read this."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1959
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1960
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1961
    __allocForceSpace(OLDSPACE);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1962
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1963
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1964
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1965
turnGarbageCollectorOn
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1966
    "turn garbage collector on again (see ObjectMemory>>turnGarbageCollectorOff)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1967
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1968
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1969
    __allocForceSpace(9999);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1970
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1971
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1972
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1973
watchTenure:flag
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1974
    "set/clear the tenureWatch. If set, an internalError exception will be raised,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1975
     whenever objects are tenured from newSpace into oldSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1976
     (except for an explicit tenure request). 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1977
     This can be used to validate that no oldSpace objects are created
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1978
     (i.e. the system operates fully in newSpace). 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1979
     Be careful, if the avoidTenure flag is not set, 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1980
     there will almost always be a tenure sooner or later.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1981
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1982
    EXPERIMENTAL - no warranty"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1983
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1984
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1985
    __watchTenure(flag == true ? 1 : 0);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1986
%}
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1987
! !
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  1988
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1989
!ObjectMemory class methodsFor:'interrupt handler access'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1990
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1991
childSignalInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1992
    "return the handler for UNIX-death-of-a-childprocess-signal interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1993
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1994
    ^ ChildSignalInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1995
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1996
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1997
customInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1998
    "return the handler for custom interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  1999
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2000
    ^ CustomInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2001
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2002
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2003
customInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2004
    "set the handler for custom interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2005
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2006
    CustomInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2007
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2008
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2009
disposeInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2010
    "return the handler for object disposal interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2011
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2012
    ^ DisposeInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2013
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2014
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2015
disposeInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2016
    "set the handler for object disposal interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2017
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2018
    DisposeInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2019
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2020
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2021
errorInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2022
    "return the handler for display error interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2023
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2024
    ^ ErrorInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2025
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2026
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2027
errorInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2028
    "set the handler for display error interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2029
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2030
    ErrorInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2031
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2032
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2033
exceptionInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2034
    "return the handler for floating point exception interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2035
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2036
    ^ ExceptionInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2037
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2038
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2039
internalErrorHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2040
    "return the handler for ST/X internal errors.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2041
     An internal error is reported for example when a methods
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2042
     bytecode is not a ByteArray, the selector table is not an Array
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2043
     etc.  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2044
     Those should not occur in normal circumstances."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2045
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2046
    ^ InternalErrorHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2047
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2048
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2049
ioInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2050
    "return the handler for I/O available signal interrupts (SIGIO/SIGPOLL)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2051
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2052
    ^ IOInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2053
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2054
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2055
ioInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2056
    "set the handler for I/O available signal interrupts (SIGIO/SIGPOLL)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2057
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2058
    IOInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2059
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2060
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2061
recursionInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2062
    "return the handler for recursion/stack overflow interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2063
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2064
    ^ RecursionInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2065
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2066
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2067
recursionInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2068
    "set the handler for recursion/stack overflow interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2069
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2070
    RecursionInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2071
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2072
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2073
registerErrorInterruptHandler:aHandler forID:errorIDSymbol
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2074
    "register a handler"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2075
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2076
    RegisteredErrorInterruptHandlers isNil ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2077
	RegisteredErrorInterruptHandlers := IdentityDictionary new
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2078
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2079
    RegisteredErrorInterruptHandlers at:errorIDSymbol put:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2080
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2081
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2082
registeredErrorInterruptHandlers
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2083
    "return registered handlers"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2084
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2085
    ^ RegisteredErrorInterruptHandlers
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2086
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2087
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2088
signalInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2089
    "return the handler for UNIX-signal interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2090
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2091
    ^ SignalInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2092
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2093
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2094
signalInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2095
    "set the handler for UNIX-signal interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2096
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2097
    SignalInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2098
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2099
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2100
spyInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2101
    "return the handler for spy-timer interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2102
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2103
    ^ SpyInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2104
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2105
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2106
spyInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2107
    "set the handler for spy-timer interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2108
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2109
    SpyInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2110
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2111
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2112
stepInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2113
    "return the handler for single step interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2114
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2115
    ^ StepInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2116
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2117
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2118
stepInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2119
    "set the handler for single step interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2120
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2121
    StepInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2122
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2123
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2124
timerInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2125
    "return the handler for timer interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2126
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2127
    ^ TimerInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2128
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2129
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2130
timerInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2131
    "set the handler for timer interrupts"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2132
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2133
    TimerInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2134
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2135
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2136
userInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2137
    "return the handler for CNTL-C interrupt handling"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2138
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2139
    ^ UserInterruptHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2140
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2141
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2142
userInterruptHandler:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2143
    "set the handler for CNTL-C interrupt handling"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2144
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2145
    UserInterruptHandler := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2146
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2147
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2148
!ObjectMemory class methodsFor:'interrupt statistics'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2149
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2150
interruptLatency:ms receiver:rec class:cls selector:sel vmActivity:vmActivity
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2151
    "example implementation of latencyTime monitoring:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2152
     This method simply measures the max-latency time.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2153
     You may want to use some other handler (see #interruptLatencyMonitor:)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2154
     and extract more information (blocking context).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2155
     DEMO Example."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2156
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2157
    ms > MaxInterruptLatency ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2158
	MaxInterruptLatency := ms.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2159
	'IRQ-LATENCY: ' infoPrint. rec class infoPrint. ' ' infoPrint. sel infoPrint. '(' infoPrint. vmActivity infoPrint . ') ---> ' infoPrint. ms infoPrintNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2160
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2161
    (InterruptLatencyGoal notNil and:[ms > InterruptLatencyGoal]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2162
	'*** IRQ REALTIME-DEADLINE MISSED: ' errorPrint. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2163
	rec isBehavior ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2164
	    rec name errorPrint. 'class' errorPrint.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2165
	] ifFalse:[     
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2166
	    rec class errorPrint
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2167
	].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2168
	' ' errorPrint. sel errorPrint. '(' errorPrint. vmActivity errorPrint . ') ---> ' errorPrint. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2169
	ms errorPrintNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2170
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2171
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2172
    "to enable the demo handler:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2173
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2174
     ObjectMemory resetMaxInterruptLatency.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2175
     ObjectMemory interruptLatencyMonitor:ObjectMemory.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2176
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2177
    "to disable timing statistics:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2178
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2179
     ObjectMemory interruptLatencyMonitor:nil.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2180
     ObjectMemory maxInterruptLatency printNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2181
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2182
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2183
    "Created: 7.11.1995 / 21:05:50 / cg"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2184
    "Modified: 7.11.1995 / 21:13:33 / cg"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2185
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2186
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2187
interruptLatencyGoal:millis
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2188
    "setup to report an error message, whenever a realtime goal could not be
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2189
     met due to blocked interrupts or long primitives or GC activity.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2190
     An argument of nil clears the check.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2191
     DEMO Example."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2192
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2193
    InterruptLatencyGoal := millis.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2194
    millis isNil ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2195
	InterruptLatencyMonitor := nil.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2196
    ] ifFalse:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2197
	MaxInterruptLatency := 0.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2198
	InterruptLatencyMonitor := self.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2199
    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2200
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2201
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2202
     ObjectMemory interruptLatencyGoal:50
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2203
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2204
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2205
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2206
interruptLatencyMonitor
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2207
    "return the interrupt-latency-monitor if any. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2208
     See comment in #interruptLatencyMonitor:.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2209
     This is a non-standard debugging/realtime instrumentation entry."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2210
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2211
    ^ InterruptLatencyMonitor
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2212
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2213
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2214
interruptLatencyMonitor:aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2215
    "set the interrupt latency monitor. If non-nil, this one will be sent
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2216
     an interruptLatency: message with the millisecond delay between
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2217
     the interrupt and its handling.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2218
     This is a non-standard debugging/realtime instrumentation entry."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2219
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2220
    InterruptLatencyMonitor := aHandler
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2221
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2222
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2223
maxInterruptLatency
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2224
    "return the maximum accumulated interrupt latency in millis.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2225
     DEMO Example."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2226
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2227
    ^ MaxInterruptLatency
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2228
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2229
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2230
resetMaxInterruptLatency
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2231
    "reset the maximum accumulated interrupt latency probe time.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2232
     DEMO Example."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2233
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2234
    MaxInterruptLatency := 0
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2235
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2236
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2237
!ObjectMemory class methodsFor:'low memory handling'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2238
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2239
memoryInterrupt
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2240
    "when a low-memory condition arises, ask all classes to
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2241
     remove possibly cached data. You may help the system a bit,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2242
     in providing a lowSpaceCleanup method in your classes which have
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2243
     lots of data kept somewhere (usually, cached data).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2244
     - this may or may not help."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2245
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2246
    Smalltalk allBehaviorsDo:[:aClass |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2247
	aClass lowSpaceCleanup
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2248
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2249
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2250
"/    self error:'almost out of memory'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2251
    'almost out of memory' errorPrintNL.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2252
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2253
    LowSpaceSemaphore signalIf.
362
claus
parents: 360
diff changeset
  2254
! !
claus
parents: 360
diff changeset
  2255
claus
parents: 360
diff changeset
  2256
!ObjectMemory class methodsFor:'object finalization'!
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2257
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2258
allChangedShadowObjectsDo:aBlock
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2259
    "evaluate the argument, aBlock for all known shadow objects which have
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2260
     lost a pointer recently."
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2261
%{
326
d2902942491d *** empty log message ***
claus
parents: 325
diff changeset
  2262
    __allChangedShadowObjectsDo(&aBlock COMMA_CON);
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2263
%}
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2264
!
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2265
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2266
disposeInterrupt
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2267
    "this is triggered by the garbage collector,
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2268
     whenever any shadowArray looses a pointer."
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2269
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2270
    FinalizationSemaphore notNil ifTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2271
	"/
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2272
	"/ background finalizer is waiting ...
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2273
	"/
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2274
	FinalizationSemaphore signal
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2275
    ] ifFalse:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2276
	"/
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2277
	"/ do it right here
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2278
	"/
291
5e036c656524 *** empty log message ***
claus
parents: 290
diff changeset
  2279
	self finalize
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2280
    ]
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2281
!
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2282
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2283
finalize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2284
    "tell all weak objects that something happened."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2285
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2286
    self allChangedShadowObjectsDo:[:aShadowArray | 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2287
	aShadowArray lostPointer.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2288
    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2289
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2290
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2291
startBackgroundFinalizationAt:aPriority
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2292
    "start a process doing finalization work in the background.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2293
     Can be used to reduce the pauses created by finalization.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2294
     Normally, these pauses are not noticed; however if you have (say)
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2295
     ten thousands of weak objects, these could become long enough to
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2296
     make background finalization usefull.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2297
     WARNING: background finalization may lead to much delayed freeing of
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2298
     system resources. Especially, you may temporarily run out of free
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2299
     color table entries or fileDescriptors etc. Use at your own risk (if at all)"
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2300
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2301
    |p|
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2302
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2303
    "/
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2304
    "/ its not useful, to run it more than once
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2305
    "/
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2306
    BackgroundFinalizationProcess notNil ifTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2307
	BackgroundFinalizationProcess priority:aPriority.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2308
	^ self
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2309
    ].
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2310
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2311
    FinalizationSemaphore := Semaphore new.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2312
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2313
    p :=
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2314
	[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2315
	    [
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2316
		[true] whileTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2317
		    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2318
		     wait till something to do ...
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2319
		    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2320
		    FinalizationSemaphore wait.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2321
		    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2322
		     ... and do it
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2323
		    "
291
5e036c656524 *** empty log message ***
claus
parents: 290
diff changeset
  2324
		    self finalize
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2325
		]
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2326
	    ] valueOnUnwindDo:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2327
		BackgroundFinalizationProcess := nil.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2328
		FinalizationSemaphore := nil
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2329
	    ]
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2330
	] newProcess.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2331
    p name:'background finalizer'.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2332
    p priority:aPriority.
339
claus
parents: 335
diff changeset
  2333
    p restartable:true.
290
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2334
    p resume.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2335
    BackgroundFinalizationProcess := p
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2336
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2337
    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2338
     ObjectMemory startBackgroundFinalizationAt:5
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2339
    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2340
!
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2341
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2342
stopBackgroundFinalization
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2343
    "stop the background finalizer"
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2344
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2345
    BackgroundFinalizationProcess notNil ifTrue:[
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2346
	BackgroundFinalizationProcess terminate.
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2347
	BackgroundFinalizationProcess := nil
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2348
    ].
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2349
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2350
    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2351
     ObjectMemory stopBackgroundFinalization
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2352
    "
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2353
! !
23994c0a7f7b *** empty log message ***
claus
parents: 282
diff changeset
  2354
178
4da1b10bf42c more GC control
claus
parents: 159
diff changeset
  2355
!ObjectMemory class methodsFor:'physical memory access'!
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2356
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2357
collectedOldSpacePagesDo:aBlock
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2358
    "evaluates aBlock for all pages in the prev. oldSpace, passing
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2359
     the pages address as argument. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2360
     For internal & debugging use only."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2361
%{
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2362
    if (__collectedOldSpacePagesDo(&aBlock COMMA_CON) < 0) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2363
	RETURN (false);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2364
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2365
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2366
    ^ true
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2367
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2368
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2369
newSpacePagesDo:aBlock
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2370
    "evaluates aBlock for all pages in the newSpace, passing
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2371
     the pages address as argument.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2372
     For internal & debugging use only."
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2373
%{
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2374
    if (__newSpacePagesDo(&aBlock COMMA_CON) < 0) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  2375
	RETURN (false);
85
claus
parents: 77
diff changeset
  2376
    }
claus
parents: 77
diff changeset
  2377
%}.
claus
parents: 77
diff changeset
  2378
    ^ true
claus
parents: 77
diff changeset
  2379
!
claus
parents: 77
diff changeset
  2380
claus
parents: 77
diff changeset
  2381
oldSpacePagesDo:aBlock
claus
parents: 77
diff changeset
  2382
    "evaluates aBlock for all pages in the oldSpace, passing
claus
parents: 77
diff changeset
  2383
     the pages address as argument. 
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2384
     For internal & debugging use only."
85
claus
parents: 77
diff changeset
  2385
%{
claus
parents: 77
diff changeset
  2386
    if (__oldSpacePagesDo(&aBlock COMMA_CON) < 0) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  2387
	RETURN (false);
85
claus
parents: 77
diff changeset
  2388
    }
claus
parents: 77
diff changeset
  2389
%}.
claus
parents: 77
diff changeset
  2390
    ^ true
claus
parents: 77
diff changeset
  2391
!
claus
parents: 77
diff changeset
  2392
claus
parents: 77
diff changeset
  2393
pageIsInCore:aPageNumber
claus
parents: 77
diff changeset
  2394
    "return true, if the page (as enumerated via oldSpacePagesDo:)
claus
parents: 77
diff changeset
  2395
     is in memory; false, if currently paged out. For internal
93
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2396
     use / monitors only; may vanish.
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2397
     NOTICE: not all systems provide this information; on those that
e31220cb391f *** empty log message ***
claus
parents: 88
diff changeset
  2398
     do not, true is returned for all pages."
85
claus
parents: 77
diff changeset
  2399
%{
claus
parents: 77
diff changeset
  2400
#ifdef HAS_MINCORE
claus
parents: 77
diff changeset
  2401
    int pageSize = getpagesize();
claus
parents: 77
diff changeset
  2402
    char result[10];
claus
parents: 77
diff changeset
  2403
    INT addr;
claus
parents: 77
diff changeset
  2404
253
30daee717a53 *** empty log message ***
claus
parents: 229
diff changeset
  2405
    if (__isSmallInteger(aPageNumber)) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  2406
	addr = _intVal(aPageNumber) & ~(pageSize - 1);
85
claus
parents: 77
diff changeset
  2407
    } else {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  2408
	addr = ((INT)aPageNumber) & ~(pageSize - 1);
85
claus
parents: 77
diff changeset
  2409
    }
claus
parents: 77
diff changeset
  2410
    if (mincore(addr, pageSize-1, result) < 0) {
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  2411
	RETURN (true);
85
claus
parents: 77
diff changeset
  2412
    }
claus
parents: 77
diff changeset
  2413
    RETURN ((result[0] & 1) ? true : false);
claus
parents: 77
diff changeset
  2414
#endif
claus
parents: 77
diff changeset
  2415
%}.
claus
parents: 77
diff changeset
  2416
    "OS does not supply this info - assume yes"
claus
parents: 77
diff changeset
  2417
    ^ true
claus
parents: 77
diff changeset
  2418
! !
claus
parents: 77
diff changeset
  2419
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2420
!ObjectMemory class methodsFor:'queries'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2421
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2422
bytesUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2423
    "return the number of bytes allocated for objects -
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2424
     this number is not exact, since some objects may already be dead
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2425
     (i.e. not yet reclaimed by the garbage collector).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2426
     If you need the exact number, you have to loop over all
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2427
     objects and ask for the bytesize using ObjectMemory>>sizeOf:."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2428
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2429
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2430
    extern unsigned __oldSpaceUsed(), __newSpaceUsed(), __freeListSpace();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2431
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2432
    RETURN ( _MKSMALLINT(__oldSpaceUsed() + __newSpaceUsed() - __freeListSpace()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2433
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2434
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2435
     ObjectMemory bytesUsed  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2436
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2437
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2438
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2439
collectObjectsWhich:aBlock
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2440
    "helper for the whoReferences queries. Returns a collection
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2441
     of objects for which aBlock returns true."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2442
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2443
    |aCollection|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2444
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2445
    aCollection := IdentitySet new.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2446
    self allObjectsDo:[:o |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2447
	(aBlock value:o) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2448
	    aCollection add:o
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2449
	]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2450
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2451
    (aCollection size == 0) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2452
	"actually this cannot happen - there is always one"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2453
	^ nil
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2454
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2455
    ^ aCollection
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2456
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2457
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2458
fixSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2459
    "return the total size of the fix space."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2460
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2461
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2462
    extern unsigned __fixSpaceSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2463
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2464
    RETURN ( _MKSMALLINT(__fixSpaceSize()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2465
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2466
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2467
     ObjectMemory fixSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2468
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2469
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2470
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2471
fixSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2472
    "return the number of bytes allocated for old objects in fix space."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2473
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2474
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2475
    extern unsigned __fixSpaceUsed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2476
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2477
    RETURN ( _MKSMALLINT(__fixSpaceUsed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2478
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2479
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2480
     ObjectMemory fixSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2481
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2482
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2483
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2484
freeListSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2485
    "return the number of bytes in the free lists.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2486
     (which is included in oldSpaceUsed)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2487
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2488
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2489
    extern unsigned __freeListSpace();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2490
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2491
    RETURN ( _MKSMALLINT(__freeListSpace()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2492
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2493
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2494
     ObjectMemory freeListSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2495
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2496
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2497
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2498
freeSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2499
    "return the number of bytes in the compact free area.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2500
     (oldSpaceUsed + freeSpaceSize = oldSpaceSize)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2501
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2502
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2503
    extern unsigned __oldSpaceSize(), __oldSpaceUsed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2504
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2505
    RETURN ( _MKSMALLINT(__oldSpaceSize() - __oldSpaceUsed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2506
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2507
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2508
     ObjectMemory freeSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2509
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2510
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2511
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2512
garbageCollectCount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2513
    "return the number of compressing collects that occurred since startup"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2514
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2515
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2516
    extern int __garbageCollectCount();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2517
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2518
    RETURN (_MKSMALLINT(__garbageCollectCount()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2519
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2520
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2521
     ObjectMemory garbageCollectCount 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2522
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2523
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2524
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2525
incrementalGCCount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2526
    "return the number of incremental collects that occurred since startup"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2527
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2528
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2529
    extern int __incrementalGCCount();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2530
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2531
    RETURN (_MKSMALLINT(__incrementalGCCount()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2532
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2533
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2534
     ObjectMemory incrementalGCCount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2535
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2536
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2537
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2538
incrementalGCPhase
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2539
    "returns the internal state of the incremental GC.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2540
     The meaning of those numbers is a secret :-).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2541
     (for the curious: (currently)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2542
      2 is idle, 3..11 are various mark phases,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2543
      12 is the sweep phase. 0 and 1 are cleanup phases when the
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2544
      incr. GC gets interrupted by a full GC).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2545
     Do not depend on the values - there may be additional phases in
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2546
     future versions (incremental compact ;-).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2547
     This is for debugging and monitoring only - and may change or vanish"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2548
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2549
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2550
    extern int __incrGCphase();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2551
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2552
    RETURN (_MKSMALLINT(__incrGCphase()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2553
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2554
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2555
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2556
lastScavengeReclamation
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2557
    "returns the number of bytes replacimed by the last scavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2558
     For statistic only - this may vanish."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2559
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2560
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2561
    extern int __newSpaceReclaimed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2562
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2563
    RETURN ( _MKSMALLINT(__newSpaceReclaimed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2564
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2565
    "percentage of reclaimed objects is returned by:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2566
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2567
     ((ObjectMemory lastScavengeReclamation)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2568
      / (ObjectMemory newSpaceSize)) * 100.0  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2569
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2570
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2571
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2572
lifoRememberedSet
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2573
    "return the lifoRemSet.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2574
     This is pure VM debugging and will vanish without notice."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2575
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2576
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2577
    extern OBJ __lifoRememberedSet();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2578
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2579
    RETURN ( __lifoRememberedSet() );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2580
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2581
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2582
     ObjectMemory lifoRememberedSet
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2583
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2584
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2585
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2586
lifoRememberedSetSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2587
    "return the size of the lifoRemSet.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2588
     This is a VM debugging interface and may vanish without notice."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2589
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2590
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2591
    extern int __lifoRememberedSetSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2592
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2593
    RETURN (_MKSMALLINT(__lifoRememberedSetSize()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2594
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2595
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2596
     ObjectMemory lifoRememberedSetSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2597
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2598
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2599
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2600
markAndSweepCount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2601
    "return the number of mark&sweep collects that occurred since startup"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2602
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2603
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2604
    extern int __markAndSweepCount();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2605
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2606
    RETURN (_MKSMALLINT(__markAndSweepCount()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2607
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2608
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2609
     ObjectMemory markAndSweepCount 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2610
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2611
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2612
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2613
maximumIdentityHashValue
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2614
    "for ST-80 compatibility: return the maximum value
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2615
     a hashKey as returned by identityHash can get.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2616
     Since ST/X uses direct pointers, a field in the objectHeader
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2617
     is used, which is currently 11 bits in size."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2618
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2619
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2620
    RETURN ( __MKSMALLINT( __MAX_HASH__ << __HASH_SHIFT__) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2621
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2622
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2623
     ObjectMemory maximumIdentityHashValue
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2624
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2625
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2626
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2627
minScavengeReclamation
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2628
    "returns the number of bytes replacimed by the least effective scavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2629
     For statistic only - this may vanish."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2630
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2631
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2632
    extern int __newSpaceReclaimedMin();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2633
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2634
    RETURN ( _MKSMALLINT(__newSpaceReclaimedMin()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2635
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2636
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2637
     ObjectMemory minScavengeReclamation
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2638
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2639
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2640
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2641
newSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2642
    "return the total size of the new space - this is usually fix"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2643
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2644
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2645
    extern unsigned __newSpaceSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2646
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2647
    RETURN ( _MKSMALLINT(__newSpaceSize()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2648
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2649
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2650
     ObjectMemory newSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2651
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2652
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2653
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2654
newSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2655
    "return the number of bytes allocated for new objects.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2656
     The returned value is usually obsolete as soon as you do
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2657
     something with it ..."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2658
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2659
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2660
    extern unsigned __newSpaceUsed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2661
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2662
    RETURN ( _MKSMALLINT(__newSpaceUsed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2663
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2664
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2665
     ObjectMemory newSpaceUsed   
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2666
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2667
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2668
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2669
numberOfObjects
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2670
    "return the number of objects in the system."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2671
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2672
    |tally "{ Class: SmallInteger }"|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2673
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2674
    tally := 0.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2675
    self allObjectsDo:[:obj | tally := tally + 1].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2676
    ^ tally
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2677
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2678
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2679
     ObjectMemory numberOfObjects  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2680
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2681
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2682
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2683
numberOfWeakObjects
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2684
    "return the number of weak objects in the system"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2685
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2686
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2687
    extern int __weakListSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2688
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2689
    RETURN ( __MKSMALLINT(__weakListSize()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2690
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2691
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2692
     ObjectMemory numberOfWeakObjects
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2693
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2694
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2695
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2696
oldSpaceAllocatedSinceLastGC
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2697
    "return the number of bytes allocated for old objects since the
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2698
     last oldspace garbage collect occured. This information is used
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2699
     by ProcessorScheduler to decide when to start the incremental
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2700
     background GC."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2701
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2702
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2703
    extern unsigned __oldSpaceAllocatedSinceLastGC();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2704
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2705
    RETURN ( _MKSMALLINT(__oldSpaceAllocatedSinceLastGC()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2706
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2707
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2708
     ObjectMemory oldSpaceAllocatedSinceLastGC   
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2709
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2710
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2711
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2712
oldSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2713
    "return the total size of the old space. - may grow slowly"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2714
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2715
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2716
    extern unsigned __oldSpaceSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2717
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2718
    RETURN ( _MKSMALLINT(__oldSpaceSize()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2719
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2720
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2721
     ObjectMemory oldSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2722
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2723
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2724
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2725
oldSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2726
    "return the number of bytes allocated for old objects.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2727
     (This includes the free lists)"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2728
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2729
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2730
    extern unsigned __oldSpaceUsed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2731
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2732
    RETURN ( _MKSMALLINT(__oldSpaceUsed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2733
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2734
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2735
     ObjectMemory oldSpaceUsed  
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2736
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2737
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2738
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2739
rememberedSetSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2740
    "return the number of old objects referencing new ones.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2741
     This is a VM debugging interface and may vanish without notice."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2742
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2743
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2744
    extern int __rememberedSetSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2745
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2746
    RETURN (_MKSMALLINT(__rememberedSetSize()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2747
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2748
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2749
     ObjectMemory rememberedSetSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2750
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2751
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2752
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2753
resetMinScavengeReclamation
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2754
    "resets the number of bytes replacimed by the least effective scavenge.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2755
     For statistic only - this may vanish."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2756
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2757
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2758
    extern int __resetNewSpaceReclaimedMin();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2759
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2760
    __resetNewSpaceReclaimedMin();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2761
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2762
    ^ self
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2763
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2764
     ObjectMemory resetMinScavengeReclamation.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2765
     ObjectMemory minScavengeReclamation
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2766
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2767
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2768
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2769
runsSingleOldSpace
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2770
    "return true, if the system runs in a single oldSpace or
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2771
     false if not.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2772
     The memory system will always drop the second semispace when 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2773
     running out of virtual memory, or the baker-limit is reached.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2774
     OBSOLETE: 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2775
	 the system may now decide at any time to switch between
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2776
	 single and double-space algorithms, depending on the overall memory
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2777
	 size. You will now almost always get false as result, since the
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2778
	 second semispace is only allocated when needed, and released
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2779
	 immediately afterwards.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2780
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2781
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2782
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2783
    extern int __runsSingleOldSpace();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2784
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2785
    RETURN ( (__runsSingleOldSpace() ? true : false) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2786
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2787
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2788
     ObjectMemory runsSingleOldSpace 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2789
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2790
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2791
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2792
scavengeCount
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2793
    "return the number of scavenges that occurred since startup"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2794
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2795
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2796
    extern int __scavengeCount();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2797
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2798
    RETURN (_MKSMALLINT(__scavengeCount()));
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2799
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2800
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2801
     ObjectMemory scavengeCount 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2802
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2803
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2804
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2805
symSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2806
    "return the total size of the sym space."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2807
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2808
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2809
    extern unsigned __symSpaceSize();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2810
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2811
    RETURN ( _MKSMALLINT(__symSpaceSize()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2812
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2813
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2814
     ObjectMemory symSpaceSize
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2815
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2816
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2817
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2818
symSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2819
    "return the number of bytes allocated for old objects in sym space."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2820
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2821
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2822
    extern unsigned __symSpaceUsed();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2823
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2824
    RETURN ( _MKSMALLINT(__symSpaceUsed()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2825
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2826
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2827
     ObjectMemory symSpaceUsed
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2828
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2829
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2830
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2831
tenureAge
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2832
    "return the current tenure age - thats the number of times
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2833
     an object has to survive scavenges to be moved into oldSpace.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2834
     For statistic/debugging only - this method may vanish"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2835
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2836
%{  /* NOCONTEXT */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2837
    extern unsigned __tenureAge();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2838
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2839
    RETURN ( _MKSMALLINT(__tenureAge()) );
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2840
%}
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2841
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2842
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2843
whoReferences:anObject
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2844
    "return a collection of objects referencing the argument, anObject"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2845
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2846
    ^ self collectObjectsWhich:[:o | o references:anObject]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2847
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2848
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2849
     (ObjectMemory whoReferences:Transcript) printNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2850
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2851
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2852
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2853
whoReferencesDerivedInstancesOf:aClass
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2854
    "return a collection of objects refering to instances
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2855
     of the argument, aClass or a subclass of it."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2856
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2857
    ^ self collectObjectsWhich:[:o | o referencesDerivedInstanceOf:aClass]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2858
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2859
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2860
     (ObjectMemory whoReferencesDerivedInstancesOf:View) printNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2861
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2862
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2863
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2864
whoReferencesInstancesOf:aClass
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2865
    "return a collection of objects refering to instances
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2866
     of the argument, aClass"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2867
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2868
    ^ self collectObjectsWhich:[:o | o referencesInstanceOf:aClass]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2869
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2870
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2871
     (ObjectMemory whoReferencesInstancesOf:SystemBrowser) printNL
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2872
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2873
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2874
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2875
!ObjectMemory class methodsFor:'semaphore access'!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2876
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2877
lowSpaceSemaphore
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2878
    "return the semaphore that is signalled when the system detects a
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2879
     low space condition. Usually, some time after this, an allocationFailure
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2880
     will happen. You can have a cleanup process sitting in that semaphore and
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2881
     start to release object."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2882
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2883
    ^ LowSpaceSemaphore
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2884
! !
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  2885
379
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2886
!ObjectMemory class methodsFor:'statistics'!
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2887
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2888
ageStatistic
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2889
%{   /* NOCONTEXT */
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2890
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2891
    __ageStatistics();
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2892
%}
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2893
! !
5b5a130ccd09 revision added
claus
parents: 375
diff changeset
  2894
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2895
!ObjectMemory class methodsFor:'system management'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2896
418
claus
parents: 403
diff changeset
  2897
allBinaryModulesDo:aBlock
claus
parents: 403
diff changeset
  2898
    "internal private method - walk over all known binary
claus
parents: 403
diff changeset
  2899
     modules and evaluate aBlock for each entry.
claus
parents: 403
diff changeset
  2900
     Do not depend on the information returned for each - this may
claus
parents: 403
diff changeset
  2901
     change without notice."
claus
parents: 403
diff changeset
  2902
claus
parents: 403
diff changeset
  2903
%{
claus
parents: 403
diff changeset
  2904
    __REGISTRATION_DO_BLOCK(&aBlock COMMA_SND);
claus
parents: 403
diff changeset
  2905
%}
claus
parents: 403
diff changeset
  2906
!
claus
parents: 403
diff changeset
  2907
claus
parents: 403
diff changeset
  2908
binaryModuleInfo
claus
parents: 403
diff changeset
  2909
    "return a collection of moduleInfo entries.
claus
parents: 403
diff changeset
  2910
     This returns a dictionary (keys are internal moduleIDs)
claus
parents: 403
diff changeset
  2911
     with one entry for each binary package."
claus
parents: 403
diff changeset
  2912
claus
parents: 403
diff changeset
  2913
    |modules|
claus
parents: 403
diff changeset
  2914
claus
parents: 403
diff changeset
  2915
    modules := IdentityDictionary new.
claus
parents: 403
diff changeset
  2916
    self allBinaryModulesDo:[:entry | 
438
claus
parents: 435
diff changeset
  2917
	|id name type libName subModuleName module dynamic infoRec pathName
claus
parents: 435
diff changeset
  2918
	 typeName nameString|
418
claus
parents: 403
diff changeset
  2919
claus
parents: 403
diff changeset
  2920
	id := entry at:1.
claus
parents: 403
diff changeset
  2921
	subModuleName := (entry at:2) asSymbol.
claus
parents: 403
diff changeset
  2922
	libName := (entry at:4).
claus
parents: 403
diff changeset
  2923
claus
parents: 403
diff changeset
  2924
	id > 0 ifTrue:[
claus
parents: 403
diff changeset
  2925
	    pathName := ObjectFileLoader pathNameFromID:id.
claus
parents: 403
diff changeset
  2926
	    dynamic := true.
438
claus
parents: 435
diff changeset
  2927
	    typeName := 'dynamic '.
claus
parents: 435
diff changeset
  2928
	    name := pathName asFilename baseName
418
claus
parents: 403
diff changeset
  2929
	] ifFalse:[
claus
parents: 403
diff changeset
  2930
	    dynamic := false.
443
Claus Gittinger <cg@exept.de>
parents: 440
diff changeset
  2931
	    typeName := 'builtIn '.
418
claus
parents: 403
diff changeset
  2932
	    pathName := nil.
claus
parents: 403
diff changeset
  2933
	    libName isNil ifTrue:[
438
claus
parents: 435
diff changeset
  2934
		name := subModuleName
418
claus
parents: 403
diff changeset
  2935
	    ] ifFalse:[
438
claus
parents: 435
diff changeset
  2936
		name := libName
418
claus
parents: 403
diff changeset
  2937
	    ].
claus
parents: 403
diff changeset
  2938
	].
438
claus
parents: 435
diff changeset
  2939
	nameString := typeName.
claus
parents: 435
diff changeset
  2940
	libName isNil ifTrue:[
claus
parents: 435
diff changeset
  2941
	    nameString := nameString, 'module '
claus
parents: 435
diff changeset
  2942
	] ifFalse:[
claus
parents: 435
diff changeset
  2943
	    nameString := nameString, 'classLib '
claus
parents: 435
diff changeset
  2944
	].
claus
parents: 435
diff changeset
  2945
	nameString := nameString , name.
claus
parents: 435
diff changeset
  2946
418
claus
parents: 403
diff changeset
  2947
	libName isNil ifTrue:[
claus
parents: 403
diff changeset
  2948
	    type := #classObject
claus
parents: 403
diff changeset
  2949
	] ifFalse:[
claus
parents: 403
diff changeset
  2950
	    type := #classLibrary
claus
parents: 403
diff changeset
  2951
	].
claus
parents: 403
diff changeset
  2952
	infoRec := modules at:id ifAbsent:nil.
claus
parents: 403
diff changeset
  2953
	infoRec notNil ifTrue:[
claus
parents: 403
diff changeset
  2954
	    (infoRec at:#classNames) add:subModuleName
claus
parents: 403
diff changeset
  2955
	] ifFalse:[
claus
parents: 403
diff changeset
  2956
	    infoRec := IdentityDictionary new.
claus
parents: 403
diff changeset
  2957
	    infoRec at:#id put:id.
claus
parents: 403
diff changeset
  2958
	    infoRec at:#classNames put:(Set with:subModuleName).
claus
parents: 403
diff changeset
  2959
	    infoRec at:#pathName put:pathName.
438
claus
parents: 435
diff changeset
  2960
	    infoRec at:#name put:nameString.
418
claus
parents: 403
diff changeset
  2961
	    infoRec at:#libraryName put:libName.
claus
parents: 403
diff changeset
  2962
	    infoRec at:#dynamic put:dynamic.
claus
parents: 403
diff changeset
  2963
	    infoRec at:#type put:type.
claus
parents: 403
diff changeset
  2964
	    modules at:id put:infoRec.
claus
parents: 403
diff changeset
  2965
	].
claus
parents: 403
diff changeset
  2966
    ].
claus
parents: 403
diff changeset
  2967
    ^ modules
claus
parents: 403
diff changeset
  2968
claus
parents: 403
diff changeset
  2969
    "
claus
parents: 403
diff changeset
  2970
     ObjectMemory binaryModuleInfo
claus
parents: 403
diff changeset
  2971
    "
claus
parents: 403
diff changeset
  2972
438
claus
parents: 435
diff changeset
  2973
    "Modified: 17.9.1995 / 16:33:02 / claus"
418
claus
parents: 403
diff changeset
  2974
!
claus
parents: 403
diff changeset
  2975
claus
parents: 403
diff changeset
  2976
fullBinaryModuleInfo
claus
parents: 403
diff changeset
  2977
    "return a full collection of moduleInfo entries.
claus
parents: 403
diff changeset
  2978
     This returns a dictionary (keys are component names)
claus
parents: 403
diff changeset
  2979
     with one entry for each component in all binary packages."
claus
parents: 403
diff changeset
  2980
claus
parents: 403
diff changeset
  2981
    |modules|
claus
parents: 403
diff changeset
  2982
claus
parents: 403
diff changeset
  2983
    modules := IdentityDictionary new.
claus
parents: 403
diff changeset
  2984
    self allBinaryModulesDo:[:entry | 
claus
parents: 403
diff changeset
  2985
	|id name type libName subModuleName module dynamic infoRec pathName
claus
parents: 403
diff changeset
  2986
	 t|
claus
parents: 403
diff changeset
  2987
claus
parents: 403
diff changeset
  2988
	id := entry at:1.
claus
parents: 403
diff changeset
  2989
	subModuleName := (entry at:2) asSymbol.
claus
parents: 403
diff changeset
  2990
	libName := (entry at:4).
claus
parents: 403
diff changeset
  2991
	t := AbsoluteTime fromOSTime:(entry at:5).
claus
parents: 403
diff changeset
  2992
claus
parents: 403
diff changeset
  2993
	id > 0 ifTrue:[
claus
parents: 403
diff changeset
  2994
	    dynamic := true.
claus
parents: 403
diff changeset
  2995
	] ifFalse:[
claus
parents: 403
diff changeset
  2996
	    dynamic := false.
claus
parents: 403
diff changeset
  2997
	].
claus
parents: 403
diff changeset
  2998
	libName isNil ifTrue:[
claus
parents: 403
diff changeset
  2999
	    type := #classObject
claus
parents: 403
diff changeset
  3000
	] ifFalse:[
claus
parents: 403
diff changeset
  3001
	    type := #classLibrary
claus
parents: 403
diff changeset
  3002
	].
claus
parents: 403
diff changeset
  3003
	infoRec := IdentityDictionary new.
claus
parents: 403
diff changeset
  3004
	infoRec at:#id put:id.
claus
parents: 403
diff changeset
  3005
	infoRec at:#className put:subModuleName.
claus
parents: 403
diff changeset
  3006
	infoRec at:#libraryName put:libName.
claus
parents: 403
diff changeset
  3007
	infoRec at:#dynamic put:dynamic.
claus
parents: 403
diff changeset
  3008
	infoRec at:#type put:type.
claus
parents: 403
diff changeset
  3009
	infoRec at:#timeStamp put:t.
claus
parents: 403
diff changeset
  3010
	modules at:subModuleName put:infoRec.
claus
parents: 403
diff changeset
  3011
    ].
claus
parents: 403
diff changeset
  3012
    ^ modules
claus
parents: 403
diff changeset
  3013
claus
parents: 403
diff changeset
  3014
    "
claus
parents: 403
diff changeset
  3015
     ObjectMemory fullBinaryModuleInfo
claus
parents: 403
diff changeset
  3016
    "
claus
parents: 403
diff changeset
  3017
claus
parents: 403
diff changeset
  3018
    "Modified: 30.8.1995 / 17:29:30 / claus"
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3019
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3020
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3021
imageBaseName
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3022
    "return a reasonable filename to use as baseName (i.e. without extension).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3023
     This is the filename of the current image (without '.img') or,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3024
     if not running from an image, the default name 'st'"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3025
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3026
    |nm|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3027
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3028
    nm := ImageName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3029
    (nm isNil or:[nm isBlank]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3030
	^ 'st'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3031
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3032
    (nm endsWith:'.sav') ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3033
	nm := nm copyWithoutLast:4
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3034
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3035
    (nm endsWith:'.img') ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3036
	^ nm copyWithoutLast:4
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3037
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3038
    ^ nm
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3039
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3040
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3041
     ObjectMemory imageBaseName    
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3042
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3043
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3044
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3045
imageName
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3046
    "return the filename of the current image, or nil
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3047
     if not running from an image."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3048
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3049
    ^ ImageName
335
claus
parents: 332
diff changeset
  3050
claus
parents: 332
diff changeset
  3051
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3052
     ObjectMemory imageName 
335
claus
parents: 332
diff changeset
  3053
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3054
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3055
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3056
loadClassBinary:aClassName
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3057
    "find the object file for aClassName and -if found - load it;
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3058
     this one loads precompiled object files"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3059
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3060
    |fName newClass|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3061
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3062
    fName := self fileNameForClass:aClassName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3063
    fName notNil ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3064
	Class withoutUpdatingChangesDo:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3065
	[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3066
	    self loadBinary:(fName , '.o')
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3067
	].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3068
	newClass := self at:(aClassName asSymbol).
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3069
	(newClass notNil and:[newClass implements:#initialize]) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3070
	    newClass initialize
159
514c749165c3 *** empty log message ***
claus
parents: 133
diff changeset
  3071
	]
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3072
    ]
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3073
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3074
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3075
nameForChanges
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3076
    "return a reasonable filename to store the changes into.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3077
     Currently, this is defined in a classVariable and defaults to 'changes'.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3078
     In future versions, this will be the basename of the current image with '.img' replaced
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3079
     by '.chg', or, if not running from an image, the default name 'st.chg'."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3080
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3081
    ChangeFileName notNil ifTrue:[^ ChangeFileName].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3082
    ^ 'changes'.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3083
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3084
"/ future versions will have:
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3085
"/ (requires some additionas at other places)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3086
"/
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3087
"/    ^ self imageBaseName , '.chg'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3088
335
claus
parents: 332
diff changeset
  3089
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3090
     ObjectMemory nameForChanges    
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3091
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3092
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3093
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3094
nameForChanges:aFilename
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3095
    "set the name of the file where changes are stored into."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3096
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3097
    ChangeFileName := aFilename
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3098
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3099
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3100
     ObjectMemory nameForChanges:'myChanges'    
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3101
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3102
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3103
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3104
nameForSnapshot
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3105
    "return a reasonable filename to store the snapshot image into.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3106
     This is the filename of the current image or,
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3107
     if not running from an image, the default name 'st.img'"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3108
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3109
    ^ self imageBaseName , '.img'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3110
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3111
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3112
     ObjectMemory nameForSnapshot    
335
claus
parents: 332
diff changeset
  3113
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3114
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  3115
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3116
nameForSources
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3117
    "return a reasonable filename to store the sources into.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3118
     This is the basename of the current image with '.img' replaced
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3119
     by '.src', or, if not running from an image, the default name 'st.src'"
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3120
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3121
    ^ self imageBaseName , '.src'
362
claus
parents: 360
diff changeset
  3122
claus
parents: 360
diff changeset
  3123
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3124
     ObjectMemory nameForSources    
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3125
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3126
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3127
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3128
primSnapShotOn:aFileName
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3129
    "create a snapshot in the given file.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3130
     Low level entry. Does not notify classes or write an entry to
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3131
     the changes file. Also, no image backup is created. Returns true if
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3132
     the snapshot worked, false if it failed for some reason.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3133
     This method should not be used in normal cases."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3134
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3135
    |ok|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3136
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3137
%{  /* STACK:32000 */
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3138
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3139
    OBJ __snapShotOn();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3140
    OBJ funny = @symbol(funnySnapshotSymbol);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3141
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3142
    if (__isString(aFileName)) {
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3143
	__BLOCKINTERRUPTS();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3144
	ok = __snapShotOn(__context, _stringVal(aFileName), funny);
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3145
	__UNBLOCKINTERRUPTS();
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3146
    }
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3147
%}.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3148
    ^ ok
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3149
!
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3150
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3151
snapShot
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3152
    "create a snapshot file containing all of the current state."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3153
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3154
    self snapShotOn:(self nameForSnapshot)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3155
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3156
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3157
     ObjectMemory snapShot
362
claus
parents: 360
diff changeset
  3158
    "
claus
parents: 360
diff changeset
  3159
!
claus
parents: 360
diff changeset
  3160
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3161
snapShotOn:aFileName
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3162
    "create a snapshot in the given file. 
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3163
     If the file exists, save it for backup.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3164
     Return true if the snapshot worked, false if it failed for some reason.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3165
     Notify dependents before and after the snapshot operation."
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3166
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3167
    |ok oldImageName|
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3168
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3169
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3170
     keep a save version - just in case something
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3171
     bad happens while writing the image.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3172
     (could be st/x internal error or file-system errors etc)
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3173
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3174
    (OperatingSystem isValidPath:aFileName) ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3175
	OperatingSystem renameFile:aFileName to:(aFileName , '.sav').
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3176
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3177
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3178
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3179
     give others a chance to fix things
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3180
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3181
    self changed:#save.             "/ will vanish ...
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3182
    self changed:#aboutToSnapshot.  "/ ... for ST-80 compatibility
362
claus
parents: 360
diff changeset
  3183
claus
parents: 360
diff changeset
  3184
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3185
     ST-80 compatibility; send #preSnapshot to all classes
362
claus
parents: 360
diff changeset
  3186
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3187
    Smalltalk allBehaviorsDo:[:aClass |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3188
	aClass preSnapshot
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3189
    ].
426
claus
parents: 418
diff changeset
  3190
claus
parents: 418
diff changeset
  3191
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3192
     save the name with it ...
426
claus
parents: 418
diff changeset
  3193
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3194
    oldImageName := ImageName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3195
    ImageName := aFileName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3196
    ok := self primSnapShotOn:aFileName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3197
    ImageName := oldImageName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3198
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3199
    ok ifTrue:[
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3200
	Class addChangeRecordForSnapshot:aFileName.
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3201
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3202
426
claus
parents: 418
diff changeset
  3203
claus
parents: 418
diff changeset
  3204
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3205
     ST-80 compatibility; send #postSnapshot to all classes
426
claus
parents: 418
diff changeset
  3206
    "
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3207
    Smalltalk allBehaviorsDo:[:aClass |
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3208
	aClass postSnapshot
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3209
    ].
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3210
    self changed:#finishedSnapshot.  "/ ST-80 compatibility
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3211
    ^ ok
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3212
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3213
    "
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3214
     ObjectMemory snapShotOn:'myimage.img'
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3215
    "
362
claus
parents: 360
diff changeset
  3216
! !
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3217
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 615
diff changeset
  3218
!ObjectMemory class methodsFor:'documentation'!
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 615
diff changeset
  3219
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 615
diff changeset
  3220
version
759
908363ce8a32 interest is written with one 'r' (shame on me)
Claus Gittinger <cg@exept.de>
parents: 703
diff changeset
  3221
    ^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.83 1995-12-15 12:47:36 cg Exp $'
630
b785d23d7c5b version at the end
Claus Gittinger <cg@exept.de>
parents: 615
diff changeset
  3222
! !
615
e9d0e782206d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 532
diff changeset
  3223
ObjectMemory initialize!