Abstract
The semantics and the recursive execution model of Prolog make it very natural to express language interpreters in form of AST (Abstract Syntax Tree) interpreters where the execution follows the tree representation of a program. An alternative implementation technique is that of bytecode interpreters. These interpreters transform the program into a compact and linear representation before evaluating it and are generally considered to be faster and to make better use of resources.
In this paper, we discuss different ways to express the control flow of interpreters in Prolog and present several implementations of AST and bytecode interpreters. On a simple language designed for this purpose, we evaluate whether techniques best known from imperative languages are applicable in Prolog and how well they perform. Our ultimate goal is to assess which interpreter design in Prolog is the most efficient as we intend to apply these results to a more complex language. However, we believe the analysis in this paper to be of more general interest.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Acol is not a backronym for Acol is a computable language.
- 2.
While, again, interoperability with C allows embedding of such data structures, standard library predicates usually only offer logarithmic access.
- 3.
A fair comparison is not possible since the C interpreter does not support unbounded integer values.
References
Abrial, J.-R.: The B-Book. Cambridge University Press, Cambridge (1996)
Aït-Kaci, H.: Warren’s abstract machine - a tutorial reconstruction (1991)
Carlsson, M., Mildner, P.: SICStus Prolog - the first 25 years. Theory Pract. Log. Program. 12(1–2), 35–66 (2012)
Carro, M.: An application of rational trees in a logic programming interpreter for a procedural language. CoRR, cs.DS/0403028, March 2004
Dahm, M.: Byte code engineering. In: Cap, C.H. (ed.) JIT 1999. INFORMAT, pp. 267–277. Springer, Heidelberg (1999). https://doi.org/10.1007/978-3-642-60247-4_25
Davis, B., Beatty, A., Casey, K., Gregg, D., Waldron, J.: The case for virtual register machines. In: Proceedings IVME, pp. 41–49. ACM (2003)
Fang, R., Liu, S.: A performance survey on stack-based and register-based virtual machines. arXiv preprint arXiv:1611.00467 (2016)
Fleming, P.J., Wallace, J.J.: How not to lie with statistics: the correct way to summarize benchmark results. Commun. ACM 29(3), 218–221 (1986)
Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice Hall, Hoboken (1993)
Leuschel, M., Butler, M.J.: ProB: an automated analysis toolset for the B method. STTT 10(2), 185–203 (2008)
The PyPy Project. The Object Space (2015). http://pypy.readthedocs.org/en/latest/objspace.html. Accessed 12 Aug 2020
Rossi, M., Sivalingam, K.: A survey of instruction dispatch techniques for byte-code interpreters. In: Seminar on Mobile Code (1996)
Shi, Y., Casey, K., Ertl, M.A., Gregg, D.: Virtual machine showdown: stack versus registers. Trans. Archit. Code Optim. 4(4), 1–36 (2008)
Warren, D.H.D.: An abstract Prolog instruction set. Technical report 309, Artificial Intelligence Center - SRI International, Stanford (1983)
Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-Prolog. Theory Pract. Log. Program. 12(1–2), 67–96 (2012)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Körner, P., Schneider, D., Leuschel, M. (2021). On the Performance of Bytecode Interpreters in Prolog. In: Hanus, M., Sacerdoti Coen, C. (eds) Functional and Constraint Logic Programming. WFLP 2020. Lecture Notes in Computer Science(), vol 12560. Springer, Cham. https://doi.org/10.1007/978-3-030-75333-7_3
Download citation
DOI: https://doi.org/10.1007/978-3-030-75333-7_3
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-75332-0
Online ISBN: 978-3-030-75333-7
eBook Packages: Computer ScienceComputer Science (R0)