A LISP Machine with Very Compact Programs

This paper introduces MicroLISP, a novel machine architecture designed for both compact representation and rapid execution of LISP programs. By tailoring the machine's instruction set and data types to the unique characteristics of LISP, MicroLISP achieves significantly smaller code sizes and potentially faster execution compared to conventional approaches.

TL;DR

MicroLISP presents a LISP-specific machine architecture that achieves 2-5x more compact code than traditional S-expressions or compiled code by directly encoding LISP's structure into machine instructions. This design simplifies compilation and enables efficient execution by closely mirroring LISP's dynamic nature, including user-defined data structures.

What Problem Does This Paper Address?

Implementing dynamic languages like LISP efficiently on conventional hardware presents a significant challenge. Traditional computers are optimized for static data types and predictable program flow, leading to a mismatch with LISP's dynamic storage allocation, recursive procedures, and explicit runtime type representation. Software solutions, like interpreters, are flexible but slow, while compilers that achieve high efficiency often sacrifice LISP's powerful features or produce code that is no less compact than the source representation. This paper addresses the need for a machine architecture that natively supports LISP's dynamic and structured nature, aiming for both efficiency and code compactness.

Methods

The core of MicroLISP's innovation lies in its machine architecture, which is designed to directly represent LISP's S-expressions and dynamic behavior. Key methods include:

  • Compact Instruction Encoding: MicroLISP's machine language is a factor of 2 to 5 more compact than S-expressions or conventional compiled code. This is achieved by using byte-sized instructions that represent LISP's structure in postfix form, referencing global and local name tables for functions and variables.
  • Simplified Compiler: The compiler is designed to be extremely simple, directly translating LISP code into this compact machine language.
  • Data Type Handling: Instead of traditional tags for every datum, MicroLISP leverages the fact that most LISP data are pointers. Integers and other types are referenced indirectly, with storage allocated in quanta. For numerical calculations, data on the stack carry type tags (integers, floating point, pointers) to avoid unnecessary memory allocation.
  • User-Defined Data Structures: MicroLISP allows users to define their own packed data structures, a feature often cited as a reason for choosing other languages for complex symbolic computation. This is achieved through a STRUCTURE primitive.
  • Unified Stack Structure: A single stack is used for both control and variable bindings, with "basic frames" for arguments and "frame extensions" for control information.
  • Efficient Variable Access: Variable access is systematized with "load" and "store" contexts, and the search for variable bindings is optimized to occur only on the first reference.
  • Name Tables (GNT/LNT): Global Name Tables (GNT) and Local Name Tables (LNT) are used to store function and variable names, allowing for very short addresses that index these tables.

Datasets

Not discussed in the paper. The paper focuses on the design of the MicroLISP architecture and its compiler, using examples of LISP code for illustration rather than formal datasets.

Key Insights and Ideas

  • Hardware-Software Co-design for LISP: The paper demonstrates the power of designing hardware specifically for a high-level language like LISP, moving beyond the traditional approach of fitting LISP onto general-purpose machines.
  • Encoding LISP Structure Directly: The most significant insight is that LISP's inherent structure (lists, function calls, variable bindings) can be directly mapped to a compact machine language, eliminating much of the overhead associated with conventional compilation.
  • The Value of User-Defined Data Structures: Providing a mechanism for users to define their own packed data structures is crucial for efficient symbolic computation and can be implemented cost-effectively at the machine level.
  • Optimizing for LISP's Dynamic Nature: MicroLISP's approach to data types and variable binding directly addresses the performance bottlenecks often encountered when implementing dynamic languages on static hardware.

Key Results

The paper reports that MicroLISP programs are consistently one-third to one-fourth the size of BBN-LISP compiled programs. The MicroLISP compiler is also reported to be about one-third the size of the corresponding part of the BBN-LISP compiler. While no direct timing data is available as no MicroLISP machine exists, a microprogrammed implementation and a software interpreter are in preparation.

Limitations and Future Work

The authors acknowledge that the compactness of MicroLISP is partly due to design decisions in BBN-LISP that result in bulkier code. They also note that while a microprogrammed implementation and a software interpreter are in preparation, no direct timing data is available.

Future work could involve:

  • Developing a MicroLISP machine and conducting performance benchmarks.
  • Exploring the potential for unambiguous decompilation of MicroLISP code back into S-expressions for editing.
  • Further investigating the application of MicroLISP's encoding scheme to data structures beyond programs.
  • Considering the "compiling" of data in a manner similar to programs, by eliminating redundant pointers and using statistical knowledge of data topology.

Summary updated

BibTeX
@inproceedings{1973lisp,
  title = {{A LISP Machine with Very Compact Programs}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1973},
}
Figure