Bug 196884 - r244079 logically broke shouldSpeculateInt52
Summary: r244079 logically broke shouldSpeculateInt52
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Saam Barati
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-12 16:10 PDT by Saam Barati
Modified: 2019-04-15 11:15 PDT (History)
16 users (show)

See Also:


Attachments
patch (9.05 KB, patch)
2019-04-12 17:45 PDT, Saam Barati
ysuzuki: review+
Details | Formatted Diff | Diff
patch for landing (9.00 KB, patch)
2019-04-12 18:07 PDT, Saam Barati
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Saam Barati 2019-04-12 16:10:17 PDT
We have code which is like:
if (shouldSpeculateInt32()) ... int32 stuff
else if (shouldSpeculateInt52()) ... int52 stuff

However, we always test for shouldSpeculateInt32 prior to shouldSpeculateInt52. But shouldSpeculateInt52 should allow int32 to flow into it. Think about a program like this:

function foo(b, y) {
    let x;
    if (b)
        x = 0; // int32
    else
        x = 0xffffffffff; // int52
    return y + x;
}

We should totally pick int52 for x, even though we weren't.
Comment 1 Saam Barati 2019-04-12 17:45:31 PDT
Created attachment 367362 [details]
patch
Comment 2 Yusuke Suzuki 2019-04-12 17:53:59 PDT
Comment on attachment 367362 [details]
patch

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

r=me

> Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:738
> +            if (type == SpecAnyIntAsDouble && enableInt52() && int52AwareSpeculationFromValue(m_currentNode->asJSValue()) == SpecNonInt32AsInt52)
> +                type = SpecNonInt32AsInt52;

Why don't we say SpecInt32AsInt52 here for Int32 values in double?
Comment 3 Saam Barati 2019-04-12 18:06:42 PDT
(In reply to Yusuke Suzuki from comment #2)
> Comment on attachment 367362 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=367362&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp:738
> > +            if (type == SpecAnyIntAsDouble && enableInt52() && int52AwareSpeculationFromValue(m_currentNode->asJSValue()) == SpecNonInt32AsInt52)
> > +                type = SpecNonInt32AsInt52;
> 
> Why don't we say SpecInt32AsInt52 here for Int32 values in double?

I spoke with Yusuke on IRC. We're going to pick what type int52AwareSpeculationFromValue gives us
Comment 4 Saam Barati 2019-04-12 18:07:12 PDT
Created attachment 367364 [details]
patch for landing
Comment 5 WebKit Commit Bot 2019-04-12 20:04:24 PDT
Comment on attachment 367364 [details]
patch for landing

Clearing flags on attachment: 367364

Committed r244238: <https://trac.webkit.org/changeset/244238>
Comment 6 WebKit Commit Bot 2019-04-12 20:04:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2019-04-12 20:05:24 PDT
<rdar://problem/49871877>
Comment 8 Ryan Haddad 2019-04-15 08:36:00 PDT
This change caused ~20 tests to fail an assertion the JSC Debug bot:

https://build.webkit.org/builders/Apple%20High%20Sierra%20Debug%20JSC%20(Tests)/builds/2587/steps/jscore-test/logs/stdio

stress/arith-abs-with-bitwise-or-zero.js.no-ftl: ASSERTION FAILED: isAnyInt52Speculation(m_type)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: ./dfg/DFGAbstractValue.cpp(443) : void JSC::DFG::AbstractValue::checkConsistency() const
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 1   0x1092f8019 WTFCrash
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 2   0x1092faffb WTFCrashWithInfo(int, char const*, char const*, int)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 3   0x109e57ee9 JSC::DFG::AbstractValue::checkConsistency() const
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 4   0x109e591d0 JSC::DFG::AbstractValue::mergeOSREntryValue(JSC::DFG::Graph&, JSC::JSValue)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 5   0x109efa5fe JSC::DFG::CFAPhase::injectOSR(JSC::DFG::BasicBlock*)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 6   0x109efa7b2 JSC::DFG::CFAPhase::performBlockCFA(JSC::DFG::BasicBlock*)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 7   0x109efa3c7 JSC::DFG::CFAPhase::performForwardCFA()
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 8   0x109efa0b7 JSC::DFG::CFAPhase::run()
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 9   0x109ef9cb1 bool JSC::DFG::runAndLog<JSC::DFG::CFAPhase>(JSC::DFG::CFAPhase&)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 10  0x109ecc7ae bool JSC::DFG::runPhase<JSC::DFG::CFAPhase>(JSC::DFG::Graph&)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 11  0x109ecc775 JSC::DFG::performCFA(JSC::DFG::Graph&)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 12  0x10a1b05a0 JSC::DFG::Plan::compileInThreadImpl()
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 13  0x10a1aeb2f JSC::DFG::Plan::compileInThread(JSC::DFG::ThreadData*)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 14  0x10a256e96 JSC::DFG::Worklist::ThreadBody::work()
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 15  0x10930ef6f WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0::operator()() const
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 16  0x10930eb59 WTF::Function<void ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0>::call()
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 17  0x10932249d WTF::Function<void ()>::operator()() const
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 18  0x1093b90f3 WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 19  0x1093c17f5 WTF::wtfThreadEntryPoint(void*)
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 20  0x7fff58297661 _pthread_body
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 21  0x7fff5829750d _pthread_body
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 22  0x7fff58296bf9 thread_start
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: test_script_1749: line 2: 50271 Segmentation fault: 11  ( "$@" ../../.vm/JavaScriptCore.framework/Resources/jsc --useFTLJIT\=false --useFunctionDotArguments\=true --validateExceptionChecks\=true --useDollarVM\=true --maxPerThreadStackUsage\=1572864 arith-abs-with-bitwise-or-zero.js )
stress/arith-abs-with-bitwise-or-zero.js.no-ftl: ERROR: Unexpected exit code: 139
Comment 9 Saam Barati 2019-04-15 08:58:49 PDT
(In reply to Ryan Haddad from comment #8)
> This change caused ~20 tests to fail an assertion the JSC Debug bot:
> 
> https://build.webkit.org/builders/
> Apple%20High%20Sierra%20Debug%20JSC%20(Tests)/builds/2587/steps/jscore-test/
> logs/stdio
> 
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: ASSERTION FAILED:
> isAnyInt52Speculation(m_type)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl:
> ./dfg/DFGAbstractValue.cpp(443) : void
> JSC::DFG::AbstractValue::checkConsistency() const
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 1   0x1092f8019 WTFCrash
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 2   0x1092faffb
> WTFCrashWithInfo(int, char const*, char const*, int)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 3   0x109e57ee9
> JSC::DFG::AbstractValue::checkConsistency() const
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 4   0x109e591d0
> JSC::DFG::AbstractValue::mergeOSREntryValue(JSC::DFG::Graph&, JSC::JSValue)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 5   0x109efa5fe
> JSC::DFG::CFAPhase::injectOSR(JSC::DFG::BasicBlock*)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 6   0x109efa7b2
> JSC::DFG::CFAPhase::performBlockCFA(JSC::DFG::BasicBlock*)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 7   0x109efa3c7
> JSC::DFG::CFAPhase::performForwardCFA()
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 8   0x109efa0b7
> JSC::DFG::CFAPhase::run()
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 9   0x109ef9cb1 bool
> JSC::DFG::runAndLog<JSC::DFG::CFAPhase>(JSC::DFG::CFAPhase&)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 10  0x109ecc7ae bool
> JSC::DFG::runPhase<JSC::DFG::CFAPhase>(JSC::DFG::Graph&)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 11  0x109ecc775
> JSC::DFG::performCFA(JSC::DFG::Graph&)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 12  0x10a1b05a0
> JSC::DFG::Plan::compileInThreadImpl()
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 13  0x10a1aeb2f
> JSC::DFG::Plan::compileInThread(JSC::DFG::ThreadData*)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 14  0x10a256e96
> JSC::DFG::Worklist::ThreadBody::work()
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 15  0x10930ef6f
> WTF::AutomaticThread::start(WTF::AbstractLocker const&)::$_0::operator()()
> const
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 16  0x10930eb59
> WTF::Function<void
> ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker
> const&)::$_0>::call()
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 17  0x10932249d
> WTF::Function<void ()>::operator()() const
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 18  0x1093b90f3
> WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 19  0x1093c17f5
> WTF::wtfThreadEntryPoint(void*)
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 20  0x7fff58297661
> _pthread_body
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 21  0x7fff5829750d
> _pthread_body
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: 22  0x7fff58296bf9
> thread_start
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: test_script_1749: line 2:
> 50271 Segmentation fault: 11  ( "$@"
> ../../.vm/JavaScriptCore.framework/Resources/jsc --useFTLJIT\=false
> --useFunctionDotArguments\=true --validateExceptionChecks\=true
> --useDollarVM\=true --maxPerThreadStackUsage\=1572864
> arith-abs-with-bitwise-or-zero.js )
> stress/arith-abs-with-bitwise-or-zero.js.no-ftl: ERROR: Unexpected exit
> code: 139

Will look once Iā€™m at a computer
Comment 10 Saam Barati 2019-04-15 11:15:05 PDT
Fixin in:
https://bugs.webkit.org/show_bug.cgi?id=196918