Re: Selectors: name find method and find signature

On 9/12/13 1:09 PM, Domenic Denicola wrote:
> Hmm, the issue is, this internal-properties thing is pretty prevalent in ES6 generally. All the built-ins can now be subclassed, and the mechanism in the spec for that is by giving them internal data properties that are initialized by their @@create, so that subclasses get those data properties too. I imagine whatever trick you guys are going to use for ensuring arrays, dates, etc. maintain their current performance in the face of this new spec mechanism

Assuming that happens...  But the problem is not speed.

 > can also be applied to `Element`s?

Maybe.  Elements aren't built into the JS engine, so they don't have the 
same facilities available to them.

But again, checking whether something is an Element is pretty quick. 
What's a problem is checking for some internal property that doesn't 
correlate with Element-ness, because then that property has to be kept 
track of separately on a per-instance basis, and your memory usage balloons.

Here's a simple example.  Right now, SpiderMonkey stores the equivalents 
of "internal properties" from ES5 ([[Get]], etc) on a struct that's 
shared by all similar-enough objects (e.g. all objects created via new 
Object() have a single pointer to one shared in-memory instance of this 
struct).  But if [[Get]] is configurable on a per-object basis, then you 
end up with a mechanism for storing [[Get]] on every object, which takes 
more memory, or is slower, or both.

So here is a real tradeoff here between specification and use 
flexibility and performant implementation.

> One thing that might help (but IANAImplementer! :P) is that `Array`, `Date`, etc. don't give you the ability to arbitrarily brand other objects as arrays, dates, etc. They just give you `Array[@@create]()`, `Date[@@create]()`, etc. for *creating* such branded objects. The same could presumably work for `Element`s?

Sure.  Again, as long as the [[QuerySelectorAll]] thing correlates with 
being branded an Element, and objects can't be branded as more than one 
thing at a time, there is no problem.  Then you just keep track of the 
brand.

-Boris

Received on Thursday, 12 September 2013 17:39:00 UTC