Skip to main content

An Abstract Machine for Asynchronous Programs with Closures and Priority Queues

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 10506))

Abstract

We present the operational semantics of an abstract machine that models computations of event-based asynchronous programs inspired to the Node.js server-side system, a convenient platform for developing Internet of Things applications. The goal of the formal description of Node.js internals is twofold: (1) integrating the existing documentation with a more rigorous semantics and (2) validating widely used programming and transformation patterns by means of mathematical tools like transition systems. Our operational semantics is parametric in the transition system of the host scripting language to mimic the infrastructure of the V8 virtual machine where Javascript code is executed on top of the event-based engine provided by the C++ libuv concurrency library. In this work we focus our attention on priority callback queues, nested callbacks, and closures; these are widely used Node.js programming features which, however, may render programs difficult to understand, manipulate, and validate.

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

Buying options

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

Learn about institutional subscriptions

Notes

  1. 1.

    Despite of the name, this is the current semantics of Node.js.

References

  1. Alimadadi, S., Sequeira, S., Mesbah, A., Pattabiraman, K.: Understanding javascript event-based interactions with clematis. ACM Trans. Softw. Eng. Methodol. 25(2), 12:1–12:38 (2016)

    Article  Google Scholar 

  2. Chadha, R., Viswanathan, M.: Decidability results for well-structured transition systems with auxiliary storage. In: Caires, L., Vasconcelos, V.T. (eds.) CONCUR 2007. LNCS, vol. 4703, pp. 136–150. Springer, Heidelberg (2007). doi:10.1007/978-3-540-74407-8_10

    Chapter  Google Scholar 

  3. Emmi, M., Ganty, P., Majumdar, R., Rosa-Velardo, F.: Analysis of asynchronous programs with event-based synchronization. In: Vitek, J. (ed.) ESOP 2015. LNCS, vol. 9032, pp. 535–559. Springer, Heidelberg (2015). doi:10.1007/978-3-662-46669-8_22

    Chapter  Google Scholar 

  4. Gallaba, K., Mesbah, A., Beschastnikh, I.: Don’t call us, we’ll call you: characterizing callbacks in Javascript. In: 2015 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement, ESEM 2015, Beijing, China, 22–23 October 2015, pp. 247–256 (2015)

    Google Scholar 

  5. Ganty, P., Majumdar, R.: Analyzing real-time event-driven programs. In: Ouaknine, J., Vaandrager, F.W. (eds.) FORMATS 2009. LNCS, vol. 5813, pp. 164–178. Springer, Heidelberg (2009). doi:10.1007/978-3-642-04368-0_14

    Chapter  Google Scholar 

  6. Ganty, P., Majumdar, R.: Algorithmic verification of asynchronous programs. ACM Trans. Program. Lang. Syst. 34(1), 6:1–6:48 (2012)

    Article  Google Scholar 

  7. Ganty, P., Majumdar, R., Rybalchenko, A.: Verifying liveness for asynchronous programs. POPL 2009, 102–113 (2009)

    MATH  Google Scholar 

  8. Geeraerts, G., Heußner, A., Raskin, J.-F.: On the verification of concurrent, asynchronous programs with waiting queues. ACM Trans. Embedded Comput. Syst. 14(3), 58:1–58:26 (2015)

    Article  Google Scholar 

  9. Park, D., Stefanescu, A., Rosu, G.: KJS: a complete formal semantics of javascript. PLDI 2015, 346–356 (2015)

    Google Scholar 

  10. Sen, K., Viswanathan, M.: Model checking multithreaded programs with asynchronous atomic methods. In: Ball, T., Jones, R.B. (eds.) CAV 2006. LNCS, vol. 4144, pp. 300–314. Springer, Heidelberg (2006). doi:10.1007/11817963_29

    Chapter  Google Scholar 

  11. https://howtonode.org/understanding-process-next-tick

  12. https://nodejs.org/en/docs/

  13. https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/

  14. http://stackoverflow.com/questions/15349733/setimmediate-vs-nexttick

  15. https://www.quora.com/

  16. http://www.disi.unige.it/person/DelzannoG/NODE/

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Giorgio Delzanno .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Springer International Publishing AG

About this paper

Cite this paper

Ancona, D. et al. (2017). An Abstract Machine for Asynchronous Programs with Closures and Priority Queues. In: Hague, M., Potapov, I. (eds) Reachability Problems. RP 2017. Lecture Notes in Computer Science(), vol 10506. Springer, Cham. https://doi.org/10.1007/978-3-319-67089-8_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-67089-8_5

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-67088-1

  • Online ISBN: 978-3-319-67089-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics