--- a/WeakArray.st Wed Oct 26 23:35:39 2016 +0100
+++ b/WeakArray.st Fri Nov 18 20:48:04 2016 +0000
@@ -180,71 +180,71 @@
ok = __addShadowObject(self, 0);
if (ok == false) {
- /*
- * the behavior of __addShadowObject() in case of overflowing
- * VM-table space can be controlled by the second argument:
- * if its 0, the weakObject is not registered, and false
- * is returned.
- * if its 1, the tables are reallocated, registration proceeds,
- * and true is returned.
- * This allows for the caller to have an influence on the VM's
- * shadow table allocation.
- *
- * If addShadowObject() returned false, too many shadow objects are
- * already there. Then collect garbage to get rid of
- * obsolete ones, and try again.
- * Since a full collect is expensive, we try
- * a scavenge first, doing a full collect only if
- * that does not help.
- *
- * THIS MAY OR MAY NOT BE A GOOD IDEA: although it reduces
- * the number of shadow objects that have to be
- * processed at GC time, it may create a long delay here,
- * at shadow object creation time.
- * Dont know which is better ...
- */
- __nonTenuringScavenge(__context);
- ok = __addShadowObject(self, 0);
+ /*
+ * the behavior of __addShadowObject() in case of overflowing
+ * VM-table space can be controlled by the second argument:
+ * if its 0, the weakObject is not registered, and false
+ * is returned.
+ * if its 1, the tables are reallocated, registration proceeds,
+ * and true is returned.
+ * This allows for the caller to have an influence on the VM's
+ * shadow table allocation.
+ *
+ * If addShadowObject() returned false, too many shadow objects are
+ * already there. Then collect garbage to get rid of
+ * obsolete ones, and try again.
+ * Since a full collect is expensive, we try
+ * a scavenge first, doing a full collect only if
+ * that does not help.
+ *
+ * THIS MAY OR MAY NOT BE A GOOD IDEA: although it reduces
+ * the number of shadow objects that have to be
+ * processed at GC time, it may create a long delay here,
+ * at shadow object creation time.
+ * Don't know which is better ...
+ */
+ __nonTenuringScavenge(__context);
+ ok = __addShadowObject(self, 0);
- if (ok == false) {
- /*
- * hard stuff - need full collect
- * if this is the very first GC, assume that we are in
- * the startup phase (where all weak stuff is allocated).
- * Then do no GC.
- * Heuristics showed, that this GC does not find much ...
- */
- if ((__garbageCollectCount() != 0)
- || (__incrementalGCCount() != 0)) {
- __markAndSweepIfUseful(__context);
- ok = __addShadowObject(self, 0);
- }
- if (ok == false) {
- /*
- * mhmh - it seems that there are really many shadow
- * objects around - force creation
- */
- ok = __addShadowObject(self, 1);
- if (ok == false) {
- /*
- * no chance - something must be wrong
- * lets fall into the exception and see.
- */
- }
- }
- }
+ if (ok == false) {
+ /*
+ * hard stuff - need full collect
+ * if this is the very first GC, assume that we are in
+ * the startup phase (where all weak stuff is allocated).
+ * Then do no GC.
+ * Heuristics showed, that this GC does not find much ...
+ */
+ if ((__garbageCollectCount() != 0)
+ || (__incrementalGCCount() != 0)) {
+ __markAndSweepIfUseful(__context);
+ ok = __addShadowObject(self, 0);
+ }
+ if (ok == false) {
+ /*
+ * mhmh - it seems that there are really many shadow
+ * objects around - force creation
+ */
+ ok = __addShadowObject(self, 1);
+ if (ok == false) {
+ /*
+ * no chance - something must be wrong
+ * lets fall into the exception and see.
+ */
+ }
+ }
+ }
}
%}.
ok ifFalse:[
- "
- the VM was not able to register the new weakArray
- This can only happen, if the VM has to resize its tables,
- and a malloc request failed. Usually, this smells like big
- trouble being on the way (soon running out of memory in
- other places as well).
- Configure your OS for more swap space.
- "
- ^ RegistrationFailedSignal raiseRequestWith:self
+ "
+ the VM was not able to register the new weakArray
+ This can only happen, if the VM has to resize its tables,
+ and a malloc request failed. Usually, this smells like big
+ trouble being on the way (soon running out of memory in
+ other places as well).
+ Configure your OS for more swap space.
+ "
+ ^ RegistrationFailedSignal raiseRequestWith:self
]
! !
@@ -253,7 +253,7 @@
at:index
"return the indexed instance variable with index, anInteger.
Reimplemented here for IGC readBarrier.
- (You dont have to understand this.)"
+ (You don't have to understand this.)"
^ self basicAt:index
@@ -264,7 +264,7 @@
"return the indexed instance variable with index, anInteger,
or exceptionValue if the index is invalid.
Reimplemented here for IGC readBarrier.
- (You dont have to understand this.)"
+ (You don't have to understand this.)"
(index < 0 or:[index > self size]) ifTrue:[^ exceptionValue].
^ self at:index
@@ -474,31 +474,34 @@
wasBlocked := OperatingSystem blockInterrupts.
[
- |deps sz dep|
+ |deps sz dep|
- deps := dependents.
- deps notNil ifTrue:[
- deps isCollection ifTrue:[
- deps remove:anObject ifAbsent:[].
- (sz := deps size) == 0 ifTrue:[
- dependents := nil
- ] ifFalse:[
- sz == 1 ifTrue:[
- (dep := deps first) isCollection ifFalse:[
- dependents := dep
- ]
- ]
- ]
- ] ifFalse:[
- deps == anObject ifTrue:[
- dependents := nil
- ]
- ]
- ]
+ deps := dependents.
+ deps notNil ifTrue:[
+ deps isCollection ifTrue:[
+ dep := deps remove:anObject ifAbsent:[].
+ "if dep is nil, nothing has changed"
+ dep notNil ifTrue:[
+ (sz := deps size) == 0 ifTrue:[
+ dependents := nil
+ ] ifFalse:[
+ sz == 1 ifTrue:[
+ (dep := deps first) isCollection ifFalse:[
+ dependents := dep
+ ]
+ ]
+ ].
+ ].
+ ] ifFalse:[
+ deps == anObject ifTrue:[
+ dependents := nil
+ ]
+ ]
+ ]
] ensure:[
- wasBlocked ifFalse:[
- OperatingSystem unblockInterrupts
- ]
+ wasBlocked ifFalse:[
+ OperatingSystem unblockInterrupts
+ ]
]
! !