Hacker News new | past | comments | ask | show | jobs | submit login

Can someone ELI5 what exactly happens when the external method call is "JIT"ed in a language like LuaJIT -- what does that mean?

I understand calling dlopen() and dlsym()

And I understand this idea of a PLT and it's indirection

But this idea of something external to the JIT'ed program being JIT'ed I do not understand.

Does it mean it inlined the instructions of the external function into the JIT'ed code?




No, I don't think Lua (or the author) is inlining the external function.

What's being JIT'd is the Lua code into machine code, and where Lua would need to call a C function, it (apparently) is just emitting a `call the_external_fn` into the JIT's resulting assembly. That's a direct function call, so it's about as fast as you're going to get, but somewhat counter-intuitively, it'll be faster than C, as we don't do anything with the PLT or indirection. Just call the function.


I think you need a layer of indirection there - you can't just directly call a function in another library in x64, whereas the library itself can. So in general the library should have a speed advantage when calling itself in x64.


Ahh got it, that makes sense -- thanks!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: