[Vm-dev] Return a value from the image to the VM
r.j.rothwell at gmail.com
Mon Nov 23 11:33:37 UTC 2009
I DID manage to build a new VM from the C source code that is available; I
have never yet GENERATED the source from VMMaker.
I guess once I figure that out I'll have a place to start now.
(I was poking around in the primitive table directly and recompiling!)
I did find ioExit() in the C-Code, but when I loaded VMMaker, I only found
it in InterpreterSimulator.
What a lot to learn!
Thanks again for pointing me towards and example,
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
> "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
> 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:
> Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev