Replies: 4 comments 2 replies
-
I am just curious what you are trying to get:
I think, the simplest implementation would be providing machine code length for each function. Then after using c2mir_compile and mir-generator it is possible to traverse all functions in all modules to get overall length. So what is your thoughts about this? |
Beta Was this translation helpful? Give feedback.
-
Generally speaking, I can add a member to mir func struct about the code length. I only can not understand why do you need to move the code. The code is not position independent. It can not be moved somewhere else and executed at the new place. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply. I have refined my question. I want to leverage MIR as a compiler to integrate a JIT compiler into a virtual machine project. Initially, I simply calculate the size of machine code generated by MIR and copy the machine code to the code cache for better memory management. This approach works when the host machine architecture is x86; however, it fails when the host machine architecture is aarch64. Is there a possible solution or any recommendations to solve this issue? |
Beta Was this translation helpful? Give feedback.
-
Again, MIR does not generate position-independent code. So where the code was generated, only there it can be executed. Saying that, there is a possibility for some generated code to be position-independent. x86-64 uses pc-relative addressing in many cases and for such cases it can be position-independent. If a MIR-code contains switch insn (used for implementing C switch-stmt), it is definitely not position-independent code on any target. |
Beta Was this translation helpful? Give feedback.
-
Currently, I am aware that the
MIR_gen
function retrieves thecode_len
from thetarget_translate
function. However, I'm interested in obtaining thecode_len
after thec2mir_compile
finishes. Is it possible to use the MIR API or any specific variables to retrieve thecode_len
at that stage?If not, how can I create an API to accomplish this task with minimal changes?
Beta Was this translation helpful? Give feedback.
All reactions