[cfe-dev] blocks and lambdas
David Chisnall
csdavec at swan.ac.uk
Wed Feb 9 01:55:17 PST 2011
On 9 Feb 2011, at 00:29, John McCall wrote:
> On Feb 8, 2011, at 3:56 PM, David Chisnall wrote:
>> Blocks are a cross-platform solution, they're just not well supported by other compilers yet[1], but they're quite useable on a variety of platforms.
>>
>> [1] Actually, they're not well supported by clang yet either - we allocate too many structures for __block variables.
>
> Can you clarify what you mean here? I'm not sure how to allocate fewer structures for __block variables, given how a single variable can be shared between multiple block objects.
A __block variable can be shared between multiple blocks, but it often isn't. We really only need to allocate one block byref structure for each set of variable / block pairs, i.e. if two variables are only referenced by the same (set of) block(s) and no others, then they can be combined. There is a note in the spec to this effect. I looked at implementing it a while ago, but the effort-reward ratio was too high unless I actually find some code where the byref allocation time is a bottleneck. The simplest (and most common) case, where a group of __block variables is only referenced by a single block would be quite easy to improve though.
David
-- Send from my Jacquard Loom
More information about the cfe-dev
mailing list