[Vm-dev] Object basicNew vs object shallowCopy

Eliot Miranda eliot.miranda at gmail.com
Mon Aug 1 07:58:46 UTC 2016


Hi John,

> On Jul 31, 2016, at 7:32 AM, John McIntosh <johnmci at smalltalkconsulting.com> wrote:
> 
> So has anyone thought about pre-allocating a few commonly used objects during idle time?  Then grabbing that object and filling in the actual details when one is needed. The Squeak VM did that for method context (and recycled them).

Thus only works to the extent that a particular kind if object us allocated all the time and to the extent that synthesizing an object is relatively expensive relative to filling in its slots.  This works for contexts above a complex object representation.  In my experience it doesn't work for floats either. But Cog does not allocate contexts often because of context-to-stack mapping and because the Spur object representation is simple, regular and very quick to synthesize (allocate).

> 
> Also a decade back I looked at the new logic and rearranged the code to fast path the creation of commonly used objects. This improved things a bit but didn't really outweight the resulting mess of if statements 
> 
> Sent from my iPhone
> 
>> On Jul 31, 2016, at 08:45, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>> 
>> 
>> Hi Denis, Hi Levente,
>> 
>>> On Jul 31, 2016, at 3:41 AM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
>>> 
>>> It can't be quicker than basicNew.
>> 
>> Depends. Decoding size and encoding header from the class receiver in basicNew might be slower than decoding size and encoding header from the instance receiver in shallowCopy.  But the difference should be small.
>> 
>>> It will be quicker than basicNew + manual copying of the fields.
>> 
>> Agreed.
>> 
>>> And yes, this is quite important to be quick along with the #copyFrom: primitive (168).
>> 
>> It's on the to do list then :-)
>> 
>>> Levente
>> 
>> _,,,^..^,,,_ (phone)


More information about the Vm-dev mailing list