Performance optimization advice from the V8 team emphasizes initializing 
properties to objects in constructors, and always in the same order (for 
example http://www.youtube.com/watch?v=UJPdhx5zTaw). The explanation is 
that this way each instance belongs to the same hidden class.

What if you have fairly computation-intensive code that uses subclassing 
and polymorphism? In this case method lookups need to go through the 
prototype object for the instances. Once execution gets to the 
type-specific method, life should be good again because that code always 
receives a "this" and arguments of the same type at each invocation. (The 
type-specific method code is typically fairly short and quick to execute in 
my software.)

My question is, to what degree should we expect a similar principle to 
apply, that prototypes for subclasses should have the same members and the 
members should be added to each subclass in the same order? Will this make 
the compiler recognize the prototypes as belonging to the same hidden class 
and make a big contribution to fast method lookup? Will method lookup code 
tend to be inlined? Is it OK that the prototypes are all directly instances 
of Object, and not some application-specific class?

Thanks much for any insights here.

-Cris

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to