--- a/ObjectMemory.st Sun Mar 21 17:58:43 2010 +0000
+++ b/ObjectMemory.st Sun Mar 21 19:37:43 2010 +0000
@@ -28,7 +28,7 @@
InterruptLatencyGoal VMSelectors DynamicCodeGCTrigger
DynamicCodeLimit JustInTimeCompilationEnabled
JavaJustInTimeCompilationEnabled JavaNativeCodeOptimization
- BackgroundCollectMaximumInterval'
+ BackgroundCollectMaximumInterval SavedGarbageCollectorSettings'
poolDictionaries:''
category:'System-Support'
!
@@ -2628,7 +2628,9 @@
%{ /* NOCONTEXT */
__avoidTenure(flag == true ? 1 : 0);
-%}
+%}.
+
+ self saveGarbageCollectorSetting:#avoidTenure: value:flag.
!
checkForFastNew:amount
@@ -2745,22 +2747,27 @@
This method returns the previous value of the flag; typically this return
value should be used to switch back."
-%{ /* NOCONTEXT */
+ |result|
+
+%{
extern int __fastMoreOldSpaceAllocation();
- RETURN (__fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false);
+ result = __fastMoreOldSpaceAllocation(aBoolean == true ? 1 : 0) ? true : false;
%}.
- ^ false
+ self saveGarbageCollectorSetting:#fastMoreOldSpaceAllocation: value:aBoolean.
+
+ ^ result
+
"
|previousSetting|
previousSetting := ObjectMemory fastMoreOldSpaceAllocation:true.
[
- ...
- allocate your huge data
- ...
+ ...
+ allocate your huge data
+ ...
] ensure:[
- ObjectMemory fastMoreOldSpaceAllocation:previousSetting
+ ObjectMemory fastMoreOldSpaceAllocation:previousSetting
]
"
@@ -2784,14 +2791,20 @@
increase the oldSpace forwever - actually, until the OS refuses to give us
more memory). The returned value is the previous setting of the limit."
-%{ /* NOCONTEXT */
+ |result|
+
+%{
extern unsigned int __fastMoreOldSpaceLimit();
if (__isInteger(aNumber)) {
- RETURN ( __MKUINT( __fastMoreOldSpaceLimit(__unsignedLongIntVal(aNumber))));
+ result = __MKUINT( __fastMoreOldSpaceLimit(__unsignedLongIntVal(aNumber)));
}
%}.
- ^ 0
+ result isNil ifTrue:[
+ ^ 0.
+ ].
+ self saveGarbageCollectorSetting:#fastMoreOldSpaceLimit: value:aNumber.
+ ^ result.
"
|prev this|
@@ -2911,12 +2924,15 @@
This entry is provided as a test interface and should not be
used by applications - it may vanish without notice"
+ |result|
+
%{
- int rslt;
-
- rslt = __incrementalSweep((aBoolean == true) ? 1 : 0);
- RETURN (rslt ? true : false);
-%}
+ result = __incrementalSweep((aBoolean == true) ? 1 : 0) ? true : false;
+%}.
+ self saveGarbageCollectorSetting:#incrementalSweep: value:aBoolean.
+
+ ^ result.
+
"
ObjectMemory incrementalSweep:false.
ObjectMemory incrementalSweep:true
@@ -2946,10 +2962,12 @@
%{
if (flag == true) {
- __tenure(__context);
+ __tenure(__context);
}
__lockTenure(flag == true ? 1 : 0);
-%}
+%}.
+
+ self saveGarbageCollectorSetting:#lockTenure: value:flag.
!
makeOld:anObject
@@ -2987,24 +3005,29 @@
If zero, it will allocate forever (until the OS wont hand out more).
The default is zero.
WARNING:
- an oldSpace limit may lead to trashing due to exorbitant GC activity;
- its usually better to let it allocate more and page in/page out.
- Usually, the background GC will catch up sooner or later and reclaim
- the memory without blocking the system"
-
-%{ /* NOCONTEXT */
+ an oldSpace limit may lead to trashing due to exorbitant GC activity;
+ its usually better to let it allocate more and page in/page out.
+ Usually, the background GC will catch up sooner or later and reclaim
+ the memory without blocking the system"
+
+ |result|
+%{
extern unsigned __maxOldSpace();
if (__isInteger(amount)) {
- RETURN (__MKUINT( __maxOldSpace(__unsignedLongIntVal(amount)) ));
+ result = __MKUINT( __maxOldSpace(__unsignedLongIntVal(amount)));
}
%}.
+ result notNil ifTrue:[
+ self saveGarbageCollectorSetting:#maxOldSpace: value:amount.
+ ^ result.
+ ].
^ 0
"
to change maximum to 1GByte:
- ObjectMemory maxOldSpace:1024*1024*1024
+ ObjectMemory maxOldSpace:1024*1024*1024
"
!
@@ -3068,18 +3091,26 @@
Experimental: this interface may valish without notice.
DANGER ALERT:
- be careful too big of a size may lead to longer scavenge pauses.
- Too small of a newSpace may lead to more CPU overhead, due to
- excessive scavenges. You have been warned."
+ be careful too big of a size may lead to longer scavenge pauses.
+ Too small of a newSpace may lead to more CPU overhead, due to
+ excessive scavenges. You have been warned."
+
+ |result|
%{
extern int __setNewSpaceSize();
if (__isSmallInteger(newSize)) {
- RETURN (__setNewSpaceSize(__intVal(newSize)) ? true : false);
+ result = __setNewSpaceSize(__intVal(newSize)) ? true : false;
}
%}.
- self primitiveFailed
+ result isNil ifTrue:[
+ self primitiveFailed.
+ ].
+ result ifTrue:[
+ self saveGarbageCollectorSetting:#newSpaceSize: value:newSize.
+ ].
+ ^ result.
" less absolute CPU overhead (but longer pauses):
@@ -3125,14 +3156,21 @@
you may want to increase this limit.
This method returns the previous increment value."
-%{ /* NOCONTEXT */
+ |result|
+
+%{
extern unsigned __compressingGCLimit();
if (__isInteger(amount)) {
- RETURN (__MKUINT( __compressingGCLimit(__unsignedLongIntVal(amount)) ));
+ result = __MKUINT( __compressingGCLimit(__unsignedLongIntVal(amount)) );
}
%}.
- ^ 0
+ result isNil ifTrue:[
+ ^ 0.
+ ].
+ self saveGarbageCollectorSetting:#oldSpaceCompressLimit: value:amount.
+ ^ result.
+
"to change the limit to 12Mb:"
"
ObjectMemory oldSpaceCompressLimit:12*1024*1024
@@ -3162,15 +3200,22 @@
In normal situations, the default value used in the VM is fine
and there is no need to change it. This method returns the
previous increment value."
-
-%{ /* NOCONTEXT */
+
+ |result|
+
+%{
extern unsigned __oldSpaceIncrement();
if (__isInteger(amount)) {
- RETURN (__MKUINT( __oldSpaceIncrement(__unsignedLongIntVal(amount)) ));
+ result = __MKUINT( __oldSpaceIncrement(__unsignedLongIntVal(amount)) );
}
%}.
- ^ 0
+ result isNil ifTrue:[
+ ^ 0.
+ ].
+ self saveGarbageCollectorSetting:#oldSpaceIncrement: value:amount.
+ ^ result.
+
"to change increment to 1Meg:"
"
ObjectMemory oldSpaceIncrement:1024*1024
@@ -3187,6 +3232,7 @@
%{ /* NOCONTEXT */
__tenureParams(magic);
%}.
+ self saveGarbageCollectorSetting:#tenureParameters: value:magic.
!
turnGarbageCollectorOff
@@ -3232,6 +3278,33 @@
%}
! !
+!ObjectMemory class methodsFor:'garbage collector settings'!
+
+restoreGarbageCollectorSettings
+ "restore the saved garbage collector settings"
+
+ SavedGarbageCollectorSettings isEmptyOrNil ifTrue:[
+ ^ self.
+ ].
+ SavedGarbageCollectorSettings keysAndValuesDo:[:eachKey :eachValue|
+ eachKey numArgs == 1 ifTrue:[
+ self perform:eachKey with:eachValue.
+ ] ifFalse:[
+ self perform:eachKey.
+ ].
+ ].
+!
+
+saveGarbageCollectorSetting:aSymbol value:something
+ "save some garbage collector setting, which is stored only in the VM,
+ to be restored on snapshot return"
+
+ SavedGarbageCollectorSettings isNil ifTrue:[
+ SavedGarbageCollectorSettings := IdentityDictionary new.
+ ].
+ SavedGarbageCollectorSettings at:aSymbol put:something.
+! !
+
!ObjectMemory class methodsFor:'interrupt handler access'!
childSignalInterruptHandler
@@ -5259,11 +5332,11 @@
!ObjectMemory class methodsFor:'documentation'!
version
- ^ '$Id: ObjectMemory.st 10496 2010-02-01 10:03:06Z vranyj1 $'
+ ^ '$Id: ObjectMemory.st 10508 2010-03-21 19:37:43Z vranyj1 $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.245 2010/01/20 19:44:24 cg Exp §'
+ ^ '§Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.246 2010/03/12 09:08:02 stefan Exp §'
! !
ObjectMemory initialize!
@@ -5271,3 +5344,4 @@
+