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.
Supplemental Material
- Babylon: A JavaScript parser used in Babel. htps://github.com/babel/ babel/tree/master/packages/babylon . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Codecademy. Learn JavaScript. htps://www.codecademy.com/learn/ learn-javascript . Accessed Nov 10 2017.Google Scholar
- CodeSchool. Learn JavaScript Online. htps://www.codeschool.com/ learn/javascript . Accessed Nov 10 2017.Google Scholar
- Codio. htps://codio.com . Accessed Nov 10 2017.Google Scholar
- The Computer Language Benchmarks Game. htps://benchmarksgame. alioth.debian.org . Accessed Nov 10 2017.Google Scholar
- Confusing behavior with exceptions inside goroutines. htps://github. com/gopherjs/gopherjs/issues/225 . Accessed Nov 10 2017.Google Scholar
- Evan Czaplicki and Stephen Chong. 2013. Asynchronous Functional Reactive Programming for GUIs. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Deferring runtime.Gosched() causes error. htps://github.com/ gopherjs/gopherjs/issues/426 . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
Digital Library
- GopherJS. htps://github.com/gopherjs/gopherjs . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
Cross Ref
- Mark Guzdial and Barbara Ericson. CS Principles: Big Ideas in Programming. htp://interactivepython.org/runestone/static/StudentCSP/ index.html . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Wayne Iba. too much recursion in 2048 example code. htps://github. com/brownplt/pyret-lang/issues/555 . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
- JetStream 1.1. htp://browserbench.org/JetStream/ . Accessed Nov 10 2017.Google Scholar
- Khan Academy: Computer programming. htps://www.khanacademy. org/computing/computer-programming . Accessed Nov 10 2017.Google Scholar
- Kotlin Coroutines. htps://github.com/Kotlin/kotlin-coroutines .Google Scholar
- Kraken. htps://wiki.mozilla.org/Kraken . Accessed Nov 10 2017.Google Scholar
- Shriram Krishnamurthi. impossible(?) to kill ininite loop w/ reactor. htps://github.com/brownplt/pyret-lang/issues/839 . Accessed Nov 10 2017.Google Scholar
- Shriram Krishnamurthi. calling plotting functions inside a reactor makes program unstoppable. htps://github.com/brownplt/pyret-lang/ issues/1089 . Accessed Nov 10 2017.Google Scholar
- Larceny Benchmarks. htp://www.larcenists.org/benchmarks2009all. html . Accessed Nov 10 2017.Google Scholar
- Benjamin S. Lerner. An ininite loop hangs big-bang. htps://github. com/brownplt/pyret-lang/issues/508 . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
- Benjamin S. Lerner. Bignums considered harmful. htps://github.com/ brownplt/pyret-lang/issues/1118 . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
- Benjamin S. Lerner. Fix broken eachLoop. htps://github.com/ brownplt/pyret-lang/commit/b7f9c9 . Accessed Nov 10 2017.Google Scholar
- Florian Loitsch. 2007. Exceptional Continuations in JavaScript. In Workshop on Scheme and Functional Programming.Google Scholar
- James Long. Unwinder. htps://github.com/jlongster/unwinder . Accessed Nov 10 2017.Google Scholar
- Amjad Masad. debug.js. htps://github.com/amasad/debugjs.com . Accessed Nov 10 2017.Google Scholar
- James Mickens. 2014. Pivot: Fast, Synchronous Mashup Isolation Using Generator Chains. In IEEE Security and Privacy (Oakland). Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Miscompilation of functions w/ defer statements. htps://github.com/ gopherjs/gopherjs/issues/493 . Accessed Nov 10 2017.Google Scholar
- Neil Mix and Dan Grisby. Narrative JavaScript. htps://sourceforge. net/projects/narrativejs . Accessed Nov 10 2017.Google Scholar
- Mozilla, Inc. SharedArrayBufer. htps://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Global O bjects/SharedArrayBufer . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
- Octane. htps://developers.google.com/octane . Accessed Nov 10 2017.Google Scholar
- OPerf Micro. htps://www.typerex.org/operf-micro.html . Accessed Nov 10 2017.Google Scholar
- Krzysztof Palacz. 2008. The Lively Kernel Application Framework. In International Conference on Scalable Vector Graphics.Google Scholar
- 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 Scholar
Digital Library
- Joe Gibbs Politz. Make module loading stack safe. htps://github.com/ brownplt/pyret-lang/issues/145 . Accessed Nov 10 2017.Google Scholar
- Joe Gibbs Politz. Printing large values is not stack-safe. htps://github. com/brownplt/pyret-lang/issues/146 . Accessed Nov 10 2017.Google Scholar
- Joe Gibbs Politz. Stopping (indeinitely) stopped programs. htps: //github.com/brownplt/pyret-lang/issues/163 . Accessed Nov 10 2017.Google Scholar
- Joe Gibbs Politz. Too much recursion. htps://github.com/brownplt/ pyret-lang/issues/213 . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
- 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 Scholar
- Joe Gibbs Politz. more ixing of eachLoop. htps://github.com/ brownplt/pyret-lang/commit/844454 . Accessed Nov 10 2017.Google Scholar
- Joe Gibbs Politz, Benjamin S. Lerner, and Shriram Krishnamurthi. Pyret. htps://www.pyret.org/ . Accessed Jul 5 2017.Google Scholar
- 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 Scholar
Digital Library
- Roldan Pozo and Bruce Miller. SciMark 2.0. htp://math.nist.gov/ scimark2/ . Accessed Nov 10 2017.Google Scholar
- Programs can incorrectly terminate with yieldLimit set to suspend at regular intervals. htps://github.com/skulpt/skulpt/issues/723 . Accessed Nov 10 2017.Google Scholar
- PyPy Benchmarks. htps://bitbucket.org/pypy/benchmarks . Accessed Nov 10 2017.Google Scholar
- PythonRoom. htps://pythonroom.com . Accessed Nov 10 2017.Google Scholar
- Quasar: Lightweight Threads and Actors for the JVM. htp://blog. paralleluniverse.co/2014/02/06/fibers-threads-strands/ . Accessed Nov 10 2017.Google Scholar
- Christopher Schuster. 2012. Reiication of Execution State in JavaScript. Master’s thesis. University of Potsdam Germany.Google Scholar
- Charles Severance. Programming for Everybody. htps://www. coursera.org/learn/python . Accessed Nov 10 2017.Google Scholar
- Charles Severance. Python Data Structures. htps://www.coursera. org/learn/python-data . Accessed Nov 10 2017.Google Scholar
- Dorai Sitaram and Matthias Felleisen. 1990. Control Delimiters and Their Hierarchies. LISP and Symbolic Computation 3, 1 (May 1990), 67ś99. Google Scholar
Digital Library
- Skulpt. htp://www.skulpt.org . Accessed Nov 10 2017.Google Scholar
- Terry Tang, Scott Rixner, and Joe Warren. 2014. An Environment for Learning Interactive Programming. In ACM Technical Symposium on Computer Science Education (SIGCSE). Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Eric Thivierge and Marc Feeley. 2012. Eicient Compilation of Tail Calls and Continuations to JavaScript. In Workshop on Scheme and Functional Programming. Google Scholar
Digital Library
- Tight loop in goroutine never yields. htps://github.com/gopherjs/ gopherjs/issues/698 . Accessed Nov 10 2017.Google Scholar
- Ton80. htps://github.com/dart-lang/ton80 . Accessed Nov 10 2017.Google Scholar
- TreeHouse. Beginning JavaScript. htps://teamtreehouse.com/tracks/ beginning-javascript . Accessed Nov 10 2017.Google Scholar
- Trinket. htps://trinket.io . Accessed Nov 10 2017.Google Scholar
- Tynker. htps://www.tynker.com . Accessed Nov 10 2017.Google Scholar
- 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 Scholar
Digital Library
- Vocareum. htps://www.vocareum.com . Accessed Nov 10 2017.Google Scholar
- W3C. Web Workers. htps://www.w3.org/TR/workers/ . Accessed Nov 10 2017.Google Scholar
- WebAssembly: Features to Add after the MVP. htps://github.com/ WebAssembly/design/blob/71c97d/FutureFeatures.md . Accessed Nov 10 2017.Google Scholar
- Why is my browser freezing when I submit an exercise? htps://help. codecademy.com/hc/en-us/articles/220803187 . Accessed Nov 10 2017.Google Scholar
- James Wright. JWACS. htp://chumsley.org/jwacs/index.html . Accessed Nov 10 2017.Google Scholar
- Danny Yoo and Shriram Krishnamurthi. 2013. Whalesong: Running Racket in the Browser. In Dynamic Languages Symposium (DLS). Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Putting in all the stops: execution control for JavaScript
Recommendations
Putting in all the stops: execution control for JavaScript
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationScores 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 ...
From bytecode to JavaScript: the Js_of_ocaml compiler
We present the design and implementation of a compiler from OCaml bytecode to JavaScript. The compiler first translates the bytecode into a static single-assignment intermediate representation on which optimizations are performed, before generating ...
JavaScript as an embedded DSL
ECOOP'12: Proceedings of the 26th European conference on Object-Oriented ProgrammingDeveloping rich web applications requires mastering different environments on the client and server sides. While there is considerable choice on the server-side, the client-side is tied to JavaScript, which poses substantial software engineering ...







Comments