Ekko: Harnessing the Power of Javascript for Rapid and Accessible Compiler Development

Date of Completion

5-4-2023

Degree Type

Honors Thesis

Discipline

Computer Science (CMSI)

First Advisor

Raymond Toal

Second Advisor

Tyler Edmiston

Abstract

LLVM is a popular and versatile compiler infrastructure that supports multiple programming languages. Languages with compilers that target LLVM include C#, CUDA, Julia, Kotlin, Lua, Objective-C, Ruby, Rust, and Swift. Although Ekko targets LLVM, its front-end is implemented entirely in JavaScript. This project serves as an exploration into the utility of using non-C-based, high-level programming languages for front-end compiler development. Despite some performance limitations, JavaScript’s rapid prototyping capabilities, interoperability, and mature ecosystem of development tools (including the Ohm parsing toolkit) prove that it merits further investigation in this space. Ekko is a statically typed, compiled language that provides the standard set of features commonly found in programming languages, encompassing variables, operators, control flow structures, and functions, among others. Its syntax is defined using the Ohm language library. Once an Ekko program is parsed into an AST, a custom-built analyzer identified semantic errors and performs optimizations. The Ekko generator includes modules for each grammar rule that generate corresponding LLVM IR — a low-level, platform-independent representation of source code that serves as a bridge between the JavaScript front-end and the LLVM back-end. After receiving LLVM IR, the LLVM compiler backend performs its own optimizations and generates target-specific machine code, which can be executed directly on a target architecture or further processed.

Share

COinS