Bug 143345

Summary: cloop overflow test is broken in recent clang
Product: WebKit Reporter: Richard O'Grady <rjogrady>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   

Richard O'Grady
Reported 2015-04-02 14:31:25 PDT
cloop.rb's cloopAddOverflowTest() uses this check: "((#{signBit}(b) != #{signBit}(a)) && (#{signBit}(b-a) == #{signBit}(a)))" to detect overflow, and similarly for subtraction. In clang r221045, an optimization was introduced which breaks this for the case where we are incrementing a value by 1. Repro on Linux (with clang r221045 or above): $ CC=clang $ CXX=clang $ build-jsc --cloop --release --gtk Then execute this in jsc: for (var i = 0x7fffffff; i < 0x80000000; i++) {print(i);} Notice that i wraps around to become negative. Using safeAdd() and safeSub() from CheckedArithmetic.h avoids the problem.
Attachments
Note You need to log in before you can comment on or make changes to this bug.