Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
They're necessary for implementing callbacks, closures, vtables, coroutines, threads, runtime incrementally optimized functions (think JIT compilers), and other low level hackery.
I mean it's literally just like any other pointer. -
iiii92194yAny function is basically just a pointer to a region in memory where the function starts. That's it.
Pointers are essentially as complicated as you make them to be while really being a very simple concept. -
@iiii I use LLVM for stuff sometimes. Found that the standard tutorial (kaleidoscope) includes using the inbuilt JIT compiler (it's literally like 5 extra lines or something). You can play around with that. I also built a basic lisp interpreter that had an incredibly crap JIT compiler. Didn't use any resource as such, you just write your compiled binary output to a page (I just used clang to compile the C output of my lisp compiler...like I said, crap), mark it as executable, and jump to that pointer, literally all there is to it.
I believe LuaJIT is a relatively simple thing you can look at too. -
@iiii yeah I don't think anyone uses LLVM for JIT, it's just there for convenience in case you want to hot reload and stuff. A good JIT compiler is intimately tied to a good runtime system, and LLVM does not provide a runtime system, that's not in its scope.
Making a good one is really really tricky. I'd say JavaScript engines do it best, along with JVMs and the CLR. Not something I know much about though. -
You people won't let me rant peacefully 😂. I know their importance, it's just a rant. That's what I told in my initial rant. I guess I am that guy who just complains about everything, no matter what 🥱
-
Your program is just data that happens to correspond to CPU instructions.
A pointer to a function is just that - a pointer to some of that data. Like a pointer to a variable or whatnot.
What's confusing about it? -
@RememberMe Definitely use LLVM for JIT. Check out Terra - we use it there for JIT.
-
@junon I meant using it as is. LLVM's JIT isn't terribly fast from what I remember, and you have to build tracing and on-the-fly optimization etc. on top of it anyway, that's the actually hard part of JIT. I could imagine it being used just for the compile step.
Related Rants
What in the holy hell is a pointer to function and function pointer.I guess they have a purpose, I hate their existence. It's solely because it is complicated
rant
hell
c++
wk229