⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 240024 in webkit


Ignore:
Timestamp:
Jan 15, 2019, 6:17:31 PM (8 years ago)
Author:
yusukesuzuki@slowstart.org
Message:

[JSC] Use KnownStringUse for GetByVal(Array::String) since AI would offer wider type information and offer non-string type after removing Check(String)
​https://bugs.webkit.org/show_bug.cgi?id=193438
<rdar://problem/45581249>

Reviewed by Saam Barati and Keith Miller.

JSTests:

Under the heavy load (like, compiling WebKit), AI in this code can broaden type information after the 1st run.
Then, GetByVal(String) crashed.

  • stress/string-get-by-val-lowering.js: Added.

(shouldBe):
(test):

  • stress/type-for-get-by-val-can-be-widen-after-ai.js: Added.

(Hello):
(foo):

Source/JavaScriptCore:

GetByVal(Array::String) emits Check(String) before that. But AI can broaden type constraint in the second run.
After the first run removes Check(String), it would happen that AI starts saying the type of 1st child is not String.
To claim that it *is* a String type, we should use KnownStringUse here.

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode): StringCharAt and GetByVal(Array::String) share the underlying compiler code. We should
change StringUse => KnownStringUse for StringCharAt too. And StringCharAt and StringCharCodeAt potentially have the same
problem. This patch fixes it too.

  • dfg/DFGSSALoweringPhase.cpp:

(JSC::DFG::SSALoweringPhase::lowerBoundsCheck):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt):

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r239982 r240024  
     12019-01-15  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        [JSC] Use KnownStringUse for GetByVal(Array::String) since AI would offer wider type information and offer non-string type after removing Check(String)
     4        https://bugs.webkit.org/show_bug.cgi?id=193438
     5        <rdar://problem/45581249>
     6
     7        Reviewed by Saam Barati and Keith Miller.
     8
     9        Under the heavy load (like, compiling WebKit), AI in this code can broaden type information after the 1st run.
     10        Then, GetByVal(String) crashed.
     11
     12        * stress/string-get-by-val-lowering.js: Added.
     13        (shouldBe):
     14        (test):
     15        * stress/type-for-get-by-val-can-be-widen-after-ai.js: Added.
     16        (Hello):
     17        (foo):
     18
    1192019-01-15  Tomas Popela  <tpopela@redhat.com>
    220
  • trunk/Source/JavaScriptCore/ChangeLog

    r240023 r240024  
     12019-01-15  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        [JSC] Use KnownStringUse for GetByVal(Array::String) since AI would offer wider type information and offer non-string type after removing Check(String)
     4        https://bugs.webkit.org/show_bug.cgi?id=193438
     5        <rdar://problem/45581249>
     6
     7        Reviewed by Saam Barati and Keith Miller.
     8
     9        GetByVal(Array::String) emits Check(String) before that. But AI can broaden type constraint in the second run.
     10        After the first run removes Check(String), it would happen that AI starts saying the type of 1st child is not String.
     11        To claim that it *is* a String type, we should use KnownStringUse here.
     12
     13        * dfg/DFGFixupPhase.cpp:
     14        (JSC::DFG::FixupPhase::fixupNode): StringCharAt and GetByVal(Array::String) share the underlying compiler code. We should
     15        change StringUse => KnownStringUse for StringCharAt too. And StringCharAt and StringCharCodeAt potentially have the same
     16        problem. This patch fixes it too.
     17        * dfg/DFGSSALoweringPhase.cpp:
     18        (JSC::DFG::SSALoweringPhase::lowerBoundsCheck):
     19        * ftl/FTLLowerDFGToB3.cpp:
     20        (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):
     21        (JSC::FTL::DFG::LowerDFGToB3::compileStringCharCodeAt):
     22
    1232019-01-15  Saam Barati  <sbarati@apple.com>
    224
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r240023 r240024  
    782782            ASSERT(node->arrayMode() == ArrayMode(Array::String, Array::Read));
    783783            blessArrayOperation(node->child1(), node->child2(), node->child3());
    784             fixEdge<KnownCellUse>(node->child1());
     784            fixEdge<KnownStringUse>(node->child1());
    785785            fixEdge<Int32Use>(node->child2());
    786786            break;
    … …  
    899899                break;
    900900            case Array::ForceExit:
     901                break;
     902            case Array::String:
     903                fixEdge<KnownStringUse>(m_graph.varArgChild(node, 0));
     904                fixEdge<Int32Use>(m_graph.varArgChild(node, 1));
    901905                break;
    902906            default:
  • trunk/Source/JavaScriptCore/dfg/DFGSSALoweringPhase.cpp

    r230144 r240024  
    125125            op = GetVectorLength;
    126126            break;
     127        case Array::String:
     128            // When we need to support this, it will require additional code since base's useKind is KnownStringUse.
     129            DFG_CRASH(m_graph, m_node, "Array::String's base.useKind() is KnownStringUse");
     130            break;
    127131        default:
    128132            break;
    … …  
    131135        Node* length = m_insertionSet.insertNode(
    132136            m_nodeIndex, SpecInt32Only, op, m_node->origin,
    133             OpInfo(m_node->arrayMode().asWord()), base, storage);
     137            OpInfo(m_node->arrayMode().asWord()), Edge(base.node(), KnownCellUse), storage);
    134138        m_insertionSet.insertNode(
    135139            m_nodeIndex, SpecInt32Only, CheckInBounds, m_node->origin,
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r240023 r240024  
    65916591    void compileStringCharAt()
    65926592    {
    6593         LValue base = lowCell(m_graph.child(m_node, 0));
     6593        LValue base = lowString(m_graph.child(m_node, 0));
    65946594        LValue index = lowInt32(m_graph.child(m_node, 1));
    65956595        LValue storage = lowStorage(m_graph.child(m_node, 2));
    … …  
    67056705        LBasicBlock continuation = m_out.newBlock();
    67066706
    6707         LValue base = lowCell(m_node->child1());
     6707        LValue base = lowString(m_node->child1());
    67086708        LValue index = lowInt32(m_node->child2());
    67096709        LValue storage = lowStorage(m_node->child3());
Note: See TracChangeset for help on using the changeset viewer.