The Trunk: Kernel-nice.1293.mcz

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

The Trunk: Kernel-nice.1293.mcz

commits-2
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1293.mcz

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

Name: Kernel-nice.1293
Author: nice
Time: 8 January 2020, 12:56:57.717854 am
UUID: 2a023bb6-8b85-41b9-bc59-fb247fc48658
Ancestors: Kernel-nice.1292

Connect the highBit primitive provided by new VM.
Since the primitive is jitted, it's about 3x faster than highBitOfPositiveReceiver.

[0 to: 1<<24 do: #highBit] bench.
 '7.66 per second. 131 milliseconds per run. 0 % GC time.'
[0 to: 1<<24 do: #highBitOfPositiveReceiver] bench.
 '2.59 per second. 386 milliseconds per run. 0 % GC time.'

It's even a bit faster than highBitOfByte.

[0 to: 255 do: #highBit] bench.
 '472,000 per second. 2.12 microseconds per run. 0 % GC time.'
[0 to: 255 do: #highBitOfByte] bench.
 '323,000 per second. 3.09 microseconds per run. 0 % GC time.'

Note: this has been tested on intel x86 and x64 architecture.
Please report the status on ARM (or mips).

=============== Diff against Kernel-nice.1292 ===============

Item was changed:
  ----- Method: SmallInteger>>highBit (in category 'bit manipulation') -----
  highBit
  "Answer the index of the high order bit of the receiver, or zero if the  
  receiver is zero. Raise an error if the receiver is negative, since  
  negative integers are defined to have an infinite number of leading 1's
  in 2's-complement arithmetic. Use >>highBitOfMagnitude if you want to
  get the highest bit of the magnitude."
+ <primitive: 575>
  self < 0 ifTrue: [^ self error: 'highBit is not defined for negative integers'].
  ^ self highBitOfPositiveReceiver!

Item was changed:
  ----- Method: SmallInteger>>highBitOfMagnitude (in category 'bit manipulation') -----
  highBitOfMagnitude
  "Answer the index of the high order bit of the receiver, or zero if the  
  receiver is zero. This method is used for negative SmallIntegers as well,  
  since Squeak's LargeIntegers are sign/magnitude."
 
+ <primitive: 575>
+ self < 0 ifTrue: [^self negated highBit].
- self < 0 ifTrue: [
- "Beware: do not use highBitOfPositiveReceiver
- because self negated is not necessarily a SmallInteger
- (see SmallInteger minVal)"
- ^self negated highBitOfMagnitude].
-
- "Implementation note: this method could be as well inlined here."
  ^self highBitOfPositiveReceiver!