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

Changeset 101298 in webkit


Ignore:
Timestamp:
Nov 28, 2011, 3:51:51 PM (15 years ago)
Author:
fpizlo@apple.com
Message:

GetById should not always speculate cell
https://bugs.webkit.org/show_bug.cgi?id=73181

Reviewed by Gavin Barraclough.

GetById will now speculate cell if the predictions of the base are cell.
Otherwise it will do like the old JIT (and like the old non-speculative
DFG JIT): if not cell, go straight to slow-path but otherwise don't OSR
out. This is a 1% speed-up on SunSpider.

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::execute):

  • dfg/DFGOperations.cpp:
  • dfg/DFGOperations.h:
  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::setupArgumentsWithExecState):
(JSC::DFG::SpeculativeJIT::callOperation):

  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r101295 r101298  
     12011-11-28  Filip Pizlo  <fpizlo@apple.com>
     2
     3        GetById should not always speculate cell
     4        https://bugs.webkit.org/show_bug.cgi?id=73181
     5
     6        Reviewed by Gavin Barraclough.
     7       
     8        GetById will now speculate cell if the predictions of the base are cell.
     9        Otherwise it will do like the old JIT (and like the old non-speculative
     10        DFG JIT): if not cell, go straight to slow-path but otherwise don't OSR
     11        out. This is a 1% speed-up on SunSpider.
     12
     13        * dfg/DFGAbstractState.cpp:
     14        (JSC::DFG::AbstractState::execute):
     15        * dfg/DFGOperations.cpp:
     16        * dfg/DFGOperations.h:
     17        * dfg/DFGSpeculativeJIT.h:
     18        (JSC::DFG::SpeculativeJIT::setupArgumentsWithExecState):
     19        (JSC::DFG::SpeculativeJIT::callOperation):
     20        * dfg/DFGSpeculativeJIT32_64.cpp:
     21        (JSC::DFG::SpeculativeJIT::cachedGetById):
     22        (JSC::DFG::SpeculativeJIT::compile):
     23        * dfg/DFGSpeculativeJIT64.cpp:
     24        (JSC::DFG::SpeculativeJIT::compile):
     25
    1262011-11-28  Oliver Hunt  <oliver@apple.com>
    227
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractState.cpp

    r101283 r101298  
    564564            break;
    565565        }
    566         forNode(node.child1()).filter(PredictCell);
     566        if (isCellPrediction(m_graph[node.child1()].prediction()))
     567            forNode(node.child1()).filter(PredictCell);
    567568        clobberStructures(nodeIndex);
    568569        forNode(nodeIndex).makeTop();
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r101283 r101298  
    4949#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function)    FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rsi)
    5050#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function)  FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rcx)
     51#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function)  FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, rcx)
    5152#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, r8)
    5253
     
    6364#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_E(function)    FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 8)
    6465#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function)  FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 16)
     66#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function)  FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 20)
    6567#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) FUNCTION_WRAPPER_WITH_RETURN_ADDRESS(function, 24)
    6668
     
    9395    );
    9496
     97#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function) \
     98    asm ( \
     99    ".text" "\n" \
     100    ".align 2" "\n" \
     101    ".globl " SYMBOL_STRING(function) "\n" \
     102    HIDE_SYMBOL(function) "\n" \
     103    ".thumb" "\n" \
     104    ".thumb_func " THUMB_FUNC_PARAM(function) "\n" \
     105    SYMBOL_STRING(function) ":" "\n" \
     106        "str lr, [sp, #0]" "\n" \
     107        "b " SYMBOL_STRING_RELOCATION(function) "WithReturnAddress" "\n" \
     108    );
     109
    95110#define FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) \
    96111    asm ( \
     
    116131FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(function)
    117132
     133#define J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function) \
     134EncodedJSValue DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, Identifier*, ReturnAddressPtr); \
     135FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(function)
     136
    118137#define V_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJCI(function) \
    119138void DFG_OPERATION function##WithReturnAddress(ExecState*, EncodedJSValue, JSCell*, Identifier*, ReturnAddressPtr); \
     
    313332}
    314333
    315 EncodedJSValue DFG_OPERATION operationGetById(ExecState* exec, JSCell* base, Identifier* propertyName)
    316 {
    317     JSValue baseValue(base);
     334EncodedJSValue DFG_OPERATION operationGetById(ExecState* exec, EncodedJSValue base, Identifier* propertyName)
     335{
     336    JSValue baseValue = JSValue::decode(base);
    318337    PropertySlot slot(baseValue);
    319338    return JSValue::encode(baseValue.get(exec, *propertyName, slot));
    320339}
    321340
    322 J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(operationGetByIdBuildList);
    323 EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ExecState* exec, JSCell* base, Identifier* propertyName, ReturnAddressPtr returnAddress)
    324 {
    325     JSValue baseValue(base);
     341J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(operationGetByIdBuildList);
     342EncodedJSValue DFG_OPERATION operationGetByIdBuildListWithReturnAddress(ExecState* exec, EncodedJSValue base, Identifier* propertyName, ReturnAddressPtr returnAddress)
     343{
     344    JSValue baseValue = JSValue::decode(base);
    326345    PropertySlot slot(baseValue);
    327346    JSValue result = baseValue.get(exec, *propertyName, slot);
     
    333352}
    334353
    335 J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(operationGetByIdProtoBuildList);
    336 EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ExecState* exec, JSCell* base, Identifier* propertyName, ReturnAddressPtr returnAddress)
    337 {
    338     JSValue baseValue(base);
     354J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(operationGetByIdProtoBuildList);
     355EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildListWithReturnAddress(ExecState* exec, EncodedJSValue base, Identifier* propertyName, ReturnAddressPtr returnAddress)
     356{
     357    JSValue baseValue = JSValue::decode(base);
    339358    PropertySlot slot(baseValue);
    340359    JSValue result = baseValue.get(exec, *propertyName, slot);
     
    346365}
    347366
    348 J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_ECI(operationGetByIdOptimize);
    349 EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ExecState* exec, JSCell* base, Identifier* propertyName, ReturnAddressPtr returnAddress)
    350 {
    351     JSValue baseValue(base);
     367J_FUNCTION_WRAPPER_WITH_RETURN_ADDRESS_EJI(operationGetByIdOptimize);
     368EncodedJSValue DFG_OPERATION operationGetByIdOptimizeWithReturnAddress(ExecState* exec, EncodedJSValue base, Identifier* propertyName, ReturnAddressPtr returnAddress)
     369{
     370    JSValue baseValue = JSValue::decode(base);
    352371    PropertySlot slot(baseValue);
    353372    JSValue result = baseValue.get(exec, *propertyName, slot);
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.h

    r101283 r101298  
    7373typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EJP)(ExecState*, EncodedJSValue, void*);
    7474typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_ECI)(ExecState*, JSCell*, Identifier*);
     75typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EJI)(ExecState*, EncodedJSValue, Identifier*);
    7576typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EP)(ExecState*, void*);
    7677typedef EncodedJSValue DFG_OPERATION (*J_DFGOperation_EPP)(ExecState*, void*, void*);
     
    100101EncodedJSValue DFG_OPERATION operationGetByVal(ExecState*, EncodedJSValue encodedBase, EncodedJSValue encodedProperty);
    101102EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState*, JSCell*, EncodedJSValue encodedProperty);
    102 EncodedJSValue DFG_OPERATION operationGetById(ExecState*, JSCell*, Identifier*);
    103 EncodedJSValue DFG_OPERATION operationGetByIdBuildList(ExecState*, JSCell*, Identifier*);
    104 EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildList(ExecState*, JSCell*, Identifier*);
    105 EncodedJSValue DFG_OPERATION operationGetByIdOptimize(ExecState*, JSCell*, Identifier*);
     103EncodedJSValue DFG_OPERATION operationGetById(ExecState*, EncodedJSValue, Identifier*);
     104EncodedJSValue DFG_OPERATION operationGetByIdBuildList(ExecState*, EncodedJSValue, Identifier*);
     105EncodedJSValue DFG_OPERATION operationGetByIdProtoBuildList(ExecState*, EncodedJSValue, Identifier*);
     106EncodedJSValue DFG_OPERATION operationGetByIdOptimize(ExecState*, EncodedJSValue, Identifier*);
     107EncodedJSValue DFG_OPERATION operationGetMethodOptimize(ExecState*, EncodedJSValue, Identifier*);
    106108EncodedJSValue DFG_OPERATION operationResolve(ExecState*, Identifier*);
    107109EncodedJSValue DFG_OPERATION operationResolveBase(ExecState*, Identifier*);
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r101283 r101298  
    872872    void cachedPutById(GPRReg base, GPRReg value, NodeIndex valueIndex, GPRReg scratchGPR, unsigned identifierNumber, PutKind, JITCompiler::Jump slowPathTarget = JITCompiler::Jump());
    873873#elif USE(JSVALUE32_64)
    874     JITCompiler::Call cachedGetById(GPRReg basePayloadGPR, GPRReg resultTagGPR, GPRReg resultPayloadGPR, GPRReg scratchGPR, unsigned identifierNumber, JITCompiler::Jump slowPathTarget = JITCompiler::Jump());
     874    JITCompiler::Call cachedGetById(GPRReg baseTagGPROrNone, GPRReg basePayloadGPR, GPRReg resultTagGPR, GPRReg resultPayloadGPR, GPRReg scratchGPR, unsigned identifierNumber, JITCompiler::Jump slowPathTarget = JITCompiler::Jump());
    875875    void cachedPutById(GPRReg basePayloadGPR, GPRReg valueTagGPR, GPRReg valuePayloadGPR, NodeIndex valueIndex, GPRReg scratchGPR, unsigned identifierNumber, PutKind, JITCompiler::Jump slowPathTarget = JITCompiler::Jump());
    876876#endif
     
    11431143
    11441144    ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, GPRReg arg2, TrustedImmPtr arg3)
     1145    {
     1146        resetCallArguments();
     1147        addCallArgument(GPRInfo::callFrameRegister);
     1148        addCallArgument(arg1);
     1149        addCallArgument(arg2);
     1150        addCallArgument(arg3);
     1151    }
     1152
     1153    ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, TrustedImm32 arg2, TrustedImmPtr arg3)
    11451154    {
    11461155        resetCallArguments();
     
    14241433    }
    14251434
     1435    ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, TrustedImm32 arg2, TrustedImm32 arg3)
     1436    {
     1437        m_jit.move(arg1, GPRInfo::argumentGPR1);
     1438        m_jit.move(arg2, GPRInfo::argumentGPR2);
     1439        m_jit.move(arg3, GPRInfo::argumentGPR3);
     1440        m_jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
     1441    }
     1442
    14261443    ALWAYS_INLINE void setupArgumentsWithExecState(GPRReg arg1, GPRReg arg2, TrustedImmPtr arg3)
    14271444    {
     
    15281545        return appendCallWithExceptionCheckSetResult(operation, result);
    15291546    }
     1547    JITCompiler::Call callOperation(J_DFGOperation_EJI operation, GPRReg result, GPRReg arg1, Identifier* identifier)
     1548    {
     1549        setupArgumentsWithExecState(arg1, TrustedImmPtr(identifier));
     1550        return appendCallWithExceptionCheckSetResult(operation, result);
     1551    }
    15301552    JITCompiler::Call callOperation(J_DFGOperation_EJA operation, GPRReg result, GPRReg arg1, GPRReg arg2)
    15311553    {
     
    16841706    {
    16851707        setupArgumentsWithExecState(arg1, TrustedImmPtr(identifier));
     1708        return appendCallWithExceptionCheckSetResult(operation, resultPayload, resultTag);
     1709    }
     1710    JITCompiler::Call callOperation(J_DFGOperation_EJI operation, GPRReg resultTag, GPRReg resultPayload, GPRReg arg1Tag, GPRReg arg1Payload, Identifier* identifier)
     1711    {
     1712        setupArgumentsWithExecState(arg1Payload, arg1Tag, TrustedImmPtr(identifier));
     1713        return appendCallWithExceptionCheckSetResult(operation, resultPayload, resultTag);
     1714    }
     1715    JITCompiler::Call callOperation(J_DFGOperation_EJI operation, GPRReg resultTag, GPRReg resultPayload, int32_t arg1Tag, GPRReg arg1Payload, Identifier* identifier)
     1716    {
     1717        setupArgumentsWithExecState(arg1Payload, TrustedImm32(arg1Tag), TrustedImmPtr(identifier));
    16861718        return appendCallWithExceptionCheckSetResult(operation, resultPayload, resultTag);
    16871719    }
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r101283 r101298  
    840840}
    841841
    842 JITCompiler::Call SpeculativeJIT::cachedGetById(GPRReg basePayloadGPR, GPRReg resultTagGPR, GPRReg resultPayloadGPR, GPRReg scratchGPR, unsigned identifierNumber, JITCompiler::Jump slowPathTarget)
     842JITCompiler::Call SpeculativeJIT::cachedGetById(GPRReg baseTagGPROrNone, GPRReg basePayloadGPR, GPRReg resultTagGPR, GPRReg resultPayloadGPR, GPRReg scratchGPR, unsigned identifierNumber, JITCompiler::Jump slowPathTarget)
    843843{
    844844    m_jit.beginUninterruptedSequence();
     
    861861
    862862    silentSpillAllRegisters(resultTagGPR, resultPayloadGPR);
    863     JITCompiler::Call functionCall = callOperation(operationGetByIdOptimize, resultTagGPR, resultPayloadGPR, basePayloadGPR, identifier(identifierNumber));
     863    JITCompiler::Call functionCall;
     864    if (baseTagGPROrNone == InvalidGPRReg)
     865        functionCall = callOperation(operationGetByIdOptimize, resultTagGPR, resultPayloadGPR, JSValue::CellTag, basePayloadGPR, identifier(identifierNumber));
     866    else
     867        functionCall = callOperation(operationGetByIdOptimize, resultTagGPR, resultPayloadGPR, baseTagGPROrNone, basePayloadGPR, identifier(identifierNumber));
    864868    silentFillAllRegisters(resultTagGPR, resultPayloadGPR);
    865869   
     
    33003304        }
    33013305       
    3302         SpeculateCellOperand base(this, node.child1());
     3306        if (isCellPrediction(at(node.child1()).prediction())) {
     3307            SpeculateCellOperand base(this, node.child1());
     3308            GPRTemporary resultTag(this, base);
     3309            GPRTemporary resultPayload(this);
     3310           
     3311            GPRReg baseGPR = base.gpr();
     3312            GPRReg resultTagGPR = resultTag.gpr();
     3313            GPRReg resultPayloadGPR = resultPayload.gpr();
     3314            GPRReg scratchGPR;
     3315           
     3316            if (resultTagGPR == baseGPR)
     3317                scratchGPR = resultPayloadGPR;
     3318            else
     3319                scratchGPR = resultTagGPR;
     3320           
     3321            base.use();
     3322           
     3323            cachedGetById(InvalidGPRReg, baseGPR, resultTagGPR, resultPayloadGPR, scratchGPR, node.identifierNumber());
     3324           
     3325            jsValueResult(resultTagGPR, resultPayloadGPR, m_compileIndex, UseChildrenCalledExplicitly);
     3326            break;
     3327        }
     3328       
     3329        JSValueOperand base(this, node.child1());
    33033330        GPRTemporary resultTag(this, base);
    33043331        GPRTemporary resultPayload(this);
    33053332       
    3306         GPRReg baseGPR = base.gpr();
     3333        GPRReg baseTagGPR = base.tagGPR();
     3334        GPRReg basePayloadGPR = base.payloadGPR();
    33073335        GPRReg resultTagGPR = resultTag.gpr();
    33083336        GPRReg resultPayloadGPR = resultPayload.gpr();
    33093337        GPRReg scratchGPR;
    3310        
    3311         if (resultTagGPR == baseGPR)
     3338
     3339        if (resultTagGPR == basePayloadGPR)
    33123340            scratchGPR = resultPayloadGPR;
    33133341        else
     
    33153343       
    33163344        base.use();
    3317 
    3318         cachedGetById(baseGPR, resultTagGPR, resultPayloadGPR, scratchGPR, node.identifierNumber());
    3319 
     3345       
     3346        JITCompiler::Jump notCell = m_jit.branch32(JITCompiler::NotEqual, baseTagGPR, TrustedImm32(JSValue::CellTag));
     3347       
     3348        cachedGetById(baseTagGPR, basePayloadGPR, resultTagGPR, resultPayloadGPR, scratchGPR, node.identifierNumber(), notCell);
     3349       
    33203350        jsValueResult(resultTagGPR, resultPayloadGPR, m_compileIndex, UseChildrenCalledExplicitly);
    33213351        break;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r101283 r101298  
    32493249        }
    32503250       
    3251         SpeculateCellOperand base(this, node.child1());
     3251        if (isCellPrediction(at(node.child1()).prediction())) {
     3252            SpeculateCellOperand base(this, node.child1());
     3253            GPRTemporary result(this, base);
     3254           
     3255            GPRReg baseGPR = base.gpr();
     3256            GPRReg resultGPR = result.gpr();
     3257            GPRReg scratchGPR;
     3258           
     3259            if (resultGPR == baseGPR)
     3260                scratchGPR = tryAllocate();
     3261            else
     3262                scratchGPR = resultGPR;
     3263           
     3264            base.use();
     3265           
     3266            cachedGetById(baseGPR, resultGPR, scratchGPR, node.identifierNumber());
     3267           
     3268            jsValueResult(resultGPR, m_compileIndex, UseChildrenCalledExplicitly);
     3269            break;
     3270        }
     3271       
     3272        JSValueOperand base(this, node.child1());
    32523273        GPRTemporary result(this, base);
    32533274       
     
    32623283       
    32633284        base.use();
    3264 
    3265         cachedGetById(baseGPR, resultGPR, scratchGPR, node.identifierNumber());
    3266 
     3285       
     3286        JITCompiler::Jump notCell = m_jit.branchTestPtr(JITCompiler::NonZero, baseGPR, GPRInfo::tagMaskRegister);
     3287       
     3288        cachedGetById(baseGPR, resultGPR, scratchGPR, node.identifierNumber(), notCell);
     3289       
    32673290        jsValueResult(resultGPR, m_compileIndex, UseChildrenCalledExplicitly);
     3291       
    32683292        break;
    32693293    }
Note: See TracChangeset for help on using the changeset viewer.