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