46 minutes ago · 5 min read1033 words · Tech · hide

Ufuk made a comment that he enjoyed my description of SSA from bytecode in Aaron’s livestream with me. While filming the livestream—an intro to ZJIT internals—I got a little nervous that people would shy away from our 1900 line add_iseq_to_hir function. This function is responsible for converting CRuby’s stack based bytecode for the YARV virtual machine into a high-level SSA IR for ZJIT to analyze and optimize. It takes bytecode that looks roughly like this: push 3 push 4 add into SSA form, giving an SSA value to each stack slot, ish: v0 = const 3 v1 = const 4 v2 = add v0, v1 While our function is 2000 lines long because it handles a lot of specific opcodes and weird facts about those opcodes, the core of it is small. Here is that core. What if a stack, but virtual The bytecode assumes that when it is run, it will be operating on a stack. This means that every opcode has implicit stack inputs and implicit stack outputs. push 3, for example, has empty stack inputs and one stack output.…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town