[LLVMdev] Calling dispatch_async() within call to ExecutionEngine::runFunction()

Rick Mann rmann at latencyzero.com
Wed Jan 30 00:57:04 PST 2013


On Jan 30, 2013, at 0:43 , David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:

> I have used libdispatch (on FreeBSD) from JIT'd code without any issues, so I think your bug is elsewhere.

That's good to know, thanks. Puzzling, though. If I call the callbacks directly, everything executes as you would expect (the stack grows to the last callback, then unwinds, and runFunction() returns.

But the dispatch_async() block is never called at all. I don't know what can cause this.

void
PDField::decode(PDPacket* inPacket,
                DecodeFieldCompletionProc inCompletionProc,
                void* inContext)
{
    NSLog(@"decodeField(%p, %p, %p, 0x%llX)", this, inPacket, inCompletionProc, (uint64_t) inContext);
    NSLog(@"Field name: %s", mFieldName);
    NSLog(@"queue: %s", dispatch_queue_get_label(dispatch_get_current_queue()));
    
    dispatch_async(dispatch_get_current_queue(),
    ^{
        NSLog(@"comp: %p", inPacket->mCompletionProc);
        inCompletionProc(this, inPacket);
    });
}

Output is:

2013-01-29 23:40:25.456 otest[66325:303] decodeField(0x106b09d20, 0x106b09d00, 0x106c90010, 0x0)
2013-01-29 23:40:25.456 otest[66325:303] Field name: packetMarker
2013-01-29 23:40:25.457 otest[66325:303] queue: com.apple.main-thread

Breakpoints set before dispatch and on first line inside the block, never stops at the inside one.

-- 
Rick







More information about the llvm-dev mailing list