The Trunk: System-bf.446.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-bf.446.mcz

commits-2
Bert Freudenberg uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-bf.446.mcz

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

Name: System-bf.446
Author: bf
Time: 11 July 2011, 11:06:25.328 am
UUID: e0bb3739-1ffb-4552-b95d-75e95f6033bf
Ancestors: System-ul.445

- provide methods to read image format from image file
- warn about saving in a different format

=============== Diff against System-ul.445 ===============

Item was changed:
  ----- Method: SmalltalkImage>>imageFormatVersion (in category 'image') -----
  imageFormatVersion
+ "Answer an integer identifying the type of image in memory. The image version number may
- "Answer an integer identifying the type of image. The image version number may
  identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
  of the image (e.g. block closure support required). This invokes an optional primitive
  that may not be available on all virtual machines."
 
  "Smalltalk image imageFormatVersion"
 
  <primitive: 'primitiveImageFormatVersion'>
  self notify: 'This virtual machine does not support the optional primitive #primitiveImageFormatVersion' translated.
  ^''!

Item was added:
+ ----- Method: SmalltalkImage>>imageFormatVersionFromFile (in category 'image') -----
+ imageFormatVersionFromFile
+ "Answer an integer identifying the type of image on file. The image version number may
+ identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
+ of the image (e.g. block closure support required)"
+
+ "Smalltalk image imageFormatVersionFromFile"
+
+ | format |
+ format := self imageFormatVersionFromFileAsIs.
+ ^format <= 16r00FFFFFF
+ ifTrue: [  "same endianness as VM"
+ format ]
+ ifFalse: [ "convert endianness"
+ ((format bitAnd: 16rFF000000) >> 24)
+ + ((format bitAnd: 16r00FF0000) >> 8)
+ + ((format bitAnd: 16r0000FF00) << 8)
+ + ((format bitAnd: 16r000000FF) << 16)]!

Item was added:
+ ----- Method: SmalltalkImage>>imageFormatVersionFromFileAsIs (in category 'image') -----
+ imageFormatVersionFromFileAsIs
+ "Answer an integer identifying the type of image on file. The image version number may
+ identify the format of the image (e.g. 32 or 64-bit word size) or specific requirements
+ of the image (e.g. block closure support required). If the image file has a different
+ endianness than the VM, the format version will appear byte-swapped."
+
+ "Smalltalk image imageFormatVersionFromFileAsIs"
+
+ ^(FileStream readOnlyFileNamed: Smalltalk imageName do: [ :file | file binary; next: 4 ])
+ unsignedLongAt: 1 bigEndian: Smalltalk isBigEndian!

Item was added:
+ ----- Method: SmalltalkImage>>okayToSave (in category 'snapshot and quit') -----
+ okayToSave
+ | wasCog isCog |
+ [wasCog := self imageFormatVersionFromFile allMask: 1]
+ on: Error do: [:ignore | "probably save-as to non-existing file" ^ true ].
+ isCog := Smalltalk isRunningCog.
+ ^wasCog = isCog or: [
+ self confirm: 'Images saved under Cog cannot be opened on an interpreter again!!
+ Really save?']
+ !

Item was changed:
  ----- Method: SmalltalkImage>>saveAs: (in category 'sources, changes log') -----
  saveAs: newName
  "Save the image  under that new name."
  newName ifNil:[^ self].
+ self okayToSave ifFalse: [^self].
  (SourceFiles at: 2) ifNotNil:
  [self closeSourceFiles; "so copying the changes file will always work"
  saveChangesInFileNamed: (self fullNameForChangesNamed: newName)].
  self saveImageInFileNamed: (self fullNameForImageNamed: newName)!

Item was changed:
  ----- Method: SmalltalkImage>>saveAsNewVersion (in category 'sources, changes log') -----
  saveAsNewVersion
  "Save the image/changes using the next available version number."
  "SmalltalkImage current saveAsNewVersion"
 
  | newName changesName aName anIndex |
+ self okayToSave ifFalse: [^self].
  aName := FileDirectory baseNameFor: (FileDirectory default localNameFor: self imageName).
  anIndex := aName lastIndexOf: FileDirectory dot asCharacter ifAbsent: [nil].
  (anIndex notNil and: [(aName copyFrom: anIndex + 1 to: aName size) isAllDigits])
  ifTrue:
  [aName := aName copyFrom: 1 to: anIndex - 1].
 
  newName := FileDirectory default nextNameFor: aName extension: FileDirectory imageSuffix.
  changesName := self fullNameForChangesNamed: newName.
 
  "Check to see if there is a .changes file that would cause a problem if we saved a new .image file with the new version number"
  (FileDirectory default fileOrDirectoryExists: changesName)
  ifTrue:
  [^ self inform:
  'There is already .changes file of the desired name,
  ', newName, '
  curiously already present, even though there is
  no corresponding .image file.   Please remedy
  manually and then repeat your request.'].
 
  (SourceFiles at: 2) ifNotNil:
  [self closeSourceFiles; "so copying the changes file will always work"
  saveChangesInFileNamed: (self fullNameForChangesNamed: newName)].
  self saveImageInFileNamed: (self fullNameForImageNamed: newName)
 
 
  !

Item was changed:
  ----- Method: SmalltalkImage>>snapshot:andQuit: (in category 'snapshot and quit') -----
  snapshot: save andQuit: quit
+ (save and: [self okayToSave not]) ifTrue: [^self].
  ^self snapshot: save andQuit: quit embedded: false!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-bf.446.mcz

Levente Uzonyi-2
On Mon, 11 Jul 2011, [hidden email] wrote:

> Bert Freudenberg uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-bf.446.mcz
>

snip

> Item was added:
> + ----- Method: SmalltalkImage>>okayToSave (in category 'snapshot and quit') -----
> + okayToSave
> + | wasCog isCog |
> + [wasCog := self imageFormatVersionFromFile allMask: 1]
> + on: Error do: [:ignore | "probably save-as to non-existing file" ^ true ].

You can also omit the argument.

> + isCog := Smalltalk isRunningCog.
> + ^wasCog = isCog or: [
> + self confirm: 'Images saved under Cog cannot be opened on an interpreter again!!
> + Really save?']

It's not entirely true. The latest release of Unix and Mac interpreter VMs
can read Cog images. Also if there were a new Windows VM released using
the current VMMaker, it would also be able to open images saved with Cog.
The proof is the VM that I built a few month ago
(http://leves.web.elte.hu/squeak/SqueakVM-Win32-4.4.9-2358-non-official-bin.zip 
), because I had to read old ImageSegments into a Cog image which were not
readable by Cog VMs.


Levente

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-bf.446.mcz

Bert Freudenberg
On 11.07.2011, at 22:08, Levente Uzonyi wrote:

> On Mon, 11 Jul 2011, [hidden email] wrote:
>
>> Bert Freudenberg uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-bf.446.mcz
>>
>
> snip
>
>> Item was added:
>> + ----- Method: SmalltalkImage>>okayToSave (in category 'snapshot and quit') -----
>> + okayToSave
>> + | wasCog isCog |
>> + [wasCog := self imageFormatVersionFromFile allMask: 1]
>> + on: Error do: [:ignore | "probably save-as to non-existing file" ^ true ].
>
> You can also omit the argument.
>
>> + isCog := Smalltalk isRunningCog.
>> + ^wasCog = isCog or: [
>> + self confirm: 'Images saved under Cog cannot be opened on an interpreter again!!
>> + Really save?']
>
> It's not entirely true.

Right. It should say "possibly".

> The latest release of Unix and Mac interpreter VMs can read Cog images.

The bleeding-edge Mac VMs do not run on older systems.  4.2.5 is the latest stable Mac VM, but it cannot read Cog images.

The VMs officially packaged in various Linux distros cannot read Cog images either.

> Also if there were a new Windows VM released using the current VMMaker, it would also be able to open images saved with Cog. The proof is the VM that I built a few month ago (http://leves.web.elte.hu/squeak/SqueakVM-Win32-4.4.9-2358-non-official-bin.zip ), because I had to read old ImageSegments into a Cog image which were not readable by Cog VMs.

Sounds good.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-bf.446.mcz

Levente Uzonyi-2
On Tue, 12 Jul 2011, Bert Freudenberg wrote:

> On 11.07.2011, at 22:08, Levente Uzonyi wrote:
>
>> On Mon, 11 Jul 2011, [hidden email] wrote:
>>
>>> Bert Freudenberg uploaded a new version of System to project The Trunk:
>>> http://source.squeak.org/trunk/System-bf.446.mcz
>>>
>>
>> snip
>>
>>> Item was added:
>>> + ----- Method: SmalltalkImage>>okayToSave (in category 'snapshot and quit') -----
>>> + okayToSave
>>> + | wasCog isCog |
>>> + [wasCog := self imageFormatVersionFromFile allMask: 1]
>>> + on: Error do: [:ignore | "probably save-as to non-existing file" ^ true ].
>>
>> You can also omit the argument.
>>
>>> + isCog := Smalltalk isRunningCog.
>>> + ^wasCog = isCog or: [
>>> + self confirm: 'Images saved under Cog cannot be opened on an interpreter again!!
>>> + Really save?']
>>
>> It's not entirely true.
>
> Right. It should say "possibly".
>
>> The latest release of Unix and Mac interpreter VMs can read Cog images.
>
> The bleeding-edge Mac VMs do not run on older systems.  4.2.5 is the latest stable Mac VM, but it cannot read Cog images.

Right, the latest stable Cocoa interpreter (5.7.4.1) should be able to
open Cog images. I'm not sure if there will be a 4.2.6 Carbon VM...

>
> The VMs officially packaged in various Linux distros cannot read Cog images either.

The latest stable release is 4.4.7.2357, which has this feature, so the
Linux packages should be updated somehow.


Levente

>
>> Also if there were a new Windows VM released using the current VMMaker, it would also be able to open images saved with Cog. The proof is the VM that I built a few month ago (http://leves.web.elte.hu/squeak/SqueakVM-Win32-4.4.9-2358-non-official-bin.zip ), because I had to read old ImageSegments into a Cog image which were not readable by Cog VMs.
>
> Sounds good.
>
> - Bert -
>
>
>
>