DFG LICM needs to go all-in on the idea that some loops can't be LICMed
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Jul 2016 17:46:39 +0000 (17:46 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Jul 2016 17:46:39 +0000 (17:46 +0000)
commitc001768288f5dca53b5db90d05a5f5f949ed2028
treef15fbfc745045bbe11910fbfee5d99d1e5497881
parentd71b08e37c3f6c1bc3c4d85919b010766d1d0eb7
DFG LICM needs to go all-in on the idea that some loops can't be LICMed
https://bugs.webkit.org/show_bug.cgi?id=159388

Reviewed by Mark Lam.

Some time ago I acknowledged that LICM required loops to meet certain requirements that
may get broken by the time we do LICM, like that the terminal of the pre-header is ExitOK.
It used to be that we just ignored that requirement and would hoist anyway, but since
r189126 we've stopped hoisting out of loops that don't have ExitOK.  We also added tests
for the case that the pre-header doesn't exist or is invalid.

It turns out that this patch didn't go far enough: even though it made LICM avoid loops
that had an invalid pre-header, the part that updated the AI state in nested loops still
assumed that these loops had valid pre-headers.  We would crash in null dereference in
that loop if a nested loop had an invalid pre-header.

The fix is simple: don't update the AI state of nested loops that don't have pre-headers,
since we won't try to hoist out of those loops anyway.

* dfg/DFGLICMPhase.cpp:
(JSC::DFG::LICMPhase::attemptHoist):
* tests/stress/licm-no-pre-header-nested.js: Added. This would always crash before this fix.
(foo):
* tests/stress/licm-pre-header-cannot-exit-nested.js: Added. This was a failed attempt at a test, but I figure it's good to have weird code anyway.
(foo):
(valueOf):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202790 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGLICMPhase.cpp
Source/JavaScriptCore/tests/stress/licm-no-pre-header-nested.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/licm-pre-header-cannot-exit-nested.js [new file with mode: 0644]
Source/WTF/benchmarks/LockFairnessTest.cpp