How can I properly exit from code being executed via "ExecutionEngine::runFunction"? My JIT'd code is executing and it calls a function in the host program. This host function then decides the executing code should be stopped and wants to return from runFunction. I've considered setjmp/longjmp, but I'm not sure if this would properly clean up the ExecutionEngine internals. -- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 261 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130130/b9a64784/attachment.sig>
On Jan 29, 2013, at 21:41 , edA-qa mort-ora-y <eda-qa at disemia.com> wrote:> How can I properly exit from code being executed via > "ExecutionEngine::runFunction"? My JIT'd code is executing and it calls > a function in the host program. This host function then decides the > executing code should be stopped and wants to return from runFunction.If the executing code wants to return, it should just return. I take it that doesn't work for you? You probably need to modify things so that your JITed code can tolerate the host code returning, or it can return some kind of error condition. I'm not sure what's required to allow an exception to be thrown through the JITed code. I'd consider doing that if I could. My own code has a similar need. I got around it by making my code very asynchronous. That is, I call runFunction, my JITed code executes, and eventually calls a method in my host with a callback. That method returns immediately, and so does runFunction. Eventually, my host code calls the callback it was given to continue processing. However, I haven't fully tested this, in that currently my host function is stubbed out to just immediately call the callback, so I don't know if this can actually work. I better test it… -- Rick
On 30/01/13 07:17, Rick Mann wrote:> If the executing code wants to return, it should just return. I take > it that doesn't work for you? You probably need to modify things so > that your JITed code can tolerate the host code returning, or it can > return some kind of error condition.The guest code in this case doesn't know that it will be returning. This "abort" conditions are detected and controlled by the host to detect misbehaving guest code. Therefore the guest can't be expected to cooperate in this situation. I'm not concerned about any tracking in the guest code, it will handle a premature finish just fine. I'm more worried about the LLVM internals: if I longjmp out of runFunction I'm assuming LLVM may leak resources, or be left in a dirty state. My guess is that exceptions won't actually work. This is because the guest code can actually use exceptions (or will, not yet in my case). I assume that if the host is also compiled with LLVM then the exception handling will interfere and the guest code will end up catching the exception and nonsense will ensue. -- edA-qa mort-ora-y -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Sign: Please digitally sign your emails. Encrypt: I'm also happy to receive encrypted mail. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 261 bytes Desc: OpenPGP digital signature URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130130/4f34bd1a/attachment.sig>