Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.399.mcz
==================== Summary ====================
Name: Collections-ul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061-bf6c-eb4a-8a87-4a9bef73ea7e
Ancestors: Collections-ul.398
- added a postscript to apply the changes
=============== Diff against Collections-ul.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/Collections-ul.399.mcz
==================== Summary ====================
Name: Collections-ul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061-bf6c-eb4a-8a87-4a9bef73ea7e
Ancestors: Collections-ul.398
- added a postscript to apply the changes
=============== Diff against Collections-ul.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/Collections-ul.399.mcz
==================== Summary ====================
Name: Collections-ul.399
Author: ul
Time: 31 October 2010, 11:36:48.538 pm
UUID: d9152061-bf6c-eb4a-8a87-4a9bef73ea7e
Ancestors: Collections-ul.398
- added a postscript to apply the changes
=============== Diff against Collections-ul.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/Collections-ul.398.mcz
==================== Summary ====================
Name: Collections-ul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b6-1bd2-dc45-9606-33aebcfdc74c
Ancestors: Collections-ar.397
- restore the behavior of the old finalization scheme
=============== Diff against Collections-ar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
- instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'Collections-Weak'!
!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 'initialize-release') -----
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/Collections-ul.398.mcz
==================== Summary ====================
Name: Collections-ul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b6-1bd2-dc45-9606-33aebcfdc74c
Ancestors: Collections-ar.397
- restore the behavior of the old finalization scheme
=============== Diff against Collections-ar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
- instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'Collections-Weak'!
!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 'initialize-release') -----
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/Collections-ul.398.mcz
==================== Summary ====================
Name: Collections-ul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b6-1bd2-dc45-9606-33aebcfdc74c
Ancestors: Collections-ar.397
- restore the behavior of the old finalization scheme
=============== Diff against Collections-ar.397 ===============
Item was changed:
Collection subclass: #WeakRegistry
+ instanceVariableNames: 'list valueDictionary sema executors'
- instanceVariableNames: 'list valueDictionary sema'
classVariableNames: 'Default'
poolDictionaries: ''
category: 'Collections-Weak'!
!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 'initialize-release') -----
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/Kernel-nice.510.mcz
==================== Summary ====================
Name: Kernel-nice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa44-3abc-4414-adae-10f3f03b0420
Ancestors: Kernel-ul.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(90-x)
thus the trick is to evaluate:
cosd(x)=sind(90-abs(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(180-x) 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(90-x) thus providing a branch free implementation.
=============== Diff against Kernel-ul.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/Kernel-nice.510.mcz
==================== Summary ====================
Name: Kernel-nice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa44-3abc-4414-adae-10f3f03b0420
Ancestors: Kernel-ul.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(90-x)
thus the trick is to evaluate:
cosd(x)=sind(90-abs(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(180-x) 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(90-x) thus providing a branch free implementation.
=============== Diff against Kernel-ul.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/Kernel-nice.510.mcz
==================== Summary ====================
Name: Kernel-nice.510
Author: nice
Time: 31 October 2010, 10:25:03.794 pm
UUID: 80b9fa44-3abc-4414-adae-10f3f03b0420
Ancestors: Kernel-ul.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(90-x)
thus the trick is to evaluate:
cosd(x)=sind(90-abs(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(180-x) 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(90-x) thus providing a branch free implementation.
=============== Diff against Kernel-ul.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!