proj-plbook-plChBackendImpl

  1. # Pointer tagging

"Most dynamic languages use pointer tagging, so most ints fit inside a pointer and don’t allocate memory. This goes back at least to Smalltalk-76, and probably all the way to LISP." [1]

"Alan Kay explicitly said that he copied this from Lisp. It’s a really old technique." [2]

  1. # Resolving jump addresses Example: https://elle.readthedocs.io/en/latest/implementation.html?source=post_page---------------------------
    1. Symbol patching

"One neat trick I pulled from otcc is the symbol patching mechanism. Namely, when we don't know the value of a given symbol yet while emitting code we use the bits dedicated to this value in the machine code to store a linked list of all locations to be patched with the given symbol value. See the code of the patch function for details about that. "

More symbol patching ("linker relaxation"): https://www.sifive.com/blog/all-aboard-part-3-linker-relaxation-in-riscv-toolchain

  1. # Code generation tools
      1. LLVM See other chapters about LLVM.
      2. Dynasm http://luajit.org/dynasm.html

targets: x86, x64, ARM, PowerPC? and MIPS

MIT license

  1. ## LibJIT? https://www.gnu.org/software/libjit/

Started as a part of DotGNU? Project.

targets: x86, x86-64, arm, also has an interpreter for unsupported architectures

IR: https://code.google.com/archive/p/libjit-linear-scan-register-allocator/wikis/LibJITVirtualMachineInstructionSet.wiki

Links: - https://eli.thegreenplace.net/2013/10/17/getting-started-with-libjit-part-1 - https://eli.thegreenplace.net/2013/11/12/getting-started-with-libjit-part-2/ - https://eli.thegreenplace.net/2014/01/07/getting-started-with-libjit-part-3 - https://code.google.com/archive/p/libjit-linear-scan-register-allocator/wikis/LLVM_and_GNU_Lightning.wiki "How does Libjit compare to LLVM or GNU lightning?" - http://lists.ximian.com/pipermail/mono-devel-list/2009-April/031640.html

Lesser GPL

The MIR project considers it a competitor as one of 3 "projects which could be considered or adapted as real universal light-weight JIT competitors". Compared to MIR:

"

      1. GNU Lightning http://lists.ximian.com/pipermail/mono-devel-list/2009-April/031640.html targets: aarch64, alpha, arm, hppa, ia64, mips, powerpc, risc-v, s390, sparc and x86

https://www.gnu.org/software/lightning/

Lesser GPL

  1. ## Asmjit

https://github.com/asmjit/asmjit

targets?: ARM AArch64 X86 X64

zlib License

  1. ## QBE

https://c9x.me/compile/

https://c9x.me/git/qbe.git

QBE vs LLVM

The MIR project considers it a competitor as one of 3 "projects which could be considered or adapted as real universal light-weight JIT competitors". Compared to MIR:

"

Tutorials and discussions:

Related:

MIT License

Opinions:

Notes:

Links:

      1. MIR

https://github.com/vnmakarov/mir

https://developers.redhat.com/blog/2020/01/20/mir-a-lightweight-jit-compiler-project/

https://github.com/vnmakarov/mir/blob/master/MIR.md

https://linuxplumbersconf.org/event/7/contributions/732/attachments/507/952/The-LightWeight-JIT-Compiler-Slides.pdf

https://developers.redhat.com/articles/2022/02/16/code-specialization-mir-lightweight-jit-compiler#tracing_and_meta_tracing_in_a_jit_compiler

targets: x86_64, aarch64, ppc64be, ppc64le, s390x Linux and x86_64 MacOS?

MIT license

MIR also has a C->MIR compiler "C11 standard w/o standard optional variable arrays, complex, and atomics" [8]

discussions:

      1. RyuJIT?

https://github.com/dotnet/coreclr/blob/master/Documentation/botr/ryujit-overview.md

"...the next generation Just in Time Compiler (aka “JIT”) for the AMD64 .NET runtime."

The MIR project considers it a competitor as one of 3 "projects which could be considered or adapted as real universal light-weight JIT competitors". Compared to MIR:

"

      1. LIBFirm

https://github.com/libfirm/libfirm

  1. ## Cranelift

https://github.com/CraneStation/cranelift

  1. ## NanoJIT?

https://github.com/dibyendumajumdar/nanojit

  1. ## LLVM JIT (ORC)

https://llvm.org/docs/ORCv2.html

(much slower startup than smaller projects like MIR [9])

  1. ## GCC JIT (libgccjit)

https://gcc.gnu.org/onlinedocs/jit/

(much slower startup than smaller projects like MIR [10])

The evolution of the ABI is documented in: https://gcc.gnu.org/onlinedocs/jit/topics/compatibility.html#abi-symbol-tags

  1. ## GCC See also https://www.reddit.com/r/ProgrammingLanguages/comments/jhaand/what_code_generators_are_there/g9ycpg8/
      1. Code generation tool discussion

"The key difficulty in adding garbage collection to code emitted with tools like this is being able to accurately tell what the root set is." -- [11]

  1. ## Code generation lists and links
    1. Calling conventions
      1. Calling conventions misc " Varargs in combination with other language fea- tures have led to calling conventions where the caller is responsible for removing the arguments from the stack. This makes it impossible to im- plement guaranteed tail-call optimization, which would be necessary to use C calls as a general con- trol flow primitive [Ste77] "

https://c9x.me/compile/bib/abi-x64.pdf https://c9x.me/compile/bib/abi-arm64.pdf

  1. # Executable format tools
    1. Debugging instrumentation
      1. DWARF
    1. Memory
      1. Memory management tools
    1. Misc
      1. Dealing with stack alignment requirements when implementing VMs

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/using-the-stack-in-aarch64-implementing-push-and-pop gives methods of dealing with AArch64's requirement that SP be 16-byte aligned when implementing VMs that expect to be able to push or pop single registers).

  1. ## Libc and stack size