BuildingAJIT5.rst 2.0 KB

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