Yes, it does have pretty tight coupling. That is the biggest risk. On a related note, I have been tossing around ideas today for using SIMD to match multiple selectors that have the same "shape" in parallel. For example, if we have ".foo #a" and ".bar #a" it may be possible to use the packed comparison instructions in SSE4 to match both at the same time. Obviously, this adds significant complexity and correspondingly increased maintenance burden, and its effectiveness depends on how often selectors have the same shape in the wild (if it works at all). So I'm filing it into the "potentially interesting project, not a high priority" mental bin. Could be neat though.
Patrick On March 29, 2014 6:55:41 PM PDT, Boris Zbarsky <bzbar...@mit.edu> wrote: >On 3/29/14 8:23 PM, Patrick Walton wrote: >> This is just 29 bytes of code when assembled. This is likely larger >than >> the equivalent `nsRuleNode` > >The right comparison is not nsRuleNode but nsCSSSelector, right? > >These are actually pretty bloated in Gecko right now. For example, >".foo #a" is parsed into a linked list of two nsCSSSelectors. >nsCSSSelector consists of 8 words and 8 more bytes, so 40 bytes on >32-bit and 72 bytes on 64-bit. So right now storing the parsed version > >of ".foo #a" is 80 or 144 bytes in Gecko. This is not great, and we've > >been talking about shrinking these for a while, but it's clearly not >fatal. > >The rest of your proposal seems pretty workable. The biggest issue, I >suspect, is a maintainability one: it forces a pretty tight coupling >between your selector jit and the object layout of your nodes, for any >of the tests performed directly in jitcode. For example, your cited >jitcode assumes that nodes have a "class" member and a "classCount" >member and that "class" points to an array of classes, right? > >I think it should be possible to minimize the amount of coupling if it >turns out to be an issue in practice. > >-Boris >_______________________________________________ >dev-servo mailing list >dev-servo@lists.mozilla.org >https://lists.mozilla.org/listinfo/dev-servo -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo