The Objective-C convention is actually fine with you stack-allocating all block arguments; it's considered the callee's responsibility to Block_copy them. cc @rjmccall
Correct. We don't do this only because we're being cautious about lifetimes. If we had a reliable way of detecting that the copy is unnecessary, it would be a significant win.
Clang has actually implemented an optimization where it eliminates the copying logic from `noescape` blocks entirely, essentially generating them as global blocks that happen to be allocated on the stack.
Additional Detail from JIRA
md5: fd60c5edf6ddc3d03a27ac1f2a14393b
Issue Description:
When we pass closures to @NoEscape objective c block arguments the closures are allocated on the heap. We should also stack allocate them.
The text was updated successfully, but these errors were encountered: