Replies: 2 comments 1 reply
-
any C compiler can do that (including mir's c2m) by creating a shared object (.so) that's loaded after compilation using dlopen+dlsym. might i point out to all you tinycc lovers that there's another alternative: it's called GCC 3.4.6 (last GCC 3.x version). it's not quite as fast as tinycc during execution but still 10x faster than current GCC versions, and unlike tcc produces actually fast&good code, sometimes superior to GCC 10 even. it supports C99, and unlike GCC >= 4.3, doesn't require any external libraries at build time. it's also written in C, unlike >= GCC 4.8. |
Beta Was this translation helpful? Give feedback.
-
The problem with usage of .so is minimal size allocated for .so object. It is a page (usually 4KB). It is too big for small JITted function. When you compile a lot of (small) functions separately (that how JIT usually works), it results in usage of many pages and trashing TLB entries and as consequence a big execution slow down. I admire the compilation speed of tcc but its generated code performance (roughly less than 50% of GCC with -O2) is unacceptable for JIT especially for dynamic programming languages when one VM insn execution needs multiple machine insns. In such case machine insns generated by GCC -O2 for one VM insn including additional machine insns for VM insn operand decoding and dispatch in the interpreter can still require less time than JITted code generated by tcc. Absence of optimization in tcc also against using it for JITting which goal is to combine code of subsequent VM insns and optimize the combined code. |
Beta Was this translation helpful? Give feedback.
-
Hello.
I'm currently using TinyCC to compile a string that contains a C function. The process happens during execution time and works as a hot code reloading. I was wondering if we could do the same using MIR. A simple example would be adding two arrays (x and y) and storing the result into another array (res):
char *str_code= "void calc(float *x, float*y, float *res, int n){int i; for (i=0; i<n; i++) res[i] = x[i] +y[i]; }";
Then something like (please ignore any possible syntax errors. :) ):
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions