[Vm-dev] VM Maker: ImageFormat-dtl.53.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Dec 26 20:14:44 UTC 2021


David T. Lewis uploaded a new version of ImageFormat to project VM Maker:
http://source.squeak.org/VMMaker/ImageFormat-dtl.53.mcz

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

Name: ImageFormat-dtl.53
Author: dtl
Time: 26 December 2021, 3:08:52.811788 pm
UUID: e08b1774-e9c5-4923-88fe-a0255af83508
Ancestors: ImageFormat-dtl.52

Rescue utility method to handle the hypothetical case of an image file written as format 68533 or 7033 by a newer VM, but no local VM is available to open this file format. ImageFormat class>>clearSistaBit: rewrites the format number in the image file, setting it back to a number usable by an older VM that nevertheless has the necessary Sista bytecode support.

=============== Diff against ImageFormat-dtl.52 ===============

Item was added:
+ ----- Method: ImageFormat class>>clearSistaBit: (in category 'utility') -----
+ clearSistaBit: imageFileName
+ 	"Rescue utility. If an image file was written by a VM that understands the new
+ 	image format numbers for multiple bytecode support, but no local VM is available
+ 	to run that image, this method can be used to rewrite the image format number
+ 	to an older format number that is likely to readable."
+ 
+ 	"ImageFormat clearSistaBit: 'imageFileToFix.image' "
+ 	
+ 	| fmt int newInt fs |
+ 	fmt := self fromFile: imageFileName.
+ 	int := fmt asInteger.
+ 	fmt requiresMultipleBytecodeSupport
+ 		ifFalse: [ ^self inform: fmt asString, ' conversion not required'].
+ 	fmt setRequiresMultipleBytecodeSupport: false.
+ 	newInt := fmt asInteger.
+ 	(self confirm: 'convert image format number ', int asString , ' to ', newInt asString)
+ 		ifFalse: [^self inform: 'image format number ', int asString, ' not changed'].
+ 	fs := FileStream fileNamed: imageFileName.
+ 	[ fs binary;
+ 		nextPut: (newInt bitAnd: 16rFF); "assume little endian"
+ 		nextPut: ((newInt >> 8) bitAnd: 16rFF);
+ 		nextPut: ((newInt >> 16) bitAnd: 16rFF);
+ 		nextPut: ((newInt >> 24) bitAnd: 16rFF) ] ensure: [ fs close ].
+ 	self inform: 'converted ', imageFileName,' image format number ', int asString , ' to ', newInt asString.
+ 	^self fromFile: imageFileName. "verify result"
+ 		
+ 	
+ !



More information about the Vm-dev mailing list