Changeset 238543 in webkit


Ignore:
Timestamp:
Nov 26, 2018 6:26:59 PM (5 years ago)
Author:
Caio Lima
Message:

Re-introduce op_bitnot
https://bugs.webkit.org/show_bug.cgi?id=190923

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/bit-not-must-generate.js: Added.
  • stress/bitwise-not-no-int32.js: Added.

Source/JavaScriptCore:

With the introduction of BigInt as a new type, we can't emit bitwise
not as x ^ -1 anymore, because this is incompatible with the new type.
Based on that, this Patch is adding op_bitnot as a new operation
into LLInt, as well as introducing ArithBitNot node into DFG to support
JIT compilation of such opcode. We will use the ValueProfile of this
intruction in the future to generate better code when its operand
is not Int32.

  • assembler/MacroAssemblerARM64.h:

(JSC::MacroAssemblerARM64::not32):

  • assembler/MacroAssemblerARMv7.h:

(JSC::MacroAssemblerARMv7::not32):

  • assembler/MacroAssemblerMIPS.h:

(JSC::MacroAssemblerMIPS::not32):

  • bytecode/BytecodeList.rb:
  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::finishCreation):

  • bytecode/Opcode.h:

(JSC::padOpcodeName):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitUnaryOp):

  • bytecompiler/NodesCodegen.cpp:

(JSC::UnaryPlusNode::emitBytecode):
(JSC::BitwiseNotNode::emitBytecode): Deleted.

  • dfg/DFGAbstractInterpreterInlines.h:

(JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):

  • dfg/DFGBackwardsPropagationPhase.cpp:

(JSC::DFG::BackwardsPropagationPhase::propagate):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):

  • dfg/DFGCapabilities.cpp:

(JSC::DFG::capabilityLevel):

  • dfg/DFGClobberize.h:

(JSC::DFG::clobberize):

  • dfg/DFGDoesGC.cpp:

(JSC::DFG::doesGC):

  • dfg/DFGFixupPhase.cpp:

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

  • dfg/DFGNodeType.h:
  • dfg/DFGOperations.cpp:
  • dfg/DFGOperations.h:
  • dfg/DFGPredictionPropagationPhase.cpp:
  • dfg/DFGSafeToExecute.h:

(JSC::DFG::safeToExecute):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileBitwiseNot):

  • dfg/DFGSpeculativeJIT.h:
  • dfg/DFGSpeculativeJIT32_64.cpp:

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

  • dfg/DFGSpeculativeJIT64.cpp:

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

  • ftl/FTLCapabilities.cpp:

(JSC::FTL::canCompile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNode):
(JSC::FTL::DFG::LowerDFGToB3::compileArithBitNot):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):

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

(JSC::JIT::emit_op_bitnot):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/cloop.rb:
  • parser/NodeConstructors.h:

(JSC::BitwiseNotNode::BitwiseNotNode):

  • parser/Nodes.h:
  • parser/ResultType.h:

(JSC::ResultType::bigIntOrInt32Type):
(JSC::ResultType::forBitOp):

  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:
Location:
trunk
Files:
2 added
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r238511 r238543  
     12018-11-26  Caio Lima  <ticaiolima@gmail.com>
     2
     3        Re-introduce op_bitnot
     4        https://bugs.webkit.org/show_bug.cgi?id=190923
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/bit-not-must-generate.js: Added.
     9        * stress/bitwise-not-no-int32.js: Added.
     10
    1112018-11-26  Saam barati  <sbarati@apple.com>
    212
  • trunk/Source/JavaScriptCore/ChangeLog

    r238511 r238543  
     12018-11-26  Caio Lima  <ticaiolima@gmail.com>
     2
     3        Re-introduce op_bitnot
     4        https://bugs.webkit.org/show_bug.cgi?id=190923
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        With the introduction of BigInt as a new type, we can't emit bitwise
     9        not as `x ^ -1` anymore, because this is incompatible with the new type.
     10        Based on that, this Patch is adding `op_bitnot` as a new operation
     11        into LLInt, as well as introducing ArithBitNot node into DFG to support
     12        JIT compilation of such opcode. We will use the ValueProfile of this
     13        intruction in the future to generate better code when its operand
     14        is not Int32.
     15
     16        * assembler/MacroAssemblerARM64.h:
     17        (JSC::MacroAssemblerARM64::not32):
     18        * assembler/MacroAssemblerARMv7.h:
     19        (JSC::MacroAssemblerARMv7::not32):
     20        * assembler/MacroAssemblerMIPS.h:
     21        (JSC::MacroAssemblerMIPS::not32):
     22        * bytecode/BytecodeList.rb:
     23        * bytecode/BytecodeUseDef.h:
     24        (JSC::computeUsesForBytecodeOffset):
     25        (JSC::computeDefsForBytecodeOffset):
     26        * bytecode/CodeBlock.cpp:
     27        (JSC::CodeBlock::finishCreation):
     28        * bytecode/Opcode.h:
     29        (JSC::padOpcodeName):
     30        * bytecompiler/BytecodeGenerator.cpp:
     31        (JSC::BytecodeGenerator::emitUnaryOp):
     32        * bytecompiler/NodesCodegen.cpp:
     33        (JSC::UnaryPlusNode::emitBytecode):
     34        (JSC::BitwiseNotNode::emitBytecode): Deleted.
     35        * dfg/DFGAbstractInterpreterInlines.h:
     36        (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects):
     37        * dfg/DFGBackwardsPropagationPhase.cpp:
     38        (JSC::DFG::BackwardsPropagationPhase::propagate):
     39        * dfg/DFGByteCodeParser.cpp:
     40        (JSC::DFG::ByteCodeParser::parseBlock):
     41        * dfg/DFGCapabilities.cpp:
     42        (JSC::DFG::capabilityLevel):
     43        * dfg/DFGClobberize.h:
     44        (JSC::DFG::clobberize):
     45        * dfg/DFGDoesGC.cpp:
     46        (JSC::DFG::doesGC):
     47        * dfg/DFGFixupPhase.cpp:
     48        (JSC::DFG::FixupPhase::fixupNode):
     49        * dfg/DFGNodeType.h:
     50        * dfg/DFGOperations.cpp:
     51        * dfg/DFGOperations.h:
     52        * dfg/DFGPredictionPropagationPhase.cpp:
     53        * dfg/DFGSafeToExecute.h:
     54        (JSC::DFG::safeToExecute):
     55        * dfg/DFGSpeculativeJIT.cpp:
     56        (JSC::DFG::SpeculativeJIT::compileBitwiseNot):
     57        * dfg/DFGSpeculativeJIT.h:
     58        * dfg/DFGSpeculativeJIT32_64.cpp:
     59        (JSC::DFG::SpeculativeJIT::compile):
     60        * dfg/DFGSpeculativeJIT64.cpp:
     61        (JSC::DFG::SpeculativeJIT::compile):
     62        * ftl/FTLCapabilities.cpp:
     63        (JSC::FTL::canCompile):
     64        * ftl/FTLLowerDFGToB3.cpp:
     65        (JSC::FTL::DFG::LowerDFGToB3::compileNode):
     66        (JSC::FTL::DFG::LowerDFGToB3::compileArithBitNot):
     67        * jit/JIT.cpp:
     68        (JSC::JIT::privateCompileMainPass):
     69        (JSC::JIT::privateCompileSlowCases):
     70        * jit/JIT.h:
     71        * jit/JITArithmetic.cpp:
     72        (JSC::JIT::emit_op_bitnot):
     73        * llint/LowLevelInterpreter32_64.asm:
     74        * llint/LowLevelInterpreter64.asm:
     75        * offlineasm/cloop.rb:
     76        * parser/NodeConstructors.h:
     77        (JSC::BitwiseNotNode::BitwiseNotNode):
     78        * parser/Nodes.h:
     79        * parser/ResultType.h:
     80        (JSC::ResultType::bigIntOrInt32Type):
     81        (JSC::ResultType::forBitOp):
     82        * runtime/CommonSlowPaths.cpp:
     83        (JSC::SLOW_PATH_DECL):
     84        * runtime/CommonSlowPaths.h:
     85
    1862018-11-26  Saam barati  <sbarati@apple.com>
    287
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARM64.h

    r237173 r238543  
    10461046    }
    10471047
     1048    void not32(RegisterID srcDest)
     1049    {
     1050        m_assembler.mvn<32>(srcDest, srcDest);
     1051    }
     1052
    10481053    void not32(RegisterID src, RegisterID dest)
    10491054    {
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h

    r236604 r238543  
    579579    }
    580580   
     581    void not32(RegisterID srcDest)
     582    {
     583        m_assembler.mvn(srcDest, srcDest);
     584    }
    581585
    582586    // Memory access operations:
  • trunk/Source/JavaScriptCore/assembler/MacroAssemblerMIPS.h

    r231554 r238543  
    817817        move(imm, immTempRegister);
    818818        m_assembler.xorInsn(dest, src, immTempRegister);
     819    }
     820
     821    void not32(RegisterID srcDest)
     822    {
     823        m_assembler.nor(srcDest, srcDest, MIPSRegisters::zero);
    819824    }
    820825
  • trunk/Source/JavaScriptCore/bytecode/BytecodeList.rb

    r237933 r238543  
    270270    }
    271271
     272op :bitnot,
     273    args: {
     274        dst: VirtualRegister,
     275        operand: VirtualRegister,
     276    },
     277    metadata: {
     278        profile: ValueProfile
     279    }
     280
    272281op_group :UnaryOp,
    273282    [
  • trunk/Source/JavaScriptCore/bytecode/BytecodeUseDef.h

    r237547 r238543  
    179179    USES(OpToObject, operand)
    180180    USES(OpNegate, operand)
     181    USES(OpBitnot, operand)
    181182    USES(OpEqNull, operand)
    182183    USES(OpNeqNull, operand)
     
    427428    DEFS(OpBitxor, dst)
    428429    DEFS(OpBitor, dst)
     430    DEFS(OpBitnot, dst)
    429431    DEFS(OpInc, srcDst)
    430432    DEFS(OpDec, srcDst)
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp

    r238367 r238543  
    567567        LINK(OpBitand, profile)
    568568        LINK(OpBitor, profile)
     569        LINK(OpBitnot, profile)
    569570
    570571        LINK(OpGetById, profile, hitCountForLLIntCaching)
  • trunk/Source/JavaScriptCore/bytecode/Opcode.h

    r238067 r238543  
    110110    macro(OpBitand) \
    111111    macro(OpBitor) \
     112    macro(OpBitnot) \
    112113
    113114#define FOR_EACH_OPCODE_WITH_ARRAY_PROFILE(macro) \
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r238281 r238543  
    16081608    case op_negate:
    16091609        OpNegate::emit(this, dst, src, types);
     1610        break;
     1611    case op_bitnot:
     1612        emitUnaryOp<OpBitnot>(dst, src);
    16101613        break;
    16111614    case op_to_number:
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r237547 r238543  
    18901890    return generator.emitToNumber(generator.finalDestination(dst), src.get());
    18911891}
    1892 
    1893 // ------------------------------ BitwiseNotNode -----------------------------------
    1894  
    1895 RegisterID* BitwiseNotNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
    1896 {
    1897     RefPtr<RegisterID> src2 = generator.emitLoad(nullptr, jsNumber(-1));
    1898     RefPtr<RegisterID> src1 = generator.emitNode(m_expr);
    1899     return generator.emitBinaryOp<OpBitxor>(generator.finalDestination(dst, src1.get()), src1.get(), src2.get(), OperandTypes(m_expr->resultDescriptor(), ResultType::numberTypeIsInt32()));
    1900 }
    19011892 
    19021893// ------------------------------ LogicalNotNode -----------------------------------
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h

    r237285 r238543  
    376376    }
    377377           
     378    case ArithBitNot: {
     379        if (node->child1().useKind() == UntypedUse) {
     380            clobberWorld();
     381            setNonCellTypeForNode(node, SpecInt32Only);
     382            break;
     383        }
     384
     385        JSValue operand = forNode(node->child1()).value();
     386        if (operand && operand.isInt32()) {
     387            int32_t a = operand.asInt32();
     388            setConstant(node, JSValue(~a));
     389            break;
     390        }
     391
     392        setNonCellTypeForNode(node, SpecInt32Only);
     393        break;
     394    }
     395
    378396    case ValueBitOr:
    379397    case ValueBitAnd:
  • trunk/Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp

    r236901 r238543  
    208208            break;
    209209           
     210        case ArithBitNot: {
     211            flags |= NodeBytecodeUsesAsInt;
     212            flags &= ~(NodeBytecodeUsesAsNumber | NodeBytecodeNeedsNegZero | NodeBytecodeUsesAsOther);
     213            flags &= ~NodeBytecodeUsesAsArrayIndex;
     214            node->child1()->mergeFlags(flags);
     215            break;
     216        }
     217
    210218        case ArithBitAnd:
    211219        case ArithBitOr:
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r237972 r238543  
    48924892           
    48934893        // === Bitwise operations ===
     4894
     4895        case op_bitnot: {
     4896            auto bytecode = currentInstruction->as<OpBitnot>();
     4897            Node* op1 = get(bytecode.operand);
     4898            set(bytecode.dst, addToGraph(ArithBitNot, op1));
     4899            NEXT_OPCODE(op_bitnot);
     4900        }
    48944901
    48954902        case op_bitand: {
  • trunk/Source/JavaScriptCore/dfg/DFGCapabilities.cpp

    r237547 r238543  
    117117    case op_check_tdz:
    118118    case op_create_this:
     119    case op_bitnot:
    119120    case op_bitand:
    120121    case op_bitor:
  • trunk/Source/JavaScriptCore/dfg/DFGClobberize.h

    r237285 r238543  
    263263        return;
    264264
     265    case ArithBitNot:
     266        if (node->child1().useKind() == UntypedUse) {
     267            read(World);
     268            write(Heap);
     269            return;
     270        }
     271        def(PureValue(node));
     272        return;
     273
    265274    case ArithBitAnd:
    266275    case ArithBitOr:
  • trunk/Source/JavaScriptCore/dfg/DFGDoesGC.cpp

    r237285 r238543  
    6868    case PhantomLocal:
    6969    case SetArgument:
     70    case ArithBitNot:
    7071    case ArithBitAnd:
    7172    case ArithBitOr:
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r237972 r238543  
    144144        }
    145145   
     146        case ArithBitNot: {
     147            if (node->child1().node()->shouldSpeculateUntypedForBitOps()) {
     148                fixEdge<UntypedUse>(node->child1());
     149                break;
     150            }
     151
     152            fixIntConvertingEdge(node->child1());
     153            node->clearFlags(NodeMustGenerate);
     154            break;
     155        }
     156
    146157        case ArithBitOr:
    147158        case ArithBitAnd: {
  • trunk/Source/JavaScriptCore/dfg/DFGNodeType.h

    r237285 r238543  
    112112    \
    113113    /* Nodes for bitwise operations. */\
     114    macro(ArithBitNot, NodeResultInt32 | NodeMustGenerate) \
    114115    macro(ValueBitAnd, NodeResultJS | NodeMustGenerate) \
    115116    macro(ArithBitAnd, NodeResultInt32) \
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r238425 r238543  
    334334}
    335335
     336EncodedJSValue JIT_OPERATION operationValueBitNot(ExecState* exec, EncodedJSValue encodedOp1)
     337{
     338    VM* vm = &exec->vm();
     339    NativeCallFrameTracer tracer(vm, exec);
     340    auto scope = DECLARE_THROW_SCOPE(*vm);
     341
     342    JSValue op1 = JSValue::decode(encodedOp1);
     343
     344    int32_t operandValue = op1.toInt32(exec);
     345    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     346
     347    return JSValue::encode(jsNumber(~operandValue));
     348}
     349
    336350EncodedJSValue JIT_OPERATION operationValueBitAnd(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2)
    337351{
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.h

    r237972 r238543  
    4949EncodedJSValue JIT_OPERATION operationToThis(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
    5050EncodedJSValue JIT_OPERATION operationToThisStrict(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
     51EncodedJSValue JIT_OPERATION operationValueBitNot(ExecState*, EncodedJSValue encodedOp1) WTF_INTERNAL;
    5152EncodedJSValue JIT_OPERATION operationValueBitAnd(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
    5253EncodedJSValue JIT_OPERATION operationValueBitOr(ExecState*, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) WTF_INTERNAL;
  • trunk/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp

    r237972 r238543  
    738738        }
    739739
     740        case ArithBitNot:
    740741        case ArithBitAnd:
    741742        case ArithBitOr:
  • trunk/Source/JavaScriptCore/dfg/DFGSafeToExecute.h

    r237285 r238543  
    198198    case PhantomLocal:
    199199    case SetArgument:
     200    case ArithBitNot:
    200201    case ArithBitAnd:
    201202    case ArithBitOr:
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r238437 r238543  
    35093509    blessedBooleanResult(resultGPR, node);
    35103510    return;
     3511}
     3512
     3513void SpeculativeJIT::compileBitwiseNot(Node* node)
     3514{
     3515    Edge& child1 = node->child1();
     3516
     3517    if (child1.useKind() == UntypedUse) {
     3518        JSValueOperand operand(this, child1);
     3519        JSValueRegs operandRegs = operand.jsValueRegs();
     3520
     3521        flushRegisters();
     3522        JSValueRegsFlushedCallResult result(this);
     3523        JSValueRegs resultRegs = result.regs();
     3524        callOperation(operationValueBitNot, resultRegs, operandRegs);
     3525        m_jit.exceptionCheck();
     3526
     3527        jsValueResult(resultRegs, node);
     3528        return;
     3529    }
     3530
     3531    SpeculateInt32Operand operand(this, child1);
     3532    GPRTemporary result(this);
     3533    GPRReg resultGPR = result.gpr();
     3534
     3535    m_jit.move(operand.gpr(), resultGPR);
     3536
     3537    m_jit.not32(resultGPR);
     3538
     3539    int32Result(resultGPR, node);
    35113540}
    35123541
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r238439 r238543  
    13291329    void compileUInt32ToNumber(Node*);
    13301330    void compileDoubleAsInt32(Node*);
     1331
     1332    void compileBitwiseNot(Node*);
    13311333
    13321334    template<typename SnippetGenerator, J_JITOperation_EJJ slowPathFunction>
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r237285 r238543  
    19891989    case BitXor:
    19901990        compileBitwiseOp(node);
     1991        break;
     1992
     1993    case ArithBitNot:
     1994        compileBitwiseNot(node);
    19911995        break;
    19921996
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

    r237285 r238543  
    20732073        // the argument is not used.
    20742074        recordSetLocal(dataFormatFor(node->variableAccessData()->flushFormat()));
     2075        break;
     2076
     2077    case ArithBitNot:
     2078        compileBitwiseNot(node);
    20752079        break;
    20762080
  • trunk/Source/JavaScriptCore/ftl/FTLCapabilities.cpp

    r237285 r238543  
    5959    case SetArgument:
    6060    case Return:
     61    case ArithBitNot:
    6162    case ArithBitAnd:
    6263    case ArithBitOr:
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r238436 r238543  
    654654            compileArithUnary();
    655655            break;
     656        case ArithBitNot:
     657            compileArithBitNot();
     658            break;
    656659        case ValueBitAnd:
    657660            compileValueBitAnd();
     
    28462849    }
    28472850   
     2851    void compileArithBitNot()
     2852    {
     2853        if (m_node->child1().useKind() == UntypedUse) {
     2854            LValue operand = lowJSValue(m_node->child1());
     2855            LValue result = vmCall(pointerType(), m_out.operation(operationValueBitNot), m_callFrame, operand);
     2856            setJSValue(result);
     2857            return;
     2858        }
     2859
     2860        setInt32(m_out.bitNot(lowInt32(m_node->child1())));
     2861    }
     2862
    28482863    void compileValueBitAnd()
    28492864    {
  • trunk/Source/JavaScriptCore/jit/JIT.cpp

    r238162 r238543  
    305305
    306306        DEFINE_OP(op_add)
     307        DEFINE_OP(op_bitnot)
    307308        DEFINE_OP(op_bitand)
    308309        DEFINE_OP(op_bitor)
     
    542543        DEFINE_SLOWCASE_SLOW_OP(inc)
    543544        DEFINE_SLOWCASE_SLOW_OP(dec)
     545        DEFINE_SLOWCASE_SLOW_OP(bitnot)
    544546        DEFINE_SLOWCASE_SLOW_OP(bitand)
    545547        DEFINE_SLOWCASE_SLOW_OP(bitor)
  • trunk/Source/JavaScriptCore/jit/JIT.h

    r238414 r238543  
    506506        void emit_op_bitor(const Instruction*);
    507507        void emit_op_bitxor(const Instruction*);
     508        void emit_op_bitnot(const Instruction*);
    508509        void emit_op_call(const Instruction*);
    509510        void emit_op_tail_call(const Instruction*);
  • trunk/Source/JavaScriptCore/jit/JITArithmetic.cpp

    r237547 r238543  
    514514}
    515515
     516void JIT::emit_op_bitnot(const Instruction* currentInstruction)
     517{
     518    auto bytecode = currentInstruction->as<OpBitnot>();
     519    int result = bytecode.dst.offset();
     520    int op1 = bytecode.operand.offset();
     521
     522#if USE(JSVALUE64)
     523    JSValueRegs leftRegs = JSValueRegs(regT0);
     524#else
     525    JSValueRegs leftRegs = JSValueRegs(regT1, regT0);
     526#endif
     527
     528    emitGetVirtualRegister(op1, leftRegs);
     529
     530    addSlowCase(branchIfNotInt32(leftRegs));
     531    not32(leftRegs.payloadGPR());
     532#if USE(JSVALUE64)
     533    boxInt32(leftRegs.payloadGPR(), leftRegs);
     534#endif
     535
     536    emitValueProfilingSiteIfProfiledOpcode(bytecode);
     537
     538    emitPutVirtualRegister(result, leftRegs);
     539}
     540
    516541void JIT::emit_op_bitand(const Instruction* currentInstruction)
    517542{
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r238439 r238543  
    11651165
    11661166bitOpProfiled(bitor, OpBitor,
    1167         macro (left, right) ori left, right end)
    1168 
     1167    macro (left, right) ori left, right end)
     1168
     1169llintOpWithProfile(op_bitnot, OpBitnot, macro (size, get, dispatch, return)
     1170    get(operand, t0)
     1171    loadConstantOrVariable(size, t0, t2, t3)
     1172    bineq t2, Int32Tag, .opBitNotSlow
     1173    noti t3
     1174    return (Int32Tag, t3)
     1175
     1176 .opBitNotSlow:
     1177    callSlowPath(_slow_path_bitnot)
     1178    dispatch()
     1179end)
    11691180
    11701181llintOp(op_overrides_has_instance, OpOverridesHasInstance, macro (size, get, dispatch)
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r238435 r238543  
    11121112    macro (left, right) urshifti left, right end)
    11131113
     1114bitOpProfiled(bitand, OpBitand,
     1115    macro (left, right) andi left, right end)
     1116
     1117bitOpProfiled(bitor, OpBitor,
     1118    macro (left, right) ori left, right end)
    11141119
    11151120bitOp(bitxor, OpBitxor,
    11161121    macro (left, right) xori left, right end)
    11171122
    1118 
    1119 bitOpProfiled(bitand, OpBitand,
    1120     macro (left, right) andi left, right end)
    1121 
    1122 
    1123 bitOpProfiled(bitor, OpBitor,
    1124     macro (left, right) ori left, right end)
     1123llintOpWithProfile(op_bitnot, OpBitnot, macro (size, get, dispatch, return)
     1124    get(operand, t0)
     1125    loadConstantOrVariableInt32(size, t0, t3, .opBitNotSlow)
     1126    noti t3
     1127    orq tagTypeNumber, t3
     1128    return(t3)
     1129.opBitNotSlow:
     1130    callSlowPath(_slow_path_bitnot)
     1131    dispatch()
     1132end)
    11251133
    11261134
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r237547 r238543  
    595595
    596596        when "noti"
    597             cloopEmitUnaryOperation(operands, :int32, "!")
     597            cloopEmitUnaryOperation(operands, :int32, "~")
    598598
    599599        when "loadi"
  • trunk/Source/JavaScriptCore/parser/NodeConstructors.h

    r233937 r238543  
    514514
    515515    inline BitwiseNotNode::BitwiseNotNode(const JSTokenLocation& location, ExpressionNode* expr)
    516         : ExpressionNode(location, ResultType::forBitOp())
    517         , m_expr(expr)
     516        : UnaryOpNode(location, ResultType::forBitOp(), expr, op_bitnot)
    518517    {
    519518    }
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r233937 r238543  
    11001100    };
    11011101
    1102     class BitwiseNotNode final : public ExpressionNode {
     1102    class BitwiseNotNode final : public UnaryOpNode {
    11031103    public:
    11041104        BitwiseNotNode(const JSTokenLocation&, ExpressionNode*);
    1105 
    1106     protected:
    1107         ExpressionNode* expr() { return m_expr; }
    1108         const ExpressionNode* expr() const { return m_expr; }
    1109 
    1110     private:
    1111         RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0) override;
    1112 
    1113         ExpressionNode* m_expr;
    11141105    };
    11151106 
  • trunk/Source/JavaScriptCore/parser/ResultType.h

    r237547 r238543  
    137137        }
    138138       
     139        static constexpr ResultType bigIntOrInt32Type()
     140        {
     141            return ResultType(TypeMaybeBigInt | TypeInt32);
     142        }
     143
    139144        static constexpr ResultType unknownType()
    140145        {
     
    170175        static constexpr ResultType forBitOp()
    171176        {
    172             return numberTypeIsInt32();
     177            return bigIntOrInt32Type();
    173178        }
    174179
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r238425 r238543  
    691691}
    692692
     693SLOW_PATH_DECL(slow_path_bitnot)
     694{
     695    BEGIN();
     696    auto bytecode = pc->as<OpBitnot>();
     697    int32_t operand = GET_C(bytecode.operand).jsValue().toInt32(exec);
     698    CHECK_EXCEPTION();
     699    RETURN_PROFILED(jsNumber(~operand));
     700}
     701
    693702SLOW_PATH_DECL(slow_path_bitand)
    694703{
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h

    r237547 r238543  
    325325SLOW_PATH_HIDDEN_DECL(slow_path_urshift);
    326326SLOW_PATH_HIDDEN_DECL(slow_path_unsigned);
     327SLOW_PATH_HIDDEN_DECL(slow_path_bitnot);
    327328SLOW_PATH_HIDDEN_DECL(slow_path_bitand);
    328329SLOW_PATH_HIDDEN_DECL(slow_path_bitor);
Note: See TracChangeset for help on using the changeset viewer.