[squeak-dev] Re: little VM fast-up : #bytesSwapped:

nicolas cellier ncellier at ifrance.com
Fri Jul 4 21:45:22 UTC 2008


Eliot Miranda a écrit :
> Thank you Nicolas!  If you send me a method with your date stamp on it 
> it'll get integrated in my changes...
> 

Just surfing over the code, diving here and there, so I didn't write 
anything in image.
Code in the mail is just the idea (not even syntaxically correct!).
But since you ask, I'm happy to feed the VM tiger.

And don't care too much of my initials, but rather to correct my bugs, 
because i did not and will not test it, i'm just too tired.

Cheers
-------------- next part --------------
'From Squeak3.10beta of 22 July 2007 [latest update: #7159] on 4 July 2008 at 11:32:09 pm'!

!Interpreter methodsFor: 'image save/restore' stamp: 'nice 7/4/2008 23:31'!
byteSwapped: w
	"Answer the given integer with its bytes in the reverse order."
	
	| x |
	x := w.
	BytesPerWord = 4
 		ifTrue: ["Note: In C, x unsigned 32 bits, first bitAnd: is not required"
			x = ((x bitAnd: 16rFFFF0000) >> 16)
			 + ((x bitAnd: 16r0000FFFF) << 16).
			x = ((x bitAnd: 16rFF00FF00) >> 8)
			 + ((x bitAnd: 16r00FF00FF) << 8)]
		ifFalse: ["Note: In C, x unsigned 64 bits, first bitAnd: is not required"
			x = ((x bitAnd: 16rFFFFFFFF00000000) >> 32)
			 + ((x bitAnd: 16r00000000FFFFFFFF) << 32).
			x = ((x bitAnd: 16rFFFF0000FFFF0000) >> 16)
			 + ((x bitAnd: 16r0000FFFF0000FFFF) << 16).
			x = ((x bitAnd: 16rFF00FF00FF00FF00) >> 8)
			 + ((x bitAnd: 16r00FF00FF00FF00FF) << 8)].
  ^x! !


More information about the Squeak-dev mailing list