-
Notifications
You must be signed in to change notification settings - Fork 62
Code Organization
This page describes the organization of the /source directory.
benchmark.py is a Python script used to benchmark the performance of Higgs JIT and gather a variety of metrics.
options.d describes the command-line options (switches) for the Higgs binary.
stats.d contains code to gather various metrics about performance and program execution characteristics. The statistics gathered are helpful in understanding performance bottlenecks.
This directory contains the source code of the lexer and parser and related tests. Both are written from scratch without the help of lexer/parser generators (e.g.: lex and yacc).
Code relating to the construction, analysis and transformation of the Intermediate Representation (IR) (see ir.d and ops.d). The Abstract Syntax Trees (AST) produced by the parser are transformed into this SSA-form IR, which is more practical for a compiler to work with (see ast.d).
vm.d defines the VM class and other structures, such as value/type pairs at the core of the Higgs virtual machine.
object.d is code used by the VM to manipulate JS objects (including arrays and closures). This code is mostly used during VM initialization and to handle edge cases. The JIT bypasses this code and generates optimized machine code to access object properties when possible.
gc.d is the implementation of the copying, stop-the-world Garbage Collector (GC) Higgs uses to manage JS objects. This GC is distinct from the D garbage collector.
runtime.js contains the self-hosted runtime primitives, written in extended JavaScript. The semantics of arithmetic and logical operators are defined in this file.
Implementation of the JavaScript standard library (e.g.: Array, Number, String, Function classes). This is written in extended JavaScript and relies on primitives defined in the runtime library (see runtime.js).
Implementation of the lazy incremental Higgs JIT and x86 machine code generation. The JIT does not use LLVM or other code generation framework, but instead implements its own minimalist x86-64 assembler. The bulk of the code generation is done in ops.d.
Unit tests meant to ensure that Higgs produces the expected results. We are always adding new tests in this directory. Tests relating to custom libraries should go under /source/tests/lib.
Benchmarks used to test the performance and proper functioning of Higgs. Contains benchmarks from the classic SunSpider and V8 suites as well as microbenchmarks designed to study the generated machine code and performance characteristics for specific language constructs.
Contains miscellaneous utility code used by Higgs.