Ignore:
Timestamp:
Oct 9, 2012, 7:14:42 PM (13 years ago)
Author:
[email protected]
Message:

Typed arrays should not be 20x slower in the baseline JIT than in the DFG JIT
https://bugs.webkit.org/show_bug.cgi?id=98605

Reviewed by Oliver Hunt and Gavin Barraclough.

This adds typed array get_by_val/put_by_val patching to the baseline JIT. It's
a big (~40%) win on benchmarks that have trouble staying in the DFG JIT. Even
if we fix those benchmarks, this functionality gives us the insurance that we
typically desire with all speculative optimizations: even if we bail to
baseline, we're still reasonably performant.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • assembler/MacroAssembler.cpp: Added.

(JSC):

  • assembler/MacroAssembler.h:

(MacroAssembler):
(JSC::MacroAssembler::patchableBranchPtr):

  • assembler/MacroAssemblerARMv7.h:

(MacroAssemblerARMv7):
(JSC::MacroAssemblerARMv7::moveDoubleToInts):
(JSC::MacroAssemblerARMv7::moveIntsToDouble):
(JSC::MacroAssemblerARMv7::patchableBranchPtr):

  • assembler/MacroAssemblerX86.h:

(MacroAssemblerX86):
(JSC::MacroAssemblerX86::moveDoubleToInts):
(JSC::MacroAssemblerX86::moveIntsToDouble):

  • bytecode/ByValInfo.h:

(JSC::hasOptimizableIndexingForClassInfo):
(JSC):
(JSC::hasOptimizableIndexing):
(JSC::jitArrayModeForClassInfo):
(JSC::jitArrayModeForStructure):
(JSC::ByValInfo::ByValInfo):
(ByValInfo):

  • dfg/DFGAssemblyHelpers.cpp:

(DFG):

  • dfg/DFGAssemblyHelpers.h:

(AssemblyHelpers):
(JSC::DFG::AssemblyHelpers::boxDouble):
(JSC::DFG::AssemblyHelpers::unboxDouble):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileGetByValOnIntTypedArray):
(JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray):

  • dfg/DFGSpeculativeJIT.h:

(SpeculativeJIT):

  • jit/JIT.h:

(JIT):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emit_op_put_by_val):
(JSC::JIT::privateCompileGetByVal):
(JSC::JIT::privateCompilePutByVal):
(JSC::JIT::emitIntTypedArrayGetByVal):
(JSC):
(JSC::JIT::emitFloatTypedArrayGetByVal):
(JSC::JIT::emitIntTypedArrayPutByVal):
(JSC::JIT::emitFloatTypedArrayPutByVal):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emit_op_put_by_val):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • runtime/JSCell.h:
  • runtime/JSGlobalData.h:

(JSGlobalData):
(JSC::JSGlobalData::typedArrayDescriptor):

  • runtime/TypedArrayDescriptor.h: Added.

(JSC):
(JSC::TypedArrayDescriptor::TypedArrayDescriptor):
(TypedArrayDescriptor):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/ByValInfo.h

    r130828 r130839  
    3131#if ENABLE(JIT)
    3232
     33#include "ClassInfo.h"
    3334#include "CodeLocation.h"
    3435#include "IndexingType.h"
    3536#include "JITStubRoutine.h"
     37#include "Structure.h"
    3638
    3739namespace JSC {
    3840
    39 enum JITArrayMode { JITContiguous, JITArrayStorage };
     41enum JITArrayMode {
     42    JITContiguous,
     43    JITArrayStorage,
     44    JITInt8Array,
     45    JITInt16Array,
     46    JITInt32Array,
     47    JITUint8Array,
     48    JITUint8ClampedArray,
     49    JITUint16Array,
     50    JITUint32Array,
     51    JITFloat32Array,
     52    JITFloat64Array
     53};
    4054
    4155inline bool isOptimizableIndexingType(IndexingType indexingType)
     
    4862        return false;
    4963    }
     64}
     65
     66inline bool hasOptimizableIndexingForClassInfo(const ClassInfo* classInfo)
     67{
     68    return classInfo->typedArrayStorageType != TypedArrayNone;
     69}
     70
     71inline bool hasOptimizableIndexing(Structure* structure)
     72{
     73    return isOptimizableIndexingType(structure->indexingType())
     74        || hasOptimizableIndexingForClassInfo(structure->classInfo());
    5075}
    5176
     
    6388}
    6489
     90inline JITArrayMode jitArrayModeForClassInfo(const ClassInfo* classInfo)
     91{
     92    switch (classInfo->typedArrayStorageType) {
     93    case TypedArrayInt8:
     94        return JITInt8Array;
     95    case TypedArrayInt16:
     96        return JITInt16Array;
     97    case TypedArrayInt32:
     98        return JITInt32Array;
     99    case TypedArrayUint8:
     100        return JITUint8Array;
     101    case TypedArrayUint8Clamped:
     102        return JITUint8ClampedArray;
     103    case TypedArrayUint16:
     104        return JITUint16Array;
     105    case TypedArrayUint32:
     106        return JITUint32Array;
     107    case TypedArrayFloat32:
     108        return JITFloat32Array;
     109    case TypedArrayFloat64:
     110        return JITFloat64Array;
     111    default:
     112        CRASH();
     113        return JITContiguous;
     114    }
     115}
     116
     117inline JITArrayMode jitArrayModeForStructure(Structure* structure)
     118{
     119    if (isOptimizableIndexingType(structure->indexingType()))
     120        return jitArrayModeForIndexingType(structure->indexingType());
     121   
     122    ASSERT(hasOptimizableIndexingForClassInfo(structure->classInfo()));
     123    return jitArrayModeForClassInfo(structure->classInfo());
     124}
     125
    65126struct ByValInfo {
    66127    ByValInfo() { }
     
    72133        , badTypeJumpToDone(badTypeJumpToDone)
    73134        , returnAddressToSlowPath(returnAddressToSlowPath)
     135        , slowPathCount(0)
    74136    {
    75137    }
     
    80142    int16_t badTypeJumpToDone;
    81143    int16_t returnAddressToSlowPath;
     144    unsigned slowPathCount;
    82145    RefPtr<JITStubRoutine> stubRoutine;
    83146};
Note: See TracChangeset for help on using the changeset viewer.