Re:Ruby 3, Concurrency and the Ecosystem
by jashmatthews on Saturday January 09, 2021 @04:01AM
(#25698778)
Context-threading is a JIT technique. CRuby can optionally use call-threading where each op is a function and dispatch is an infinite loop of function calls. It's not the default since direct or token threading are faster but it's there.
Call-threading looks like this:
while(1) { interpreter_state = *virtual_program_counter++(interpreter_state); }
There's an indirect jump here.With context-threading you JIT very simple code which looks like this and has only direct calls:
interpreter_state = put1(interpreter_state);
interpreter_state = put1(interpreter_state);
interpreter_state = plus(interpreter_state);
Ruby has already been doing threaded dispatch on bytecodes since 1.9.