[squeakdev] The Trunk: Kernelul.1051.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Dec 6 18:03:23 UTC 2016
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelul.1051.mcz
==================== Summary ====================
Name: Kernelul.1051
Author: ul
Time: 6 December 2016, 6:50:56.960382 pm
UUID: 15f0443ea6cc4c91ba44190ef66534c7
Ancestors: Kerneleem.1050
 simplified Semaphore >> critical:ifLocked:
 Float >> #arcTan: always return a Float + some microoptimizations
 microoptimizations in Float >> #sign
=============== Diff against Kerneleem.1050 ===============
Item was changed:
 Method: Float>>arcTan: (in category 'mathematical functions') 
arcTan: denominator
"Answer the angle in radians.
Optional. See Object documentation whatIsAPrimitive.
Implementation note: use sign in order to catch cases of negativeZero"
+ self = 0.0 ifTrue: [
+ denominator sign >= 0 ifTrue: [ ^0.0 ].
+ self sign >= 0 ifTrue: [ ^Pi ].
+ ^0.0  Pi ].
+ denominator = 0.0 ifTrue: [
+ self > 0.0 ifTrue: [ ^Halfpi ].
+ ^0.0  Halfpi ].
+ denominator > 0.0 ifTrue: [ ^(self / denominator) arcTan ].
+ self > 0.0 ifTrue: [ ^(self / denominator) arcTan + Pi ].
+ ^(self / denominator) arcTan  Pi!
 ^self = 0.0
 ifTrue: [denominator sign >= 0
 ifTrue: [ 0 ]
 ifFalse: [ self sign >= 0
 ifTrue: [ Pi ]
 ifFalse: [ Pi negated ]]]
 ifFalse: [denominator = 0.0
 ifTrue: [self > 0.0
 ifTrue: [ Halfpi ]
 ifFalse: [ Halfpi negated ]]
 ifFalse: [denominator > 0
 ifTrue: [ (self / denominator) arcTan ]
 ifFalse: [self > 0
 ifTrue: [ ((self / denominator) arcTan) + Pi ]
 ifFalse: [ ((self / denominator) arcTan)  Pi ]]]]!
Item was changed:
 Method: Float>>sign (in category 'mathematical functions') 
sign
"Answer 1 if the receiver is greater than 0, 1 if less than 0, else 0.
Handle IEEE754 negativezero by reporting a sign of 1"
+ self > 0.0 ifTrue: [ ^1 ].
+ self < 0.0 ifTrue: [ ^1 ].
+ ^0  ((self at: 1) bitShift: 31) "1 for negative zero, 0 otherwise"!
 self > 0.0 ifTrue: [^ 1].
 (self < 0.0 or: [((self at: 1) bitShift: 31) = 1]) ifTrue: [^ 1].
 ^ 0!
Item was changed:
 Method: Semaphore>>critical:ifLocked: (in category 'mutual exclusion') 
critical: mutuallyExcludedBlock ifLocked: alternativeBlock
"Evaluate mutuallyExcludedBlock only if the receiver is not currently in
the process of running the critical: message. If the receiver is, then evaluate
alternativeBlock and return."
"See the comment of #critical: for the explanation how this pattern works
before changing the code."
+ 0 == excessSignals ifTrue: [ ^alternativeBlock value ].
+ excessSignals := excessSignals  1.
+ ^mutuallyExcludedBlock ensure: [ self signal ]!
  caught 
 caught := false.
 ^[
 "We're using #== here instead of #=, because it won't introduce a
 suspension point, while #= may do that."
 excessSignals == 0
 ifTrue: [ alternativeBlock value ]
 ifFalse: [
 excessSignals := excessSignals  1.
 caught := true.
 mutuallyExcludedBlock value ] ]
 ensure: [ caught ifTrue: [ self signal ] ]!
More information about the Squeakdev
mailing list
