Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

On the Performance of Bytecode Interpreters in Prolog

  • Conference paper
  • First Online:
Functional and Constraint Logic Programming (WFLP 2020)

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    Acol is not a backronym for Acol is a computable language.

  2. 2.

    While, again, interoperability with C allows embedding of such data structures, standard library predicates usually only offer logarithmic access.

  3. 3.

    A fair comparison is not possible since the C interpreter does not support unbounded integer values.

References

  1. Abrial, J.-R.: The B-Book. Cambridge University Press, Cambridge (1996)

    Book  Google Scholar 

  2. Aït-Kaci, H.: Warren’s abstract machine - a tutorial reconstruction (1991)

    Google Scholar 

  3. Carlsson, M., Mildner, P.: SICStus Prolog - the first 25 years. Theory Pract. Log. Program. 12(1–2), 35–66 (2012)

    Article  MathSciNet  Google Scholar 

  4. Carro, M.: An application of rational trees in a logic programming interpreter for a procedural language. CoRR, cs.DS/0403028, March 2004

    Google Scholar 

  5. 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

    Chapter  Google Scholar 

  6. Davis, B., Beatty, A., Casey, K., Gregg, D., Waldron, J.: The case for virtual register machines. In: Proceedings IVME, pp. 41–49. ACM (2003)

    Google Scholar 

  7. Fang, R., Liu, S.: A performance survey on stack-based and register-based virtual machines. arXiv preprint arXiv:1611.00467 (2016)

  8. 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)

    Article  Google Scholar 

  9. Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice Hall, Hoboken (1993)

    MATH  Google Scholar 

  10. Leuschel, M., Butler, M.J.: ProB: an automated analysis toolset for the B method. STTT 10(2), 185–203 (2008)

    Article  Google Scholar 

  11. The PyPy Project. The Object Space (2015). http://pypy.readthedocs.org/en/latest/objspace.html. Accessed 12 Aug 2020

  12. Rossi, M., Sivalingam, K.: A survey of instruction dispatch techniques for byte-code interpreters. In: Seminar on Mobile Code (1996)

    Google Scholar 

  13. Shi, Y., Casey, K., Ertl, M.A., Gregg, D.: Virtual machine showdown: stack versus registers. Trans. Archit. Code Optim. 4(4), 1–36 (2008)

    Article  Google Scholar 

  14. Warren, D.H.D.: An abstract Prolog instruction set. Technical report 309, Artificial Intelligence Center - SRI International, Stanford (1983)

    Google Scholar 

  15. Wielemaker, J., Schrijvers, T., Triska, M., Lager, T.: SWI-Prolog. Theory Pract. Log. Program. 12(1–2), 67–96 (2012)

    Article  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Philipp Körner .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics