Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

microvm/pypy-mu

Repository files navigation

PyPy-Mu: A Mu Backend for PyPy

Welcome to PyPy-Mu!

PyPy-Mu is a fork of PyPy that aims to add a Mu Micro Virtual Machine backend for it.

This project is currently under active development, progressing towards a Mu backend that allows RPython to successfully compile SOM interpreter.

Building

Obtaining a Mu implementation

The reference implementation for Mu can be found here. Build the Mu implementation, make sure to build the C binding as well.

Compiling some RPython C backend support source code

Currently the Mu backend still requires some support from the C backend function implementations. We thus build them into a shared library that's loaded by the Mu RPython client launcher.

$ cd rpython/translator/mu/rpyc
$ make

This will produce the shared library librpyc.so.

Setting up environment variable

  • Set up an environment variable $MU to point to the cloned Mu MicroVM repository.
$ export MU=$REPOS/microvm-refimpl2
  • Make an alias for the client launcher, adding Python binding and C binding to environment varible:
$ alias murpy="PYTHONPATH=$MU/pythonbinding:$PYTHONPATH LD_LIBRARY_PATH=$MU/cbinding:$LD_LIBRARY_PATH python $PYPY_MU/rpython/mucli/murpy.py"

Compiling & Executing RPython Target

Specify -b mu option to compile using the Mu backend:

$ rpython/bin/rpython -O0 -b mu <target>

This outputs a <target>-mu.mu file in the current directory. This is a zipped bundle of the IR, HAIL and external function list files.

Use murpy to load and run the compiled bundle program:

$ murpy <target>-mu.mu

Currently due to the limitation of the Mu implementation in Scala, the performance of the Mu backend is about 100,000 times slower than that of the C backend...