[squeak-dev] The Trunk: Compiler-eem.472.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Mar 10 21:39:35 UTC 2022


Eliot Miranda uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-eem.472.mcz

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

Name: Compiler-eem.472
Author: eem
Time: 10 March 2022, 1:39:22.234426 pm
UUID: 9930db94-e91a-4ef8-91d1-5e8309511442
Ancestors: Compiler-nice.471

The image level fix for issue https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/618.  Redefine SistaV1's extended Push Character bytecode to take an unsigned extension.  Adapt Nicolas' patch (thanks man!) to have the SistaV1 bytecode encoder not use the extended form at all unless running on a suitably fixed VM.  Requires System-eem.1321 (which is why there's an update).

This fixes the following:

self assert: 
(Compiler evaluate: '$', (Character value: 16r8000)) asInteger = 16r8000

This finds occurrences of the old broken code sequence:
self systemNavigation browseAllSelect: [:m| m scanFor: [:a :b :c| a = 16rE1 and: [c = 16rE9]]]

This finds occurrences of the new sequence supported by newer VMs.
self systemNavigation browseAllSelect: [:m| m scanFor: [:a :b :c| a = 16rE0 and: [c = 16rE9]]]

And since there aren't any here's a doit that shows that teh scanFor: will work if there were any:

Compiler evaluate: '{ ', (String with: $$ with: (Character value: 16r8000)), '. thisContext method symbolic. thisContext method scanFor: [:a :b :c| a = 16rE0 and: [c = 16rE9]]}'.

=============== Diff against Compiler-nice.471 ===============

Item was changed:
  BytecodeEncoder subclass: #EncoderForSistaV1
(excessive size, no diff calculated)

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 A * 256)"
+ 	"Why restrict the range to 16 bits when we could encode arbitrary 32-bit Characters?
+ 	 Well, 16 bits requires 4 bytes (extA + byte, 233 + byte) and so beyond this range we
- 	"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 versions is important if we
+ 	 want to be able to load binary code from one to the other (e.g. via Fuel)."
- 	 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].
+ 	(code < 0 or: [code > 65535]) ifTrue:
+ 		[^self outOfRangeError: 'character' index: code range: 0 to: 65535].
- 	"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 > 255) ifTrue:
+ 		[self genUnsignedSingleExtendA: (code bitShift: -8)].
- 		[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:
+ 					[Smalltalk interpreterVMMakerVersion >= 3174
+ 						ifTrue:
+ 							[literal asInteger between: 0 and: 65535]
+ 						ifFalse:
+ 							["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: 16rFF]]]
- 					["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]]
  	 	ifTrue:
  			[literal between: -32768 and: 32767]!



More information about the Squeak-dev mailing list