don't pragma pack ipc message headers

RESOLVED FIXED in mozilla26

Status

()

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: froydnj, Unassigned)

Tracking

unspecified
mozilla26
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

The IPC::Message header is surrounded by:

#pragma pack(push,2)
...
#pragma pack(pop)

which (at least on GCC) specifies that structure members defined lexically
within the pragma should be two-byte aligned, rather than the ABI's declared
alignment.

But for IPC::Message::Header, this is a silly requirement, as everything there
is four bytes; there's no reason to pack the members any tighter.  And packing
tighter means that strict alignment platforms (like ARM) need to use more
complex code for something as simple as storing to one of the members--like
when we set a message's request ID, over and over and over.  The current code
for setting a message's request ID on ARM looks like:

     264:	6863      	ldr	r3, [r4, #4]
     266:	696a      	ldr	r2, [r5, #20]
     268:	809a      	strh	r2, [r3, #4]
     26a:	0c12      	lsrs	r2, r2, #16
     26c:	80da      	strh	r2, [r3, #6]

With the patch, it looks like:

     264:	6863      	ldr	r3, [r4, #4]
     266:	696a      	ldr	r2, [r5, #20]
     268:	605a      	str	r2, [r3, #4]

Only four bytes, but multiplied over several hundred set_routing_id calls, it
saves some code size and runtime.  I verified that the header's length doesn't
change by looking at debug information.
Created attachment 796244 [details] [diff] [review]
don't pragma pack ipc message headers

See comment 0 or the commit message for a description of the problem.
Attachment #796244 - Flags: review?(bent.mozilla)
Comment on attachment 796244 [details] [diff] [review]
don't pragma pack ipc message headers

Review of attachment 796244 [details] [diff] [review]:
-----------------------------------------------------------------

Awesome, thanks!
Attachment #796244 - Flags: review?(bent.mozilla) → review+
https://hg.mozilla.org/mozilla-central/rev/c78a87a9aa66
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.