Jan Rehders
2007-Jun-11 20:35 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
Hi,> I know nothing about this, but the failed assertion suggests the PPC > code generator can't cope with a constant that's bigger than > expected at > that point. Have you taken a look at PPCJITInfo.cpp:382? It may shed > some light.It's inside PPCJITInfo::relocate but unfortunately I could not figure out anything from the source. It looks like it's calculating new addresses for functions which does not make much sense for a native function, at all Greetings, Jan
Jonas Maebe
2007-Jun-11 21:55 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
On 11 Jun 2007, at 22:35, Jan Rehders wrote:> It's inside PPCJITInfo::relocate but unfortunately I could not figure > out anything from the source. It looks like it's calculating new > addresses for functions which does not make much sense for a native > function, at allOn the PPC, unconditional branches are limited to 24 bit signed displacements. When you call a function in a program, the compiler therefore will create a stub which will indirectly load the address of the function (the first time it's called, usually with the help of the dynamic linker) and then perform an indirect branch using this calculated address. This stub will be placed close to the call site, so the displacement to the stub will be in range. LLVM presumably needs to generate such stubs for native functions introduced at run time as well, which it may not yet do. I have not looked into the code though, so I can't really say for sure what goes wrong here. Jonas
Chris Lattner
2007-Jun-11 22:47 UTC
[LLVMdev] How to call native functions from bytecode run in JIT?
On Mon, 11 Jun 2007, Jonas Maebe wrote:> On 11 Jun 2007, at 22:35, Jan Rehders wrote: >> It's inside PPCJITInfo::relocate but unfortunately I could not figure >> out anything from the source. It looks like it's calculating new >> addresses for functions which does not make much sense for a native >> function, at all > > On the PPC, unconditional branches are limited to 24 bit signed > displacements. When you call a function in a program, the compiler > therefore will create a stub which will indirectly load the address > of the function (the first time it's called, usually with the help of > the dynamic linker) and then perform an indirect branch using this > calculated address. This stub will be placed close to the call site, > so the displacement to the stub will be in range.Right.> LLVM presumably needs to generate such stubs for native functions > introduced at run time as well, which it may not yet do. I have not > looked into the code though, so I can't really say for sure what goes > wrong here.The LLVM PPC JIT certainly does produce these stubs. The PPCJITInfo::emitFunctionStub method is the one that actually creates them :) Jan, how are you doing this? Are you creating an external LLVM Function object named "get5", then using EE::addGlobalMapping? If 'get5' exists in the address space, why not just let the JIT resolve it (which will then create the stub)? -Chris -- http://nondot.org/sabre/ http://llvm.org/
Possibly Parallel Threads
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?
- [LLVMdev] How to call native functions from bytecode run in JIT?