Changeset 244480 in webkit


Ignore:
Timestamp:
Apr 19, 2019 5:37:43 PM (5 years ago)
Author:
sbarati@apple.com
Message:

AbstractValue can represent more than int52
https://bugs.webkit.org/show_bug.cgi?id=197118
<rdar://problem/49969960>

Reviewed by Michael Saboff.

JSTests:

  • stress/abstract-value-can-include-int52.js: Added.

(foo):
(index.index.8.index.60.index.65.index.1234.index.1234.parseInt.string_appeared_here.String.fromCharCode):

Source/JavaScriptCore:

Let's analyze this control flow diamond:

#0
branch #1, #2

#1:
PutStack(JSValue, loc42)
Jump #3

#2:
PutStack(Int52, loc42)
Jump #3

#3:
...

Our abstract value for loc42 at the head of #3 will contain an abstract
value that us the union of Int52 with other things. Obviously in the
above program, a GetStack for loc42 would be inavlid, since it might
be loading either JSValue or Int52. However, the abstract interpreter
just tracks what the value could be, and it could be Int52 or JSValue.

When I did the Int52 refactoring, I expected such things to never happen,
but it turns out it does. We should just allow for this instead of asserting
against it since it's valid IR to do the above.

  • bytecode/SpeculatedType.cpp:

(JSC::dumpSpeculation):

  • dfg/DFGAbstractValue.cpp:

(JSC::DFG::AbstractValue::checkConsistency const):

  • dfg/DFGAbstractValue.h:

(JSC::DFG::AbstractValue::validateTypeAcceptingBoxedInt52 const):

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r244429 r244480  
     12019-04-19  Saam Barati  <sbarati@apple.com>
     2
     3        AbstractValue can represent more than int52
     4        https://bugs.webkit.org/show_bug.cgi?id=197118
     5        <rdar://problem/49969960>
     6
     7        Reviewed by Michael Saboff.
     8
     9        * stress/abstract-value-can-include-int52.js: Added.
     10        (foo):
     11        (index.index.8.index.60.index.65.index.1234.index.1234.parseInt.string_appeared_here.String.fromCharCode):
     12
    1132019-04-18  Yusuke Suzuki  <ysuzuki@apple.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r244470 r244480  
     12019-04-19  Saam Barati  <sbarati@apple.com>
     2
     3        AbstractValue can represent more than int52
     4        https://bugs.webkit.org/show_bug.cgi?id=197118
     5        <rdar://problem/49969960>
     6
     7        Reviewed by Michael Saboff.
     8
     9        Let's analyze this control flow diamond:
     10       
     11        #0
     12        branch #1, #2
     13       
     14        #1:
     15        PutStack(JSValue, loc42)
     16        Jump #3
     17       
     18        #2:
     19        PutStack(Int52, loc42)
     20        Jump #3
     21       
     22        #3:
     23        ...
     24       
     25        Our abstract value for loc42 at the head of #3 will contain an abstract
     26        value that us the union of Int52 with other things. Obviously in the
     27        above program, a GetStack for loc42 would be inavlid, since it might
     28        be loading either JSValue or Int52. However, the abstract interpreter
     29        just tracks what the value could be, and it could be Int52 or JSValue.
     30       
     31        When I did the Int52 refactoring, I expected such things to never happen,
     32        but it turns out it does. We should just allow for this instead of asserting
     33        against it since it's valid IR to do the above.
     34
     35        * bytecode/SpeculatedType.cpp:
     36        (JSC::dumpSpeculation):
     37        * dfg/DFGAbstractValue.cpp:
     38        (JSC::DFG::AbstractValue::checkConsistency const):
     39        * dfg/DFGAbstractValue.h:
     40        (JSC::DFG::AbstractValue::validateTypeAcceptingBoxedInt52 const):
     41
    1422019-04-19  Tadeu Zagallo  <tzagallo@apple.com>
    243
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp

    r244079 r244480  
    249249            isTop = false;
    250250    }
    251    
    252     if (value & SpecInt32AsInt52)
    253         strOut.print("Int32AsInt52");
    254 
    255     if (value & SpecNonInt32AsInt52)
    256         strOut.print("NonInt32AsInt52");
    257        
     251
    258252    if ((value & SpecBytecodeDouble) == SpecBytecodeDouble)
    259253        strOut.print("BytecodeDouble");
     
    288282        isTop = false;
    289283   
    290     if (isTop)
     284    if (value & SpecEmpty)
     285        strOut.print("Empty");
     286    else
     287        isTop = false;
     288
     289    if (value & SpecInt52Any) {
     290        if ((value & SpecInt52Any) == SpecInt52Any)
     291            strOut.print("Int52Any");
     292        else if (value & SpecInt32AsInt52)
     293            strOut.print("Int32AsInt52");
     294        else if (value & SpecNonInt32AsInt52)
     295            strOut.print("NonInt32AsInt52");
     296    } else
     297        isTop = false;
     298   
     299    if (value == SpecBytecodeTop)
     300        out.print("BytecodeTop");
     301    else if (value == SpecHeapTop)
     302        out.print("HeapTop");
     303    else if (value == SpecFullTop)
     304        out.print("FullTop");
     305    else if (isTop)
    291306        out.print("Top");
    292307    else
    293308        out.print(strStream.toCString());
    294    
    295     if (value & SpecEmpty)
    296         out.print("Empty");
    297309}
    298310
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.cpp

    r244287 r244480  
    453453        RELEASE_ASSERT(!m_value);
    454454   
    455     if (m_type & SpecInt52Any) {
    456         if (m_type != SpecFullTop)
    457             RELEASE_ASSERT(isAnyInt52Speculation(m_type));
    458     }
    459 
    460455    if (!!m_value)
    461456        RELEASE_ASSERT(validateTypeAcceptingBoxedInt52(m_value));
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.h

    r244287 r244480  
    527527       
    528528        if (m_type & SpecInt52Any) {
    529             ASSERT(!(m_type & ~SpecInt52Any));
    530 
    531             if (mergeSpeculations(m_type, int52AwareSpeculationFromValue(value)) != m_type)
    532                 return false;
    533             return true;
     529            if (mergeSpeculations(m_type, int52AwareSpeculationFromValue(value)) == m_type)
     530                return true;
    534531        }
    535532
Note: See TracChangeset for help on using the changeset viewer.