Open Bug 1042922 Opened 10 years ago Updated 2 years ago

trim down pointer-happy mozilla::dom::NativeProperties

Categories

(Core :: DOM: Core & HTML, defect, P5)

defect

Tracking

()

People

(Reporter: froydnj, Unassigned)

Details

NativeProperties has quite a lot of pointers: struct NativeProperties { const Prefable<const JSFunctionSpec>* staticMethods; jsid* staticMethodIds; const JSFunctionSpec* staticMethodsSpecs; const Prefable<const JSPropertySpec>* staticAttributes; jsid* staticAttributeIds; const JSPropertySpec* staticAttributeSpecs; const Prefable<const JSFunctionSpec>* methods; jsid* methodIds; const JSFunctionSpec* methodsSpecs; const Prefable<const JSPropertySpec>* attributes; jsid* attributeIds; const JSPropertySpec* attributeSpecs; const Prefable<const JSFunctionSpec>* unforgeableMethods; jsid* unforgeableMethodIds; const JSFunctionSpec* unforgeableMethodSpecs; const Prefable<const JSPropertySpec>* unforgeableAttributes; jsid* unforgeableAttributeIds; const JSPropertySpec* unforgeableAttributeSpecs; const Prefable<const ConstantSpec>* constants; jsid* constantIds; const ConstantSpec* constantSpecs; }; and we have several hundred of them: [froydnj@cerebro build-mc]$ readelf -sW dom/bindings/*.o |grep -e sChromeOnlyNativeProperties -e sNativeProperties|wc -l 638 which adds up to quite some space (x86-64): [froydnj@cerebro build-mc]$ readelf -sW dom/bindings/*.o |grep -e sChromeOnlyNativeProperties -e sNativeProperties|f 3|addup 107184 So ~50K on x86/ARM. This doesn't count the relocations required by the pointers, which would be 638 * 21 pointers * 24 bytes/reloc ~= 360K. (This is a much smaller number on 32-bit platforms, more like ~120K, and mitigated by elfhack on both. Still.) I think we could save some space with a flatter layout like: { jsid* allIds; // staticMethodsIdsOffset implicitly 0 uint16_t staticAttributesIdsOffset; uint16_t methodsIdsOffset; uint16_t attributesIdsOffset; uint16_t unforgeableMethodIdsOffset uint16_t unforgeableAttributesIdsOffset; uint16_t constantIdsOffset; const Prefable<const JSFunctionSpec>* allMethods; // staticMethodsOffset implicitly 0 uint16_t methodsOffset; uint16_t unforgeableMethodsOffset; const Prefable<const JSPropertySpec>* allAttributes; // staticAttributesOffset implicitly 0 uint16_t attributesOffset; uint16_t unforgeableMethodsOffset; const Prefable<const ConstantSpec>* constants; const ConstantSpec* constantSpecs; }; which would save about half of the space on 32-bit platforms and somewhat more on 64-bit (possibly with some rearrangement of *Offset fields to pack nicely), assuming I've not botched my numbers. Some of those uint16_ts might even be able to be uint8_t. Relocations due to these structures would be reduced by ~75% (21 pointers/structure -> 5 pointers/structure) This would make the codegen of all those bits not nearly so nice, though. :(
(In reply to Nathan Froyd (:froydnj) from comment #0) > This doesn't count the relocations required by the pointers, which would be > 638 * 21 pointers * 24 bytes/reloc ~= 360K. (This is a much smaller number > on 32-bit platforms, more like ~120K, and mitigated by elfhack on both. > Still.) I thought this number sounded ridiculously high...it's nowhere near this much, because rarely do these structures have all the fields filled with non-nullptr values. The relocations are still a concern, but they probably take up only tens of K or less, rather than hundreds.
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.