Skip to content

a-gafiyatullin/coolc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The COOL Programming Language Compiler

This directory and its subdirectories contain source code for coolc, the compiler for Classroom Object Oriented Language created for educational purposes by Alexander Aiken.

Please see the documentation provided in docs/ for further assistance with coolc.

Getting the Source Code and Building COOLC

  1. Checkout COOLC:

    • git clone https://github.com/a-gafiyatullin/coolc.git
  2. Configure and build COOLC:

    • Prerequirements:
      • clang-14;
      • gtest;
      • boost-1.61;
      • llvm-14;
      • You can use VS Code and Dev Containers extension to get Ubuntu 22.04 which contains these packages.
    • build.sh [-release/-debug] [options]
      Some useful options:
      • -clean --- clean build directory before compilation.
      • -asan --- build with AddressSanitizer (debug only).
      • -ubsan --- build with UndefinedBehaviorSanitizer (debug only).
      • -test --- run tests after building.
      • -mips --- build for SPIM emulator.
      • -llvm --- build with LLVM for host architecture.
      • -shadow-stack-gc --- (llvm build) build with LLVM Shadow Stack.
      • -statepoint-example-gc --- (llvm build) build with LLVM Stack Maps. (default)
      • -no-gc --- (llvm build) build without GC (ZeroGC only).
  3. Some useful runtime options for LLVM-based build with GC (pass them as argument to executable):

    1. MaxHeapSize --- maximal heap size (e.g. MaxHeapSize=1024[Gb/Mb/Kb/no specifier for bytes]).
    2. GCAlgo --- GC algorithm (e.g. GCAlgo=1):
      1. ZeroGC (code 0) --- just allocate memory without collecting.
      2. MarkSweepGC (code 1) --- use Mark-and-Sweep GC.
      3. ThreadedCompactionGC (code 2) --- use Jonkers's threaded compaction (Mark-and-Compact) GC (default).
      4. CompressorGC (code 3) --- use Kermany and Petrank's compressor (Mark-and-Compact) GC.
      5. SemispaceCopyingGC (code 4) --- use Semispace Copying GC (Copying) GC.
    3. PrintGCStatistics --- print some statistics about GC (e.g. +PrintGCStatistics);
    4. DoOpts --- do custom optimizations:
      1. NCE --- Null Check Elimination;
      2. DAE --- Dead Allocation Elimination (in pair with GVN).
  4. Note, that executables, that were generated by coolc, require runtime library (libcool-rt.so):

    1. This library is located in bin folder with coolc;
    2. You have to add it to your LD_LIBRARY_PATH;
    3. The easiest way to do it is to build compiler with command source ./build.sh