JavaScript Sealed Classes

Author Manuel Serrano



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2022.24.pdf
  • Filesize: 1.24 MB
  • 27 pages

Document Identifiers

Author Details

Manuel Serrano
  • Inria/UCA, Inria Sophia Méditerranée, 2004 route des Lucioles, Sophia Antipolis, France

Acknowledgements

My gratitude to L. Tratt for his suggestions to improve this paper, and to O. Melançon, E. Rohou, M. Feeley, and R. Findler for their comments, suggestions, and corrections.

Cite AsGet BibTex

Manuel Serrano. JavaScript Sealed Classes. In 36th European Conference on Object-Oriented Programming (ECOOP 2022). Leibniz International Proceedings in Informatics (LIPIcs), Volume 222, pp. 24:1-24:27, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2022)
https://doi.org/10.4230/LIPIcs.ECOOP.2022.24

Abstract

In this work, we study the JavaScript Sealed Classes, which differ from regular classes in a few ways that allow ahead-of-time (AoT) compilers to implement them more efficiently. Sealed classes are compatible with the rest of the language so that they can be combined with all other structures, including regular classes, and can be gradually integrated into existing code bases. We present the design of the sealed classes and study their implementation in the hopc AoT compiler. We present an in-depth analysis of the speed of sealed classes compared to regular classes. To do so, we assembled a new suite of benchmarks that focuses on the efficiency of the class implementations. On this suite, we found that sealed classes provide an average speedup of 19%. The more classes and methods programs use, the greater the speedup. For the most favorable test that uses them intensively, we measured a speedup of 56%.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Just-in-time compilers
  • Software and its engineering → Source code generation
  • Software and its engineering → Object oriented languages
  • Software and its engineering → Functional languages
Keywords
  • JavaScript
  • Compiler
  • Dynamic Languages
  • Classes
  • Inline Caches

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Gavin Bierman, Martín Abadi, and Mads Torgersen. Understanding TypeScript. In Proceedings of the 28th European Conference on ECOOP 2014 - Object-Oriented Programming - Volume 8586, pages 257-281, Berlin, Heidelberg, 2014. Springer-Verlag. URL: https://doi.org/10.1007/978-3-662-44202-9_11.
  2. Carl Friedrich Bolz. Better JIT Support for Auto-Generated Python Code. https://www.pypy.org/blog/, September 2021.
  3. C. Chambers and D. Ungar. Customization: Optimizing Compiler Technology for SELF, a Dynamically-Typed Object-Oriented Programming Language. In Conference Proceedings on Programming Language Design and Implementation, PLDI '89, New York, NY, USA, 1989. ACM. URL: https://doi.org/10.1145/73141.74831.
  4. C. Chambers, D. Ungar, and E. Lee. An Efficient Implementation of SELF a Dynamically-typed Object-oriented Language Based on Prototypes. In Conference Proceedings on Object-oriented Programming Systems, Languages and Applications, OOPSLA '89, pages 49-70, USA, 1989. ACM. URL: https://doi.org/10.1145/74878.74884.
  5. Avik Chaudhuri, Basil Hosmer, and Gabriel Levi. Flow, a new static type checker for JavaScript, November 2014. URL: https://engineering.fb.com/2014/11/18/web/flow-a-new-static-type-checker-for-javascript.
  6. D. Clifford, H. Payer, M. Stanton, and B. Titzer. Memento Mori: Dynamic Allocation-site-based Optimizations. In Proceedings of the 2015 ACM SIGPLAN International Symposium on Memory Management, New York, NY, USA, 2015. URL: https://doi.org/10.1145/2887746.2754181.
  7. N. Cohen. Type-extension type tests can be performed in constant time. ACM Transactions on Programming Languages and Systems (TOPLAS), 13(4):626-629, 1991. URL: https://doi.org/10.1145/115372.115297.
  8. Jeffrey Dean, David Grove, and Craig Chambers. Optimization of Object-Oriented Programs Using Static Class Hierarchy Analysis. In Proceedings of the 9th European Conference on Object-Oriented Programming, ECOOP '95, pages 77-101, 1995. URL: https://doi.org/10.1007/3-540-49538-X_5.
  9. Peter L. Deutsch and Allan M. Schiffman. Efficient Implementation of the Smalltalk-80 System. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL '84, pages 297-302, New York, NY, USA, 1984. Association for Computing Machinery. URL: https://doi.org/10.1145/800017.800542.
  10. Sébastien Doeraene. Cross-Platform Language Design in Scala.Js (Keynote). In Proceedings of the 9th ACM SIGPLAN International Symposium on Scala, Scala 2018, page 1, New York, NY, USA, 2018. Association for Computing Machinery. URL: https://doi.org/10.1145/3241653.3266230.
  11. Roland Ducournau. Implementing statically typed object-oriented programming languages. ACM Comput. Surv., 43(3):18:1-18:48, 2011. URL: https://doi.org/10.1145/1922649.1922655.
  12. ECMA International. Standard ECMA-262 - ECMAScript Language Specification. ECMA, 6.0 edition, June 2015. Google Scholar
  13. Brendan Gregg. Linux systems performance. https://www.usenix.org/conference/lisa19/presentation/gregg-linux, October 2019.
  14. M. Hölttä. Super fast super property access. https://v8.dev/blog/fast-super, February 2021.
  15. U. Hölzle, C. Chambers, and D. Ungar. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proceedings of the European Conference on Object-Oriented Programming, ECOOP '91, pages 21-38, UK, 1991. URL: https://doi.org/10.1.1.126.7745.
  16. B. Meurer and M. Bynens. The story of a V8 performance cliff in React. https://v8.dev/blog/react-cliff, August 2019.
  17. Microsoft. TypeScript, Language Specification, version 0.9.5, November 2013. Google Scholar
  18. Mozilla Developper Network. Classes. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes, November 2021.
  19. Mozilla Developper Network. Public class fields. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields, July 2021.
  20. F. Pizlo. Speculation in JavaScriptCore. https://webkit.org/blog/10308/speculationinjavascriptcore, July 2020. Google Scholar
  21. Aseem Rastogi, Nikhil Swamy, Cédric Fournet, Gavin Bierman, and Panagiotis Vekris. Safe & Efficient Gradual Typing for TypeScript. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '15, pages 167-180, New York, NY, USA, 2015. Association for Computing Machinery. URL: https://doi.org/10.1145/2676726.2676971.
  22. Gregor Richards, Francesco Zappa Nardelli, and Jan Vitek. Concrete Types for TypeScript. In John Tang Boyland, editor, 29th European Conference on Object-Oriented Programming (ECOOP 2015), volume 37 of Leibniz International Proceedings in Informatics (LIPIcs), pages 76-100, Dagstuhl, Germany, 2015. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik. URL: https://doi.org/10.4230/LIPIcs.ECOOP.2015.76.
  23. Andreas Rossberg. A Strong Mode for JavaScript (Strawman proposal). URL: https://docs.google.com/document/d/1Qk0qC4s_XNCLemj42FqfsRLp49nDQMZ1y7fwf5YjaI4/view#heading=h.w5az3vf8le5k.
  24. Andreas Rossberg. An update on Strong Mode, February 2016. URL: https://groups.google.com/g/strengthen-js/c/ojj3TDxbHpQ/m/5ENNAiUzEgAJ.
  25. M. Serrano. Javascript aot compilation. In 14th Dynamic Language Symposium (DLS), Boston, USA, November 2018. URL: https://doi.org/10.1145/3276945.3276950.
  26. M. Serrano. Of AOT Compilation Performance. Proceedings of the ACM on Programming Languages, August 2021. URL: https://doi.org/10.1145/3473575.
  27. M. Serrano and M. Feeley. Property Caches Revisited. In Proceedings of the 28th Compiler Construction Conference (CC'19), Washington, USA, February 2019. URL: https://doi.org/10.1145/3302516.3307344.
  28. M. Serrano and R. Findler. Dynamic Property Caches, a Step towards Faster JavaScripts Proxy Objects. In Proceedings of the 29th Compiler Construction Conference (CC'20), San Dieo, USA, February 2020. URL: https://doi.org/10.1145/3377555.3377888.
  29. V. Stinner et al. The Python Benchmark Suite. https://github.com/python/pyperformance, 2021.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail