skip to main content
research-article
Artifacts Evaluated & Functional

Putting in all the stops: execution control for JavaScript

Published:11 June 2018Publication History
Skip Abstract Section

Abstract

Scores of compilers produce JavaScript, enabling programmers to use many languages on the Web, reuse existing code, and even use Web IDEs. Unfortunately, most compilers inherit the browser's compromised execution model, so long-running programs freeze the browser tab, infinite loops crash IDEs, and so on. The few compilers that avoid these problems suffer poor performance and are difficult to engineer.

This paper presents Stopify, a source-to-source compiler that extends JavaScript with debugging abstractions and blocking operations, and easily integrates with existing compilers. We apply Stopify to ten programming languages and develop a Web IDE that supports stopping, single-stepping, breakpointing, and long-running computations. For nine languages, Stopify requires no or trivial compiler changes. For eight, our IDE is the first that provides these features. Two of our subject languages have compilers with similar features. Stopify's performance is competitive with these compilers and it makes them dramatically simpler.

Stopify's abstractions rely on first-class continuations, which it provides by compiling JavaScript to JavaScript. We also identify sub-languages of JavaScript that compilers implicitly use, and exploit these to improve performance. Finally, Stopify needs to repeatedly interrupt and resume program execution. We use a sampling-based technique to estimate program speed that outperforms other systems.

Skip Supplemental Material Section

Supplemental Material

p30-baxter.webm

References

  1. Babylon: A JavaScript parser used in Babel. htps://github.com/babel/ babel/tree/master/packages/babylon . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  2. Henry G. Baker. 1995. CONS Should Not CONS Its Arguments, Part II: Cheney on the M.T.A. ACM SIGPLAN Notices 30, 9 (Sept. 1995), 17ś20. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Carl Bruggeman, Oscar Waddell, and Kent R. Dybvig. 1996. Representing Control in the Presence of One-shot Continuations. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Sebastian Burckhardt, Manuel Fahndrich, Peli de Halleux, Sean McDirmid, Michal Moskal, Nokolai Tillmann, and Jun Kato. 2013. It’s Alive! Continuous Feedback in UI Programming. In ACM SIG-PLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Benjamin Canou, Roberto Di Cosmo, and Grégoire Henry. 2017. Scaling up Functional Programming Education: Under the Hood of the OCaml MOOC. In ACM International Conference on Functional Programming (ICFP).Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Codecademy. Learn JavaScript. htps://www.codecademy.com/learn/ learn-javascript . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  7. CodeSchool. Learn JavaScript Online. htps://www.codeschool.com/ learn/javascript . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  8. Codio. htps://codio.com . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  9. The Computer Language Benchmarks Game. htps://benchmarksgame. alioth.debian.org . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  10. Confusing behavior with exceptions inside goroutines. htps://github. com/gopherjs/gopherjs/issues/225 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  11. Evan Czaplicki and Stephen Chong. 2013. Asynchronous Functional Reactive Programming for GUIs. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Deferring runtime.Gosched() causes error. htps://github.com/ gopherjs/gopherjs/issues/426 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  13. Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In ACM SIG-PLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. GopherJS. htps://github.com/gopherjs/gopherjs . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  15. Philip J. Guo, Jefery White, and Renan Zanelatto. 2015. Codechella: Multi-user program visualizations for real-time tutoring and collaborative learning. In IEEE Symposium on Visual Languages and HumanCentric Computing (VL/HCC).Google ScholarGoogle ScholarCross RefCross Ref
  16. Mark Guzdial and Barbara Ericson. CS Principles: Big Ideas in Programming. htp://interactivepython.org/runestone/static/StudentCSP/ index.html . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  17. Andreas Haas, Andreas Rossberg, Derek L. Schuf, Ben L. Titzer, Michael Holman, Dan Gohman, Luke Wagner, Alon Zakai, and JF Bastien. 2017. Bringing the Web Up to Speed with WebAssembly. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Hieb, R. Kent Dybvig, and Carl Bruggeman. 1990. Representing Control in the Presence of First-class Continuations. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Wayne Iba. too much recursion in 2048 example code. htps://github. com/brownplt/pyret-lang/issues/555 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  20. List of Languages that Compile to JS. htps://github.com/jashkenas/ cofeescript/wiki/list-of-languages-that-compile-to-js . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  21. JetStream 1.1. htp://browserbench.org/JetStream/ . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  22. Khan Academy: Computer programming. htps://www.khanacademy. org/computing/computer-programming . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  23. Kotlin Coroutines. htps://github.com/Kotlin/kotlin-coroutines .Google ScholarGoogle Scholar
  24. Kraken. htps://wiki.mozilla.org/Kraken . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  25. Shriram Krishnamurthi. impossible(?) to kill ininite loop w/ reactor. htps://github.com/brownplt/pyret-lang/issues/839 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  26. Shriram Krishnamurthi. calling plotting functions inside a reactor makes program unstoppable. htps://github.com/brownplt/pyret-lang/ issues/1089 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  27. Larceny Benchmarks. htp://www.larcenists.org/benchmarks2009all. html . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  28. Benjamin S. Lerner. An ininite loop hangs big-bang. htps://github. com/brownplt/pyret-lang/issues/508 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  29. Benjamin S. Lerner. Responsiveness for rendering huge data at the REPL. htps://github.com/brownplt/code.pyret.org/issues/37 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  30. Benjamin S. Lerner. Bignums considered harmful. htps://github.com/ brownplt/pyret-lang/issues/1118 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  31. Benjamin S. Lerner. eachLoop was simply broken: it did not restore the stack properly. htps://github.com/brownplt/pyret-lang/commit/ 812d1c . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  32. Benjamin S. Lerner. Fix broken eachLoop. htps://github.com/ brownplt/pyret-lang/commit/b7f9c9 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  33. Florian Loitsch. 2007. Exceptional Continuations in JavaScript. In Workshop on Scheme and Functional Programming.Google ScholarGoogle Scholar
  34. James Long. Unwinder. htps://github.com/jlongster/unwinder . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  35. Amjad Masad. debug.js. htps://github.com/amasad/debugjs.com . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  36. James Mickens. 2014. Pivot: Fast, Synchronous Mashup Isolation Using Generator Chains. In IEEE Security and Privacy (Oakland). Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Brad Miller and David Ranum. Problem Solving with Algorithms and Data Structures using Python. htp://interactivepython.org/runestone/ static/pythonds/index.html . Accessed Nov 10 2017. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Brad Miller and David Ranum. How to Think Like a Computer Scientist: Interactive Edition. htp://interactivepython.org/runestone/static/ thinkcspy/index.html . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  39. Miscompilation of functions w/ defer statements. htps://github.com/ gopherjs/gopherjs/issues/493 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  40. Neil Mix and Dan Grisby. Narrative JavaScript. htps://sourceforge. net/projects/narrativejs . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  41. Mozilla, Inc. SharedArrayBufer. htps://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Global O bjects/SharedArrayBufer . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  42. Rachit Nigam. Unsafe calls in runtime need to be wrapped with safeCall. htps://github.com/brownplt/pyret-lang/issues/1251 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  43. Octane. htps://developers.google.com/octane . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  44. OPerf Micro. htps://www.typerex.org/operf-micro.html . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  45. Krzysztof Palacz. 2008. The Lively Kernel Application Framework. In International Conference on Scalable Vector Graphics.Google ScholarGoogle Scholar
  46. Greg Pettyjohn, John Clements, Joe Marshall, Shriram Krishnamurthi, and Matthias Felleisen. 2005. Continuations from generalized stack inspection. In ACM International Conference on Functional Programming (ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Joe Gibbs Politz. Make module loading stack safe. htps://github.com/ brownplt/pyret-lang/issues/145 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  48. Joe Gibbs Politz. Printing large values is not stack-safe. htps://github. com/brownplt/pyret-lang/issues/146 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  49. Joe Gibbs Politz. Stopping (indeinitely) stopped programs. htps: //github.com/brownplt/pyret-lang/issues/163 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  50. Joe Gibbs Politz. Too much recursion. htps://github.com/brownplt/ pyret-lang/issues/213 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  51. Joe Gibbs Politz. Caja interferes with stack management/events during big-bang. htps://github.com/brownplt/pyret-lang/issues/512 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  52. Joe Gibbs Politz. Stack management fails on shallow, but long-lasting, recursion. htps://github.com/brownplt/pyret-lang/issues/596 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  53. Joe Gibbs Politz. more ixing of eachLoop. htps://github.com/ brownplt/pyret-lang/commit/844454 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  54. Joe Gibbs Politz, Benjamin S. Lerner, and Shriram Krishnamurthi. Pyret. htps://www.pyret.org/ . Accessed Jul 5 2017.Google ScholarGoogle Scholar
  55. Bobby Powers, John Vilk, and Emery D. Berger. 2017. Browsix: Bridging the Gap Between Unix and the Browser. In ACM International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Roldan Pozo and Bruce Miller. SciMark 2.0. htp://math.nist.gov/ scimark2/ . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  57. Programs can incorrectly terminate with yieldLimit set to suspend at regular intervals. htps://github.com/skulpt/skulpt/issues/723 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  58. PyPy Benchmarks. htps://bitbucket.org/pypy/benchmarks . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  59. PythonRoom. htps://pythonroom.com . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  60. Quasar: Lightweight Threads and Actors for the JVM. htp://blog. paralleluniverse.co/2014/02/06/fibers-threads-strands/ . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  61. Christopher Schuster. 2012. Reiication of Execution State in JavaScript. Master’s thesis. University of Potsdam Germany.Google ScholarGoogle Scholar
  62. Charles Severance. Programming for Everybody. htps://www. coursera.org/learn/python . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  63. Charles Severance. Python Data Structures. htps://www.coursera. org/learn/python-data . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  64. Dorai Sitaram and Matthias Felleisen. 1990. Control Delimiters and Their Hierarchies. LISP and Symbolic Computation 3, 1 (May 1990), 67ś99. Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. Skulpt. htp://www.skulpt.org . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  66. Terry Tang, Scott Rixner, and Joe Warren. 2014. An Environment for Learning Interactive Programming. In ACM Technical Symposium on Computer Science Education (SIGCSE). Google ScholarGoogle ScholarDigital LibraryDigital Library
  67. David Tarditi, Peter Lee, and Anurag Acharya. 1992. No Assembly Required: Compiling Standard ML to C. ACM Letters on Programming Languages and Systems (LOPLAS) 1, 2 (June 1992), 161ś177. Google ScholarGoogle ScholarDigital LibraryDigital Library
  68. Eric Thivierge and Marc Feeley. 2012. Eicient Compilation of Tail Calls and Continuations to JavaScript. In Workshop on Scheme and Functional Programming. Google ScholarGoogle ScholarDigital LibraryDigital Library
  69. Tight loop in goroutine never yields. htps://github.com/gopherjs/ gopherjs/issues/698 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  70. Ton80. htps://github.com/dart-lang/ton80 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  71. TreeHouse. Beginning JavaScript. htps://teamtreehouse.com/tracks/ beginning-javascript . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  72. Trinket. htps://trinket.io . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  73. Tynker. htps://www.tynker.com . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  74. John Vilk and Emery D. Berger. 2014. Doppio: Breaking the Browser Language Barrier. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google ScholarGoogle ScholarDigital LibraryDigital Library
  75. Vocareum. htps://www.vocareum.com . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  76. W3C. Web Workers. htps://www.w3.org/TR/workers/ . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  77. WebAssembly: Features to Add after the MVP. htps://github.com/ WebAssembly/design/blob/71c97d/FutureFeatures.md . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  78. Why is my browser freezing when I submit an exercise? htps://help. codecademy.com/hc/en-us/articles/220803187 . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  79. James Wright. JWACS. htp://chumsley.org/jwacs/index.html . Accessed Nov 10 2017.Google ScholarGoogle Scholar
  80. Danny Yoo and Shriram Krishnamurthi. 2013. Whalesong: Running Racket in the Browser. In Dynamic Languages Symposium (DLS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  81. Danny Yoo, Emmanuel Schanzer, Shriram Krishnamurthi, and Kathi Fisler. 2011. WeScheme: The Browser is Your Programming Environment. In Conference on Innovation and Technology in Computer Science Education (ITiCSE). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Putting in all the stops: execution control for JavaScript

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 53, Issue 4
      PLDI '18
      April 2018
      834 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/3296979
      Issue’s Table of Contents
      • cover image ACM Conferences
        PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation
        June 2018
        825 pages
        ISBN:9781450356985
        DOI:10.1145/3192366

      Copyright © 2018 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 11 June 2018

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!