Depending on usage patterns, you might see a further speed boost if you
split your objects into two parts, where one has the same shape for all
objects and the other is type dependent, roughly:

class Thing {
  constructor(type, specific, ...) {
    this.type = type;
    this.other_common_field = ...;

    // If type === 100, this is a Foo; if type === 101, it's a Bar; etc.
    this.type_specific_stuff = specific;
  }
}

var x = new Thing(100, new Foo(...), ...);  // Maybe wrap in a factory?

if (x.type === 100) {
  var data = x.type_specific_stuff.foo_field;  // Both loads are
monomorphic, yay!
}



On Thu, Mar 1, 2018 at 12:31 PM Andrew Wilcox <andrew.wil...@gmail.com>
wrote:

> can anyone tell me what LoadIC is?
>>
>>
>
>> The thing that handles property loads (like foo.bar;).
>
>
> Thank you Jacob!
>
>
> Seeing it take 22% is rare. Is your app heavy on polymorphic property
>> loads?
>
>
> Yes, I'm writing an interpreter and it was doing a *lot* of instanceof
> checks.  Since I don't have undefined or null values in my interpreter,
> rather than use x instanceof Foo I can instead give Foo instances a
> "type" property of e.g. 100 and use x.type === 100, which is faster.  So
> indeed yes, now it's doing a lot of polymorphic property loads! :-)  Makes
> perfect sense, thanks!
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to