Changeset 192896 in webkit


Ignore:
Timestamp:
Dec 1, 2015, 11:31:58 AM (9 years ago)
Author:
mark.lam@apple.com
Message:

Refactor FTL sub snippet code to support general binary op snippets.
https://bugs.webkit.org/show_bug.cgi?id=151706

Reviewed by Geoffrey Garen.

  • ftl/FTLCompile.cpp:
  • Moved the BinarySnippetRegisterContext to FTLCompileBinaryOp.cpp verbatim.
  • Generalize generateArithSubICFastPath() to generateBinaryOpICFastPath(). It now uses snippet specific helpers in FTLCompileBinaryOp.cpp to generate the fast paths.
  • ftl/FTLCompileBinaryOp.cpp: Added.

(JSC::FTL::BinarySnippetRegisterContext::BinarySnippetRegisterContext):
(JSC::FTL::BinarySnippetRegisterContext::initializeRegisters):
(JSC::FTL::BinarySnippetRegisterContext::restoreRegisters):

  • Moved here without changed from FTLCompile.cpp.

(JSC::FTL::generateArithSubFastPath):

  • ftl/FTLCompileBinaryOp.h: Added.
  • ftl/FTLInlineCacheDescriptor.h:

(JSC::FTL::BinaryOpDescriptor::nodeType):
(JSC::FTL::BinaryOpDescriptor::size):
(JSC::FTL::BinaryOpDescriptor::name):
(JSC::FTL::BinaryOpDescriptor::fastPathICName):
(JSC::FTL::BinaryOpDescriptor::slowPathFunction):
(JSC::FTL::BinaryOpDescriptor::leftOperand):
(JSC::FTL::BinaryOpDescriptor::rightOperand):
(JSC::FTL::BinaryOpDescriptor::BinaryOpDescriptor):
(JSC::FTL::ArithSubDescriptor::ArithSubDescriptor): Deleted.
(JSC::FTL::ArithSubDescriptor::leftType): Deleted.
(JSC::FTL::ArithSubDescriptor::rightType): Deleted.

  • Refactor ArithSubDescriptor into BinaryOpDescriptor, and re-add a sub-class ArithSubDescriptor as specializations of BinaryOpDescriptor.
  • ftl/FTLInlineCacheDescriptorInlines.h: Added.

(JSC::FTL::ArithSubDescriptor::ArithSubDescriptor):
(JSC::FTL::ArithSubDescriptor::icSize):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::DFG::LowerDFGToLLVM::compileArithAddOrSub):

  • ftl/FTLOSRExit.cpp:

(JSC::FTL::OSRExit::willArriveAtExitFromIndirectExceptionCheck):
(JSC::FTL::OSRExit::willArriveAtOSRExitFromCallOperation):

  • ftl/FTLOSRExit.h:
  • ftl/FTLState.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r192836 r192896  
    998998        ftl/FTLCommonValues.cpp
    999999        ftl/FTLCompile.cpp
     1000        ftl/FTLCompileBinaryOp.cpp
    10001001        ftl/FTLDWARFDebugLineInfo.cpp
    10011002        ftl/FTLDWARFRegister.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r192882 r192896  
     12015-12-01  Mark Lam  <mark.lam@apple.com>
     2
     3        Refactor FTL sub snippet code to support general binary op snippets.
     4        https://bugs.webkit.org/show_bug.cgi?id=151706
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * CMakeLists.txt:
     9        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     10        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     11        * JavaScriptCore.xcodeproj/project.pbxproj:
     12
     13        * ftl/FTLCompile.cpp:
     14        - Moved the BinarySnippetRegisterContext to FTLCompileBinaryOp.cpp verbatim.
     15        - Generalize generateArithSubICFastPath() to generateBinaryOpICFastPath().
     16          It now uses snippet specific helpers in FTLCompileBinaryOp.cpp to generate
     17          the fast paths.
     18
     19        * ftl/FTLCompileBinaryOp.cpp: Added.
     20        (JSC::FTL::BinarySnippetRegisterContext::BinarySnippetRegisterContext):
     21        (JSC::FTL::BinarySnippetRegisterContext::initializeRegisters):
     22        (JSC::FTL::BinarySnippetRegisterContext::restoreRegisters):
     23        - Moved here without changed from FTLCompile.cpp.
     24        (JSC::FTL::generateArithSubFastPath):
     25        * ftl/FTLCompileBinaryOp.h: Added.
     26
     27        * ftl/FTLInlineCacheDescriptor.h:
     28        (JSC::FTL::BinaryOpDescriptor::nodeType):
     29        (JSC::FTL::BinaryOpDescriptor::size):
     30        (JSC::FTL::BinaryOpDescriptor::name):
     31        (JSC::FTL::BinaryOpDescriptor::fastPathICName):
     32        (JSC::FTL::BinaryOpDescriptor::slowPathFunction):
     33        (JSC::FTL::BinaryOpDescriptor::leftOperand):
     34        (JSC::FTL::BinaryOpDescriptor::rightOperand):
     35        (JSC::FTL::BinaryOpDescriptor::BinaryOpDescriptor):
     36        (JSC::FTL::ArithSubDescriptor::ArithSubDescriptor): Deleted.
     37        (JSC::FTL::ArithSubDescriptor::leftType): Deleted.
     38        (JSC::FTL::ArithSubDescriptor::rightType): Deleted.
     39        - Refactor ArithSubDescriptor into BinaryOpDescriptor, and re-add a sub-class
     40          ArithSubDescriptor as specializations of BinaryOpDescriptor.
     41
     42        * ftl/FTLInlineCacheDescriptorInlines.h: Added.
     43        (JSC::FTL::ArithSubDescriptor::ArithSubDescriptor):
     44        (JSC::FTL::ArithSubDescriptor::icSize):
     45
     46        * ftl/FTLLowerDFGToLLVM.cpp:
     47        (JSC::FTL::DFG::LowerDFGToLLVM::compileArithAddOrSub):
     48        * ftl/FTLOSRExit.cpp:
     49        (JSC::FTL::OSRExit::willArriveAtExitFromIndirectExceptionCheck):
     50        (JSC::FTL::OSRExit::willArriveAtOSRExitFromCallOperation):
     51        * ftl/FTLOSRExit.h:
     52        * ftl/FTLState.h:
     53
    1542015-12-01  Carlos Garcia Campos  <cgarcia@igalia.com>
    255
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r192836 r192896  
    523523    <ClCompile Include="..\ftl\FTLCommonValues.cpp" />
    524524    <ClCompile Include="..\ftl\FTLCompile.cpp" />
     525    <ClCompile Include="..\ftl\FTLCompileBinaryOp.cpp" />
    525526    <ClCompile Include="..\ftl\FTLDataSection.cpp" />
    526527    <ClCompile Include="..\ftl\FTLDWARFDebugLineInfo.cpp" />
     
    12911292    <ClInclude Include="..\ftl\FTLCommonValues.h" />
    12921293    <ClInclude Include="..\ftl\FTLCompile.h" />
     1294    <ClInclude Include="..\ftl\FTLCompileBinaryOp.h" />
    12931295    <ClInclude Include="..\ftl\FTLDataSection.h" />
    12941296    <ClInclude Include="..\ftl\FTLDWARFDebugLineInfo.h" />
     
    13071309    <ClInclude Include="..\ftl\FTLGeneratedFunction.h" />
    13081310    <ClInclude Include="..\ftl\FTLInlineCacheDescriptor.h" />
     1311    <ClInclude Include="..\ftl\FTLInlineCacheDescriptorInlines.h" />
    13091312    <ClInclude Include="..\ftl\FTLInlineCacheSize.h" />
    13101313    <ClInclude Include="..\ftl\FTLIntrinsicRepository.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r192836 r192896  
    15611561      <Filter>ftl</Filter>
    15621562    </ClCompile>
     1563    <ClCompile Include="..\ftl\FTLCompileBinaryOp.cpp">
     1564      <Filter>ftl</Filter>
     1565    </ClCompile>
    15631566    <ClCompile Include="..\ftl\FTLDataSection.cpp">
    15641567      <Filter>ftl</Filter>
     
    41334136      <Filter>ftl</Filter>
    41344137    </ClInclude>
     4138    <ClInclude Include="..\ftl\FTLCompileBinaryOp.h">
     4139      <Filter>ftl</Filter>
     4140    </ClInclude>
    41354141    <ClInclude Include="..\ftl\FTLDataSection.h">
    41364142      <Filter>ftl</Filter>
     
    41734179    </ClInclude>
    41744180    <ClInclude Include="..\ftl\FTLInlineCacheDescriptor.h">
     4181      <Filter>ftl</Filter>
     4182    </ClInclude>
     4183    <ClInclude Include="..\ftl\FTLInlineCacheDescriptorInlines.h">
    41754184      <Filter>ftl</Filter>
    41764185    </ClInclude>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r192863 r192896  
    19771977                FE187A0E1C030D640038BBCA /* JITDivGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE187A0A1C0229230038BBCA /* JITDivGenerator.cpp */; settings = {ASSET_TAGS = (); }; };
    19781978                FE187A0F1C030D6C0038BBCA /* SnippetOperand.h in Headers */ = {isa = PBXBuildFile; fileRef = FE187A0C1C02EBA70038BBCA /* SnippetOperand.h */; settings = {ASSET_TAGS = (); }; };
     1979                FE187A181C0E13DD0038BBCA /* FTLInlineCacheDescriptorInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FE187A171C0E13C60038BBCA /* FTLInlineCacheDescriptorInlines.h */; settings = {ASSET_TAGS = (); }; };
     1980                FE187A191C0E13E30038BBCA /* FTLCompileBinaryOp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE187A151C0E13C60038BBCA /* FTLCompileBinaryOp.cpp */; settings = {ASSET_TAGS = (); }; };
     1981                FE187A1A1C0E13E60038BBCA /* FTLCompileBinaryOp.h in Headers */ = {isa = PBXBuildFile; fileRef = FE187A161C0E13C60038BBCA /* FTLCompileBinaryOp.h */; settings = {ASSET_TAGS = (); }; };
    19791982                FE1C0FFD1B193E9800B53FCA /* Exception.h in Headers */ = {isa = PBXBuildFile; fileRef = FE1C0FFC1B193E9800B53FCA /* Exception.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19801983                FE1C0FFF1B194FD100B53FCA /* Exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE1C0FFE1B194FD100B53FCA /* Exception.cpp */; };
     
    41214124                FE187A0B1C0229230038BBCA /* JITDivGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITDivGenerator.h; sourceTree = "<group>"; };
    41224125                FE187A0C1C02EBA70038BBCA /* SnippetOperand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetOperand.h; sourceTree = "<group>"; };
     4126                FE187A151C0E13C60038BBCA /* FTLCompileBinaryOp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLCompileBinaryOp.cpp; path = ftl/FTLCompileBinaryOp.cpp; sourceTree = "<group>"; };
     4127                FE187A161C0E13C60038BBCA /* FTLCompileBinaryOp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLCompileBinaryOp.h; path = ftl/FTLCompileBinaryOp.h; sourceTree = "<group>"; };
     4128                FE187A171C0E13C60038BBCA /* FTLInlineCacheDescriptorInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLInlineCacheDescriptorInlines.h; path = ftl/FTLInlineCacheDescriptorInlines.h; sourceTree = "<group>"; };
    41234129                FE1C0FFC1B193E9800B53FCA /* Exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Exception.h; sourceTree = "<group>"; };
    41244130                FE1C0FFE1B194FD100B53FCA /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = "<group>"; };
     
    43954401                                0FEA0A00170513DB00BB722C /* FTLCompile.cpp */,
    43964402                                0FEA0A01170513DB00BB722C /* FTLCompile.h */,
     4403                                FE187A151C0E13C60038BBCA /* FTLCompileBinaryOp.cpp */,
     4404                                FE187A161C0E13C60038BBCA /* FTLCompileBinaryOp.h */,
    43974405                                0FE95F7718B5694700B531FB /* FTLDataSection.cpp */,
    43984406                                0FE95F7818B5694700B531FB /* FTLDataSection.h */,
     
    44224430                                A78A977C179738D5009DF744 /* FTLGeneratedFunction.h */,
    44234431                                0F25F1A7181635F300522F39 /* FTLInlineCacheDescriptor.h */,
     4432                                FE187A171C0E13C60038BBCA /* FTLInlineCacheDescriptorInlines.h */,
    44244433                                0F25F1A8181635F300522F39 /* FTLInlineCacheSize.cpp */,
    44254434                                0F25F1A9181635F300522F39 /* FTLInlineCacheSize.h */,
     
    66606669                                0FFA549816B8835300B3A982 /* A64DOpcode.h in Headers */,
    66616670                                0F1FE51C1922A3BC006987C5 /* AbortReason.h in Headers */,
     6671                                FE187A1A1C0E13E60038BBCA /* FTLCompileBinaryOp.h in Headers */,
    66626672                                860161E30F3A83C100F84710 /* AbstractMacroAssembler.h in Headers */,
    66636673                                0F55F0F514D1063C00AC7649 /* AbstractPC.h in Headers */,
     
    68556865                                0F7C11AD1BC3862C00C74CDB /* CopyBarrier.h in Headers */,
    68566866                                0F5A52D017ADD717008ECB2D /* CopyToken.h in Headers */,
     6867                                FE187A181C0E13DD0038BBCA /* FTLInlineCacheDescriptorInlines.h in Headers */,
    68576868                                C2239D1816262BDD005AC5FD /* CopyVisitor.h in Headers */,
    68586869                                C2239D1916262BDD005AC5FD /* CopyVisitorInlines.h in Headers */,
     
    85348545                                0F3A1BF91A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp in Sources */,
    85358546                                0F2FCCFB18A60070001A27F8 /* DFGSafepoint.cpp in Sources */,
     8547                                FE187A191C0E13E30038BBCA /* FTLCompileBinaryOp.cpp in Sources */,
    85368548                                86EC9DD21328DF82002B2AD7 /* DFGSpeculativeJIT.cpp in Sources */,
    85378549                                86880F1F14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp in Sources */,
  • trunk/Source/JavaScriptCore/ftl/FTLCompile.cpp

    r192845 r192896  
    3838#include "DataView.h"
    3939#include "Disassembler.h"
     40#include "FTLCompileBinaryOp.h"
    4041#include "FTLExceptionHandlerManager.h"
    4142#include "FTLExitThunkGenerator.h"
     43#include "FTLInlineCacheDescriptorInlines.h"
    4244#include "FTLInlineCacheSize.h"
    4345#include "FTLJITCode.h"
    4446#include "FTLThunks.h"
    4547#include "FTLUnwindInfo.h"
    46 #include "JITSubGenerator.h"
    4748#include "LLVMAPI.h"
    4849#include "LinkBuffer.h"
     
    308309}
    309310
    310 class BinarySnippetRegisterContext {
    311     // The purpose of this class is to shuffle registers to get them into the state
    312     // that baseline code expects so that we can use the baseline snippet generators i.e.
    313     //    1. Ensure that the inputs and output are not in reserved registers (which
    314     //       include the tag registers). The snippet will use these reserved registers.
    315     //       Hence, we need to put the inputs and output in other scratch registers.
    316     //    2. Tag registers are loaded with the expected values.
    317     //
    318     // When the snippet is done:
    319     //    1. If we had re-assigned the result register to a scratch, we need to copy the
    320     //       result back from the scratch.
    321     //    2. Restore the input and tag registers to the values that LLVM put there originally.
    322     //       That is unless when one of them is also the result register. In that case, we
    323     //       don't want to trash the result, and hence, should not restore into it.
    324 
    325 public:
    326     BinarySnippetRegisterContext(ScratchRegisterAllocator& allocator, GPRReg& result, GPRReg& left, GPRReg& right)
    327         : m_allocator(allocator)
    328         , m_result(result)
    329         , m_left(left)
    330         , m_right(right)
    331         , m_origResult(result)
    332         , m_origLeft(left)
    333         , m_origRight(right)
    334     {
    335         m_allocator.lock(m_result);
    336         m_allocator.lock(m_left);
    337         m_allocator.lock(m_right);
    338 
    339         RegisterSet inputAndOutputRegisters = RegisterSet(m_left, m_right, m_result);
    340         RegisterSet reservedRegisters;
    341         for (GPRReg reg : GPRInfo::reservedRegisters())
    342             reservedRegisters.set(reg);
    343 
    344         if (reservedRegisters.get(m_left))
    345             m_left = m_allocator.allocateScratchGPR();
    346         if (reservedRegisters.get(m_right)) {
    347             if (m_origRight == m_origLeft)
    348                 m_right = m_left;
    349             else
    350                 m_right = m_allocator.allocateScratchGPR();
    351         }
    352         if (reservedRegisters.get(m_result)) {
    353             if (m_origResult == m_origLeft)
    354                 m_result = m_left;
    355             else if (m_origResult == m_origRight)
    356                 m_result = m_right;
    357             else
    358                 m_result = m_allocator.allocateScratchGPR();
    359         }
    360 
    361         if (!inputAndOutputRegisters.get(GPRInfo::tagMaskRegister))
    362             m_savedTagMaskRegister = m_allocator.allocateScratchGPR();
    363         if (!inputAndOutputRegisters.get(GPRInfo::tagTypeNumberRegister))
    364             m_savedTagTypeNumberRegister = m_allocator.allocateScratchGPR();
    365     }
    366 
    367     void initializeRegisters(CCallHelpers& jit)
    368     {
    369         if (m_left != m_origLeft)
    370             jit.move(m_origLeft, m_left);
    371         if (m_right != m_origRight && m_origRight != m_origLeft)
    372             jit.move(m_origRight, m_right);
    373 
    374         if (m_savedTagMaskRegister != InvalidGPRReg)
    375             jit.move(GPRInfo::tagMaskRegister, m_savedTagMaskRegister);
    376         if (m_savedTagTypeNumberRegister != InvalidGPRReg)
    377             jit.move(GPRInfo::tagTypeNumberRegister, m_savedTagTypeNumberRegister);
    378 
    379         jit.emitMaterializeTagCheckRegisters();
    380     }
    381 
    382     void restoreRegisters(CCallHelpers& jit)
    383     {
    384         if (m_origResult != m_result)
    385             jit.move(m_result, m_origResult);
    386         if (m_origLeft != m_left && m_origLeft != m_origResult)
    387             jit.move(m_left, m_origLeft);
    388         if (m_origRight != m_right && m_origRight != m_origResult && m_origRight != m_origLeft)
    389             jit.move(m_right, m_origRight);
    390 
    391         // We are guaranteed that the tag registers are not the same as the original input
    392         // or output registers. Otherwise, we would not have allocated a scratch for them.
    393         // Hence, we don't need to need to check for overlap like we do for the input registers.
    394         if (m_savedTagMaskRegister != InvalidGPRReg) {
    395             ASSERT(GPRInfo::tagMaskRegister != m_origLeft);
    396             ASSERT(GPRInfo::tagMaskRegister != m_origRight);
    397             ASSERT(GPRInfo::tagMaskRegister != m_origResult);
    398             jit.move(m_savedTagMaskRegister, GPRInfo::tagMaskRegister);
    399         }
    400         if (m_savedTagTypeNumberRegister != InvalidGPRReg) {
    401             ASSERT(GPRInfo::tagTypeNumberRegister != m_origLeft);
    402             ASSERT(GPRInfo::tagTypeNumberRegister != m_origRight);
    403             ASSERT(GPRInfo::tagTypeNumberRegister != m_origResult);
    404             jit.move(m_savedTagTypeNumberRegister, GPRInfo::tagTypeNumberRegister);
    405         }
    406     }
    407 
    408 private:
    409     ScratchRegisterAllocator& m_allocator;
    410 
    411     GPRReg& m_result;
    412     GPRReg& m_left;
    413     GPRReg& m_right;
    414 
    415     GPRReg m_origResult;
    416     GPRReg m_origLeft;
    417     GPRReg m_origRight;
    418 
    419     GPRReg m_savedTagMaskRegister { InvalidGPRReg };
    420     GPRReg m_savedTagTypeNumberRegister { InvalidGPRReg };
    421 };
    422 
    423 static void generateArithSubICFastPath(
     311static void generateBinaryOpICFastPath(
    424312    State& state, CodeBlock* codeBlock, GeneratedFunction generatedFunction,
    425     StackMaps::RecordMap& recordMap, ArithSubDescriptor& ic)
     313    StackMaps::RecordMap& recordMap, BinaryOpDescriptor& ic)
    426314{
    427315    VM& vm = state.graph.m_vm;
    428     size_t sizeOfIC = sizeOfArithSub();
     316    size_t sizeOfIC = ic.size();
    429317
    430318    StackMaps::RecordMap::iterator iter = recordMap.find(ic.stackmapID());
     
    441329        CCallHelpers fastPathJIT(&vm, codeBlock);
    442330
    443         SnippetOperand leftOperand(ic.leftType());
    444         SnippetOperand rightOperand(ic.rightType());
    445 
    446331        GPRReg result = record.locations[0].directGPR();
    447332        GPRReg left = record.locations[1].directGPR();
    448333        GPRReg right = record.locations[2].directGPR();
    449 
    450334        RegisterSet usedRegisters = usedRegistersFor(record);
    451         ScratchRegisterAllocator allocator(usedRegisters);
    452 
    453         BinarySnippetRegisterContext context(allocator, result, left, right);
    454 
    455         GPRReg scratchGPR = allocator.allocateScratchGPR();
    456         FPRReg leftFPR = allocator.allocateScratchFPR();
    457         FPRReg rightFPR = allocator.allocateScratchFPR();
    458         FPRReg scratchFPR = InvalidFPRReg;
    459 
    460         JITSubGenerator gen(leftOperand, rightOperand, JSValueRegs(result), JSValueRegs(left), JSValueRegs(right), leftFPR, rightFPR, scratchGPR, scratchFPR);
    461 
    462         auto numberOfBytesUsedToPreserveReusedRegisters =
    463             allocator.preserveReusedRegistersByPushing(fastPathJIT, ScratchRegisterAllocator::ExtraStackSpace::NoExtraSpace);
    464 
    465         context.initializeRegisters(fastPathJIT);
    466         gen.generateFastPath(fastPathJIT);
    467 
    468         ASSERT(gen.didEmitFastPath());
    469         gen.endJumpList().link(&fastPathJIT);
    470         context.restoreRegisters(fastPathJIT);
    471         allocator.restoreReusedRegistersByPopping(fastPathJIT, numberOfBytesUsedToPreserveReusedRegisters,
    472             ScratchRegisterAllocator::ExtraStackSpace::SpaceForCCall);
    473         CCallHelpers::Jump done = fastPathJIT.jump();
    474 
    475         gen.slowPathJumpList().link(&fastPathJIT);
    476         context.restoreRegisters(fastPathJIT);
    477         allocator.restoreReusedRegistersByPopping(fastPathJIT, numberOfBytesUsedToPreserveReusedRegisters,
    478             ScratchRegisterAllocator::ExtraStackSpace::SpaceForCCall);
    479         CCallHelpers::Jump slowPathStart = fastPathJIT.jump();
     335
     336        CCallHelpers::Jump done;
     337        CCallHelpers::Jump slowPathStart;
     338
     339        switch (ic.nodeType()) {
     340        case ArithSub:
     341            generateArithSubFastPath(ic, fastPathJIT, result, left, right, usedRegisters, done, slowPathStart);
     342            break;
     343        default:
     344            RELEASE_ASSERT_NOT_REACHED();
     345        }
    480346
    481347        char* startOfIC = bitwise_cast<char*>(generatedFunction) + record.instructionOffset;
    482         generateInlineIfPossibleOutOfLineIfNot(state, vm, codeBlock, fastPathJIT, startOfIC, sizeOfIC, "ArithSub inline cache fast path", [&] (LinkBuffer& linkBuffer, CCallHelpers&, bool) {
     348        const char* fastPathICName = ic.fastPathICName();
     349        generateInlineIfPossibleOutOfLineIfNot(state, vm, codeBlock, fastPathJIT, startOfIC, sizeOfIC, fastPathICName, [&] (LinkBuffer& linkBuffer, CCallHelpers&, bool) {
    483350            linkBuffer.link(done, CodeLocationLabel(startOfIC + sizeOfIC));
    484351            state.finalizer->sideCodeLinkBuffer->link(ic.m_slowPathDone[i], CodeLocationLabel(startOfIC + sizeOfIC));
     
    651518
    652519                OSRExit* callOperationExit = nullptr;
    653                 if (exitDescriptor.m_exceptionType == ExceptionType::SubGenerator) {
     520                if (exitDescriptor.m_exceptionType == ExceptionType::BinaryOpGenerator) {
    654521                    exceptionHandlerManager.addNewCallOperationExit(iter->value[j].index, state.jitCode->osrExit.size() - 1);
    655522                    callOperationExit = &exit;
     
    695562                    if (base == result)
    696563                        callOperationExit->registersToPreserveForCallThatMightThrow.set(base);
    697                 } else if (exitDescriptor.m_exceptionType == ExceptionType::SubGenerator) {
     564                } else if (exitDescriptor.m_exceptionType == ExceptionType::BinaryOpGenerator) {
    698565                    GPRReg result = record.locations[0].directGPR();
    699566                    GPRReg left = record.locations[1].directGPR();
     
    756623        || !state.putByIds.isEmpty()
    757624        || !state.checkIns.isEmpty()
    758         || !state.arithSubs.isEmpty()
     625        || !state.binaryOps.isEmpty()
    759626        || !state.lazySlowPaths.isEmpty()) {
    760627        CCallHelpers slowPathJIT(&vm, codeBlock);
     
    904771        }
    905772
    906         for (size_t i = state.arithSubs.size(); i--;) {
    907             ArithSubDescriptor& arithSub = state.arithSubs[i];
     773        for (size_t i = state.binaryOps.size(); i--;) {
     774            BinaryOpDescriptor& binaryOp = state.binaryOps[i];
    908775           
    909776            if (verboseCompilationEnabled())
    910                 dataLog("Handling ArithSub stackmap #", arithSub.stackmapID(), "\n");
    911            
    912             auto iter = recordMap.find(arithSub.stackmapID());
     777                dataLog("Handling ", binaryOp.name(), " stackmap #", binaryOp.stackmapID(), "\n");
     778           
     779            auto iter = recordMap.find(binaryOp.stackmapID());
    913780            if (iter == recordMap.end())
    914781                continue; // It was optimized out.
    915782           
    916             CodeOrigin codeOrigin = arithSub.codeOrigin();
     783            CodeOrigin codeOrigin = binaryOp.codeOrigin();
    917784            for (unsigned i = 0; i < iter->value.size(); ++i) {
    918785                StackMaps::Record& record = iter->value[i].record;
     
    923790                GPRReg right = record.locations[2].directGPR();
    924791
    925                 arithSub.m_slowPathStarts.append(slowPathJIT.label());
     792                binaryOp.m_slowPathStarts.append(slowPathJIT.label());
    926793                bool addedUniqueExceptionJump = addNewExceptionJumpIfNecessary(iter->value[i].index);
    927794                if (result == left || result == right) {
     
    933800
    934801                callOperation(state, usedRegisters, slowPathJIT, codeOrigin, addedUniqueExceptionJump ? &exceptionJumpsToLink.last().first : &exceptionTarget,
    935                     operationValueSub, result, left, right).call();
    936 
    937                 arithSub.m_slowPathDone.append(slowPathJIT.jump());
     802                    binaryOp.slowPathFunction(), result, left, right).call();
     803
     804                binaryOp.m_slowPathDone.append(slowPathJIT.jump());
    938805            }
    939806        }
     
    1023890                sizeOfIn());
    1024891        }
    1025         for (unsigned i = state.arithSubs.size(); i--;) {
    1026             ArithSubDescriptor& arithSub = state.arithSubs[i];
    1027             generateArithSubICFastPath(state, codeBlock, generatedFunction, recordMap, arithSub);
     892        for (unsigned i = state.binaryOps.size(); i--;) {
     893            BinaryOpDescriptor& binaryOp = state.binaryOps[i];
     894            generateBinaryOpICFastPath(state, codeBlock, generatedFunction, recordMap, binaryOp);
    1028895        }
    1029896        for (unsigned i = state.lazySlowPaths.size(); i--;) {
  • trunk/Source/JavaScriptCore/ftl/FTLInlineCacheDescriptor.h

    r192334 r192896  
    3030
    3131#include "CodeOrigin.h"
     32#include "DFGAbstractValue.h"
    3233#include "FTLLazySlowPath.h"
    3334#include "JITInlineCacheGenerator.h"
    3435#include "MacroAssembler.h"
     36#include "SnippetOperand.h"
    3537#include <wtf/text/UniquedStringImpl.h>
    3638
     
    124126};
    125127
    126 class ArithSubDescriptor : public InlineCacheDescriptor {
    127 public:
    128     ArithSubDescriptor(unsigned stackmapID, CodeOrigin codeOrigin, ResultType leftType, ResultType rightType)
     128class BinaryOpDescriptor : public InlineCacheDescriptor {
     129public:
     130    typedef EncodedJSValue (*SlowPathFunction)(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2);
     131
     132    unsigned nodeType() const { return m_nodeType; }
     133    size_t size() const { return m_size; }
     134    const char* name() const { return m_name; }
     135    const char* fastPathICName() const { return m_fastPathICName; }
     136    SlowPathFunction slowPathFunction() const { return m_slowPathFunction; }
     137
     138    SnippetOperand leftOperand() { return m_leftOperand; }
     139    SnippetOperand rightOperand() { return m_rightOperand; }
     140
     141    Vector<MacroAssembler::Label> m_slowPathStarts;
     142
     143protected:
     144    BinaryOpDescriptor(unsigned nodeType, unsigned stackmapID, CodeOrigin codeOrigin,
     145        size_t size, const char* name, const char* fastPathICName,
     146        SlowPathFunction slowPathFunction, const SnippetOperand& leftOperand, const SnippetOperand& rightOperand)
    129147        : InlineCacheDescriptor(stackmapID, codeOrigin, nullptr)
    130         , m_leftType(leftType)
    131         , m_rightType(rightType)
    132     {
    133     }
    134 
    135     ResultType leftType() const { return m_leftType; }
    136     ResultType rightType() const { return m_rightType; }
    137    
    138     Vector<MacroAssembler::Label> m_slowPathStarts;
    139 
    140 private:
    141     ResultType m_leftType;
    142     ResultType m_rightType;
     148        , m_nodeType(nodeType)
     149        , m_size(size)
     150        , m_name(name)
     151        , m_fastPathICName(fastPathICName)
     152        , m_slowPathFunction(slowPathFunction)
     153        , m_leftOperand(leftOperand)
     154        , m_rightOperand(rightOperand)
     155    {
     156    }
     157
     158    unsigned m_nodeType;
     159    size_t m_size;
     160    const char* m_name;
     161    const char* m_fastPathICName;
     162    SlowPathFunction m_slowPathFunction;
     163
     164    SnippetOperand m_leftOperand;
     165    SnippetOperand m_rightOperand;
     166};
     167
     168class ArithSubDescriptor : public BinaryOpDescriptor {
     169public:
     170    ArithSubDescriptor(unsigned stackmapID, CodeOrigin, const SnippetOperand& leftOperand, const SnippetOperand& rightOperand);
     171    static size_t icSize();
    143172};
    144173
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToLLVM.cpp

    r192882 r192896  
    16561656            StackmapArgumentList arguments;
    16571657            arguments.append(m_out.constInt64(stackmapID));
    1658             arguments.append(m_out.constInt32(sizeOfArithSub()));
     1658            arguments.append(m_out.constInt32(ArithSubDescriptor::icSize()));
    16591659            arguments.append(constNull(m_out.ref8));
    16601660            arguments.append(m_out.constInt32(2));
     
    16621662            arguments.append(right);
    16631663
    1664             appendOSRExitArgumentsForPatchpointIfWillCatchException(arguments, ExceptionType::SubGenerator, 3); // left, right, and result show up in the stackmap locations.
     1664            appendOSRExitArgumentsForPatchpointIfWillCatchException(arguments,
     1665                ExceptionType::BinaryOpGenerator, 3); // left, right, and result show up in the stackmap locations.
    16651666
    16661667            LValue call = m_out.call(m_out.int64, m_out.patchpointInt64Intrinsic(), arguments);
    16671668            setInstructionCallingConvention(call, LLVMAnyRegCallConv);
    16681669
    1669             m_ftlState.arithSubs.append(ArithSubDescriptor(stackmapID, m_node->origin.semantic,
    1670                 abstractValue(m_node->child1()).resultType(),
    1671                 abstractValue(m_node->child2()).resultType()));
     1670            SnippetOperand leftOperand(abstractValue(m_node->child1()).resultType());
     1671            SnippetOperand rightOperand(abstractValue(m_node->child2()).resultType());
     1672            m_ftlState.binaryOps.append(ArithSubDescriptor(stackmapID, m_node->origin.semantic, leftOperand, rightOperand));
    16721673
    16731674            setJSValue(call);
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExit.cpp

    r192845 r192896  
    173173    case ExceptionType::PutById:
    174174    case ExceptionType::LazySlowPath:
    175     case ExceptionType::SubGenerator:
     175    case ExceptionType::BinaryOpGenerator:
    176176    case ExceptionType::GetByIdCallOperation:
    177177    case ExceptionType::PutByIdCallOperation:
     
    201201    case ExceptionType::GetByIdCallOperation:
    202202    case ExceptionType::PutByIdCallOperation:
    203     case ExceptionType::SubGenerator:
     203    case ExceptionType::BinaryOpGenerator:
    204204        return true;
    205205    default:
  • trunk/Source/JavaScriptCore/ftl/FTLOSRExit.h

    r192845 r192896  
    146146    PutByIdCallOperation,
    147147    LazySlowPath,
    148     SubGenerator,
     148    BinaryOpGenerator,
    149149};
    150150
  • trunk/Source/JavaScriptCore/ftl/FTLState.h

    r192605 r192896  
    9292    SegmentedVector<PutByIdDescriptor> putByIds;
    9393    SegmentedVector<CheckInDescriptor> checkIns;
    94     SegmentedVector<ArithSubDescriptor> arithSubs;
     94    SegmentedVector<BinaryOpDescriptor> binaryOps;
    9595    SegmentedVector<LazySlowPathDescriptor> lazySlowPaths;
    9696#if ENABLE(MASM_PROBE)
Note: See TracChangeset for help on using the changeset viewer.