Skip to content
  • shend's avatar
    Exploit sharing when comparing and copying groups in ComputedStyle. · 51ad943c
    shend authored
    Groups inside ComputedStyle, such as StyleSurroundData, are stored as
    pointers. When we copy the StyleSurroundData of a ComputedStyle, instead
    of copying each member inside StyleSurroundData, we can copy the pointer
    itself and do a copy when we write to it (copy-on-write). Similarly,
    when we compare two StyleSurroundData pointers, we can first check if
    they're pointing to the same object. If so, then we know that the two
    StyleSurroundDatas are equal without having to compare each member
    inside StyleSurroundData.
    
    This patch introduces two macros: fieldwise_compare and fieldwise_copy,
    which generate the code to do this optimisation. These macros take a
    a list of fields to compare/copy and generate the cheapest set of code
    for that task, taking advantage of group sharing.
    
    This patch removes the perf cost of:
    https://codereview.chromium.org/2786883002
    
    by generating the exact same code as what was originally handwritten.
    
    Diff of generated code:
    https://gist.github.com/darrnshn/fe97404e680016753030fc788fcf24ff/revisions
    
    BUG=628043
    
    Review-Url: https://codereview.chromium.org/2826633002
    Cr-Commit-Position: refs/heads/master@{#467243}
    51ad943c