Changeset 133135 in webkit


Ignore:
Timestamp:
Nov 1, 2012 12:41:43 AM (12 years ago)
Author:
fpizlo@apple.com
Message:

DFG optimized string access code should be enabled
https://bugs.webkit.org/show_bug.cgi?id=100825

Reviewed by Oliver Hunt.

  • Removes prediction checks from the parser.


  • Fixes the handling of array mode refinement for strings. I.e. we don't do any refinement - we already know it's going to be a string. We could revisit this in the future, but for now the DFG lacks the ability to handle any array modes other than Array::String for string intrinsics, so this is as good as it gets.


  • Removes uses of isBlahSpeculation for checking if a mode is already checked. isBlahSpeculation implicitly checks if the SpeculatedType is not BOTTOM ("empty"), which breaks for checking if a mode is already checked since a mode may already be "checked" in the sense that we've proven that the code is unreachable.


~1% speed-up on V8v7, mostly from a speed-up on crypto, which uses string
intrinsics in one of the hot functions.

  • bytecode/SpeculatedType.h:

(JSC::speculationChecked):
(JSC):

  • dfg/DFGArrayMode.cpp:

(JSC::DFG::ArrayMode::alreadyChecked):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::handleIntrinsic):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetCharCodeAt):

Location:
trunk/Source/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r133131 r133135  
     12012-10-31  Filip Pizlo  <fpizlo@apple.com>
     2
     3        DFG optimized string access code should be enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=100825
     5
     6        Reviewed by Oliver Hunt.
     7
     8        - Removes prediction checks from the parser.
     9       
     10        - Fixes the handling of array mode refinement for strings. I.e. we don't do
     11          any refinement - we already know it's going to be a string. We could
     12          revisit this in the future, but for now the DFG lacks the ability to
     13          handle any array modes other than Array::String for string intrinsics, so
     14          this is as good as it gets.
     15       
     16        - Removes uses of isBlahSpeculation for checking if a mode is already
     17          checked. isBlahSpeculation implicitly checks if the SpeculatedType is not
     18          BOTTOM ("empty"), which breaks for checking if a mode is already checked
     19          since a mode may already be "checked" in the sense that we've proven that
     20          the code is unreachable.
     21       
     22        ~1% speed-up on V8v7, mostly from a speed-up on crypto, which uses string
     23        intrinsics in one of the hot functions.
     24
     25        * bytecode/SpeculatedType.h:
     26        (JSC::speculationChecked):
     27        (JSC):
     28        * dfg/DFGArrayMode.cpp:
     29        (JSC::DFG::ArrayMode::alreadyChecked):
     30        * dfg/DFGByteCodeParser.cpp:
     31        (JSC::DFG::ByteCodeParser::handleIntrinsic):
     32        * dfg/DFGFixupPhase.cpp:
     33        (JSC::DFG::FixupPhase::fixupNode):
     34        * dfg/DFGSpeculativeJIT.cpp:
     35        (JSC::DFG::SpeculativeJIT::compileGetCharCodeAt):
     36
    1372012-10-31  Filip Pizlo  <fpizlo@apple.com>
    238
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r127189 r133135  
    285285}
    286286
     287inline bool speculationChecked(SpeculatedType actual, SpeculatedType desired)
     288{
     289    return (actual | desired) == desired;
     290}
     291
    287292SpeculatedType speculationFromClassInfo(const ClassInfo*);
    288293SpeculatedType speculationFromStructure(Structure*);
  • trunk/Source/JavaScriptCore/dfg/DFGArrayMode.cpp

    r132759 r133135  
    160160       
    161161    case Array::String:
    162         return isStringSpeculation(value.m_type);
     162        return speculationChecked(value.m_type, SpecString);
    163163       
    164164    case Array::Contiguous:
     
    202202       
    203203    case Array::Arguments:
    204         return isArgumentsSpeculation(value.m_type);
     204        return speculationChecked(value.m_type, SpecArguments);
    205205       
    206206    case Array::Int8Array:
    207         return isInt8ArraySpeculation(value.m_type);
     207        return speculationChecked(value.m_type, SpecInt8Array);
    208208       
    209209    case Array::Int16Array:
    210         return isInt16ArraySpeculation(value.m_type);
     210        return speculationChecked(value.m_type, SpecInt16Array);
    211211       
    212212    case Array::Int32Array:
    213         return isInt32ArraySpeculation(value.m_type);
     213        return speculationChecked(value.m_type, SpecInt32Array);
    214214       
    215215    case Array::Uint8Array:
    216         return isUint8ArraySpeculation(value.m_type);
     216        return speculationChecked(value.m_type, SpecUint8Array);
    217217       
    218218    case Array::Uint8ClampedArray:
    219         return isUint8ClampedArraySpeculation(value.m_type);
     219        return speculationChecked(value.m_type, SpecUint8ClampedArray);
    220220       
    221221    case Array::Uint16Array:
    222         return isUint16ArraySpeculation(value.m_type);
     222        return speculationChecked(value.m_type, SpecUint16Array);
    223223       
    224224    case Array::Uint32Array:
    225         return isUint32ArraySpeculation(value.m_type);
     225        return speculationChecked(value.m_type, SpecUint32Array);
    226226
    227227    case Array::Float32Array:
    228         return isFloat32ArraySpeculation(value.m_type);
     228        return speculationChecked(value.m_type, SpecFloat32Array);
    229229
    230230    case Array::Float64Array:
    231         return isFloat64ArraySpeculation(value.m_type);
     231        return speculationChecked(value.m_type, SpecFloat64Array);
    232232       
    233233    case Array::SelectUsingPredictions:
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r132759 r133135  
    16901690
    16911691        int thisOperand = registerOffset + argumentToOperand(0);
    1692         if (!(m_graph[get(thisOperand)].prediction() & SpecString))
    1693             return false;
    1694        
    16951692        int indexOperand = registerOffset + argumentToOperand(1);
    16961693        NodeIndex charCode = addToGraph(StringCharCodeAt, OpInfo(Array::String), get(thisOperand), getToInt32(indexOperand));
     
    17061703
    17071704        int thisOperand = registerOffset + argumentToOperand(0);
    1708         if (!(m_graph[get(thisOperand)].prediction() & SpecString))
    1709             return false;
    1710 
    17111705        int indexOperand = registerOffset + argumentToOperand(1);
    17121706        NodeIndex charCode = addToGraph(StringCharAt, OpInfo(Array::String), get(thisOperand), getToInt32(indexOperand));
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r132759 r133135  
    128128            break;
    129129        }
    130         case GetByVal:
    131         case StringCharAt:
    132         case StringCharCodeAt: {
     130        case GetByVal: {
    133131            node.setArrayMode(
    134132                node.arrayMode().refine(
     
    136134                    m_graph[node.child2()].prediction()));
    137135           
     136            blessArrayOperation(node.child1(), node.child2(), 2);
     137            break;
     138        }
     139        case StringCharAt:
     140        case StringCharCodeAt: {
     141            // Currently we have no good way of refining these.
     142            ASSERT(node.arrayMode() == ArrayMode(Array::String));
    138143            blessArrayOperation(node.child1(), node.child2(), 2);
    139144            break;
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r132759 r133135  
    18001800void SpeculativeJIT::compileGetCharCodeAt(Node& node)
    18011801{
    1802     ASSERT(node.child3() == NoNode);
    18031802    SpeculateCellOperand string(this, node.child1());
    18041803    SpeculateStrictInt32Operand index(this, node.child2());
     
    18091808    GPRReg storageReg = storage.gpr();
    18101809   
    1811     if (!isStringSpeculation(m_state.forNode(node.child1()).m_type)) {
    1812         ASSERT(!(at(node.child1()).prediction() & SpecString));
    1813         terminateSpeculativeExecution(Uncountable, JSValueRegs(), NoNode);
    1814         noResult(m_compileIndex);
    1815         return;
    1816     }
     1810    ASSERT(speculationChecked(m_state.forNode(node.child1()).m_type, SpecString));
    18171811
    18181812    // unsigned comparison so we can filter out negative indices and indices that are too large
Note: See TracChangeset for help on using the changeset viewer.