[squeak-dev] The Trunk: Compiler-nice.471.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 10 09:06:17 UTC 2022


Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.471.mcz

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

Name: Compiler-nice.471
Author: nice
Time: 10 March 2022, 10:06:12.445899 am
UUID: ebc43c86-7bbc-764d-9bbb-6c9ecfb21a10
Ancestors: Compiler-mt.470

Workaround VM bug https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/618

We avoid using extend B bytecode (225) + push character bytecode (233) when character value > 16r7FFF.

In this case, the character literal will be accessed thru traditional genPushLiteral: bytecode.

=============== Diff against Compiler-mt.470 ===============

Item was changed:
  ----- Method: EncoderForSistaV1>>genPushCharacter: (in category 'bytecode generation') -----
  genPushCharacter: aCharacterOrCode
  	"233		11101001	i i i i i i i i	Push Character #iiiiiiii (+ Extend B * 256)"
  	"Why restrict the range to 16 bits when we could encode arbitrarily 32-bit Characters?
  	 Well, 16 bits requires 4 bytes (extB + byte, 78 + byte) and so beyond this range we
  	 lose space verses a single-byte pushLiteral and a 4 byte Character literal on 32-bits.
  	 And generating the same bytecode on 64-bit and 32-bit is important if we want to be
  	 able to load binary code from one to the other (e.g. via Fuel)."
  	| code |
  	code := aCharacterOrCode isInteger ifTrue: [aCharacterOrCode] ifFalse: [aCharacterOrCode asInteger].
+ 	"Note: due to a bug at VM side, Character above 16r8000 are reconstructed with a negative value.
+ 	This is because extend B is interpreted as signed integer.
+ 	See https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/618
+ 	For compatibility with old VM, we restrict usage of push character bytecode to safe cases extB < 16r80."
+ 	(code < 0 or: [code > 16r7FFF]) ifTrue:
+ 		[^self outOfRangeError: 'character' index: code range: 0 to: 16r7FFF].
- 	(code < 0 or: [code > 65535]) ifTrue:
- 		[^self outOfRangeError: 'character' index: code range: 0 to: 65535].
  	(code > 255) ifTrue:
  		[self genUnsignedSingleExtendB: (code bitShift: -8)].
  	stream
  		nextPut: 233;
  		nextPut: (code bitAnd: 255)!

Item was changed:
  ----- Method: EncoderForSistaV1>>isSpecialLiteralForPush: (in category 'special literal encodings') -----
  isSpecialLiteralForPush: literal
  	^literal isInteger
  		ifFalse:
  			[literal isCharacter
  				ifFalse:
  					[false == literal
  					 or: [true == literal
  					 or: [nil == literal]]]
  				ifTrue:
+ 					["Restrict character range due to VM bug at character value reconstruction
+ 					See https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/618"
+ 					literal asInteger between: 0 and: 16r7FFF]]
- 					[literal asInteger between: 0 and: 65535]]
  	 	ifTrue:
  			[literal between: -32768 and: 32767]!



More information about the Squeak-dev mailing list