commit | e8abebbc560bc64554c06e0480c2c9e75b0d3d32 | [log] [tgz] |
---|---|---|
author | shend <shend@chromium.org> | Mon May 01 05:53:20 2017 |
committer | Commit bot <commit-bot@chromium.org> | Mon May 01 05:53:20 2017 |
tree | ad5023b6977c9f0929ede7c0fe59713efda2818d | |
parent | 73fe6ba4ceb2db91a43ee2305f69ffde08001f62 [diff] |
Add heuristic to order non bit fields in ComputedStyleBase. Currently, when we generate non bit fields, we order them in alphabetical order. This may result in unnecessary padding, e.g. struct { char a; /* char padding[3] */ int b; char c; /* char padding[3] */ }; See [1] for an explanation. This patch defines an ordering on field types so that we can sort non bit fields from largest alignment size to smallest. This heuristic minimises the padding most of the time: struct { int b; char a; char c; /* char padding[2] */ }; This is purely a memory optimisation, not speed. It does not take into account data access patterns and cache locality. We use the data from [2] to define the order of types. With this heuristic, some of the generated code has changed, but it is unlikely to have changed the size of any structs. Diff of generated files: https://gist.github.com/darrnshn/81d146c2696ef100d56309e5b4b529ff/revisions [1] http://www.drdobbs.com/cpp/padding-and-rearranging-structure-member/240007649?pgno=2 [2] https://codereview.chromium.org/2841413002 BUG=628043 Review-Url: https://codereview.chromium.org/2844223002 Cr-Commit-Position: refs/heads/master@{#468293}