Changeset 96461 in webkit


Ignore:
Timestamp:
Oct 1, 2011 2:46:51 PM (13 years ago)
Author:
oliver@apple.com
Message:

Support string length in the DFG
https://bugs.webkit.org/show_bug.cgi?id=69215

Reviewed by Geoff Garen.

Adds a GetStringLength node to the DFG so that we can support
string.length inline.

  • dfg/DFGNode.h:
  • dfg/DFGPropagator.cpp:

(JSC::DFG::Propagator::propagateNodePredictions):
(JSC::DFG::Propagator::fixupNode):
(JSC::DFG::Propagator::performNodeCSE):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::isKnownString):

  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

  • runtime/JSString.h:

(JSC::JSString::offsetOfLength):

Location:
trunk/Source/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r96458 r96461  
     12011-10-01  Oliver Hunt  <oliver@apple.com>
     2
     3        Support string length in the DFG
     4        https://bugs.webkit.org/show_bug.cgi?id=69215
     5
     6        Reviewed by Geoff Garen.
     7
     8        Adds a GetStringLength node to the DFG so that we can support
     9        string.length inline.
     10
     11        * dfg/DFGNode.h:
     12        * dfg/DFGPropagator.cpp:
     13        (JSC::DFG::Propagator::propagateNodePredictions):
     14        (JSC::DFG::Propagator::fixupNode):
     15        (JSC::DFG::Propagator::performNodeCSE):
     16        * dfg/DFGSpeculativeJIT.h:
     17        (JSC::DFG::SpeculativeJIT::isKnownString):
     18        * dfg/DFGSpeculativeJIT32_64.cpp:
     19        (JSC::DFG::SpeculativeJIT::compile):
     20        * dfg/DFGSpeculativeJIT64.cpp:
     21        (JSC::DFG::SpeculativeJIT::compile):
     22        * runtime/JSString.h:
     23        (JSC::JSString::offsetOfLength):
     24
    1252011-10-01  Yuqiang Xian  <yuqiang.xian@intel.com>
    226
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r96379 r96461  
    10711071                86880F1A14328BB900B08D42 /* DFGJITCompilerInlineMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGJITCompilerInlineMethods.h; path = dfg/DFGJITCompilerInlineMethods.h; sourceTree = "<group>"; };
    10721072                86880F1B14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGSpeculativeJIT32_64.cpp; path = dfg/DFGSpeculativeJIT32_64.cpp; sourceTree = "<group>"; };
    1073                 86880F311434FFAF00B08D42 /* ChangeLog */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChangeLog; sourceTree = "<group>"; };
    10741073                86880F43143531A700B08D42 /* DFGJITCodeGenerator64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGJITCodeGenerator64.cpp; path = dfg/DFGJITCodeGenerator64.cpp; sourceTree = "<group>"; };
    10751074                86880F4C14353B2100B08D42 /* DFGSpeculativeJIT64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGSpeculativeJIT64.cpp; path = dfg/DFGSpeculativeJIT64.cpp; sourceTree = "<group>"; };
     
    15431542                        isa = PBXGroup;
    15441543                        children = (
    1545                                 86880F311434FFAF00B08D42 /* ChangeLog */,
    15461544                                651122E5140469BA002B101D /* testRegExp.cpp */,
    15471545                                A718F8211178EB4B002465A7 /* create_regex_tables */,
  • trunk/Source/JavaScriptCore/dfg/DFGNode.h

    r96443 r96461  
    320320    macro(PutByOffset, NodeMustGenerate | NodeClobbersWorld) \
    321321    macro(GetArrayLength, NodeResultInt32) \
     322    macro(GetStringLength, NodeResultInt32) \
    322323    macro(GetMethod, NodeResultJS | NodeMustGenerate) \
    323324    macro(CheckMethod, NodeResultJS | NodeMustGenerate) \
  • trunk/Source/JavaScriptCore/dfg/DFGPropagator.cpp

    r96443 r96461  
    560560           
    561561        case ValueToDouble:
    562         case GetArrayLength: {
     562        case GetArrayLength:
     563        case GetStringLength: {
    563564            // This node should never be visible at this stage of compilation. It is
    564565            // inserted by fixup(), which follows this phase.
     
    707708           
    708709        case GetById: {
    709             if (!isArrayPrediction(m_predictions[node.child1()]))
     710            bool isArray = isArrayPrediction(m_predictions[node.child1()]);
     711            bool isString = isStringPrediction(m_predictions[node.child1()]);
     712            if (!isArray && !isString)
    710713                break;
    711714            if (!isInt32Prediction(m_predictions[m_compileIndex]))
     
    715718           
    716719#if ENABLE(DFG_DEBUG_PROPAGATION_VERBOSE)
    717             printf("  @%u -> GetArrayLength", nodeIndex);
    718 #endif
    719             node.op = GetArrayLength;
     720            printf("  @%u -> %s", nodeIndex, isArray ? "GetArrayLength" : "GetStringLength");
     721#endif
     722            node.op = isArray ? GetArrayLength : GetStringLength;
    720723            break;
    721724        }
     
    11901193        case GetCallee:
    11911194        case GetArrayLength:
     1195        case GetStringLength:
    11921196            setReplacement(pureCSE(node));
    11931197            break;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r96458 r96461  
    580580        }
    581581    }
     582
     583    bool isKnownString(NodeIndex op1)
     584    {
     585        Node& node = m_jit.graph()[op1];
     586        switch (node.op) {
     587        case GetLocal:
     588            return isStringPrediction(node.variableAccessData()->prediction());
     589
     590        default:
     591            return false;
     592        }
     593    }
    582594   
    583595    bool compare(Node&, MacroAssembler::RelationalCondition, MacroAssembler::DoubleCondition, Z_DFGOperation_EJJ);
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r96443 r96461  
    16561656    }
    16571657
     1658    case GetStringLength: {
     1659        SpeculateCellOperand base(this, node.child1());
     1660        GPRTemporary result(this);
     1661       
     1662        GPRReg baseGPR = base.gpr();
     1663        GPRReg resultGPR = result.gpr();
     1664       
     1665        if (!isKnownString(node.child1()))
     1666            speculationCheck(m_jit.branchPtr(MacroAssembler::NotEqual, MacroAssembler::Address(baseGPR), MacroAssembler::TrustedImmPtr(m_jit.globalData()->jsStringVPtr)));
     1667       
     1668        m_jit.load32(MacroAssembler::Address(baseGPR, JSString::offsetOfLength()), resultGPR);
     1669
     1670        integerResult(resultGPR, m_compileIndex);
     1671        break;
     1672    }
     1673
    16581674    case CheckStructure: {
    16591675        SpeculateCellOperand base(this, node.child1());
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r96443 r96461  
    17161716    }
    17171717
     1718    case GetStringLength: {
     1719        SpeculateCellOperand base(this, node.child1());
     1720        GPRTemporary result(this);
     1721       
     1722        GPRReg baseGPR = base.gpr();
     1723        GPRReg resultGPR = result.gpr();
     1724       
     1725        if (!isKnownString(node.child1()))
     1726            speculationCheck(m_jit.branchPtr(MacroAssembler::NotEqual, MacroAssembler::Address(baseGPR), MacroAssembler::TrustedImmPtr(m_jit.globalData()->jsStringVPtr)));
     1727       
     1728        m_jit.load32(MacroAssembler::Address(baseGPR, JSString::offsetOfLength()), resultGPR);
     1729
     1730        integerResult(resultGPR, m_compileIndex);
     1731        break;
     1732    }
     1733
    17181734    case CheckStructure: {
    17191735        SpeculateCellOperand base(this, node.child1());
  • trunk/Source/JavaScriptCore/runtime/JSString.h

    r96381 r96461  
    446446            return Structure::create(globalData, globalObject, proto, TypeInfo(StringType, OverridesGetOwnPropertySlot), &s_info);
    447447        }
    448        
     448
     449        static size_t offsetOfLength() { return OBJECT_OFFSETOF(JSString, m_length); }
     450
    449451        static const ClassInfo s_info;
    450452
Note: See TracChangeset for help on using the changeset viewer.