Changeset 241210 in webkit


Ignore:
Timestamp:
Feb 8, 2019 2:32:00 PM (5 years ago)
Author:
mark.lam@apple.com
Message:

Fix DFG's doesGC() for CheckTierUp*, GetByVal, PutByVal*, and StringCharAt nodes.
https://bugs.webkit.org/show_bug.cgi?id=194446
<rdar://problem/47926792>

Reviewed by Saam Barati.

Fix doesGC() for the following nodes:

CheckTierUpAtReturn:

Calls triggerTierUpNow(), which calls triggerFTLReplacementCompile(),
which calls Worklist::completeAllReadyPlansForVM(), which uses DeferGC.

CheckTierUpInLoop:

Calls triggerTierUpNowInLoop(), which calls tierUpCommon(), which calls
Worklist::completeAllReadyPlansForVM(), which uses DeferGC.

CheckTierUpAndOSREnter:

Calls triggerOSREntryNow(), which calls tierUpCommon(), which calls
Worklist::completeAllReadyPlansForVM(), which uses DeferGC.

GetByVal:

case Array::String calls operationSingleCharacterString(), which calls
jsSingleCharacterString(), which can allocate a string.

PutByValDirect:
PutByVal:
PutByValAlias:

For the DFG only, the integer TypeArrays calls compilePutByValForIntTypedArray(),
which may call slow paths operationPutByValDirectStrict(), operationPutByValDirectNonStrict(),
operationPutByValStrict(), or operationPutByValNonStrict(). All of these
slow paths call putByValInternal(), which may create exception objects, or
call the generic JSValue::put() which may execute arbitrary code.

StringCharAt:

Can call operationSingleCharacterString(), which calls jsSingleCharacterString(),
which can allocate a string.

Also fix DFG::SpeculativeJIT::compileGetByValOnString() and FTL's compileStringCharAt()
to use the maxSingleCharacterString constant instead of a literal constant.

  • dfg/DFGDoesGC.cpp:

(JSC::DFG::doesGC):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetByValOnString):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileGetByVal):
(JSC::FTL::DFG::LowerDFGToB3::compilePutByVal):
(JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r241201 r241210  
     12019-02-08  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix DFG's doesGC() for CheckTierUp*, GetByVal, PutByVal*, and StringCharAt nodes.
     4        https://bugs.webkit.org/show_bug.cgi?id=194446
     5        <rdar://problem/47926792>
     6
     7        Reviewed by Saam Barati.
     8
     9        Fix doesGC() for the following nodes:
     10
     11            CheckTierUpAtReturn:
     12                Calls triggerTierUpNow(), which calls triggerFTLReplacementCompile(),
     13                which calls Worklist::completeAllReadyPlansForVM(), which uses DeferGC.
     14
     15            CheckTierUpInLoop:
     16                Calls triggerTierUpNowInLoop(), which calls tierUpCommon(), which calls
     17                Worklist::completeAllReadyPlansForVM(), which uses DeferGC.
     18
     19            CheckTierUpAndOSREnter:
     20                Calls triggerOSREntryNow(), which calls tierUpCommon(), which calls
     21                Worklist::completeAllReadyPlansForVM(), which uses DeferGC.
     22
     23            GetByVal:
     24                case Array::String calls operationSingleCharacterString(), which calls
     25                jsSingleCharacterString(), which can allocate a string.
     26
     27            PutByValDirect:
     28            PutByVal:
     29            PutByValAlias:
     30                For the DFG only, the integer TypeArrays calls compilePutByValForIntTypedArray(),
     31                which may call slow paths operationPutByValDirectStrict(), operationPutByValDirectNonStrict(),
     32                operationPutByValStrict(), or operationPutByValNonStrict().  All of these
     33                slow paths call putByValInternal(), which may create exception objects, or
     34                call the generic JSValue::put() which may execute arbitrary code.
     35
     36            StringCharAt:
     37                Can call operationSingleCharacterString(), which calls jsSingleCharacterString(),
     38                which can allocate a string.
     39
     40        Also fix DFG::SpeculativeJIT::compileGetByValOnString() and FTL's compileStringCharAt()
     41        to use the maxSingleCharacterString constant instead of a literal constant.
     42
     43        * dfg/DFGDoesGC.cpp:
     44        (JSC::DFG::doesGC):
     45        * dfg/DFGSpeculativeJIT.cpp:
     46        (JSC::DFG::SpeculativeJIT::compileGetByValOnString):
     47        * dfg/DFGSpeculativeJIT64.cpp:
     48        (JSC::DFG::SpeculativeJIT::compile):
     49        * ftl/FTLLowerDFGToB3.cpp:
     50        (JSC::FTL::DFG::LowerDFGToB3::compileGetByVal):
     51        (JSC::FTL::DFG::LowerDFGToB3::compilePutByVal):
     52        (JSC::FTL::DFG::LowerDFGToB3::compileStringCharAt):
     53
    1542019-02-08  Yusuke Suzuki  <ysuzuki@apple.com>
    255
  • trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp

    r241140 r241210  
    5454    //        such as between Array types.
    5555    //     5. Calls to a JS function, which can execute arbitrary code including allocating objects.
     56    //     6. Calls operations that uses DeferGC, because it may GC in its destructor.
    5657
    5758    switch (node->op()) {
     
    178179    case ExtractCatchLocal:
    179180    case ClearCatchLocals:
    180     case CheckTierUpInLoop:
    181     case CheckTierUpAtReturn:
    182     case CheckTierUpAndOSREnter:
    183181    case LoopHint:
    184182    case StoreBarrier:
     
    197195    case GetGetter:
    198196    case GetSetter:
    199     case GetByVal:
    200197    case GetArrayLength:
    201198    case GetVectorLength:
    202     case StringCharAt:
    203199    case StringCharCodeAt:
    204200    case GetTypedArrayByteOffset:
    205201    case GetPrototypeOf:
    206     case PutByValDirect:
    207     case PutByVal:
    208     case PutByValAlias:
    209202    case PutStructure:
    210203    case GetByOffset:
     
    273266    case CallObjectConstructor:
    274267    case CallVarargs:
     268    case CheckTierUpAndOSREnter:
     269    case CheckTierUpAtReturn:
     270    case CheckTierUpInLoop:
    275271    case Construct:
    276272    case ConstructForwardVarargs:
     
    326322    case ResolveScopeForHoistingFuncDeclInEval:
    327323    case Return:
     324    case StringCharAt:
    328325    case TailCall:
    329326    case TailCallForwardVarargs:
     
    413410
    414411    case GetIndexedPropertyStorage:
     412    case GetByVal:
    415413        if (node->arrayMode().type() == Array::String)
    416414            return true;
     415        return false;
     416
     417    case PutByValDirect:
     418    case PutByVal:
     419    case PutByValAlias:
     420        if (!graph.m_plan.isFTL()) {
     421            switch (node->arrayMode().modeForPut().type()) {
     422            case Array::Int8Array:
     423            case Array::Int16Array:
     424            case Array::Int32Array:
     425            case Array::Uint8Array:
     426            case Array::Uint8ClampedArray:
     427            case Array::Uint16Array:
     428            case Array::Uint32Array:
     429                return true;
     430            default:
     431                break;
     432            }
     433        }
    417434        return false;
    418435
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r240327 r241210  
    23452345    case GetByVal: {
    23462346        switch (node->arrayMode().type()) {
     2347        case Array::AnyTypedArray:
     2348        case Array::ForceExit:
     2349        case Array::SelectUsingArguments:
    23472350        case Array::SelectUsingPredictions:
    2348         case Array::ForceExit:
     2351        case Array::Unprofiled:
    23492352            DFG_CRASH(m_jit.graph(), node, "Bad array mode type");
    23502353            break;
     
    25672570            compileGetByValOnScopedArguments(node);
    25682571            break;
    2569         default: {
     2572        case Array::Int8Array:
     2573        case Array::Int16Array:
     2574        case Array::Int32Array:
     2575        case Array::Uint8Array:
     2576        case Array::Uint8ClampedArray:
     2577        case Array::Uint16Array:
     2578        case Array::Uint32Array:
     2579        case Array::Float32Array:
     2580        case Array::Float64Array: {
    25702581            TypedArrayType type = node->arrayMode().typedArrayType();
    25712582            if (isInt(type))
     
    28012812        }
    28022813           
    2803         default: {
     2814        case Array::Int8Array:
     2815        case Array::Int16Array:
     2816        case Array::Int32Array:
     2817        case Array::Uint8Array:
     2818        case Array::Uint8ClampedArray:
     2819        case Array::Uint16Array:
     2820        case Array::Uint32Array:
     2821        case Array::Float32Array:
     2822        case Array::Float64Array: {
    28042823            TypedArrayType type = arrayMode.typedArrayType();
    28052824            if (isInt(type))
     
    28072826            else
    28082827                compilePutByValForFloatTypedArray(base.gpr(), property.gpr(), node, type);
    2809         } }
    2810 
     2828            break;
     2829        }
     2830
     2831        case Array::AnyTypedArray:
     2832        case Array::String:
     2833        case Array::DirectArguments:
     2834        case Array::ForceExit:
     2835        case Array::Generic:
     2836        case Array::ScopedArguments:
     2837        case Array::SelectUsingArguments:
     2838        case Array::SelectUsingPredictions:
     2839        case Array::Undecided:
     2840        case Array::Unprofiled:
     2841            RELEASE_ASSERT_NOT_REACHED();
     2842        }
    28112843        break;
    28122844    }
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r240998 r241210  
    41644164        }
    41654165           
    4166         default: {
     4166        case Array::Int8Array:
     4167        case Array::Int16Array:
     4168        case Array::Int32Array:
     4169        case Array::Uint8Array:
     4170        case Array::Uint8ClampedArray:
     4171        case Array::Uint16Array:
     4172        case Array::Uint32Array:
     4173        case Array::Float32Array:
     4174        case Array::Float64Array: {
    41674175            LValue index = lowInt32(m_graph.varArgChild(m_node, 1));
    41684176            LValue storage = lowStorage(m_graph.varArgChild(m_node, 2));
    41694177           
    41704178            TypedArrayType type = m_node->arrayMode().typedArrayType();
    4171            
    4172             if (isTypedView(type)) {
     4179            ASSERT(isTypedView(type));
     4180            {
    41734181                TypedPointer pointer = pointerIntoTypedArray(storage, index, type);
    41744182               
     
    41974205                return;
    41984206            }
    4199            
     4207        }
     4208
     4209        case Array::AnyTypedArray:
     4210        case Array::ForceExit:
     4211        case Array::SelectUsingArguments:
     4212        case Array::SelectUsingPredictions:
     4213        case Array::Unprofiled:
    42004214            DFG_CRASH(m_graph, m_node, "Bad array type");
    42014215            return;
    4202         } }
     4216        }
    42034217    }
    42044218   
     
    44894503        }
    44904504           
    4491         default: {
     4505        case Array::Int8Array:
     4506        case Array::Int16Array:
     4507        case Array::Int32Array:
     4508        case Array::Uint8Array:
     4509        case Array::Uint8ClampedArray:
     4510        case Array::Uint16Array:
     4511        case Array::Uint32Array:
     4512        case Array::Float32Array:
     4513        case Array::Float64Array: {
    44924514            TypedArrayType type = arrayMode.typedArrayType();
    44934515           
    4494             if (isTypedView(type)) {
     4516            ASSERT(isTypedView(type));
     4517            {
    44954518                TypedPointer pointer = TypedPointer(
    44964519                    m_heaps.typedArrayProperties,
     
    45454568                return;
    45464569            }
    4547 
     4570        }
     4571
     4572        case Array::AnyTypedArray:
     4573        case Array::String:
     4574        case Array::DirectArguments:
     4575        case Array::ForceExit:
     4576        case Array::Generic:
     4577        case Array::ScopedArguments:
     4578        case Array::SelectUsingArguments:
     4579        case Array::SelectUsingPredictions:
     4580        case Array::Undecided:
     4581        case Array::Unprofiled:
    45484582            DFG_CRASH(m_graph, m_node, "Bad array type");
    45494583            break;
    4550         }
    45514584        }
    45524585    }
Note: See TracChangeset for help on using the changeset viewer.