| Summary: | Compiler Incorrect Optimization | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | zhiyi <vulbugs> | ||||||
| Component: | JavaScriptCore | Assignee: | Mark Lam <mark.lam> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | ews-watchlist, fpizlo, keith_miller, mark.lam, msaboff, saam, tzagallo, vulbugs, webkit-bug-importer, ysuzuki | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Nightly Build | ||||||||
| Hardware: | Unspecified | ||||||||
| OS: | Unspecified | ||||||||
| Attachments: |
|
||||||||
Created attachment 433828 [details]
proposed patch.
Comment on attachment 433828 [details] proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=433828&action=review > Source/JavaScriptCore/dfg/DFGOperations.cpp:206 > + if (static_cast<double>(asInt) == input) { > + if (asInt || !std::signbit(input)) I think it is worth putting `LIKELY`. if (LIKELY(static_cast<double>(asInt) == input && (asInt || !std::signbit(input)))) return JSValue::encode(jsNumber(asInt)); (In reply to Yusuke Suzuki from comment #3) > Comment on attachment 433828 [details] > proposed patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=433828&action=review > > > Source/JavaScriptCore/dfg/DFGOperations.cpp:206 > > + if (static_cast<double>(asInt) == input) { > > + if (asInt || !std::signbit(input)) > > I think it is worth putting `LIKELY`. > > if (LIKELY(static_cast<double>(asInt) == input && (asInt || > !std::signbit(input)))) > return JSValue::encode(jsNumber(asInt)); OK, will do. Created attachment 433830 [details]
patch for landing.
Thanks for the review. Landed in r280060: <http://trac.webkit.org/r280060>. |
OS: ubuntu18.04 Architecture: <x64> ./jsc bug.js expected output -Infinity -Infinity actual output -Infinity Infinity bug.js ################################## function f() { v0 = (-0.0).toLocaleString(); return parseInt(v0); } let a0 = f(); print(1 / a0); for (let i = 0; i < 0x1000; i++) { f(); } let a3 = f(); print(1 / a3);