Personal tools

Ministg

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
Line 4: Line 4:
   
 
Ministg follows the rules in the paper very closely, to the point that each evaluation rule in the paper corresponds to an equation in the interpreter. This makes is easy to check that the interpreter follows the rules properly, and it also makes is easy to understand how new rules can be added, and what effect they might have.
 
Ministg follows the rules in the paper very closely, to the point that each evaluation rule in the paper corresponds to an equation in the interpreter. This makes is easy to check that the interpreter follows the rules properly, and it also makes is easy to understand how new rules can be added, and what effect they might have.
  +
  +
=== Motivation ===
  +
  +
The main motivations for Ministg are twofold:
  +
# To illustrate the dynamic behaviour of the STG machine.
  +
# To provide a simple testbed for STG extensions.
  +
  +
It is expected that Ministg will be useful two main groups of people:
  +
# Researchers who are working on the STG machine (and GHC's backend in general).
  +
# Students who are learning about the implementation of programming languages (especially of the lazy functional kind).
  +
  +
=== Feature summary ===
   
 
The following is a summary of the main features of Ministg; they are discussed in more detail below:
 
The following is a summary of the main features of Ministg; they are discussed in more detail below:
  +
* Support for both the push/enter and eval/apply rules for partial function applications (which was the main point of study in the "fast curry" paper from which the semantic rules are taken).
 
* Optional tracing of program execution, rendered in HTML.
 
* Optional tracing of program execution, rendered in HTML.
 
* Optional garbage collection.
 
* Optional garbage collection.

Revision as of 14:19, 19 August 2009

1 Ministg

Ministg is an interpreter for a high-level, small-step, operational semantics for the STG machine. The STG machine is the abstract machine at the core of GHC. The operational semantics used in Ministg is taken from the paper Making a fast curry: push/enter vs. eval/apply for higher-order languages by Simon Marlow and Simon Peyton Jones.

Ministg follows the rules in the paper very closely, to the point that each evaluation rule in the paper corresponds to an equation in the interpreter. This makes is easy to check that the interpreter follows the rules properly, and it also makes is easy to understand how new rules can be added, and what effect they might have.

1.1 Motivation

The main motivations for Ministg are twofold:

  1. To illustrate the dynamic behaviour of the STG machine.
  2. To provide a simple testbed for STG extensions.

It is expected that Ministg will be useful two main groups of people:

  1. Researchers who are working on the STG machine (and GHC's backend in general).
  2. Students who are learning about the implementation of programming languages (especially of the lazy functional kind).

1.2 Feature summary

The following is a summary of the main features of Ministg; they are discussed in more detail below:

  • Support for both the push/enter and eval/apply rules for partial function applications (which was the main point of study in the "fast curry" paper from which the semantic rules are taken).
  • Optional tracing of program execution, rendered in HTML.
  • Optional garbage collection.
  • Optional standard Prelude of useful functions (much like Haskell).
  • Optional call-stack tracing and stack dumping on errors.
  • Program annotations for call-stack tracing, similar to GHC's scc annotation for cost centre stacks.
  • Optional automatic call-stack annoation of top-level declarations in the program, similar to GHC's --auto-all option for profiling.

One of the most useful features of Ministg is its ability to trace the steps of program execution. If tracing is enabled, Ministg will save each step of execution to a HTML file. Each such file contains the entire state of the STG machine at that point in the computation: namely the code, stack and heap. An example trace is shown here: [1]. The files are linked together allowing you to step forwards and backwards through the execution.