VM Maker: VMMaker-oscog-dtl.59.mcz

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

VM Maker: VMMaker-oscog-dtl.59.mcz

squeak-dev-noreply
 
Dave Lewis uploaded a new version of VMMaker to project VM Maker:
http://www.squeaksource.com/VMMaker/VMMaker-oscog-dtl.59.mcz

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

Name: VMMaker-oscog-dtl.59
Author: dtl
Time: 17 April 2011, 10:32:55 am
UUID: c1d30608-042d-4bb7-20ca-2bf7a46c1508
Ancestors: VMMaker-oscog-dtl.58

Merge VMMaker-oscog.dtl.58, and add #primitiveImageFormatVersion

Add primitiveMillisecondClockMask, an optional named primitive used in conjunction with primitiveMillisecondClock for duration calculations. The image assumes a value for this constant that is assumed to correspond to the actual value used in the VM. This primitive permits the VM to report the actual value being used.

Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg

On 18.04.2011, at 07:23, [hidden email] wrote:

> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html

Is there a way to detect if an image will be saved in a different format than it was loaded?

In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Tobias Pape


Am 2011-04-18 um 10:56 schrieb Bert Freudenberg:

>
> On 18.04.2011, at 07:23, [hidden email] wrote:
>
>> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>
> Is there a way to detect if an image will be saved in a different format than it was loaded?
>
> In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?

And: wasn't there a plan to make
Cog-saved images loadable in non-cogs?

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Levente Uzonyi-2
In reply to this post by Bert Freudenberg
 
On Mon, 18 Apr 2011, Bert Freudenberg wrote:

>
> On 18.04.2011, at 07:23, [hidden email] wrote:
>
>> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>
> Is there a way to detect if an image will be saved in a different format than it was loaded?
>
> In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?

Why don't you read the first four bytes from the image file to get the
image version? Also, there's SmalltalkImage >> #isRunningCog to check if
the current VM is a CogVM.

imageFormat := (FileStream fileNamed: Smalltalk imageName do: [ :file |
  file binary; next: 4 ]) unsignedLongAt: 1 bigEndian: false.
isCogVM := Smalltalk isRunningCog.


Levente

>
> - Bert -
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Levente Uzonyi-2
In reply to this post by Tobias Pape
 
On Mon, 18 Apr 2011, Tobias Pape wrote:

>
>
> Am 2011-04-18 um 10:56 schrieb Bert Freudenberg:
>
>>
>> On 18.04.2011, at 07:23, [hidden email] wrote:
>>
>>> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>>
>> Is there a way to detect if an image will be saved in a different format than it was loaded?
>>
>> In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?
>
> And: wasn't there a plan to make
> Cog-saved images loadable in non-cogs?

The last official unix VM can do that and probably the 5.7.4 mac VM can do
it too, but there's no official windows VM with this feature. Also this
doesn't help much if your users have an older VM installed.


Levente

>
> So Long,
> -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Tobias Pape


Am 2011-04-18 um 12:14 schrieb Levente Uzonyi:

> On Mon, 18 Apr 2011, Tobias Pape wrote:
>
>>
>>
>> Am 2011-04-18 um 10:56 schrieb Bert Freudenberg:
>>
>>>
>>> On 18.04.2011, at 07:23, [hidden email] wrote:
>>>
>>>> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>>>
>>> Is there a way to detect if an image will be saved in a different format than it was loaded?
>>>
>>> In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?
>>
>> And: wasn't there a plan to make
>> Cog-saved images loadable in non-cogs?
>
> The last official unix VM can do that and probably the 5.7.4 mac VM can do it too, but there's no official windows VM with this feature. Also this doesn't help much if your users have an older VM installed.

Is there any problem in "backconverting"
an image when saving it in Cog ?

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Levente Uzonyi-2
 
On Mon, 18 Apr 2011, Tobias Pape wrote:

>
> Is there any problem in "backconverting"
> an image when saving it in Cog ?

For most use cases, there's none. However Cog has to read the whole
non-cog image into memory to swap the floats, which increases startup
time.


Levente

>
> So Long,
> -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Tobias Pape


Am 2011-04-18 um 12:26 schrieb Levente Uzonyi:

> On Mon, 18 Apr 2011, Tobias Pape wrote:
>
>>
>> Is there any problem in "backconverting"
>> an image when saving it in Cog ?
>
> For most use cases, there's none. However Cog has to read the whole non-cog image into memory to swap the floats, which increases startup time.
>

Yes, but consider LittleEndian vs BigEndian
-Images and -VMs.
They have to do the same, all the time.

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg

On 18.04.2011, at 12:43, Tobias Pape wrote:

> Am 2011-04-18 um 12:26 schrieb Levente Uzonyi:
>
>> On Mon, 18 Apr 2011, Tobias Pape wrote:
>>
>>> Is there any problem in "backconverting"
>>> an image when saving it in Cog ?
>>
>> For most use cases, there's none. However Cog has to read the whole non-cog image into memory to swap the floats, which increases startup time.
>
> Yes, but consider LittleEndian vs BigEndian
> -Images and -VMs.
> They have to do the same, all the time.

Not all the time, just when switching platforms. AFAIK we never have done any converting when saving, only when loading.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Igor Stasenko
In reply to this post by squeak-dev-noreply

What are corresponding image-side changes? Is there a code which using
new prims?
I will create a Cog issue tracker entry for this.

@David,  could you register on google services, so i could add you as
a member to Cog project?

On 18 April 2011 07:23,  <[hidden email]> wrote:

>
> Dave Lewis uploaded a new version of VMMaker to project VM Maker:
> http://www.squeaksource.com/VMMaker/VMMaker-oscog-dtl.59.mcz
>
> ==================== Summary ====================
>
> Name: VMMaker-oscog-dtl.59
> Author: dtl
> Time: 17 April 2011, 10:32:55 am
> UUID: c1d30608-042d-4bb7-20ca-2bf7a46c1508
> Ancestors: VMMaker-oscog-dtl.58
>
> Merge VMMaker-oscog.dtl.58, and add #primitiveImageFormatVersion
>
> Add primitiveMillisecondClockMask, an optional named primitive used in conjunction with primitiveMillisecondClock for duration calculations. The image assumes a value for this constant that is assumed to correspond to the actual value used in the VM. This primitive permits the VM to report the actual value being used.
>
> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>
>



--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Igor Stasenko
In reply to this post by Bert Freudenberg
 
http://code.google.com/p/cog/issues/detail?id=27

--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg
In reply to this post by Igor Stasenko
 

On 18.04.2011, at 13:01, Igor Stasenko wrote:

>
> What are corresponding image-side changes? Is there a code which using
> new prims?
> I will create a Cog issue tracker entry for this.

http://source.squeak.org/trunk/System-dtl.315.diff

http://source.squeak.org/trunk/changes/System-dtl.315(ar.314).cs

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg
 
On 18.04.2011, at 13:10, Bert Freudenberg wrote:

> On 18.04.2011, at 13:01, Igor Stasenko wrote:
>
>> What are corresponding image-side changes? Is there a code which using
>> new prims?
>> I will create a Cog issue tracker entry for this.
>
> http://source.squeak.org/trunk/System-dtl.315.diff
>
> http://source.squeak.org/trunk/changes/System-dtl.315(ar.314).cs
>
> - Bert -

Oh, and for the clock mask:

http://source.squeak.org/trunk/Kernel-dtl.569.diff

http://source.squeak.org/trunk/changes/Kernel-dtl.569(cmm.568).cs

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg
In reply to this post by Levente Uzonyi-2


On 18.04.2011, at 12:12, Levente Uzonyi wrote:

> On Mon, 18 Apr 2011, Bert Freudenberg wrote:
>
>>
>> On 18.04.2011, at 07:23, [hidden email] wrote:
>>
>>> Add primitiveImageFormatVersion, an optional named primitive answering the image format number of the current image. This is the value stored in the first word of an image file header when the image is saved, and possibly modified on image load if the VM adds or removes capabilities for the running image. This primitive was added to VMMaker trunk in VMMaker-dtl.169. Rationale: supports float word order handing for image segments, reference http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>>
>> Is there a way to detect if an image will be saved in a different format than it was loaded?
>>
>> In some images I want to avoid saving them accidentally as a Cog image. I have been doing this by adding a preference "warnAboutSavingAsCog" and checking the VM version string for "cog". With this new primitive I could more reliably detect Cog, but I guess no information about the loaded image is retained?
>
> Why don't you read the first four bytes from the image file to get the image version?

Because if this was a save-as, then "Smalltalk imageName" has already been changed to the new one.

But I should put an extra check into saveImageInFileNamed: I guess.

> Also, there's SmalltalkImage >> #isRunningCog to check if the current VM is a CogVM.

Ah. I didn't know we had that test method. I thought I had asked before but apparently I only imagined that :)

- Bert -

> imageFormat := (FileStream fileNamed: Smalltalk imageName do: [ :file |
> file binary; next: 4 ]) unsignedLongAt: 1 bigEndian: false.
> isCogVM := Smalltalk isRunningCog.


Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

David T. Lewis
In reply to this post by Levente Uzonyi-2
 
On Mon, Apr 18, 2011 at 12:12:22PM +0200, Levente Uzonyi wrote:

>
> On Mon, 18 Apr 2011, Bert Freudenberg wrote:
>
> >
> >On 18.04.2011, at 07:23, [hidden email]
> >wrote:
> >
> >>Add primitiveImageFormatVersion, an optional named primitive answering
> >>the image format number of the current image. This is the value stored in
> >>the first word of an image file header when the image is saved, and
> >>possibly modified on image load if the VM adds or removes capabilities
> >>for the running image. This primitive was added to VMMaker trunk in
> >>VMMaker-dtl.169. Rationale: supports float word order handing for image
> >>segments, reference
> >>http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
> >
> >Is there a way to detect if an image will be saved in a different format
> >than it was loaded?
> >
> >In some images I want to avoid saving them accidentally as a Cog image. I
> >have been doing this by adding a preference "warnAboutSavingAsCog" and
> >checking the VM version string for "cog". With this new primitive I could
> >more reliably detect Cog, but I guess no information about the loaded
> >image is retained?
>
> Why don't you read the first four bytes from the image file to get the
> image version? Also, there's SmalltalkImage >> #isRunningCog to check if
> the current VM is a CogVM.
>
> imageFormat := (FileStream fileNamed: Smalltalk imageName do: [ :file |
> file binary; next: 4 ]) unsignedLongAt: 1 bigEndian: false.
> isCogVM := Smalltalk isRunningCog.

The image format number in the file is not necessarily the same as the
image format currently being used. For example, when an interpreter VM
reads an image saved from Cog (i.e. format 6505), it converts the image
to format 6504 prior to entering the interpreter. So the disk file will
tell you that you are using a 6505 image, but the VM knows better and
will report the current image format version as 6504.

Similarly, Cog converts a 6504 image from disk into a 6505 image in
memory, and will later save the image as 6505.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: VM Maker: VMMaker-oscog-dtl.59.mcz

Bert Freudenberg


On 18.04.2011, at 16:46, David T. Lewis wrote:

>
> On Mon, Apr 18, 2011 at 12:12:22PM +0200, Levente Uzonyi wrote:
>>
>> On Mon, 18 Apr 2011, Bert Freudenberg wrote:
>>
>>>
>>> On 18.04.2011, at 07:23, [hidden email]
>>> wrote:
>>>
>>>> Add primitiveImageFormatVersion, an optional named primitive answering
>>>> the image format number of the current image. This is the value stored in
>>>> the first word of an image file header when the image is saved, and
>>>> possibly modified on image load if the VM adds or removes capabilities
>>>> for the running image. This primitive was added to VMMaker trunk in
>>>> VMMaker-dtl.169. Rationale: supports float word order handing for image
>>>> segments, reference
>>>> http://lists.squeakfoundation.org/pipermail/vm-dev/2011-April/007712.html
>>>
>>> Is there a way to detect if an image will be saved in a different format
>>> than it was loaded?
>>>
>>> In some images I want to avoid saving them accidentally as a Cog image. I
>>> have been doing this by adding a preference "warnAboutSavingAsCog" and
>>> checking the VM version string for "cog". With this new primitive I could
>>> more reliably detect Cog, but I guess no information about the loaded
>>> image is retained?
>>
>> Why don't you read the first four bytes from the image file to get the
>> image version? Also, there's SmalltalkImage >> #isRunningCog to check if
>> the current VM is a CogVM.
>>
>> imageFormat := (FileStream fileNamed: Smalltalk imageName do: [ :file |
>> file binary; next: 4 ]) unsignedLongAt: 1 bigEndian: false.
>> isCogVM := Smalltalk isRunningCog.
>
> The image format number in the file is not necessarily the same as the
> image format currently being used. For example, when an interpreter VM
> reads an image saved from Cog (i.e. format 6505), it converts the image
> to format 6504 prior to entering the interpreter. So the disk file will
> tell you that you are using a 6505 image, but the VM knows better and
> will report the current image format version as 6504.

Yes, that is precisely the use case here. I wanted to detect when an interpreter image was saved as cog image for the first time.

wasCog := self imageFormatVersionFromFile allMask: 1.
isCog := Smalltalk isRunningCog.

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) << 24)]

imageFormatVersionFromFileAsIs
        ^(FileStream fileNamed: Smalltalk imageName do: [ :file | file binary; next: 4 ])
                unsignedLongAt: 1 bigEndian: Smalltalk isBigEndian



- Bert -