Changeset 95742 in webkit


Ignore:
Timestamp:
Sep 22, 2011 11:51:02 AM (13 years ago)
Author:
oliver@apple.com
Message:

Implement get_scoped_var in the DFG
https://bugs.webkit.org/show_bug.cgi?id=68640

Reviewed by Gavin Barraclough.

Naive implementation of get_scoped_var in the DFG. Essentially this
is the bare minimum required to get correct behaviour, so there's no
load/store coalescing or type profiling involved, even though these
would be wins. No impact on SunSpider or V8.

  • dfg/DFGByteCodeParser.cpp:

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

  • dfg/DFGCapabilities.h:

(JSC::DFG::canCompileOpcode):

  • dfg/DFGNode.h:

(JSC::DFG::Node::hasVarNumber):
(JSC::DFG::Node::hasScopeChainDepth):
(JSC::DFG::Node::scopeChainDepth):

  • dfg/DFGPropagator.cpp:

(JSC::DFG::Propagator::propagateNodePredictions):

  • dfg/DFGSpeculativeJIT.cpp:

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

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r95734 r95742  
     12011-09-22  Oliver Hunt  <oliver@apple.com>
     2
     3        Implement get_scoped_var in the DFG
     4        https://bugs.webkit.org/show_bug.cgi?id=68640
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Naive implementation of get_scoped_var in the DFG.  Essentially this
     9        is the bare minimum required to get correct behaviour, so there's no
     10        load/store coalescing or type profiling involved, even though these
     11        would be wins.  No impact on SunSpider or V8.
     12
     13        * dfg/DFGByteCodeParser.cpp:
     14        (JSC::DFG::ByteCodeParser::parseBlock):
     15        * dfg/DFGCapabilities.h:
     16        (JSC::DFG::canCompileOpcode):
     17        * dfg/DFGNode.h:
     18        (JSC::DFG::Node::hasVarNumber):
     19        (JSC::DFG::Node::hasScopeChainDepth):
     20        (JSC::DFG::Node::scopeChainDepth):
     21        * dfg/DFGPropagator.cpp:
     22        (JSC::DFG::Propagator::propagateNodePredictions):
     23        * dfg/DFGSpeculativeJIT.cpp:
     24        (JSC::DFG::SpeculativeJIT::compile):
     25
    1262011-09-22  Adam Roben  <aroben@apple.com>
    227
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r95683 r95742  
    10821082            continue;
    10831083        }
    1084 
     1084        case op_get_scoped_var: {
     1085            int dst = currentInstruction[1].u.operand;
     1086            int slot = currentInstruction[2].u.operand;
     1087            int depth = currentInstruction[3].u.operand;
     1088            NodeIndex getScopedVar = addToGraph(GetScopedVar, OpInfo(slot), OpInfo(depth));
     1089            set(dst, getScopedVar);
     1090            NEXT_OPCODE(op_get_scoped_var);
     1091        }
    10851092        case op_get_by_id: {
    10861093            NodeIndex base = get(currentInstruction[2].u.operand);
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.h

    r95683 r95742  
    8383    case op_put_by_val:
    8484    case op_method_check:
     85    case op_get_scoped_var:
    8586    case op_get_by_id:
    8687    case op_put_by_id:
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r95683 r95742  
    269269    macro(GetMethod, NodeResultJS | NodeMustGenerate) \
    270270    macro(CheckMethod, NodeResultJS | NodeMustGenerate) \
     271    macro(GetScopedVar, NodeResultJS | NodeMustGenerate) \
    271272    macro(GetGlobalVar, NodeResultJS | NodeMustGenerate) \
    272273    macro(PutGlobalVar, NodeMustGenerate | NodeClobbersWorld) \
     
    538539    bool hasVarNumber()
    539540    {
    540         return op == GetGlobalVar || op == PutGlobalVar;
     541        return op == GetGlobalVar || op == PutGlobalVar || op == GetScopedVar;
    541542    }
    542543
     
    545546        ASSERT(hasVarNumber());
    546547        return m_opInfo;
     548    }
     549
     550    bool hasScopeChainDepth()
     551    {
     552        return op == GetScopedVar;
     553    }
     554   
     555    unsigned scopeChainDepth()
     556    {
     557        ASSERT(hasScopeChainDepth());
     558        return m_opInfo2;
    547559    }
    548560
  • trunk/Source/JavaScriptCore/dfg/DFGPropagator.cpp

    r95683 r95742  
    561561        case ResolveBase:
    562562        case ResolveBaseStrictPut:
     563        case GetScopedVar:
    563564            break;
    564565           
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r95683 r95742  
    16261626        break;
    16271627    }
    1628 
     1628    case GetScopedVar: {
     1629        GPRTemporary result(this);
     1630        GPRReg resultGPR = result.gpr();
     1631
     1632        m_jit.loadPtr(JITCompiler::addressFor(static_cast<VirtualRegister>(RegisterFile::ScopeChain)), resultGPR);
     1633        bool checkTopLevel = m_jit.codeBlock()->codeType() == FunctionCode && m_jit.codeBlock()->needsFullScopeChain();
     1634        int skip = node.scopeChainDepth();
     1635        ASSERT(skip || !checkTopLevel);
     1636        if (checkTopLevel && skip--) {
     1637            JITCompiler::Jump activationNotCreated;
     1638            if (checkTopLevel)
     1639                activationNotCreated = m_jit.branchTestPtr(JITCompiler::Zero, JITCompiler::addressFor(static_cast<VirtualRegister>(m_jit.codeBlock()->activationRegister())));
     1640            m_jit.loadPtr(JITCompiler::Address(resultGPR, OBJECT_OFFSETOF(ScopeChainNode, next)), resultGPR);
     1641            activationNotCreated.link(&m_jit);
     1642        }
     1643        while (skip--)
     1644            m_jit.loadPtr(JITCompiler::Address(resultGPR, OBJECT_OFFSETOF(ScopeChainNode, next)), resultGPR);
     1645       
     1646        m_jit.loadPtr(JITCompiler::Address(resultGPR, OBJECT_OFFSETOF(ScopeChainNode, object)), resultGPR);
     1647        m_jit.loadPtr(JITCompiler::Address(resultGPR, JSVariableObject::offsetOfRegisters()), resultGPR);
     1648        m_jit.loadPtr(JITCompiler::Address(resultGPR, node.varNumber() * sizeof(Register)), resultGPR);
     1649        jsValueResult(resultGPR, m_compileIndex);
     1650        break;
     1651    }
    16291652    case GetById: {
    16301653        SpeculateCellOperand base(this, node.child1());
Note: See TracChangeset for help on using the changeset viewer.