JIT relocations and stub memory issue

Hi All,

Can anyone explain why the MachineRelocation field “NeedsStub” is set to true for GlobalValues on x86_64, but false on plain x86? This is causing the JITEmitter to allocate a stub for every GlobalValue relocation it encounters on x86_64, quickly exhausting the 512K region for stubs in the default JIT memory manager. Is this expected behavior? Is there anyway to override the stub generation? In this case, why are stubs even being allocated, my understanding was that they were merely placeholders for lazy JIT?

The same application running on plain x86 requires no such stubs and therefore runs correctly. There is currently no stub deallocation functionality in the default memory manager, so the x86_64 version can only JIT a few thousand functions before the ExecutionEngine crashes with a JIT: Ran out of space for function stubs error.

Thoughts?

Thanks,
Eric

Hi All,

Can anyone explain why the MachineRelocation field "NeedsStub" is set to true for GlobalValues on x86_64, but

That's true for large code model or Mac OS X. Right now, x86_64 targets uses small code model by default. However, in JIT, the GV memory are allocated in heap and they are not guaranteed to be *close*. So the JIT is currently emitting stubs for all of them.

Evan