[Vm-dev] Return a value from the image to the VM

Rob Rothwell r.j.rothwell at gmail.com
Thu Nov 26 03:06:31 UTC 2009


I miraculously managed to somehow load VMMaker in Pharo on Windows XP.

Furthermore, I managed to create a new Primitive:
 Interpreter>>primitiveSetOSErrorCode.

I was even able to use that primitive without the VM crashing!

But I can't seem to find the declaration of my instance variable osErrorCode
outside the scope of the primitive so I can use it in ioExit...

Any tips?  Is there something special you have to do to create the instance
variables?

Thanks again for pointing me in the right direction...

Rob

On Mon, Nov 23, 2009 at 12:19 AM, John M McIntosh <
johnmci at smalltalkconsulting.com> wrote:

>
> Well yes you need to use VMMaker
> Look at the gcBiasToGrowGCLimit setup.
> gcBiasToGrowGCLimit is an instance var on Interpreter
> Then you need
>
> Interpreter>>primitiveSetGCBiasToGrowGCLimit
>        "Primitive. If the GC logic has  bias to grow, set growth limit"
>        | value |
>        self export: true.
>        value := self stackIntegerValue: 0.
>        successFlag ifTrue:[
>                gcBiasToGrowGCLimit := value.
>                //Other clutter here which is not important to the example
>                self pop: argumentCount.
>        ].
>
> Then an example to call it.
>
> SystemDictionary>>setGCBiasToGrowGCLimit: aNumber
>        "Primitive. Indicate that the bias to grow logic should do a GC
> after aNumber Bytes"
>        <primitive: 'primitiveSetGCBiasToGrowGCLimit'>
>        ^self primitiveFailed
> "Example:
>        Smalltalk setGCBiasToGrowGCLimit: 16*1024*1024.
> "
>
> Squeak calls the routine ioExit() to exit, which is platform dependent, in
> that routine you
> would need to load the return code and do something interesting with it.
>
>
> On 2009-11-22, at 5:12 AM, Rob Rothwell wrote:
>
> >
> > On 22.11.2009, at 05:07, Rob Rothwell wrote:
> > > Hello...
> > >
> > > For scripting purposes, I just want to be able to do something like:
> > >
> > > SmalltalkImage current quit: errorCode.
> > >
> > > So that in the VM I can essentially do:
> > >
> > > return errorCode.
> > >
> > > at the end of sqMain?
> > >
> > > Any pointers on how to push a value BACK to the VM?  I have only barely
> dabbled with adding some custom menu commands to the VM long ago, and have
> no idea where to start.
> >
> > You would need to add a primitive to set the errorCode. This would be
> stored in an interpreter variable. Then the VM's exit code would be modified
> to retrieve that value.
> >
> > So, unlike all the other examples out there, this would probably be best
> if it were NOT an external plugin?  Would you be able to use VMMaker to do
> this (I've never done that before), or just go hand code some stuff?
> >
> > Do you think this seems like a generically pretty useful think to add to
> the VM?  If so, I suppose I would like to do it right!
> >
> > I hacked a temporary solution together with batch files and unique file
> names, but it feels a little sloppy.
> >
> > Thanks,
> >
> > Rob
>
> --
> ===========================================================================
> John M. McIntosh <johnmci at smalltalkconsulting.com>   Twitter:
>  squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
> ===========================================================================
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20091125/5d0a46b9/attachment.htm


More information about the Vm-dev mailing list