Closed Bug 236753 Opened 21 years ago Closed 21 years ago

use __builtin_expect to provide branch prediction hints

Categories

(SeaMonkey :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bryner, Assigned: bryner)

Details

Attachments

(2 files)

We should use gcc's __builtin_expect() to provide branch prediction hints to the compiler. I'd propose adding macros NS_LIKELY and NS_UNLIKELY that wrap the expression to be tested and give the expected value as 1 and 0 respectively. And a good place to make use of this would be NS_SUCCEEDED and NS_FAILED. We should expect success.
Attached patch patchSplinter Review
Attachment #143229 - Flags: superreview?(dbaron)
Attachment #143229 - Flags: review?(dbaron)
Comment on attachment 143229 [details] [diff] [review] patch r+sr=dbaron, but feel free to drop the outer set of parentheses on the definitions of NS_FAILED and NS_SUCCEEDED.
Attachment #143229 - Flags: superreview?(dbaron)
Attachment #143229 - Flags: superreview+
Attachment #143229 - Flags: review?(dbaron)
Attachment #143229 - Flags: review+
Comment on attachment 143229 [details] [diff] [review] patch Also, your definitions of NS_LIKELY and NS_UNLIKELY should parenthesize the x inside the macro.
(And you actually should be ok without the outer paretheses in the definitions of NS_LIKELY and NS_UNLIKELY as well -- for the gcc3 definitions -- which is what the previous comment was referring to as well.)
checked in.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
mark NS_ENSURE_TRUE's test as unlikely. The only concern I have with this is that you will get two __builtin_expect()s with NS_ENSURE_SUCCESS: if (__builtin_expect(__builtin_expect(!(rv & 0x80000000), 0), 0)) but I don't think this causes a problem.
Attachment #143250 - Flags: superreview?(dbaron)
Attachment #143250 - Flags: review?(dbaron)
Attachment #143250 - Flags: superreview?(dbaron)
Attachment #143250 - Flags: superreview+
Attachment #143250 - Flags: review?(dbaron)
Attachment #143250 - Flags: review+
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: