[Paper Review] The Language Features and Architecture of B-Prolog
This paper presents B-Prolog, a high-performance Prolog system enhanced with advanced features like finite-domain constraint solving, tabling, action rules, and arrays. It details the TOAM Jr. abstract machine architecture—featuring stack-based argument passing, variable-sized instructions, and native support for action rules and linear tabling—achieving over 60% speed improvement on standard benchmarks through reduced interpretation overhead and efficient context switching.
B-Prolog is a high-performance implementation of the standard Prolog language with several extensions including matching clauses, action rules for event handling, finite-domain constraint solving, arrays and hash tables, declarative loop constructs, and tabling. The B-Prolog system is based on the TOAM architecture which differs from the WAM mainly in that (1) arguments are passed old-fashionedly through the stack, (2) only one frame is used for each predicate call, and (3) instructions are provided for encoding matching trees. The most recent architecture, called TOAM Jr., departs further from the WAM in that it employs no registers for arguments or temporary variables, and provides variable-size instructions for encoding predicate calls. This paper gives an overview of the language features and a detailed description of the TOAM Jr. architecture, including architectural support for action rules and tabling.
Motivation & Objective
- To design and implement a high-performance Prolog system with advanced language features for constraint solving and dynamic programming.
- To address the performance bottleneck of fine-grained instruction interpretation in abstract machine emulators.
- To support efficient event-driven programming and constraint propagation through action rules and suspension frames.
- To enable efficient fixed-point computation in logic programs via linear tabling with minimal architectural changes.
- To improve memory management and scalability for large-scale applications like machine learning.
Proposed method
- The TOAM Jr. architecture uses stack-based argument passing and eliminates temporary registers to reduce interpretation overhead.
- Variable-sized, specialized instructions encode predicate calls directly, minimizing dispatching costs common in fine-grained instruction sets.
- Action rules are compiled into propagators stored as suspension frames on the stack, enabling fast context switching without heap allocation.
- Linear tabling uses iterative computation of top-most looping subgoals, avoiding the need to freeze stack frames and preserving the garbage collector.
- Tabled predicates use a new tabled frame type with SubgoalTable and CurrentAnswer pointers to manage answer consumption and subgoal reuse.
- The system integrates optimizations to reduce re-computation costs in linear tabling, making it competitive with SLG in time efficiency.
Experimental results
Research questions
- RQ1How can a Prolog abstract machine be redesigned to reduce interpretation overhead while supporting advanced language features?
- RQ2What architectural changes are needed to efficiently support action rules and event-driven constraint propagation?
- RQ3How can linear tabling be implemented with minimal changes to the abstract machine while maintaining space efficiency?
- RQ4Can variable-sized instructions improve performance over traditional fine-grained instruction sets in Prolog emulators?
- RQ5How does the integration of tabling and action rules impact the scalability and performance of logic programs?
Key findings
- The TOAM Jr. architecture improved B-Prolog’s speed by over 60% on the Aquarius benchmarks compared to the previous ATOAM-based system.
- Eliminating temporary registers and using variable-sized instructions significantly reduced the dispatching cost in interpretation.
- Suspension frames on the stack enabled fast context switching for propagators, crucial for efficient constraint solving.
- Linear tabling achieved better space efficiency than SLG by avoiding frozen stack frames, while optimizations reduced re-computation costs.
- The minimal architectural changes for tabling and action rules demonstrated the extensibility of the TOAM Jr. design.
- The integration of PRISM’s tabling and memory management improvements enhanced the robustness and performance of B-Prolog’s core system.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.