RESOLVED FIXED 51866
Use __builtin_expect when compiling using RVCT in GNU mode
https://bugs.webkit.org/show_bug.cgi?id=51866
Summary Use __builtin_expect when compiling using RVCT in GNU mode
Daniel Bates
Reported 2011-01-03 21:14:29 PST
When in GNU mode, RVCT supports the GNU language intrinsic __builtin_expect, which is used to provide the compiler with branch prediction information. We should favor using this intrinsic if we are compiling with RVCT in GNU mode (i.e. COMPILER(RVCT) && defined(__GNUC__)).
Attachments
Patch (1.21 KB, patch)
2011-01-03 21:20 PST, Daniel Bates
no flags
Exclude RVCT2.2 from using this intrinsic (1.16 KB, patch)
2011-01-10 12:08 PST, Siddharth Mathur
no flags
Same patch as above, but with Changelog format issue corrected. (1.16 KB, patch)
2011-01-10 12:11 PST, Siddharth Mathur
dbates: review-
dbates: commit-queue-
Patch (3.42 KB, patch)
2011-01-10 15:37 PST, Daniel Bates
darin: review+
Daniel Bates
Comment 1 2011-01-03 21:20:05 PST
Darin Adler
Comment 2 2011-01-03 21:29:07 PST
Comment on attachment 77867 [details] Patch OK
Laszlo Gombos
Comment 3 2011-01-04 08:47:33 PST
Looks good to me too. A simpler way to express this is to test for defined(__GNUC__), instead of "COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__))".
Daniel Bates
Comment 4 2011-01-04 09:31:00 PST
(In reply to comment #3) > Looks good to me too. A simpler way to express this is to test for defined(__GNUC__), instead of "COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__))". Will change before I land.
Daniel Bates
Comment 5 2011-01-04 09:44:51 PST
Siddharth Mathur
Comment 6 2011-01-10 12:08:33 PST
Created attachment 78423 [details] Exclude RVCT2.2 from using this intrinsic According to ARM's documentation (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0202h/Cjabddedbde.html), this GNU-style intrinsic is only available with RVCT 3 and later , so exclude previous major version from using it.
Siddharth Mathur
Comment 7 2011-01-10 12:11:20 PST
Created attachment 78425 [details] Same patch as above, but with Changelog format issue corrected.
Eric Seidel (no email)
Comment 8 2011-01-10 13:50:40 PST
Comment on attachment 78425 [details] Same patch as above, but with Changelog format issue corrected. rs=me.
Eric Seidel (no email)
Comment 9 2011-01-10 13:51:19 PST
Comment on attachment 77867 [details] Patch I'm confused by the status of this bug. Did this get landed?
Siddharth Mathur
Comment 10 2011-01-10 14:03:14 PST
(In reply to comment #9) > (From update of attachment 77867 [details]) > I'm confused by the status of this bug. Did this get landed? Sorry Eric for the confusion. I reopened a previously closed bug (manually landed by Daniel Bates) to add an amendment, which you just r+ed.
Daniel Bates
Comment 11 2011-01-10 14:36:20 PST
Comment on attachment 78425 [details] Same patch as above, but with Changelog format issue corrected. Why are we hardcoding __ARMCC_2_2__ instead of checking __ARMCC_VERSION >= 300000?
Daniel Bates
Comment 12 2011-01-10 14:37:49 PST
(In reply to comment #11) > (From update of attachment 78425 [details]) > Why are we hardcoding __ARMCC_2_2__ instead of checking __ARMCC_VERSION >= 300000? I mean checking that __ARMCC_VERSION <= 300000
Daniel Bates
Comment 13 2011-01-10 15:05:33 PST
(In reply to comment #12) > (In reply to comment #11) > > (From update of attachment 78425 [details] [details]) > > Why are we hardcoding __ARMCC_2_2__ instead of checking __ARMCC_VERSION >= 300000? > > I mean checking that __ARMCC_VERSION <= 300000 Disregard this comment. The inequality in the previous comment (comment 11) was correct. That is, we should change the check from: #if defined(__GNUC__) to #if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__) && __ARMCC_VERSION >= 300000) so that we only use __builtin_expect if we are compiling with GCC or compiling with RVCT version 3.0 or higher in GNU mode.
Daniel Bates
Comment 14 2011-01-10 15:37:35 PST
WebKit Review Bot
Comment 15 2011-01-10 15:39:40 PST
Attachment 78461 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1 Source/JavaScriptCore/wtf/Platform.h:1016: Missing space after , [whitespace/comma] [3] Source/JavaScriptCore/wtf/AlwaysInline.h:44: Missing space after , [whitespace/comma] [3] Source/JavaScriptCore/wtf/AlwaysInline.h:52: Missing space after , [whitespace/comma] [3] Total errors found: 3 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 16 2011-01-10 15:40:35 PST
Comment on attachment 78461 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=78461&action=review > Source/JavaScriptCore/wtf/Platform.h:79 > +/* Define this for !RVCT compilers, just so we can write things like COMPILER(RVCT) && RVCT_VERSION_AT_LEAST(3,0,0,0). */ It occurs to me that this means that you could always just use RVCT_VERSION_AT_LEAST(3,0,0,0) without COMPILER(RVCT); maybe we should. > Source/JavaScriptCore/wtf/Platform.h:91 > -/* define this for !GCC compilers, just so we can write things like COMPILER(GCC) && GCC_VERSION_AT_LEAST(4,1,0) */ > +/* Define this for !GCC compilers, just so we can write things like COMPILER(GCC) && GCC_VERSION_AT_LEAST(4,1,0). */ > #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 It occurs to me that this means that you could always just use GCC_VERSION_AT_LEAST(3,0,0,0) without COMPILER(GCC); maybe we should.
Daniel Bates
Comment 17 2011-01-10 16:03:44 PST
(In reply to comment #16) > (From update of attachment 78461 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=78461&action=review > > > Source/JavaScriptCore/wtf/Platform.h:79 > > +/* Define this for !RVCT compilers, just so we can write things like COMPILER(RVCT) && RVCT_VERSION_AT_LEAST(3,0,0,0). */ > > It occurs to me that this means that you could always just use RVCT_VERSION_AT_LEAST(3,0,0,0) without COMPILER(RVCT); maybe we should. Correct. Will change both comment and callsites before landing. > > > Source/JavaScriptCore/wtf/Platform.h:91 > > -/* define this for !GCC compilers, just so we can write things like COMPILER(GCC) && GCC_VERSION_AT_LEAST(4,1,0) */ > > +/* Define this for !GCC compilers, just so we can write things like COMPILER(GCC) && GCC_VERSION_AT_LEAST(4,1,0). */ > > #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 > > It occurs to me that this means that you could always just use GCC_VERSION_AT_LEAST(3,0,0,0) without COMPILER(GCC); maybe we should. Correct. Will change comment before landing. I suggest that we update the callsites in a separate bug.
Daniel Bates
Comment 18 2011-01-10 16:18:21 PST
Daniel Bates
Comment 19 2011-01-10 16:52:01 PST
(In reply to comment #17) > (In reply to comment #16) > > It occurs to me that this means that you could always just use GCC_VERSION_AT_LEAST(3,0,0,0) without COMPILER(GCC); maybe we should. > > Correct. Will change comment before landing. I suggest that we update the callsites in a separate bug. Filed bug #52178 for this and decided to make the comment change in the patch for this bug.
Note You need to log in before you can comment on or make changes to this bug.