[squeak-dev] The Trunk: Sound-dtl.33.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Jan 3 00:55:02 UTC 2013


David T. Lewis uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-dtl.33.mcz

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

Name: Sound-dtl.33
Author: dtl
Time: 2 January 2013, 7:54:41.501 pm
UUID: 59c3722b-80fe-415c-855c-25ec40ef5856
Ancestors: Sound-ul.32

Bitshift optimizations by Nicolas Cellier. Use #>> or #<< operator rather than #bitShift: in cases where shift direction is known in order to eliminate runtime check for shift direction in compiled VM methods.

These changes affect ADPCMCodec methods that are translated as primitives in the ADPCMCodecPlugin and are thus part of the compiled VM. See VMMaker-dtl.293 in the VMMaker repository for related changes affecting other methods in the VM.

Discussion thread: http://lists.squeakfoundation.org/pipermail/vm-dev/2012-December/011688.html

Original change sets: http://code.google.com/p/cog/issues/detail?id=111

=============== Diff against Sound-ul.32 ===============

Item was changed:
  ----- Method: ADPCMCodec>>nextBits: (in category 'bit streaming') -----
  nextBits: n
  	"Answer the next n bits of my bit stream as an unsigned integer."
  
  	| result remaining shift |
  	<inline: true>
  
  	result := 0.
  	remaining := n.
  	
  	[
  		shift := remaining - bitPosition.
- 		result := result + (currentByte bitShift: shift).
  		shift > 0
  			ifTrue: [  "consumed currentByte buffer; fetch next byte"
+ 				result := result + (currentByte << shift).
  				remaining := remaining - bitPosition.			
  				currentByte := (encodedBytes at: (byteIndex := byteIndex + 1)).
  				bitPosition := 8]
  			ifFalse: [  "still some bits left in currentByte buffer"
+ 				result := result + (currentByte >> (0 - shift)).
  				bitPosition := bitPosition - remaining.
  				"mask out the consumed bits:"
+ 				currentByte := currentByte bitAnd: (255 >> (8 - bitPosition)).
- 				currentByte := currentByte bitAnd: (255 bitShift: (bitPosition - 8)).
  				^ result]] repeat
  !

Item was changed:
  ----- Method: ADPCMCodec>>nextBits:put: (in category 'bit streaming') -----
  nextBits: n put: anInteger
  	"Write the next n bits to my bit stream."
  
  	| buf bufBits bitsAvailable shift |
  	<inline: true>
  
  	buf := anInteger.
  	bufBits := n.
  	[
  		bitsAvailable := 8 - bitPosition.
  		shift := bitsAvailable - bufBits.  "either left or right shift"
  		"append high bits of buf to end of currentByte:"
- 		currentByte := currentByte + (buf bitShift: shift).
  		shift < 0
  			ifTrue: [  "currentByte buffer filled; output it"
+ 				currentByte := currentByte + (buf >> (0 - shift)).
  				encodedBytes at: (byteIndex := byteIndex + 1) put: currentByte.
  				bitPosition := 0.
  				currentByte := 0.
  				"clear saved high bits of buf:"
+ 				buf := buf bitAnd: (1 << (0 - shift)) - 1.
- 				buf := buf bitAnd: (1 bitShift: 0 - shift) - 1.
  				bufBits := bufBits - bitsAvailable]
  			ifFalse: [  "still some bits available in currentByte buffer"
+ 				currentByte := currentByte + (buf << shift).
  				bitPosition := bitPosition + bufBits.
  				^ self]] repeat
  !



More information about the Squeak-dev mailing list