Changeset 95753 in webkit


Ignore:
Timestamp:
Sep 22, 2011 2:55:07 PM (13 years ago)
Author:
oliver@apple.com
Message:

Implement put_scoped_var in the DFG jit
https://bugs.webkit.org/show_bug.cgi?id=68653

Reviewed by Gavin Barraclough.

Naive implementation of put_scoped_var. Same story as the
get_scoped_var implementation, although I've hoisted scope
object acquisition into a separate dfg node. Ideally in the
future we would reuse the resolved scope chain object, but
for now we don't.

  • dfg/DFGByteCodeParser.cpp:

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

  • dfg/DFGCapabilities.h:

(JSC::DFG::canCompileOpcode):

  • dfg/DFGNode.h:

(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

    r95751 r95753  
     12011-09-22  Oliver Hunt  <oliver@apple.com>
     2
     3        Implement put_scoped_var in the DFG jit
     4        https://bugs.webkit.org/show_bug.cgi?id=68653
     5
     6        Reviewed by Gavin Barraclough.
     7
     8        Naive implementation of put_scoped_var.  Same story as the
     9        get_scoped_var implementation, although I've hoisted scope
     10        object acquisition into a separate dfg node.  Ideally in the
     11        future we would reuse the resolved scope chain object, but
     12        for now we don't.
     13
     14        * dfg/DFGByteCodeParser.cpp:
     15        (JSC::DFG::ByteCodeParser::parseBlock):
     16        * dfg/DFGCapabilities.h:
     17        (JSC::DFG::canCompileOpcode):
     18        * dfg/DFGNode.h:
     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  Gavin Barraclough  <barraclough@apple.com>
    227
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r95742 r95753  
    10861086            int slot = currentInstruction[2].u.operand;
    10871087            int depth = currentInstruction[3].u.operand;
    1088             NodeIndex getScopedVar = addToGraph(GetScopedVar, OpInfo(slot), OpInfo(depth));
     1088            NodeIndex getScopeChain = addToGraph(GetScopeChain, OpInfo(depth));
     1089            NodeIndex getScopedVar = addToGraph(GetScopedVar, OpInfo(slot), getScopeChain);
    10891090            set(dst, getScopedVar);
    10901091            NEXT_OPCODE(op_get_scoped_var);
     1092        }
     1093        case op_put_scoped_var: {
     1094            int slot = currentInstruction[1].u.operand;
     1095            int depth = currentInstruction[2].u.operand;
     1096            int source = currentInstruction[3].u.operand;
     1097            NodeIndex getScopeChain = addToGraph(GetScopeChain, OpInfo(depth));
     1098            addToGraph(PutScopedVar, OpInfo(slot), getScopeChain, get(source));
     1099            NEXT_OPCODE(op_put_scoped_var);
    10911100        }
    10921101        case op_get_by_id: {
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.h

    r95742 r95753  
    8484    case op_method_check:
    8585    case op_get_scoped_var:
     86    case op_put_scoped_var:
    8687    case op_get_by_id:
    8788    case op_put_by_id:
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r95742 r95753  
    269269    macro(GetMethod, NodeResultJS | NodeMustGenerate) \
    270270    macro(CheckMethod, NodeResultJS | NodeMustGenerate) \
     271    macro(GetScopeChain, NodeResultJS) \
    271272    macro(GetScopedVar, NodeResultJS | NodeMustGenerate) \
     273    macro(PutScopedVar, NodeMustGenerate | NodeClobbersWorld) \
    272274    macro(GetGlobalVar, NodeResultJS | NodeMustGenerate) \
    273275    macro(PutGlobalVar, NodeMustGenerate | NodeClobbersWorld) \
     
    550552    bool hasScopeChainDepth()
    551553    {
    552         return op == GetScopedVar;
     554        return op == GetScopeChain;
    553555    }
    554556   
     
    556558    {
    557559        ASSERT(hasScopeChainDepth());
    558         return m_opInfo2;
     560        return m_opInfo;
    559561    }
    560562
  • trunk/Source/JavaScriptCore/dfg/DFGPropagator.cpp

    r95742 r95753  
    534534            break;
    535535        }
    536            
     536
     537        case GetScopeChain:
    537538        case GetCallee: {
    538539            changed |= setPrediction(makePrediction(PredictObjectOther, StrongPrediction));
     
    567568        case Phantom:
    568569            break;
    569            
     570
    570571        default:
    571572            ASSERT_NOT_REACHED();
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r95742 r95753  
    16261626        break;
    16271627    }
    1628     case GetScopedVar: {
     1628
     1629    case GetScopeChain: {
    16291630        GPRTemporary result(this);
    16301631        GPRReg resultGPR = result.gpr();
     
    16451646       
    16461647        m_jit.loadPtr(JITCompiler::Address(resultGPR, OBJECT_OFFSETOF(ScopeChainNode, object)), resultGPR);
    1647         m_jit.loadPtr(JITCompiler::Address(resultGPR, JSVariableObject::offsetOfRegisters()), resultGPR);
     1648
     1649        cellResult(resultGPR, m_compileIndex);
     1650        break;
     1651    }
     1652    case GetScopedVar: {
     1653        SpeculateCellOperand scopeChain(this, node.child1());
     1654        GPRTemporary result(this);
     1655        GPRReg resultGPR = result.gpr();
     1656        m_jit.loadPtr(JITCompiler::Address(scopeChain.gpr(), JSVariableObject::offsetOfRegisters()), resultGPR);
    16481657        m_jit.loadPtr(JITCompiler::Address(resultGPR, node.varNumber() * sizeof(Register)), resultGPR);
    16491658        jsValueResult(resultGPR, m_compileIndex);
     1659        break;
     1660    }
     1661    case PutScopedVar: {
     1662        SpeculateCellOperand scopeChain(this, node.child1());
     1663        GPRTemporary scratchRegister(this);
     1664        GPRReg scratchGPR = scratchRegister.gpr();
     1665        m_jit.loadPtr(JITCompiler::Address(scopeChain.gpr(), JSVariableObject::offsetOfRegisters()), scratchGPR);
     1666        JSValueOperand value(this, node.child2());
     1667        m_jit.storePtr(value.gpr(), JITCompiler::Address(scratchGPR, node.varNumber() * sizeof(Register)));
     1668        writeBarrier(m_jit, scopeChain.gpr(), scratchGPR, WriteBarrierForVariableAccess);
    16501669        break;
    16511670    }
Note: See TracChangeset for help on using the changeset viewer.