Home | History | Annotate | Download | only in tutorial
      1 =============================================================================
      2 Building a JIT: Remote-JITing -- Process Isolation and Laziness at a Distance
      3 =============================================================================
      4 
      5 .. contents::
      6    :local:
      7 
      8 **This tutorial is under active development. It is incomplete and details may
      9 change frequently.** Nonetheless we invite you to try it out as it stands, and
     10 we welcome any feedback.
     11 
     12 Chapter 5 Introduction
     13 ======================
     14 
     15 Welcome to Chapter 5 of the "Building an ORC-based JIT in LLVM" tutorial. This
     16 chapter introduces the ORC RemoteJIT Client/Server APIs and shows how to use
     17 them to build a JIT stack that will execute its code via a communications
     18 channel with a different process. This can be a separate process on the same
     19 machine, a process on a different machine, or even a process on a different
     20 platform/architecture. The code builds on top of the lazy-AST-compiling JIT
     21 stack from `Chapter 4 <BuildingAJIT3.html>`_.
     22 
     23 **To be done -- this is going to be a long one:**
     24 
     25 **(1) Introduce channels, RPC, RemoteJIT Client and Server APIs**
     26 
     27 **(2) Describe the client code in greater detail. Discuss modifications of the
     28 KaleidoscopeJIT class, and the REPL itself.**
     29 
     30 **(3) Describe the server code.**
     31 
     32 **(4) Describe how to run the demo.**
     33 
     34 Full Code Listing
     35 =================
     36 
     37 Here is the complete code listing for our running example that JITs lazily from
     38 Kaleidoscope ASTS. To build this example, use:
     39 
     40 .. code-block:: bash
     41 
     42     # Compile
     43     clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O3 -o toy
     44     clang++ -g Server/server.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core orcjit native` -O3 -o toy-server
     45     # Run
     46     ./toy-server &
     47     ./toy
     48 
     49 Here is the code for the modified KaleidoscopeJIT:
     50 
     51 .. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
     52    :language: c++
     53 
     54 And the code for the JIT server:
     55 
     56 .. literalinclude:: ../../examples/Kaleidoscope/BuildingAJIT/Chapter5/Server/server.cpp
     57    :language: c++
     58