[Development] Qt 5.9's new garbage collector documentation? + root_ptr
Phil Bouchard
philippeb8 at gmail.com
Sun Jul 16 01:49:15 CEST 2017
On 07/15/2017 07:21 PM, Tim Blechmann wrote:
>>>>> fwiw, to get this thread back to the main topic, i still fail to see
>>>>> how
>>>>> root_ptr deals with objects which are reachable from multiple roots,
>>>>> which have independent lifetime
>>>>
>>>> Please provide an example.
>>>
>>> i've posted some already
>>
>> I'm working on the parser right now but I thought I proved my point with
>> the following code:
>>
>> var temporary = 0;
>>
>> var bar = function (object)
>> {
>> return 10;
>> };
>>
>> var foo = function ()
>> {
>> var object;
>> var result = function() { return object; };
>> return function() { return bar( object ); };
>> };
>>
>> for (var i = 0; i < 1000000; ++ i)
>> console_log((foo())(temporary));
>
> after `foo` returns, you only have one root, as neither `result` nor
> `object` will escape `foo` and `object` will only be referenced by the
> closure returned by `foo`.
>
> `result` is a perfect target for escape analysis. maybe even `object`.
> you have read about escape analysis, right?
Yes I understand escape analysis and that's exactly why I had to add a
run-time stack.
More information about the Development
mailing list