Type-Aware Optimizations with Imperfect Types

dc.contributor.advisorRichards, Gregor
dc.contributor.authorIkosin, Jeremiah
dc.date.accessioned2024-05-10T17:14:01Z
dc.date.available2024-05-10T17:14:01Z
dc.date.issued2024-05-10
dc.date.submitted2024-05-08
dc.description.abstractJavaScript, a programming language originally designed for web browsers, has become ubiquitous, experiencing adoption across multiple platforms. Its dynamic type system and prototype-based object orientation are well-known properties that make the language applicable to several programming paradigms, particularly functional and object-oriented programming. However, issues such as global scope pollution, implicit type conversion, the absence of native null safety features, and the complexities of asynchronous callback structures, among others, make the language difficult to work with. To address these challenges, particularly within the context of large-scale application development, TypeScript was introduced. TypeScript incorporates a structural type system and compiles to JavaScript. The design objective is to ensure seamless interoperability with JavaScript, incorporating various ergonomic features, notably static typing. TypeScript introduces improved tooling, IDE support, ES6 features with extensions, and compatibility with existing JavaScript code. Despite these advantages, TypeScript deliberately refrains from optimizing its JavaScript output. Although JavaScript’s flexibility can often be useful in practice, a naive implementation of the language would be slow. Modern JavaScript engine implementations are intricate systems that employ cutting-edge optimization techniques to achieve efficient executions. This thesis introduces a method for improving the runtime performance of JavaScript by utilizing type information from TypeScript. It categorizes TypeScript types based on usage into two groups: nominal (similar to classes in Java) and non-nominal (structural or arbitrary). Although TypeScript’s type system is inherently unsound, types tend to be consistent in most nominal use cases. This characteristic renders a significant proportion of type information amenable to optimization with reasonable guarantees. I modified the TypeScript compiler (tsc) to leverage nominal type usage for optimizations. This modification produces optimized code through the utilization of enhanced heuristics for runtime optimizations. Additionally, I integrated WebKit’s JavaScript engine, JavaScriptCore (JSC), by introducing a new runtime intrinsic specifically designed to utilize type information from TypeScript. Performance is assessed by comparing JavaScript programs from the JetStream 2.1 JavaScript test suite with equivalent programs ported to TypeScript. These TypeScript programs are then compiled to JavaScript using the modified TypeScript compiler in two modes: with optimizations enabled and with optimizations disabled. The results show that adopting a nominal typing style in TypeScript leads to improved performance in the resulting JavaScript when compiled with optimizations enabled, by up to 12%.en
dc.identifier.urihttp://hdl.handle.net/10012/20553
dc.language.isoenen
dc.pendingfalse
dc.publisherUniversity of Waterlooen
dc.subjectjavascripten
dc.subjectoptimizationen
dc.subjecttypescripten
dc.subjectjs enginesen
dc.subjectjit compilationen
dc.subjecttype systemsen
dc.subjectprogramming languagesen
dc.titleType-Aware Optimizations with Imperfect Typesen
dc.typeMaster Thesisen
uws-etd.degreeMaster of Mathematicsen
uws-etd.degree.departmentDavid R. Cheriton School of Computer Scienceen
uws-etd.degree.disciplineComputer Scienceen
uws-etd.degree.grantorUniversity of Waterlooen
uws-etd.embargo.terms0en
uws.contributor.advisorRichards, Gregor
uws.contributor.affiliation1Faculty of Mathematicsen
uws.peerReviewStatusUnrevieweden
uws.published.cityWaterlooen
uws.published.countryCanadaen
uws.published.provinceOntarioen
uws.scholarLevelGraduateen
uws.typeOfResourceTexten

Files

Original bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
Ikosin_Jeremiah.pdf
Size:
1010.54 KB
Format:
Adobe Portable Document Format
Description:

License bundle

Now showing 1 - 1 of 1
No Thumbnail Available
Name:
license.txt
Size:
6.4 KB
Format:
Item-specific license agreed upon to submission
Description: