|
From: Kevin K. <kev...@gm...> - 2018-05-01 18:21:19
|
THe last few messages, I mentioned working on a mystery bug in calling procedures that returned CALLFRAME COROHANDLE. I now realize that the call-and-return mechanisms were innocent. Instead, the true culprit was the entry of a procedure that has variables that must be kept in the Tcl callframe. The local variable table was being allocated with '$builder allocArray', which turns into an 'alloca' instruction. That instruction was not in the entry block of the function, and for whatever reason, LLVM's optimizer decided it couldn't move it there. The result was that the LVT was allocated on the stack, and promptly went away at the first coroutine suspension, and nasal daemons were promptly invoked. People who work on this stuff should be aware that there's a variable $entryBlock in the compiler, that holds an unclosed block, and the builder has methods 'allocInBlock' and 'allocArrayInBlock' to make use of it. Anything brought in with a conventional 'alloca' cannot persist across suspending an LLVM coroutine. It appears that constant-size 'alloc' operations in the entry blocks of inline procedures are safely moved to the entry block of the procedure in which they appear, but other 'alloca's should all appear before the first 'call', lest the 'call' be inlined and the 'alloca' appear outside the entry block as a consequence. With the allocation issue fixed, 'rectest3' started working, so I'm back to having all the existing tests pass. I still need to do code and tests for NRE-aware invocation of commands (rather than compiled procs) and NRE-aware invokeExpanded. Then I'll turn on the change that makes the I/O commands require NRE (because several packages yield from stacked channel handlers). Last will come the implementation of 'tailcall' and 'yield'. 'yieldto' may be a bridge too far at this point; I have Absolutely No Idea what to do in a compiled caller of a coroutine that does 'yieldto'! So, continuing to plug ahead - along with boxing up my office, they're insisting that I have to move to a different space. :( |