Ignore:
Timestamp:
Oct 14, 2019, 1:28:41 PM (6 years ago)
Author:
[email protected]
Message:

Split ArithProfile into a Unary and a Binary version
https://bugs.webkit.org/show_bug.cgi?id=202832

Reviewed by Keith Miller.

ArithProfile was for a long time only used for add/sub/mul/div, but recently it started being used for negate. And it will soon also have to be used for inc and dec due to BigInt.
So in this patch I make a separate version that only has the data for a single argument, and thus takes half as much memory.

  • bytecode/ArithProfile.cpp:

(JSC::ArithProfile<BitfieldType>::emitObserveResult):
(JSC::ArithProfile<BitfieldType>::shouldEmitSetDouble const):
(JSC::ArithProfile<BitfieldType>::emitSetDouble const):
(JSC::ArithProfile<BitfieldType>::shouldEmitSetNonNumeric const):
(JSC::ArithProfile<BitfieldType>::shouldEmitSetBigInt const):
(JSC::ArithProfile<BitfieldType>::emitSetNonNumeric const):
(JSC::ArithProfile<BitfieldType>::emitSetBigInt const):
(WTF::printInternal):

  • bytecode/ArithProfile.h:

(JSC::ArithProfile::didObserveNonInt32 const):
(JSC::ArithProfile::didObserveDouble const):
(JSC::ArithProfile::didObserveNonNegZeroDouble const):
(JSC::ArithProfile::didObserveNegZeroDouble const):
(JSC::ArithProfile::didObserveNonNumeric const):
(JSC::ArithProfile::didObserveBigInt const):
(JSC::ArithProfile::didObserveInt32Overflow const):
(JSC::ArithProfile::didObserveInt52Overflow const):
(JSC::ArithProfile::setObservedNonNegZeroDouble):
(JSC::ArithProfile::setObservedNegZeroDouble):
(JSC::ArithProfile::setObservedNonNumeric):
(JSC::ArithProfile::setObservedBigInt):
(JSC::ArithProfile::setObservedInt32Overflow):
(JSC::ArithProfile::setObservedInt52Overflow):
(JSC::ArithProfile::observeResult):
(JSC::ArithProfile::addressOfBits const):
(JSC::ArithProfile::bits const):
(JSC::ArithProfile::ArithProfile):
(JSC::ArithProfile::hasBits const):
(JSC::ArithProfile::setBit):
(JSC::UnaryArithProfile::UnaryArithProfile):
(JSC::UnaryArithProfile::observedIntBits):
(JSC::UnaryArithProfile::observedNumberBits):
(JSC::UnaryArithProfile::argResultType const):
(JSC::UnaryArithProfile::argObservedType const):
(JSC::UnaryArithProfile::setArgObservedType):
(JSC::UnaryArithProfile::argSawInt32):
(JSC::UnaryArithProfile::argSawNumber):
(JSC::UnaryArithProfile::argSawNonNumber):
(JSC::UnaryArithProfile::observeArg):
(JSC::UnaryArithProfile::isObservedTypeEmpty):
(JSC::BinaryArithProfile::BinaryArithProfile):
(JSC::BinaryArithProfile::observedIntIntBits):
(JSC::BinaryArithProfile::observedNumberIntBits):
(JSC::BinaryArithProfile::observedIntNumberBits):
(JSC::BinaryArithProfile::observedNumberNumberBits):
(JSC::BinaryArithProfile::observeLHS):
(JSC::BinaryArithProfile::observeLHSAndRHS):
(JSC::BinaryArithProfile::isObservedTypeEmpty):

  • bytecode/BytecodeList.rb:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::addJITAddIC):
(JSC::CodeBlock::addJITMulIC):
(JSC::CodeBlock::addJITSubIC):
(JSC::CodeBlock::addJITNegIC):
(JSC::CodeBlock::binaryArithProfileForBytecodeOffset):
(JSC::CodeBlock::unaryArithProfileForBytecodeOffset):
(JSC::CodeBlock::binaryArithProfileForPC):
(JSC::CodeBlock::unaryArithProfileForPC):
(JSC::CodeBlock::couldTakeSpecialFastCase):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addMathIC):

  • bytecode/Fits.h:
  • bytecode/MethodOfGettingAValueProfile.cpp:

(JSC::MethodOfGettingAValueProfile::emitReportValue const):
(JSC::MethodOfGettingAValueProfile::reportValue):

  • bytecode/MethodOfGettingAValueProfile.h:

(JSC::MethodOfGettingAValueProfile::MethodOfGettingAValueProfile):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitUnaryOp):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::UnaryOpNode::emitBytecode):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::makeSafe):
(JSC::DFG::ByteCodeParser::makeDivSafe):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::methodOfGettingAValueProfileFor):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileValueSub):
(JSC::DFG::SpeculativeJIT::compileValueNegate):
(JSC::DFG::SpeculativeJIT::compileValueMul):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileValueAdd):
(JSC::FTL::DFG::LowerDFGToB3::compileValueSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueMul):
(JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueNegate):

  • jit/JIT.h:
  • jit/JITAddGenerator.cpp:

(JSC::JITAddGenerator::generateInline):
(JSC::JITAddGenerator::generateFastPath):

  • jit/JITAddGenerator.h:
  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_negate):
(JSC::JIT::emit_op_add):
(JSC::JIT::emitMathICFast):
(JSC::JIT::emitMathICSlow):
(JSC::JIT::emit_op_div):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_sub):

  • jit/JITDivGenerator.cpp:

(JSC::JITDivGenerator::generateFastPath):

  • jit/JITDivGenerator.h:

(JSC::JITDivGenerator::JITDivGenerator):

  • jit/JITInlines.h:

(JSC::JIT::copiedArithProfile):

  • jit/JITMathIC.h:

(JSC::JITMathIC::JITMathIC):
(JSC::JITMathIC::generateInline):
(JSC::JITMathIC::arithProfile const):
(JSC::isBinaryProfileEmpty):
(JSC::JITBinaryMathIC::JITBinaryMathIC):
(JSC::isUnaryProfileEmpty):
(JSC::JITUnaryMathIC::JITUnaryMathIC):

  • jit/JITMulGenerator.cpp:

(JSC::JITMulGenerator::generateInline):
(JSC::JITMulGenerator::generateFastPath):

  • jit/JITMulGenerator.h:
  • jit/JITNegGenerator.cpp:

(JSC::JITNegGenerator::generateInline):
(JSC::JITNegGenerator::generateFastPath):

  • jit/JITNegGenerator.h:
  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • jit/JITSubGenerator.cpp:

(JSC::JITSubGenerator::generateInline):
(JSC::JITSubGenerator::generateFastPath):

  • jit/JITSubGenerator.h:
  • llint/LLIntData.cpp:

(JSC::LLInt::Data::performAssertions):

  • llint/LLIntOffsetsExtractor.cpp:

(JSC::LLIntOffsetsExtractor::dummy):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • parser/ResultType.h:

(JSC::ResultType::ResultType):

  • runtime/CommonSlowPaths.cpp:

(JSC::updateArithProfileForUnaryArithOp):
(JSC::updateArithProfileForBinaryArithOp):
(JSC::SLOW_PATH_DECL):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r250094 r251090  
    453453void JIT::emit_op_negate(const Instruction* currentInstruction)
    454454{
    455     ArithProfile* arithProfile = &currentInstruction->as<OpNegate>().metadata(m_codeBlock).m_arithProfile;
     455    UnaryArithProfile* arithProfile = &currentInstruction->as<OpNegate>().metadata(m_codeBlock).m_arithProfile;
    456456    JITNegIC* negateIC = m_codeBlock->addJITNegIC(arithProfile);
    457457    m_instructionToMathIC.add(currentInstruction, negateIC);
     
    634634}
    635635
    636 ALWAYS_INLINE static OperandTypes getOperandTypes(const ArithProfile& arithProfile)
    637 {
    638     return OperandTypes(arithProfile.lhsResultType(), arithProfile.rhsResultType());
    639 }
    640 
    641636void JIT::emit_op_add(const Instruction* currentInstruction)
    642637{
    643     ArithProfile* arithProfile = &currentInstruction->as<OpAdd>().metadata(m_codeBlock).m_arithProfile;
     638    BinaryArithProfile* arithProfile = &currentInstruction->as<OpAdd>().metadata(m_codeBlock).m_arithProfile;
    644639    JITAddIC* addIC = m_codeBlock->addJITAddIC(arithProfile);
    645640    m_instructionToMathIC.add(currentInstruction, addIC);
     
    686681    bool generatedInlineCode = mathIC->generateInline(*this, mathICGenerationState);
    687682    if (!generatedInlineCode) {
    688         ArithProfile* arithProfile = mathIC->arithProfile();
     683        UnaryArithProfile* arithProfile = mathIC->arithProfile();
    689684        if (arithProfile && shouldEmitProfiling())
    690685            callOperationWithResult(profiledFunction, resultRegs, srcRegs, arithProfile);
     
    709704{
    710705    auto bytecode = currentInstruction->as<Op>();
    711     OperandTypes types = getOperandTypes(copiedArithProfile(bytecode));
     706    BinaryArithProfile arithProfile = copiedArithProfile(bytecode);
    712707    int result = bytecode.m_dst.offset();
    713708    int op1 = bytecode.m_lhs.offset();
     
    728723#endif
    729724
    730     SnippetOperand leftOperand(types.first());
    731     SnippetOperand rightOperand(types.second());
     725    SnippetOperand leftOperand(arithProfile.lhsResultType());
     726    SnippetOperand rightOperand(arithProfile.rhsResultType());
    732727
    733728    if (isOperandConstantInt(op1))
     
    759754        else if (rightOperand.isConst())
    760755            emitGetVirtualRegister(op2, rightRegs);
    761         ArithProfile* arithProfile = mathIC->arithProfile();
     756        BinaryArithProfile* arithProfile = mathIC->arithProfile();
    762757        if (arithProfile && shouldEmitProfiling())
    763758            callOperationWithResult(profiledFunction, resultRegs, leftRegs, rightRegs, arithProfile);
     
    799794#endif
    800795
    801     ArithProfile* arithProfile = mathIC->arithProfile();
     796    UnaryArithProfile* arithProfile = mathIC->arithProfile();
    802797    if (arithProfile && shouldEmitProfiling()) {
    803798        if (mathICGenerationState.shouldSlowPathRepatch)
     
    831826
    832827    auto bytecode = currentInstruction->as<Op>();
    833     OperandTypes types = getOperandTypes(copiedArithProfile(bytecode));
     828    BinaryArithProfile consistentArithProfile = copiedArithProfile(bytecode);
    834829    int result = bytecode.m_dst.offset();
    835830    int op1 = bytecode.m_lhs.offset();
     
    846841#endif
    847842   
    848     SnippetOperand leftOperand(types.first());
    849     SnippetOperand rightOperand(types.second());
     843    SnippetOperand leftOperand(consistentArithProfile.lhsResultType());
     844    SnippetOperand rightOperand(consistentArithProfile.rhsResultType());
    850845
    851846    if (isOperandConstantInt(op1))
     
    865860#endif
    866861
    867     ArithProfile* arithProfile = mathIC->arithProfile();
     862    BinaryArithProfile* arithProfile = mathIC->arithProfile();
    868863    if (arithProfile && shouldEmitProfiling()) {
    869864        if (mathICGenerationState.shouldSlowPathRepatch)
     
    893888{
    894889    auto bytecode = currentInstruction->as<OpDiv>();
    895     auto& metadata = bytecode.metadata(m_codeBlock);
     890    BinaryArithProfile consistentArithProfile = copiedArithProfile(bytecode);
    896891    int result = bytecode.m_dst.offset();
    897892    int op1 = bytecode.m_lhs.offset();
     
    899894
    900895#if USE(JSVALUE64)
    901     OperandTypes types = getOperandTypes(metadata.m_arithProfile);
    902896    JSValueRegs leftRegs = JSValueRegs(regT0);
    903897    JSValueRegs rightRegs = JSValueRegs(regT1);
     
    905899    GPRReg scratchGPR = regT2;
    906900#else
    907     OperandTypes types = getOperandTypes(metadata.m_arithProfile);
    908901    JSValueRegs leftRegs = JSValueRegs(regT1, regT0);
    909902    JSValueRegs rightRegs = JSValueRegs(regT3, regT2);
     
    913906    FPRReg scratchFPR = fpRegT2;
    914907
    915     ArithProfile* arithProfile = nullptr;
     908    BinaryArithProfile* arithProfile = nullptr;
    916909    if (shouldEmitProfiling())
    917910        arithProfile = &currentInstruction->as<OpDiv>().metadata(m_codeBlock).m_arithProfile;
    918911
    919     SnippetOperand leftOperand(types.first());
    920     SnippetOperand rightOperand(types.second());
     912    SnippetOperand leftOperand(consistentArithProfile.lhsResultType());
     913    SnippetOperand rightOperand(consistentArithProfile.rhsResultType());
    921914
    922915    if (isOperandConstantInt(op1))
     
    960953void JIT::emit_op_mul(const Instruction* currentInstruction)
    961954{
    962     ArithProfile* arithProfile = &currentInstruction->as<OpMul>().metadata(m_codeBlock).m_arithProfile;
     955    BinaryArithProfile* arithProfile = &currentInstruction->as<OpMul>().metadata(m_codeBlock).m_arithProfile;
    963956    JITMulIC* mulIC = m_codeBlock->addJITMulIC(arithProfile);
    964957    m_instructionToMathIC.add(currentInstruction, mulIC);
     
    976969void JIT::emit_op_sub(const Instruction* currentInstruction)
    977970{
    978     ArithProfile* arithProfile = &currentInstruction->as<OpSub>().metadata(m_codeBlock).m_arithProfile;
     971    BinaryArithProfile* arithProfile = &currentInstruction->as<OpSub>().metadata(m_codeBlock).m_arithProfile;
    979972    JITSubIC* subIC = m_codeBlock->addJITSubIC(arithProfile);
    980973    m_instructionToMathIC.add(currentInstruction, subIC);
Note: See TracChangeset for help on using the changeset viewer.