Changeset 96391 in webkit


Ignore:
Timestamp:
Sep 29, 2011 11:17:13 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Add op_call/op_constructor support to JSVALUE32_64 DFG JIT
https://bugs.webkit.org/show_bug.cgi?id=69120

Patch by Yuqiang Xian <yuqiang.xian@intel.com> on 2011-09-29
Reviewed by Gavin Barraclough.

Improve the coverage of JSVALUE32_64 DFG JIT.

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.h:

(JSC::DFG::canCompileOpcode):

  • dfg/DFGJITCodeGenerator.h:

(JSC::DFG::tagOfCallData):
(JSC::DFG::payloadOfCallData):

  • dfg/DFGJITCodeGenerator32_64.cpp:

(JSC::DFG::JITCodeGenerator::emitCall):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96389 r96391  
     12011-09-29  Yuqiang Xian  <yuqiang.xian@intel.com>
     2
     3        Add op_call/op_constructor support to JSVALUE32_64 DFG JIT
     4        https://bugs.webkit.org/show_bug.cgi?id=69120
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Improve the coverage of JSVALUE32_64 DFG JIT.
     9
     10        * dfg/DFGByteCodeParser.cpp:
     11        (JSC::DFG::ByteCodeParser::parseBlock):
     12        * dfg/DFGCapabilities.h:
     13        (JSC::DFG::canCompileOpcode):
     14        * dfg/DFGJITCodeGenerator.h:
     15        (JSC::DFG::tagOfCallData):
     16        (JSC::DFG::payloadOfCallData):
     17        * dfg/DFGJITCodeGenerator32_64.cpp:
     18        (JSC::DFG::JITCodeGenerator::emitCall):
     19
    1202011-09-29  Yuqiang Xian  <yuqiang.xian@intel.com>
    221
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r96375 r96391  
    13831383            LAST_OPCODE(op_throw_reference_error);
    13841384           
    1385 #if USE(JSVALUE64)
    13861385        case op_call: {
    13871386            NodeIndex callTarget = get(currentInstruction[1].u.operand);
     
    14171416            NEXT_OPCODE(op_construct);
    14181417        }
    1419 #endif
    14201418           
    14211419        case op_call_put_result:
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.h

    r96189 r96391  
    114114    case op_ret:
    115115    case op_end:
    116 #if USE(JSVALUE64)
    117116    case op_call:
    118117    case op_construct:
    119 #endif
    120118    case op_call_put_result:
    121119    case op_resolve:
  • trunk/Source/JavaScriptCore/dfg/DFGJITCodeGenerator.h

    r96286 r96391  
    786786        return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + idx) * static_cast<int>(sizeof(Register)));
    787787    }
    788    
     788
     789#if USE(JSVALUE32_64)   
     790    MacroAssembler::Address tagOfCallData(int idx)
     791    {
     792        return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + idx) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.tag));
     793    }
     794
     795    MacroAssembler::Address payloadOfCallData(int idx)
     796    {
     797        return MacroAssembler::Address(GPRInfo::callFrameRegister, (m_jit.codeBlock()->m_numCalleeRegisters + idx) * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload));
     798    }
     799#endif
     800
    789801    void emitCall(Node&);
    790802   
  • trunk/Source/JavaScriptCore/dfg/DFGJITCodeGenerator32_64.cpp

    r96377 r96391  
    15871587}
    15881588
    1589 void NO_RETURN JITCodeGenerator::emitCall(Node& node)
    1590 {
    1591     // FIXME: It's not supported yet!
    1592     ASSERT_NOT_REACHED();
    1593     UNUSED_PARAM(node);
     1589void JITCodeGenerator::emitCall(Node& node)
     1590{
     1591    P_DFGOperation_E slowCallFunction;
     1592    bool isCall;
     1593
     1594    if (node.op == Call) {
     1595        slowCallFunction = operationLinkCall;
     1596        isCall = true;
     1597    } else {
     1598        ASSERT(node.op == Construct);
     1599        slowCallFunction = operationLinkConstruct;
     1600        isCall = false;
     1601    }
     1602
     1603    NodeIndex calleeNodeIndex = m_jit.graph().m_varArgChildren[node.firstChild()];
     1604    JSValueOperand callee(this, calleeNodeIndex);
     1605    GPRReg calleeTagGPR = callee.tagGPR();
     1606    GPRReg calleePayloadGPR = callee.payloadGPR();
     1607    use(calleeNodeIndex);
     1608
     1609    // the call instruction's first child is either the function (normal call) or the
     1610    // receiver (method call). subsequent children are the arguments.
     1611    int numArgs = node.numChildren() - 1;
     1612
     1613    // For constructors, the this argument is not passed but we have to make space
     1614    // for it.
     1615    int numPassedArgs = numArgs + (isCall ? 0 : 1);
     1616
     1617    // amount of stuff (in units of sizeof(Register)) that we need to place at the
     1618    // top of the JS stack.
     1619    int callDataSize = 0;
     1620
     1621    // first there are the arguments
     1622    callDataSize += numPassedArgs;
     1623
     1624    // and then there is the call frame header
     1625    callDataSize += RegisterFile::CallFrameHeaderSize;
     1626
     1627    m_jit.store32(MacroAssembler::TrustedImm32(numPassedArgs), payloadOfCallData(RegisterFile::ArgumentCount));
     1628    m_jit.store32(MacroAssembler::TrustedImm32(JSValue::Int32Tag), tagOfCallData(RegisterFile::ArgumentCount));
     1629    m_jit.storePtr(GPRInfo::callFrameRegister, payloadOfCallData(RegisterFile::CallerFrame));
     1630    m_jit.store32(MacroAssembler::TrustedImm32(JSValue::CellTag), tagOfCallData(RegisterFile::CallerFrame));
     1631
     1632    for (int argIdx = 0; argIdx < numArgs; argIdx++) {
     1633        NodeIndex argNodeIndex = m_jit.graph().m_varArgChildren[node.firstChild() + 1 + argIdx];
     1634        JSValueOperand arg(this, argNodeIndex);
     1635        GPRReg argTagGPR = arg.tagGPR();
     1636        GPRReg argPayloadGPR = arg.payloadGPR();
     1637        use(argNodeIndex);
     1638
     1639        m_jit.store32(argTagGPR, tagOfCallData(-callDataSize + argIdx + (isCall ? 0 : 1)));
     1640        m_jit.store32(argPayloadGPR, payloadOfCallData(-callDataSize + argIdx + (isCall ? 0 : 1)));
     1641    }
     1642
     1643    m_jit.store32(calleeTagGPR, tagOfCallData(RegisterFile::Callee));
     1644    m_jit.store32(calleePayloadGPR, payloadOfCallData(RegisterFile::Callee));
     1645
     1646    flushRegisters();
     1647
     1648    GPRResult resultPayload(this);
     1649    GPRResult2 resultTag(this);
     1650    GPRReg resultPayloadGPR = resultPayload.gpr();
     1651    GPRReg resultTagGPR = resultTag.gpr();
     1652
     1653    JITCompiler::DataLabelPtr targetToCheck;
     1654    JITCompiler::Jump slowPath;
     1655
     1656    slowPath = m_jit.branchPtrWithPatch(MacroAssembler::NotEqual, calleePayloadGPR, targetToCheck);
     1657    m_jit.loadPtr(MacroAssembler::Address(calleePayloadGPR, OBJECT_OFFSETOF(JSFunction, m_scopeChain)), resultPayloadGPR);
     1658    m_jit.storePtr(resultPayloadGPR, payloadOfCallData(RegisterFile::ScopeChain));
     1659    m_jit.store32(MacroAssembler::TrustedImm32(JSValue::CellTag), tagOfCallData(RegisterFile::ScopeChain));
     1660
     1661    m_jit.addPtr(Imm32(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister);
     1662
     1663    JITCompiler::Call fastCall = m_jit.nearCall();
     1664    m_jit.notifyCall(fastCall, m_jit.graph()[m_compileIndex].codeOrigin);
     1665
     1666    JITCompiler::Jump done = m_jit.jump();
     1667
     1668    slowPath.link(&m_jit);
     1669
     1670    m_jit.addPtr(Imm32(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
     1671    m_jit.push(GPRInfo::argumentGPR0);
     1672    JITCompiler::Call slowCall = m_jit.appendCallWithFastExceptionCheck(slowCallFunction, m_jit.graph()[m_compileIndex].codeOrigin);
     1673    m_jit.move(Imm32(numPassedArgs), GPRInfo::regT1);
     1674    m_jit.addPtr(Imm32(m_jit.codeBlock()->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister);
     1675    m_jit.notifyCall(m_jit.call(GPRInfo::returnValueGPR), m_jit.graph()[m_compileIndex].codeOrigin);
     1676
     1677    done.link(&m_jit);
     1678
     1679    setupResults(resultTagGPR, resultPayloadGPR);
     1680
     1681    jsValueResult(resultTagGPR, resultPayloadGPR, m_compileIndex, DataFormatJS, UseChildrenCalledExplicitly);
     1682
     1683    m_jit.addJSCall(fastCall, slowCall, targetToCheck, isCall, m_jit.graph()[m_compileIndex].codeOrigin);
    15941684}
    15951685
Note: See TracChangeset for help on using the changeset viewer.