MicroSqueak's Interpreter

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

MicroSqueak's Interpreter

Chris Cunnington
MicroSqueak comes with an Interpreter class. InterpreterSupportCode
writeMacSourceFiles spits out:

msq.h
msqFilePrims.c
msqMain.c
msqMiscPrims.c
projectArchive.sit (which opens up into MicroSqueak VM.proj)

The README mentions an interp.c, which doesn't appear anywhere.

These files are from 1999 and PPC, so I'd imagine compiling from these
is not feasible.
But they point to an interesting direction for learning how to make a
vm: a tiny set of files.

sq.h and interp.c are clearly required. The README gives the impression
the .c files are where the options are. Connecting to to stdio.h is
important, of course.

A good approach would be to have somebody list equivalent files produced
by the current VM.
Maybe /platforms/Cross/vm:

sq.h
sqMemoryAccess.h
sqNamedPrims.c
sqVirtualMachine.c
sqVirtualMachine.h
and,
/platforms/unix/src/interp.c

If somebody could point to a subset of what the VMBuilderTool produces,
I think it could go a long way to making vm hacking more approachable. I
understand that any file set would need some doctoring, but even so,
looking at five files is something that wouldn't make a beginner balk.

Any suggestions as to a tight subset for me to explore and compile on my
Mac using the process described in Adrian's blog would be greatly
appreciated.

Then I could see the relationship to MicroSqueak's 56k image. :)
Actually, I guess you have to see what the image does and then work back
to the capabilities available in the vm. Anyway...you get the idea.


Chris






_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: MicroSqueak's Interpreter

johnmci
Also see
http://isqueak.org/PlatformVMAPI

On 2011-01-08, at 1:21 PM, Chris Cunnington wrote:

> MicroSqueak comes with an Interpreter class. InterpreterSupportCode writeMacSourceFiles spits out:
>
> msq.h
> msqFilePrims.c
> msqMain.c
> msqMiscPrims.c
> projectArchive.sit (which opens up into MicroSqueak VM.proj)
>
> The README mentions an interp.c, which doesn't appear anywhere.
>
> These files are from 1999 and PPC, so I'd imagine compiling from these is not feasible.
> But they point to an interesting direction for learning how to make a vm: a tiny set of files.
>
> sq.h and interp.c are clearly required. The README gives the impression the .c files are where the options are. Connecting to to stdio.h is important, of course.
>
> A good approach would be to have somebody list equivalent files produced by the current VM.
> Maybe /platforms/Cross/vm:
>
> sq.h
> sqMemoryAccess.h
> sqNamedPrims.c
> sqVirtualMachine.c
> sqVirtualMachine.h
> and,
> /platforms/unix/src/interp.c
>
> If somebody could point to a subset of what the VMBuilderTool produces, I think it could go a long way to making vm hacking more approachable. I understand that any file set would need some doctoring, but even so, looking at five files is something that wouldn't make a beginner balk.
>
> Any suggestions as to a tight subset for me to explore and compile on my Mac using the process described in Adrian's blog would be greatly appreciated.
>
> Then I could see the relationship to MicroSqueak's 56k image. :)
> Actually, I guess you have to see what the image does and then work back to the capabilities available in the vm. Anyway...you get the idea.
>
>
> Chris
>
>
>
>
>
>
> _______________________________________________
> VM-beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners

--
===========================================================================
John M. McIntosh <[hidden email]>   Twitter:  squeaker68882
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================




_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: MicroSqueak's Interpreter

David T. Lewis
In reply to this post by Chris Cunnington
On Sat, Jan 08, 2011 at 04:21:12PM -0500, Chris Cunnington wrote:

> MicroSqueak comes with an Interpreter class. InterpreterSupportCode
> writeMacSourceFiles spits out:
>
> msq.h
> msqFilePrims.c
> msqMain.c
> msqMiscPrims.c
> projectArchive.sit (which opens up into MicroSqueak VM.proj)
>
> The README mentions an interp.c, which doesn't appear anywhere.
>
> These files are from 1999 and PPC, so I'd imagine compiling from these
> is not feasible.
> But they point to an interesting direction for learning how to make a
> vm: a tiny set of files.
>
> sq.h and interp.c are clearly required. The README gives the impression
> the .c files are where the options are. Connecting to to stdio.h is
> important, of course.
>
> A good approach would be to have somebody list equivalent files produced
> by the current VM.
> Maybe /platforms/Cross/vm:
>
> sq.h
> sqMemoryAccess.h
> sqNamedPrims.c
> sqVirtualMachine.c
> sqVirtualMachine.h
> and,
> /platforms/unix/src/interp.c
>
> If somebody could point to a subset of what the VMBuilderTool produces,
> I think it could go a long way to making vm hacking more approachable. I
> understand that any file set would need some doctoring, but even so,
> looking at five files is something that wouldn't make a beginner balk.
>
> Any suggestions as to a tight subset for me to explore and compile on my
> Mac using the process described in Adrian's blog would be greatly
> appreciated.
>
> Then I could see the relationship to MicroSqueak's 56k image. :)
> Actually, I guess you have to see what the image does and then work back
> to the capabilities available in the vm. Anyway...you get the idea.

All early versions of Squeak included the virtual machine itself in
the image. If you look on ftp.squeak.org you can find all of these
earlier versions (and I recommend doing so). Some simple platform
support source code was saved in the image, and the #writeMacSourceFiles
method wrote them to disk. Nowadays, the platform support code has
become more sophisticated and covers a range of computer platforms,
so it is now managed in a Subversion repository on squeakvm.org.
Similarly, the Smalltalk implementation of the object memory and
interpreter have been moved to the VMMaker repository on SqueakSource.

Putting the VM into separate packages and repositories is great for
managing the code, but it does have one unfortunate side effect.
Over time, folks have gotten the idea that the VM is some kind of
separate thing that is only accessible to "gurus". That is not
the case! Squeak is a Smalltalk written in itself, and anyone
with an interest in the VM can and should load VMMaker into their
image, explore the platform support code on squeakvm.org, write
a new plugin, tinker with the garbage collector, try implementing
a 48 bit object memory, or try anything else that catches your
fancy :)

As far as looking at a "subset of what the VMBuilderTool produces",
a key thing to understand is that the C code that the tool
produces is not the main thing of interest. The VM builder
translates the interpreter, written in Smalltalk, into a compilable
format (the C files). So if you want to understand the interpreter,
it is good to look at the original source code - the object memory
and interpreter classes in the VMMaker package.

If you use an up to date Squeak image, and bring your VMMaker
package fully up to date by evaluating "VMMaker updateFromServer",
you will also be able to browse the C code at the same time
you are looking at the Smalltalk sources. Try doing this:

 - Open a browser on class ObjectMemory.
 - Read the class comments for ObjectMemory, Interpreter, and
   BitBltSimulation. You will want to come back and re-read these
   later, so don't worry if they do not make sense the first time.
 - In class ObjectMemory, look at one of the methods. Let's pick
   #accessibleObjectAfter: as an example. You will see the Smalltalk
   implementation with a method comment explaining what is does,
   and you can look for senders of this method to get a feel for
   how it is used in the VM.
 - Now click the "source" button (middle right side of the browser)
   and select the "translate inlined C" option. You will see
   the generated C code for this method.
 - Find a copy of a generated interp.c file. Open it in a text
   editor, and find the C function accessibleObjectAfter() in
   the source code. You should see the same source code that
   was displayed in your browser window.

Dave

_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: MicroSqueak's Interpreter

David T. Lewis
In reply to this post by Chris Cunnington
On Sat, Jan 08, 2011 at 04:21:12PM -0500, Chris Cunnington wrote:
>
> Any suggestions as to a tight subset for me to explore and compile on my
> Mac using the process described in Adrian's blog would be greatly
> appreciated.

To make a minimal VM from the standard VMMaker package, open a
VMMakerTool and drag the following three items from the left
pane to the center pane ("Internal Plugins"):

        BalloonEnginePlugin
        BitBltSimulation
        FilePlugin

This is the smallest usable configuration. If you expect to use
any networking functions, then you should also include SocketPlugin.

I am not sure if the resulting VM will be usable with MicroSqueak,
because there have been some changes to the special objects array
over the years, so some image/VM compatibility issues are possible.

Dave

_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners