Remix.run Logo
tekknolagi 7 hours ago

In this case, we used to abort (i.e. abort(); intentionally crash the entire process) but now we jump into the interpreter to handle the dynamic behavior.

If someone writes dynamic ruby code to add two objects, it should succeed in both integer and string cases. The JIT just wants to optimize whatever the common case is.

zingar 4 hours ago | parent | next [-]

I’m assuming that when you talk about crashing processes as the status quo you’re referring to earlier versions of zjit rather than current Ruby on yjit? Because I’ve never seen a Ruby process crash because + was called with different arguments.

tekknolagi an hour ago | parent [-]

Yes; see the first ZJIT blog post. https://railsatscale.com/2025-05-14-merge-zjit/

ComputerGuru 6 hours ago | parent | prev [-]

I guess I’m confused why an actual add instruction is emitted rather than whatever overloaded operation takes place when the + symbol (or overloaded add vtable entry) is called (like it would in other OOP languages).

tekknolagi 5 hours ago | parent | next [-]

If all you're doing is summing small integers---frequently the case---it's much preferable to optimize that to be fast and then skip the very dynamic method lookup (the slower, less common case)

zingar 4 hours ago | parent | prev [-]

Presumably other languages with JIT do exactly the same thing?