Re:c4x86 - JIT compiler for x86 in 86 lines
by chubot on Saturday December 13, 2014 @03:30PM
(#8746294)
What prevents c4x86.c from compiling with c4.c? Is it the <sys/mman.h> header? (Note the "not self-hosted" comment in the README.)
[ Parent
| on HN ]
Re:c4x86 - JIT compiler for x86 in 86 lines
by dmytrish on Saturday December 13, 2014 @03:39PM
(#8746320)
It's `mmap` call and syntax of function pointer at the end of the file (needed to call the compiled code).
P.S. Otherwise, it is ready to run itself, work in progress.
Re:c4x86 - JIT compiler for x86 in 86 lines
by userbinator on Sunday December 14, 2014 @12:55AM
(#8747572)
Allowing it to call arbitrary functions using dlopen()/dlsym() would be the idea I have for fixing the first problem - it'd also increase its power substantially since it can then make use of any other library's functions instead of the currently hardcoded list. Supporting function pointers would be a bit harder and involve changing the parser/code generator.
Re:c4x86 - JIT compiler for x86 in 86 lines
by hyc_symas on Sunday December 14, 2014 @02:50PM
(#8749321)
How would you tell it which shared library to dlopen?
Was looking into changing the order of arguments to go the right way 'round. Also changing address refs to be PC-relative, to avoid the relocation phase. Seems pretty straightforward.
Re:c4x86 - JIT compiler for x86 in 86 lines
by dmytrish on Sunday December 14, 2014 @03:57PM
(#8749536)
I thought about `dlopen`, but did not know how to fetch it libc platform-independently (`dlopen(argv[0])` is fine on OS X, but not on Linux).
Now I see that the first argument can be NULL, that approach is feasible.