[Vm-dev] Re: [squeak-dev] compiled squeakjs
florin.mateoc at gmail.com
Mon Jan 19 01:15:41 UTC 2015
Sorry, I forgot to mention something:
On 1/18/2015 7:26 PM, Ryan Macnak wrote:
> On Sun, Jan 18, 2015 at 12:59 PM, <florin.mateoc at gmail.com <mailto:florin.mateoc at gmail.com>> wrote:
> Can you please explain what you do for initialization (especially for large arrays, sets, etc)? Assuming that
> Newspeak also has something like Smalltalk's nil, do you fill them at creation time with nil?
> We eagerly assign nil to all slots. For regular objects, it is important that slots for a given class are always
> initialized in the same order, otherwise a JS engine like V8 won't consider all the instances to be of the same Map
> (hidden class), things will seem more polymorphic than they are, and optimizations won't happen. For arrays, I don't
> know whether this is more harmful to performance because we pollute type data about the array's elements with
> UndefinedObject or this is more helpful because we don't need checks for undefined in #at:. Certainly in terms of
> implementation effort, eager initialization is much better than sprinkling checks in all the places that access slots.
There is no need to check for undefined in #at:, or in any place that just references slots. Undefined can be assigned
and passed around in general. The only checks needed are for receivers at invocation time (and even those can be
sometimes avoided), and then (if receiver is undefined) delegate to the UndefinedObject instance
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev