[Vm-dev] Re: [squeak-dev] A Bootstrap Compiler
yoshiki at vpri.org
Thu Dec 30 04:31:47 UTC 2010
At Tue, 28 Dec 2010 10:22:35 -0800,
Eliot Miranda wrote:
> I simply don't see the benefit of putting energy into other languages. I see the benefit of a textual bootstrap. But why
> is it worth-while implementing that in C instead of Smalltalk? If Smalltalk is more productive (which it is) then
> writing such a bootstrap in C is a waste of effort, reinvents several wheels at considerable expense and produces an
> artifact that is less flexible, less extensible, less useful than implementing the same functionality in Smalltalk.
Like I wrote in another reply, it is more about the a meta-language
(in this case, a PEG or PEG-like generator). In the last S3
conference, Ian and Takashi and myself showed that the same
S-expression language can be targeted to x86 code and Adobe Bytecode.
Similar to this, a good bootstrapping strategy would be to write the
major part of compiler in something like PEG and provide different
backend to produce different executables. For my Bootstrap Compiler,
it is not C as much as Leg; C is convenient and have a workable parser
generator, so it was an okay step, I thought. (Arguably, Leg does not
support structual matching of trees; One of the phase in the reference
implementation is written directly in C, even though the pattern in
the code just resembles to the PEG implementation.
> On the other hand, as Andreas suggests, trying to implement something using the simulator looks to be really powerful.
> Recent;y I've been playing tangentally in this area. In recent days I've produced a new code generator for Cog that has
> some useful speedups (Compiler recompileAll ~ 9% faster, benchFib 2x). To test the code generator I needed to check
> stack depths at various points in JIT compilation and execution of the JITted code. I have a Smalltalk class
> StackDepthFinder that answers the stack depths for each bytecode of a method. By adding two classes VMObjectProxy and
> VMCompiledMethodProxy I could apply StackDepthFinder to methods in the simulator's heap and hence derive stack depths
> for any method in the simulators image. To test the JIT it was also convenient to be able to JIT methods in my work
> image, synthesised test cases etc, not just methods in the simulated image. Again a facade class allows the simulator to
> JIT any method in my work image. This worked well and was easy to implement. Extending in this direction seems
Ah, okay. Just an analogy, in the way Slang works, the
meta-language here happen to be Slang/Smalltalk and different
executables are produced with different backend. As you said,
however, Slang is not a language implementation but a practical
vehicle to get to a place; with a nicer meta-language, the picture
could look prettier.
> One starts up wit a simulator and an empty heap and bootstraps objects into that heap, using whatever bytecode set and
> object format one chooses. One can test the image using the simulator which should be quite fast enough if the image is
> a small kernel. All the implementation is useful and adds to the simulator/VMMaker ecosystem. All the code is Squeak and
> can reuse substantial parts of the system. Seems like a win to me. I think I'll take this approach in implementing the
> new object format. It could be a new backend to MicroSqueak.
More information about the Vm-dev