add 5 + 3 end Field Description iseq Instruction Sequence (the method) PC Program Counter (what are we running right now?) SP Stack Pointer (what is on the stack?) opt_plus 3 5
executable memory jitbuf = Fisk::Helpers.jitbuffer 4096 fisk = Fisk.new # Add 5 and 3 in machine language, and write to the JIT buffer fisk.asm(jitbuf) do mov rax, imm(5) # Store 5 in RAX mov r9, imm(3) # Store 3 in R9 add rax, r9 # Add R9 to RAX ret # Return from this function end # Define an add method define_method :add, &jitbuf.to_function([], Fiddle::TYPE_INT) p add # Call add and print it