Curious: can LLVM be used for z-machine Infocom code, and if so, how? (generally)

Forgive me if this is a stupid question, but I am wondering if LLVM can be used to get higher performance Z-Machine VM for interactive fiction. (If it can be used, I'm just looking for some high-level ideas or suggestions, not a detailed solution.)

It may seem strange to seek higher performance for technology around 1978, but it seems that Z-Machine games created by the modern IDE Inform 7 may have performance problems due to the sheer number of rules that need to be evaluated with each turn.

Thanks!

FYI: Z-machine architecture was redesigned by Graham Nelson and documented at http://www.inform-fiction.org/zmachine/standards/z1point0/overview.html

+4
source share
2 answers

Yes it is possible. The naive port of the interpreter for the compiler can be done relatively easily.

However, this will not be a big win in performance. The problem with any compiler for ZCode or Glulx is that they are both relatively low level. For example, Glulx supports indirect jumps and self-modifying code. There is no way to statically compile this into efficient native code. To make it really fast, you will need to compile a trace or something similar.

+2
source

Of course, it would be (but difficult) to use LLVM as a kind of JIT for Z-machine code, but would it be easier to just compile the Inform source directly into a faster language? For example, C for maximum speed, or .NET or Java if you prefer portability. I suspect that this route will be much simpler and more efficient than just the jerry rigging JIT on the interpreter side.

+1
source

Source: https://habr.com/ru/post/1307238/


All Articles