Bug 143532 - DFG::IntegerCheckCombiningPhase's wrap-around check shouldn't trigger C++ undef behavior on wrap-around
Summary: DFG::IntegerCheckCombiningPhase's wrap-around check shouldn't trigger C++ und...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-08 12:48 PDT by Filip Pizlo
Modified: 2015-04-10 09:36 PDT (History)
11 users (show)

See Also:


Attachments
the patch (2.40 KB, patch)
2015-04-08 12:50 PDT, Filip Pizlo
barraclough: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2015-04-08 12:48:06 PDT
Oh the irony!  We were protecting an optimization that only worked if there was no wrap-around in JavaScript.  But the C++ code had wrap-around, which is undef in C++.  So, if the compiler was smart enough, our compiler would think that there never was wrap-around.
Comment 1 Filip Pizlo 2015-04-08 12:50:13 PDT
Created attachment 250376 [details]
the patch
Comment 2 Filip Pizlo 2015-04-08 13:24:02 PDT
Landed in http://trac.webkit.org/changeset/182562
Comment 3 Darin Adler 2015-04-10 09:36:33 PDT
Comment on attachment 250376 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250376&action=review

> Source/JavaScriptCore/dfg/DFGIntegerCheckCombiningPhase.cpp:367
> +            uint32_t unsignedDifference = maxBound - minBound;
> +            return !(unsignedDifference >> 31);

Could also have written:

   int32_t difference = maxBound - minBound;
   return difference >= 0;