The Trunk: System-ul.714.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-ul.714.mcz

commits-2
Levente Uzonyi uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.714.mcz

==================== Summary ====================

Name: System-ul.714
Author: ul
Time: 1 April 2015, 11:19:18.334 pm
UUID: 85f78b85-369c-4bd7-8e6d-52c9e63f27c1
Ancestors: System-ul.713

Avoid LargeInteger arithmetic in ThirtyTwoBitRegister>>leftRotateBy:.

=============== Diff against System-ul.713 ===============

Item was changed:
  ----- Method: ThirtyTwoBitRegister>>leftRotateBy: (in category 'accumulator ops') -----
  leftRotateBy: bits
  "Rotate my contents left by the given number of bits, retaining exactly 32 bits."
+ "Details: Perform this operation with no LargeInteger arithmetic."
- "Details: Perform this operation with as little LargeInteger arithmetic as possible."
 
+ | bitCount newHi |
+ bitCount := bits.
+ bitCount >= 32 ifTrue: [ bitCount := bitCount \\ 32 ].
+ bitCount >= 16 ifTrue: [
+ newHi := low.
+ low := hi.
+ hi := newHi.
+ bitCount := bitCount - 16 ].
+ bitCount >= 15 ifTrue: [
+ newHi := ((hi bitAnd: 16r1) bitShift: 15) bitOr: (low bitShift: -1).
+ low := ((low bitAnd: 16r1) bitShift: 15) bitOr: (hi bitShift: -1).
+ hi := newHi.
+ ^self ].
+ bitCount >= 1 ifTrue: [
+ | shift |
+ shift := bitCount - 16.
+ newHi := ((hi bitShift: bitCount) bitAnd: 16rFFFF) bitOr: (low bitShift: shift).
+ low := ((low bitShift: bitCount) bitAnd: 16rFFFF) bitOr: (hi bitShift: shift).
+ hi := newHi ]!
- | bitCount s1 s2 newHi |
- "ensure bitCount is in range [0..31]"
- bitCount := bits \\ 32.
- bitCount > 16
- ifTrue: [
- s1 := bitCount - 16.
- s2 := s1 - 16.
- newHi := ((low bitShift: s1) bitAnd: 16rFFFF) bitOr: (hi bitShift: s2).
- low := ((hi bitShift: s1) bitAnd: 16rFFFF) bitOr: (low bitShift: s2).
- hi := newHi]
- ifFalse: [
- s1 := bitCount.
- s2 := s1 - 16.
- newHi := ((hi bitShift: s1) bitAnd: 16rFFFF) bitOr: (low bitShift: s2).
- low := ((low bitShift: s1) bitAnd: 16rFFFF) bitOr: (hi bitShift: s2).
- hi := newHi]
- !