[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Tue, 25 Jan 2005 15:50:58 +0000 
Subject:Re: How to read the sources 
From:Chris Dollin 
Volume-ID: 

Mystifier wrote:

> I am a non cs computer programming and am currently trying to write a
> Virtual Machine for Ruby.
> 
> I am reading how VMs have been designed in past and learning about
> them. I downloaded POP but I find it has plenty of .p files. Is the VM
> not written in C? Where do I find them or docs talking about in detail
> design of VM.

Poplog is mostly written in Pop11. The VM is implemented by compiling to
native machine code - there's no "vm interpreter". The compiler is
written in (the system dialect of) Pop11.

Poplog's VM is unusual in several respects. You don't get to see any
abstract instructions, only the procedure calls that plant them. The
VM has a two-stack model, where arguments/results go on the "value
stack" and local variables/return addresses go on the "control stack".
(Like FORTH and Postscript.) And there are no instructions for, say,
addition, because as far as the VM is concerned they're just calls to
built-in procedures.

You want to find the document usually referred to as REF VMCODE; it's
in pop/ref/vcmode under v15.53 (or whatever the number is in your
download). You'll likely have to start ved up to read it, since it
uses those funny ved highlighting characters.

-- 
Chris "electric hedgehog" Dollin
>From A.Sloman@cs.bham.ac.uk Sun Jan 30 13:27:28 2005
Path: news.demon.co.uk!mutlu.news.demon.net!peer-uk.news.demon.net!kibo.news.demon.net!demon!news-lond.gip.net!news.gsl.net!gip.net!easynet-monga!easynet.net!feed4.jnfs.ja.net!feed3.jnfs.ja.net!feed2.jnfs.ja.net!jnfs.ja.net!warwick!news-out.ftel.co.uk!bhamcs!not-for-mail
From: Aaron Sloman <A.Sloman@cs.bham.ac.uk>
Newsgroups: comp.lang.pop
Subject: Re: How to read the sources
Date: Sun, 30 Jan 2005 13:27:28 +0000 (UTC)
Organization: School of Computer Science, The University of Birmingham
Lines: 188
Message-ID: <ctinc0$2kh4$1@soapbox.cs.bham.ac.uk>
References: <1106572734.043554.299370@z14g2000cwz.googlegroups.com>
X-Trace: soapbox.cs.bham.ac.uk 1107091648 86564 147.188.194.39 (30 Jan 2005 13:27:28 GMT)
X-Complaints-To: abuse@cs.bham.ac.uk
Xref: news.demon.co.uk comp.lang.pop:1403


"Mystifier" <rohitlodha@gmail.com> writes:

> Date: 24 Jan 2005 06:06:25 -0800
>
> I am a non cs computer programming and am currently trying to write a
> Virtual Machine for Ruby.

I know nothing about Ruby and had not even heard of it till I saw
your comp.lang.pop message.

So I can tell you about Poplog and leave it to you to investigate
the match to Ruby. My comments supplement the previously
circulated comments by Chris Dollin.

(Because I am lazy, I always write pop11 instead of pop-11, which
some will say is the correct name of the language. I think it now
has two names! It is invoked as pop11, not pop-11.)

> I am reading how VMs have been designed in past and learning about
> them. I downloaded POP but I find it has plenty of .p files.

Which version did you fetch from where? On which machine are you
trying to run it?

Did you actually get it to run?

The core language of poplog is pop11, for which there is an
introductory description here

    http://www.cs.bham.ac.uk/research/poplog/primer/START.html

pop11 is also used to implement the other poplog languages: Prolog,
Common Lisp, and ML.

Most of the sources of poplog are writtein in pop11 in the directory

    $usepop/pop/src/*.p
    $usepop/pop/src/*.ph
        (.ph files are like 'include' .h files in C, but useful
        only for pop11)

Most of the files are common to all versions of poplog, but some
are specific to OS+CPU platform.

There are also some hand-coded assembler files in there, specific
to OS+CPU platform.
    $usepop/pop/src/*.s

There is also some C code here

    $usepop/pop/extern/lib/

Because poplog is mostly implemented in Pop11, there are, besides
the incremental compiler used in a running poplog system for
compiling user code, also tools for compiling and rebuilding the
system using the pop11 system sources. These tools are also
implemented in pop11 and are used to create poplog saved images
that are used for compiling, archiving, and linking Poplog.

The code for those system-building (and porting) tools is all
in
    $usepop/pop/src/syscomp

Once a system is built and running, it can compile and run pop11
programs (including interactive pop11 commands). Because the
incremental compiler tools are part of the run time system they
can be used to implement incrementatl compilers for other languages,
including the three that come with poplog:

The sources and documentation for the Prolog incremental compiler
are in

    $usepop/pop/plog/

For Common Lisp

    $usepop/pop/lisp/

For ML

    $usepop/pop/pml/

Sources in other places in the $usepop/pop tree are concerned with
the editor Ved,
    $usepop/pop/ved/src/

the X version of the editor XVed,
    $usepop/pop/x/ved/

the low level interface to the X window system (written in C),
    $usepop/pop/x/Xpw/

and other graphical facilities built on top of those:
    $usepop/pop/x/pop/

If Ruby requires any changes to the core poplog system, you will
have to understand the sources in $usepop/pop/src/ in order to
design and implement a new poplog. For that you will have to
learn about the system dialect of pop11, syspop11 used only in those
sources. There is information about the system dialect, porting
processes, and the poplog virtual machine here:

    http://www.cs.bham.ac.uk/research/poplog/sysdoc/

There are elementary (and very basic) introductions to the poplog
VM in some teach files that can be read most easily in the editor
Ved (or XVed) or in Emacs if you have the poplog Emacs extension.
(Using these to read the code makes it easy to follow the hypertext
links, e.g. by typing 'ESC h' in Ved.)

The introductory files include
    TEACH VM
    $usepop/pop/teach/vm

and a tool for displaying intermediate VM code generated when
pop11 expressions are compiled, described in HELP SHOWCODE

    $usepop/pop/help/showcode

The most detailed technical description of the Poplog VM (which is
not easy to understand if you are not already familiar with pop11)
is

    REF VMCODE
    $usepop/pop/ref/vmcode

Chris Dollin wrote:

> You want to find the document usually referred to as REF VMCODE; it's in
> pop/ref/vcmode under v15.53 (or whatever the number is in your
> download). You'll likely have to start ved up to read it, since it uses
> those funny ved highlighting characters.

There are versions of the system documentation with all the 'funny'
characters removed here
    http://www.cs.bham.ac.uk/research/poplog/doc/

or in a tar file
    http://www.cs.bham.ac.uk/research/poplog/docdirs.tar.gz
(Some of the files in there may be a bit out of date, but that will
not affect the files concerned with the VM.)

E.g. REF VMCODE is available in plain ascii text here:
    http://www.cs.bham.ac.uk/research/poplog/doc/popref/vmcode

There are also html versions of the documentation at Reading
University maintained by Anthony Worrall. See

    http://www.poplog.cs.reading.ac.uk/poplog/
    http://www.cs.bham.ac.uk/research/poplog/poplog.info.html


> Is the VM not written in C? Where do I find them or docs talking                   
> about in detail design of VM.

I hope the above anwer provides useful information.

It would be very difficult to implement poplog in C. One benefit of
implementing it in pop11 is that the run-time (incremental) compiler
for pop11 can share a great deal with the build-time
(non-incremental) compiler used for rebuilding the system or porting
it to new machines.


> Mystifier

Hope you are less mystified now?

If you do build a ruby implementation in poplog it should be able
to benefit from the graphical facilities that already exist, as
illustrated here

    http://www.cs.bham.ac.uk/research/poplog/figs/

and should also allow mixing of ruby code with pop11, prolog, common
lisp, or ML. (And any other languages that get implemented in
poplog).

There is a sourceforge project concerned with longer term
development of poplog and pop11

    http://www.cs.bham.ac.uk/research/poplog/openpoplog.html

Aaron
====
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )