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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
Despite of the name, this is the current semantics of Node.js.
References
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)
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
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
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)
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
Ganty, P., Majumdar, R.: Algorithmic verification of asynchronous programs. ACM Trans. Program. Lang. Syst. 34(1), 6:1–6:48 (2012)
Ganty, P., Majumdar, R., Rybalchenko, A.: Verifying liveness for asynchronous programs. POPL 2009, 102–113 (2009)
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)
Park, D., Stefanescu, A., Rosu, G.: KJS: a complete formal semantics of javascript. PLDI 2015, 346–356 (2015)
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
https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/
http://stackoverflow.com/questions/15349733/setimmediate-vs-nexttick
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights 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)