Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.399.mcz
==================== Summary ====================
Name: Collectionsul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061bf6ceb4a8a874a9bef73ea7e
Ancestors: Collectionsul.398
 added a postscript to apply the changes
=============== Diff against Collectionsul.398 ===============
Item was changed:
+ (PackageInfo named: 'Collections') postscript: 'WeakRegistry allInstancesDo: [ :each  each installFinalizer ]'!
 (PackageInfo named: 'Collections') postscript: 'WeakFinalizationRegistry migrateOldRegistries'!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.399.mcz
==================== Summary ====================
Name: Collectionsul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061bf6ceb4a8a874a9bef73ea7e
Ancestors: Collectionsul.398
 added a postscript to apply the changes
=============== Diff against Collectionsul.398 ===============
Item was changed:
+ (PackageInfo named: 'Collections') postscript: 'WeakRegistry allInstancesDo: [ :each  each installFinalizer ]'!
 (PackageInfo named: 'Collections') postscript: 'WeakFinalizationRegistry migrateOldRegistries'!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.399.mcz
==================== Summary ====================
Name: Collectionsul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061bf6ceb4a8a874a9bef73ea7e
Ancestors: Collectionsul.398
 added a postscript to apply the changes
=============== Diff against Collectionsul.398 ===============
Item was changed:
+ (PackageInfo named: 'Collections') postscript: 'WeakRegistry allInstancesDo: [ :each  each installFinalizer ]'!
 (PackageInfo named: 'Collections') postscript: 'WeakFinalizationRegistry migrateOldRegistries'!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.398.mcz
==================== Summary ====================
Name: Collectionsul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b61bd2dc45960633aebcfdc74c
Ancestors: Collectionsar.397
 restore the behavior of the old finalization scheme
=============== Diff against Collectionsar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
 instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'CollectionsWeak'!
!WeakRegistry commentStamp: 'ul 9/26/2010 02:51' prior: 0!
I am a registry for objects needing finalization. When an object is added the object as well as its executor is stored. When the object is garbage collected, the executor can take the appropriate action for any resources associated with the object.
This kind of WeakRegistry is using a new VM feature, which allows a more robust finalization support. In contrast to the old implementation, it doesn't spend linear time checking which elements became garbage.
See also:
Object executor
Object actAsExecutor
Object finalize!
Item was changed:
 Method: WeakRegistry>>finalizeValues (in category 'finalization') 
finalizeValues
"Finalize any values, which happen to stocked in our list, due to some weak references become garbage"
 finalizer 

WeakFinalizationList hasNewFinalization ifFalse: [
+ self protected: [
+ valueDictionary finalizeValues.
+ finalizer := executors.
+ executors := nil ].
+ finalizer ifNotNil: [
+ finalizer do: [ :each  each finalizeValues ] ].
 self protected: [ valueDictionary finalizeValues ].
^ self ].
+ finalizer := self protected: [ list swapWithNil ].
 self protected: [ finalizer := list swapWithNil ].
"We don't need to protect a following loop from concurrent access,
because at the moment we're finalizing values,
only we can access this list of finalizers, because valueDictionary already see them
as an unused slots, because they're associated with key == nil"
[ finalizer notNil ] whileTrue: [
 next 
next := finalizer next.
finalizer finalizeValues.
+ finalizer := next ].
 finalizer := next
 ].
!
Item was changed:
 Method: WeakRegistry>>installFinalizer (in category 'initializerelease') 
installFinalizer
+ valueDictionary finalizer: [ :executor 
+ WeakFinalizationList hasNewFinalization
+ ifTrue: [ executor finalizeValues ]
+ ifFalse: [
+ (executors ifNil: [ executors := OrderedCollection new ]) add: executor ] ]!
 valueDictionary finalizer: #finalizeValues!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.398.mcz
==================== Summary ====================
Name: Collectionsul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b61bd2dc45960633aebcfdc74c
Ancestors: Collectionsar.397
 restore the behavior of the old finalization scheme
=============== Diff against Collectionsar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
 instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'CollectionsWeak'!
!WeakRegistry commentStamp: 'ul 9/26/2010 02:51' prior: 0!
I am a registry for objects needing finalization. When an object is added the object as well as its executor is stored. When the object is garbage collected, the executor can take the appropriate action for any resources associated with the object.
This kind of WeakRegistry is using a new VM feature, which allows a more robust finalization support. In contrast to the old implementation, it doesn't spend linear time checking which elements became garbage.
See also:
Object executor
Object actAsExecutor
Object finalize!
Item was changed:
 Method: WeakRegistry>>finalizeValues (in category 'finalization') 
finalizeValues
"Finalize any values, which happen to stocked in our list, due to some weak references become garbage"
 finalizer 

WeakFinalizationList hasNewFinalization ifFalse: [
+ self protected: [
+ valueDictionary finalizeValues.
+ finalizer := executors.
+ executors := nil ].
+ finalizer ifNotNil: [
+ finalizer do: [ :each  each finalizeValues ] ].
 self protected: [ valueDictionary finalizeValues ].
^ self ].
+ finalizer := self protected: [ list swapWithNil ].
 self protected: [ finalizer := list swapWithNil ].
"We don't need to protect a following loop from concurrent access,
because at the moment we're finalizing values,
only we can access this list of finalizers, because valueDictionary already see them
as an unused slots, because they're associated with key == nil"
[ finalizer notNil ] whileTrue: [
 next 
next := finalizer next.
finalizer finalizeValues.
+ finalizer := next ].
 finalizer := next
 ].
!
Item was changed:
 Method: WeakRegistry>>installFinalizer (in category 'initializerelease') 
installFinalizer
+ valueDictionary finalizer: [ :executor 
+ WeakFinalizationList hasNewFinalization
+ ifTrue: [ executor finalizeValues ]
+ ifFalse: [
+ (executors ifNil: [ executors := OrderedCollection new ]) add: executor ] ]!
 valueDictionary finalizer: #finalizeValues!
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collectionsul.398.mcz
==================== Summary ====================
Name: Collectionsul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b61bd2dc45960633aebcfdc74c
Ancestors: Collectionsar.397
 restore the behavior of the old finalization scheme
=============== Diff against Collectionsar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
 instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'CollectionsWeak'!
!WeakRegistry commentStamp: 'ul 9/26/2010 02:51' prior: 0!
I am a registry for objects needing finalization. When an object is added the object as well as its executor is stored. When the object is garbage collected, the executor can take the appropriate action for any resources associated with the object.
This kind of WeakRegistry is using a new VM feature, which allows a more robust finalization support. In contrast to the old implementation, it doesn't spend linear time checking which elements became garbage.
See also:
Object executor
Object actAsExecutor
Object finalize!
Item was changed:
 Method: WeakRegistry>>finalizeValues (in category 'finalization') 
finalizeValues
"Finalize any values, which happen to stocked in our list, due to some weak references become garbage"
 finalizer 

WeakFinalizationList hasNewFinalization ifFalse: [
+ self protected: [
+ valueDictionary finalizeValues.
+ finalizer := executors.
+ executors := nil ].
+ finalizer ifNotNil: [
+ finalizer do: [ :each  each finalizeValues ] ].
 self protected: [ valueDictionary finalizeValues ].
^ self ].
+ finalizer := self protected: [ list swapWithNil ].
 self protected: [ finalizer := list swapWithNil ].
"We don't need to protect a following loop from concurrent access,
because at the moment we're finalizing values,
only we can access this list of finalizers, because valueDictionary already see them
as an unused slots, because they're associated with key == nil"
[ finalizer notNil ] whileTrue: [
 next 
next := finalizer next.
finalizer finalizeValues.
+ finalizer := next ].
 finalizer := next
 ].
!
Item was changed:
 Method: WeakRegistry>>installFinalizer (in category 'initializerelease') 
installFinalizer
+ valueDictionary finalizer: [ :executor 
+ WeakFinalizationList hasNewFinalization
+ ifTrue: [ executor finalizeValues ]
+ ifFalse: [
+ (executors ifNil: [ executors := OrderedCollection new ]) add: executor ] ]!
 valueDictionary finalizer: #finalizeValues!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelnice.510.mcz
==================== Summary ====================
Name: Kernelnice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa443abc4414adae10f3f03b0420
Ancestors: Kernelul.509
Provide an implementation of #degreeCos and #degreeSin such that results are exact for any multiple of 90.
Care is also taken to evaluate the sine between 90° and 90°, this will avoid #degreesToRadians and i386 FPU sine fonction to accumulate round off errors due to approximate representation of pi.
We can thus evaluate 240 degreeCos with at most 1 ulp error. It's not perfect, but better than previous implementation.
For cosine, we know that:
cosd(x)=cosd(abs(x))
cosd(x)=sind(90x)
thus the trick is to evaluate:
cosd(x)=sind(90abs(x)) after appropriate modulo in [180,180[
This way, we are sure to evaluate the sine between 90° and 90°
The #degreesToRadians and #sin are used rather than #degreeSin to avoid cycles.
For sine, it would be necessary to evaluate either
sind(x) if abs(x) <=90
or sind(180x) if abs(x) >= 90
A possible implementation would be:
 x 
x := 90 + self \\ 360  90.
x >= 180 ifTrue: [x := 180  x].
^x degreesToRadians sin
We prefer evaluating cosd(90x) thus providing a branch free implementation.
=============== Diff against Kernelul.509 ===============
Item was changed:
 Method: Float>>degreeCos (in category 'mathematical functions') 
degreeCos
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeCos].
+ ^self radiansToDegrees cos!
 "Answer the cosine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians cos!
Item was changed:
 Method: Float>>degreeSin (in category 'mathematical functions') 
degreeSin
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeSin].
+ ^self radiansToDegrees sin!
 "Answer the sine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians sin!
Item was changed:
 Method: Number>>degreeCos (in category 'mathematical functions') 
degreeCos
"Answer the cosine of the receiver taken as an angle in degrees."
+ ^ (90  (180 + self \\ 360  180) abs) degreesToRadians sin!
 ^ (90 + self) degreeSin!
Item was changed:
 Method: Number>>degreeSin (in category 'mathematical functions') 
degreeSin
"Answer the sine of the receiver taken as an angle in degrees."
+ ^(90  self) degreeCos!
 ^ self asFloat degreesToRadians sin!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelnice.510.mcz
==================== Summary ====================
Name: Kernelnice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa443abc4414adae10f3f03b0420
Ancestors: Kernelul.509
Provide an implementation of #degreeCos and #degreeSin such that results are exact for any multiple of 90.
Care is also taken to evaluate the sine between 90° and 90°, this will avoid #degreesToRadians and i386 FPU sine fonction to accumulate round off errors due to approximate representation of pi.
We can thus evaluate 240 degreeCos with at most 1 ulp error. It's not perfect, but better than previous implementation.
For cosine, we know that:
cosd(x)=cosd(abs(x))
cosd(x)=sind(90x)
thus the trick is to evaluate:
cosd(x)=sind(90abs(x)) after appropriate modulo in [180,180[
This way, we are sure to evaluate the sine between 90° and 90°
The #degreesToRadians and #sin are used rather than #degreeSin to avoid cycles.
For sine, it would be necessary to evaluate either
sind(x) if abs(x) <=90
or sind(180x) if abs(x) >= 90
A possible implementation would be:
 x 
x := 90 + self \\ 360  90.
x >= 180 ifTrue: [x := 180  x].
^x degreesToRadians sin
We prefer evaluating cosd(90x) thus providing a branch free implementation.
=============== Diff against Kernelul.509 ===============
Item was changed:
 Method: Float>>degreeCos (in category 'mathematical functions') 
degreeCos
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeCos].
+ ^self radiansToDegrees cos!
 "Answer the cosine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians cos!
Item was changed:
 Method: Float>>degreeSin (in category 'mathematical functions') 
degreeSin
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeSin].
+ ^self radiansToDegrees sin!
 "Answer the sine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians sin!
Item was changed:
 Method: Number>>degreeCos (in category 'mathematical functions') 
degreeCos
"Answer the cosine of the receiver taken as an angle in degrees."
+ ^ (90  (180 + self \\ 360  180) abs) degreesToRadians sin!
 ^ (90 + self) degreeSin!
Item was changed:
 Method: Number>>degreeSin (in category 'mathematical functions') 
degreeSin
"Answer the sine of the receiver taken as an angle in degrees."
+ ^(90  self) degreeCos!
 ^ self asFloat degreesToRadians sin!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelnice.510.mcz
==================== Summary ====================
Name: Kernelnice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa443abc4414adae10f3f03b0420
Ancestors: Kernelul.509
Provide an implementation of #degreeCos and #degreeSin such that results are exact for any multiple of 90.
Care is also taken to evaluate the sine between 90° and 90°, this will avoid #degreesToRadians and i386 FPU sine fonction to accumulate round off errors due to approximate representation of pi.
We can thus evaluate 240 degreeCos with at most 1 ulp error. It's not perfect, but better than previous implementation.
For cosine, we know that:
cosd(x)=cosd(abs(x))
cosd(x)=sind(90x)
thus the trick is to evaluate:
cosd(x)=sind(90abs(x)) after appropriate modulo in [180,180[
This way, we are sure to evaluate the sine between 90° and 90°
The #degreesToRadians and #sin are used rather than #degreeSin to avoid cycles.
For sine, it would be necessary to evaluate either
sind(x) if abs(x) <=90
or sind(180x) if abs(x) >= 90
A possible implementation would be:
 x 
x := 90 + self \\ 360  90.
x >= 180 ifTrue: [x := 180  x].
^x degreesToRadians sin
We prefer evaluating cosd(90x) thus providing a branch free implementation.
=============== Diff against Kernelul.509 ===============
Item was changed:
 Method: Float>>degreeCos (in category 'mathematical functions') 
degreeCos
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeCos].
+ ^self radiansToDegrees cos!
 "Answer the cosine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians cos!
Item was changed:
 Method: Float>>degreeSin (in category 'mathematical functions') 
degreeSin
+ "Take care of exceptional values"
+
+ self isFinite ifTrue: [^super degreeSin].
+ ^self radiansToDegrees sin!
 "Answer the sine of the receiver taken as an angle in degrees."

 ^ self degreesToRadians sin!
Item was changed:
 Method: Number>>degreeCos (in category 'mathematical functions') 
degreeCos
"Answer the cosine of the receiver taken as an angle in degrees."
+ ^ (90  (180 + self \\ 360  180) abs) degreesToRadians sin!
 ^ (90 + self) degreeSin!
Item was changed:
 Method: Number>>degreeSin (in category 'mathematical functions') 
degreeSin
"Answer the sine of the receiver taken as an angle in degrees."
+ ^(90  self) degreeCos!
 ^ self asFloat degreesToRadians sin!