WebKit Bugzilla
Attachment 359607 Details for
Bug 192663
: [BigInt] Add ValueBitRShift into DFG
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192663-20190119120603.patch (text/plain), 28.02 KB, created by
Caio Lima
on 2019-01-19 07:06:05 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Caio Lima
Created:
2019-01-19 07:06:05 PST
Size:
28.02 KB
patch
obsolete
>Subversion Revision: 240201 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index d6c084b72f51b6bbc9cce155c6088fde981d58bc..70f23c0035a7d61c0cee9be20c2630abcf166641 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,60 @@ >+2019-01-19 Caio Lima <ticaiolima@gmail.com> >+ >+ [BigInt] Add ValueBitRShift into DFG >+ https://bugs.webkit.org/show_bug.cgi?id=192663 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We are introducing a new node called ValueBitRShift that is >+ responsible to handle speculation of UntypedUse and BigIntUse during >+ DFG. Following the approach from other bitwise operations, we >+ now have 2 nodes to handle ">>" operator during JIT, mainly because >+ of the introduction of BigInt, that makes this operator result into >+ Int32 or BigInt. We renamed BitRShift node to ArithBitRShift and such >+ node handles Integers and Numbers speculation and can only return >+ Int32 values. >+ >+ * dfg/DFGAbstractInterpreterInlines.h: >+ (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): >+ * dfg/DFGBackwardsPropagationPhase.cpp: >+ (JSC::DFG::BackwardsPropagationPhase::isWithinPowerOfTwo): >+ (JSC::DFG::BackwardsPropagationPhase::propagate): >+ * dfg/DFGByteCodeParser.cpp: >+ (JSC::DFG::ByteCodeParser::parseBlock): >+ * dfg/DFGClobberize.h: >+ (JSC::DFG::clobberize): >+ * dfg/DFGDoesGC.cpp: >+ (JSC::DFG::doesGC): >+ * dfg/DFGFixupPhase.cpp: >+ (JSC::DFG::FixupPhase::fixupNode): >+ * dfg/DFGNode.h: >+ (JSC::DFG::Node::hasNumericResult): >+ * dfg/DFGNodeType.h: >+ * dfg/DFGOperations.cpp: >+ * dfg/DFGOperations.h: >+ * dfg/DFGPredictionPropagationPhase.cpp: >+ * dfg/DFGSafeToExecute.h: >+ (JSC::DFG::safeToExecute): >+ * dfg/DFGSpeculativeJIT.cpp: >+ (JSC::DFG::SpeculativeJIT::emitUntypedRightShiftBitOp): >+ (JSC::DFG::SpeculativeJIT::compileValueBitRShift): >+ (JSC::DFG::SpeculativeJIT::compileShiftOp): >+ * dfg/DFGSpeculativeJIT.h: >+ (JSC::DFG::SpeculativeJIT::shiftOp): >+ * dfg/DFGSpeculativeJIT32_64.cpp: >+ (JSC::DFG::SpeculativeJIT::compile): >+ * dfg/DFGSpeculativeJIT64.cpp: >+ (JSC::DFG::SpeculativeJIT::compile): >+ * dfg/DFGStrengthReductionPhase.cpp: >+ (JSC::DFG::StrengthReductionPhase::handleNode): >+ * ftl/FTLCapabilities.cpp: >+ (JSC::FTL::canCompile): >+ * ftl/FTLLowerDFGToB3.cpp: >+ (JSC::FTL::DFG::LowerDFGToB3::compileNode): >+ (JSC::FTL::DFG::LowerDFGToB3::compileValueBitRShift): >+ (JSC::FTL::DFG::LowerDFGToB3::compileArithBitRShift): >+ (JSC::FTL::DFG::LowerDFGToB3::compileBitRShift): Deleted. >+ > 2019-01-19 Antoine Quint <graouts@apple.com> > > Add a POINTER_EVENTS feature flag >diff --git a/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h b/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h >index b966adcbf7a50e1fd07d836118eb81088ef8b58e..b6e1ec0e686563eebbb828774ef95aed2392ba91 100644 >--- a/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h >+++ b/Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h >@@ -397,6 +397,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi > case ValueBitXor: > case ValueBitAnd: > case ValueBitOr: >+ case ValueBitRShift: > if (node->binaryUseKind() == BigIntUse) > setTypeForNode(node, SpecBigInt); > else { >@@ -408,7 +409,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi > case ArithBitAnd: > case ArithBitOr: > case ArithBitXor: >- case BitRShift: >+ case ArithBitRShift: > case BitLShift: > case BitURShift: { > if (node->child1().useKind() == UntypedUse || node->child2().useKind() == UntypedUse) { >@@ -432,7 +433,7 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi > case ArithBitXor: > setConstant(node, JSValue(a ^ b)); > break; >- case BitRShift: >+ case ArithBitRShift: > setConstant(node, JSValue(a >> static_cast<uint32_t>(b))); > break; > case BitLShift: >diff --git a/Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp b/Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp >index f4ce71eba58adbd5b36109e6fb6b32962cdd72f9..e2a29763a723341f9c5f88e5c524a543f8c2be16 100644 >--- a/Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp >+++ b/Source/JavaScriptCore/dfg/DFGBackwardsPropagationPhase.cpp >@@ -127,7 +127,8 @@ private: > return power > 31; > } > >- case BitRShift: >+ case ArithBitRShift: >+ case ValueBitRShift: > case BitURShift: { > if (power > 31) > return true; >@@ -221,10 +222,11 @@ private: > case ArithBitAnd: > case ArithBitOr: > case ArithBitXor: >+ case ArithBitRShift: >+ case ValueBitRShift: > case ValueBitAnd: > case ValueBitOr: > case ValueBitXor: >- case BitRShift: > case BitLShift: > case BitURShift: > case ArithIMul: { >diff --git a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp >index 4e18df703d3d216686f5859824f2ac6cb97fe00e..e71aa197053303b3d96b8c4275f77e49768390a2 100644 >--- a/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp >+++ b/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp >@@ -4955,7 +4955,10 @@ void ByteCodeParser::parseBlock(unsigned limit) > auto bytecode = currentInstruction->as<OpRshift>(); > Node* op1 = get(bytecode.m_lhs); > Node* op2 = get(bytecode.m_rhs); >- set(bytecode.m_dst, addToGraph(BitRShift, op1, op2)); >+ if (op1->hasNumberOrAnyIntResult() && op2->hasNumberOrAnyIntResult()) >+ set(bytecode.m_dst, addToGraph(ArithBitRShift, op1, op2)); >+ else >+ set(bytecode.m_dst, addToGraph(ValueBitRShift, op1, op2)); > NEXT_OPCODE(op_rshift); > } > >diff --git a/Source/JavaScriptCore/dfg/DFGClobberize.h b/Source/JavaScriptCore/dfg/DFGClobberize.h >index 9c2707332c5e75acf05881bd8841a16852c715bc..3b17665880650e1e9c6848651d677def1c6f5947 100644 >--- a/Source/JavaScriptCore/dfg/DFGClobberize.h >+++ b/Source/JavaScriptCore/dfg/DFGClobberize.h >@@ -272,7 +272,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu > case ArithBitOr: > case ArithBitXor: > case BitLShift: >- case BitRShift: >+ case ArithBitRShift: > case BitURShift: > if (node->child1().useKind() == UntypedUse || node->child2().useKind() == UntypedUse) { > read(World); >@@ -670,6 +670,7 @@ void clobberize(Graph& graph, Node* node, const ReadFunctor& read, const WriteFu > case ValueSub: > case ValueMul: > case ValueDiv: >+ case ValueBitRShift: > if (node->isBinaryUseKind(BigIntUse)) { > def(PureValue(node)); > return; >diff --git a/Source/JavaScriptCore/dfg/DFGDoesGC.cpp b/Source/JavaScriptCore/dfg/DFGDoesGC.cpp >index 4f79af6c4cc5c1d9a9581e712441ad703994cb2d..0f535c503eb3dba5ead3f7d9c49fdd060c5b9870 100644 >--- a/Source/JavaScriptCore/dfg/DFGDoesGC.cpp >+++ b/Source/JavaScriptCore/dfg/DFGDoesGC.cpp >@@ -72,7 +72,7 @@ bool doesGC(Graph& graph, Node* node) > case ArithBitOr: > case ArithBitXor: > case BitLShift: >- case BitRShift: >+ case ArithBitRShift: > case BitURShift: > case ValueToInt32: > case UInt32ToNumber: >@@ -100,6 +100,7 @@ bool doesGC(Graph& graph, Node* node) > case ValueBitAnd: > case ValueBitOr: > case ValueBitXor: >+ case ValueBitRShift: > case ValueAdd: > case ValueSub: > case ValueMul: >diff --git a/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp b/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp >index 18b65a306c9659ff15f3feafe9bf8df8a989cab9..a9ff042600f2c40aa778cf8b8f1bc3c217a38005 100644 >--- a/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp >+++ b/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp >@@ -196,6 +196,7 @@ private: > break; > } > >+ case ValueBitRShift: > case ValueBitXor: > case ValueBitOr: > case ValueBitAnd: { >@@ -222,6 +223,9 @@ private: > case ValueBitAnd: > node->setOp(ArithBitAnd); > break; >+ case ValueBitRShift: >+ node->setOp(ArithBitRShift); >+ break; > default: > DFG_CRASH(m_graph, node, "Unexpected node during ValueBit operation fixup"); > break; >@@ -253,7 +257,7 @@ private: > break; > } > >- case BitRShift: >+ case ArithBitRShift: > case BitLShift: > case BitURShift: { > if (Node::shouldSpeculateUntypedForBitOps(node->child1().node(), node->child2().node())) { >diff --git a/Source/JavaScriptCore/dfg/DFGNode.h b/Source/JavaScriptCore/dfg/DFGNode.h >index 4c7deb6ad68ab008c2a663b9e413f710a2ade36a..b9a0f9f41592a07d759c235ba5ace3c8a3b52079 100644 >--- a/Source/JavaScriptCore/dfg/DFGNode.h >+++ b/Source/JavaScriptCore/dfg/DFGNode.h >@@ -1387,6 +1387,7 @@ public: > case ValueBitOr: > case ValueBitXor: > case ValueNegate: >+ case ValueBitRShift: > return true; > default: > return false; >diff --git a/Source/JavaScriptCore/dfg/DFGNodeType.h b/Source/JavaScriptCore/dfg/DFGNodeType.h >index ded0e2680b8e82018c3d4868335b4d03e4ac8fd2..b7fac366a60a3c8eb41e2c0726835daef9713255 100644 >--- a/Source/JavaScriptCore/dfg/DFGNodeType.h >+++ b/Source/JavaScriptCore/dfg/DFGNodeType.h >@@ -119,7 +119,8 @@ namespace JSC { namespace DFG { > macro(ValueBitXor, NodeResultJS | NodeMustGenerate) \ > macro(ArithBitXor, NodeResultInt32) \ > macro(BitLShift, NodeResultInt32) \ >- macro(BitRShift, NodeResultInt32) \ >+ macro(ArithBitRShift, NodeResultInt32) \ >+ macro(ValueBitRShift, NodeResultJS | NodeMustGenerate) \ > macro(BitURShift, NodeResultInt32) \ > /* Bitwise operators call ToInt32 on their operands. */\ > macro(ValueToInt32, NodeResultInt32) \ >diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp >index 6075ea327ceb92b0b9cbb726d2af6707c4abcdcd..042eacae7d3b83824cabd788c9080b7e41d95d42 100644 >--- a/Source/JavaScriptCore/dfg/DFGOperations.cpp >+++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp >@@ -474,11 +474,22 @@ EncodedJSValue JIT_OPERATION operationValueBitRShift(ExecState* exec, EncodedJSV > JSValue op1 = JSValue::decode(encodedOp1); > JSValue op2 = JSValue::decode(encodedOp2); > >- int32_t a = op1.toInt32(exec); >+ auto leftNumeric = op1.toBigIntOrInt32(exec); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); >- scope.release(); >- uint32_t b = op2.toUInt32(exec); >- return JSValue::encode(jsNumber(a >> (b & 0x1f))); >+ auto rightNumeric = op2.toBigIntOrInt32(exec); >+ RETURN_IF_EXCEPTION(scope, encodedJSValue()); >+ >+ if (WTF::holds_alternative<JSBigInt*>(leftNumeric) || WTF::holds_alternative<JSBigInt*>(rightNumeric)) { >+ if (WTF::holds_alternative<JSBigInt*>(leftNumeric) && WTF::holds_alternative<JSBigInt*>(rightNumeric)) { >+ JSBigInt* result = JSBigInt::signedRightShift(exec, WTF::get<JSBigInt*>(leftNumeric), WTF::get<JSBigInt*>(rightNumeric)); >+ RETURN_IF_EXCEPTION(scope, encodedJSValue()); >+ return JSValue::encode(result); >+ } >+ >+ return throwVMTypeError(exec, scope, "Invalid mix of BigInt and other type in signed right shift operation."); >+ } >+ >+ return JSValue::encode(jsNumber(WTF::get<int32_t>(leftNumeric) >> (WTF::get<int32_t>(rightNumeric) & 0x1f))); > } > > EncodedJSValue JIT_OPERATION operationValueBitURShift(ExecState* exec, EncodedJSValue encodedOp1, EncodedJSValue encodedOp2) >@@ -1387,6 +1398,17 @@ JSCell* JIT_OPERATION operationAddBigInt(ExecState* exec, JSCell* op1, JSCell* o > return JSBigInt::add(exec, leftOperand, rightOperand); > } > >+JSCell* JIT_OPERATION operationBitRShiftBigInt(ExecState* exec, JSCell* op1, JSCell* op2) >+{ >+ VM* vm = &exec->vm(); >+ NativeCallFrameTracer tracer(vm, exec); >+ >+ JSBigInt* leftOperand = jsCast<JSBigInt*>(op1); >+ JSBigInt* rightOperand = jsCast<JSBigInt*>(op2); >+ >+ return JSBigInt::signedRightShift(exec, leftOperand, rightOperand); >+} >+ > JSCell* JIT_OPERATION operationBitOrBigInt(ExecState* exec, JSCell* op1, JSCell* op2) > { > VM* vm = &exec->vm(); >diff --git a/Source/JavaScriptCore/dfg/DFGOperations.h b/Source/JavaScriptCore/dfg/DFGOperations.h >index 8b76f4d6bf37401de2c4a97c1c3205527cc63951..584940ce066789affe08c87d2c99a79bb189705f 100644 >--- a/Source/JavaScriptCore/dfg/DFGOperations.h >+++ b/Source/JavaScriptCore/dfg/DFGOperations.h >@@ -172,6 +172,7 @@ JSCell* JIT_OPERATION operationDivBigInt(ExecState*, JSCell* op1, JSCell* op2) W > JSCell* JIT_OPERATION operationBitAndBigInt(ExecState*, JSCell* op1, JSCell* op2) WTF_INTERNAL; > JSCell* JIT_OPERATION operationBitOrBigInt(ExecState*, JSCell* op1, JSCell* op2) WTF_INTERNAL; > JSCell* JIT_OPERATION operationAddBigInt(ExecState*, JSCell* op1, JSCell* op2) WTF_INTERNAL; >+JSCell* JIT_OPERATION operationBitRShiftBigInt(ExecState*, JSCell* op1, JSCell* op2) WTF_INTERNAL; > JSCell* JIT_OPERATION operationBitXorBigInt(ExecState*, JSCell* op1, JSCell* op2) WTF_INTERNAL; > size_t JIT_OPERATION operationSameValue(ExecState*, EncodedJSValue, EncodedJSValue) WTF_INTERNAL; > JSCell* JIT_OPERATION operationCreateActivationDirect(ExecState*, Structure*, JSScope*, SymbolTable*, EncodedJSValue); >diff --git a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp >index b0d49e08539baafadd215df51c784938cddee2f4..dacc83aef23bd8369a699e9edad483be1ee70dde 100644 >--- a/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp >+++ b/Source/JavaScriptCore/dfg/DFGPredictionPropagationPhase.cpp >@@ -277,6 +277,21 @@ private: > break; > } > >+ case ValueBitRShift: { >+ SpeculatedType left = node->child1()->prediction(); >+ SpeculatedType right = node->child2()->prediction(); >+ >+ if (left && right) { >+ if (isBigIntSpeculation(left) && isBigIntSpeculation(right)) >+ changed |= mergePrediction(SpecBigInt); >+ else if (isFullNumberOrBooleanSpeculationExpectingDefined(left) && isFullNumberOrBooleanSpeculationExpectingDefined(right)) >+ changed |= mergePrediction(SpecInt32Only); >+ else >+ changed |= mergePrediction(SpecBigInt | SpecInt32Only); >+ } >+ break; >+ } >+ > case ValueNegate: > case ArithNegate: { > SpeculatedType prediction = node->child1()->prediction(); >@@ -750,7 +765,7 @@ private: > case ArithBitAnd: > case ArithBitOr: > case ArithBitXor: >- case BitRShift: >+ case ArithBitRShift: > case BitLShift: > case BitURShift: > case ArithIMul: >@@ -1113,6 +1128,7 @@ private: > case GetLocal: > case SetLocal: > case UInt32ToNumber: >+ case ValueBitRShift: > case ValueNegate: > case ValueAdd: > case ValueSub: >diff --git a/Source/JavaScriptCore/dfg/DFGSafeToExecute.h b/Source/JavaScriptCore/dfg/DFGSafeToExecute.h >index c4e566cb6c6ba121336b6c2e28bf70d951857fe1..5883761e6345408dbbb7cc1f0892311dabfdb657 100644 >--- a/Source/JavaScriptCore/dfg/DFGSafeToExecute.h >+++ b/Source/JavaScriptCore/dfg/DFGSafeToExecute.h >@@ -203,7 +203,7 @@ bool safeToExecute(AbstractStateType& state, Graph& graph, Node* node, bool igno > case ArithBitOr: > case ArithBitXor: > case BitLShift: >- case BitRShift: >+ case ArithBitRShift: > case BitURShift: > case ValueToInt32: > case UInt32ToNumber: >@@ -231,6 +231,7 @@ bool safeToExecute(AbstractStateType& state, Graph& graph, Node* node, bool igno > case ValueBitAnd: > case ValueBitXor: > case ValueBitOr: >+ case ValueBitRShift: > case ValueNegate: > case ValueAdd: > case ValueSub: >diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp >index 948bb979c8e65429f4bc620a24672ece294b50ac..2c4c960c68fc6fe295124e96ad7bb1865f703400 100644 >--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp >+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp >@@ -3719,9 +3719,9 @@ void SpeculativeJIT::compileBitwiseOp(Node* node) > > void SpeculativeJIT::emitUntypedRightShiftBitOp(Node* node) > { >- J_JITOperation_EJJ snippetSlowPathFunction = node->op() == BitRShift >+ J_JITOperation_EJJ snippetSlowPathFunction = node->op() == ValueBitRShift > ? operationValueBitRShift : operationValueBitURShift; >- JITRightShiftGenerator::ShiftType shiftType = node->op() == BitRShift >+ JITRightShiftGenerator::ShiftType shiftType = node->op() == ValueBitRShift > ? JITRightShiftGenerator::SignedShift : JITRightShiftGenerator::UnsignedShift; > > Edge& leftChild = node->child1(); >@@ -3816,6 +3816,30 @@ void SpeculativeJIT::emitUntypedRightShiftBitOp(Node* node) > return; > } > >+void SpeculativeJIT::compileValueBitRShift(Node* node) >+{ >+ if (node->isBinaryUseKind(BigIntUse)) { >+ SpeculateCellOperand left(this, node->child1()); >+ SpeculateCellOperand right(this, node->child2()); >+ GPRReg leftGPR = left.gpr(); >+ GPRReg rightGPR = right.gpr(); >+ >+ speculateBigInt(node->child1(), leftGPR); >+ speculateBigInt(node->child2(), rightGPR); >+ >+ flushRegisters(); >+ GPRFlushedCallResult result(this); >+ GPRReg resultGPR = result.gpr(); >+ callOperation(operationBitRShiftBigInt, resultGPR, leftGPR, rightGPR); >+ m_jit.exceptionCheck(); >+ >+ cellResult(resultGPR, node); >+ return; >+ } >+ >+ emitUntypedRightShiftBitOp(node); >+} >+ > void SpeculativeJIT::compileShiftOp(Node* node) > { > NodeType op = node->op(); >@@ -3827,7 +3851,6 @@ void SpeculativeJIT::compileShiftOp(Node* node) > case BitLShift: > emitUntypedBitOp<JITLeftShiftGenerator, operationValueBitLShift>(node); > return; >- case BitRShift: > case BitURShift: > emitUntypedRightShiftBitOp(node); > return; >diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h >index a2ad6bed487cb34d687d7bedb51b5540d6befd8a..6616cdc9851eea7e90bba7bc5e0ff0563d75f68b 100644 >--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h >+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h >@@ -665,7 +665,7 @@ public: > void shiftOp(NodeType op, GPRReg op1, int32_t shiftAmount, GPRReg result) > { > switch (op) { >- case BitRShift: >+ case ArithBitRShift: > m_jit.rshift32(op1, Imm32(shiftAmount), result); > break; > case BitLShift: >@@ -681,7 +681,7 @@ public: > void shiftOp(NodeType op, GPRReg op1, GPRReg shiftAmount, GPRReg result) > { > switch (op) { >- case BitRShift: >+ case ArithBitRShift: > m_jit.rshift32(op1, shiftAmount, result); > break; > case BitLShift: >@@ -1338,6 +1338,7 @@ public: > void compileValueBitwiseOp(Node*); > > void emitUntypedRightShiftBitOp(Node*); >+ void compileValueBitRShift(Node*); > void compileShiftOp(Node*); > > template <typename Generator, typename RepatchingFunction, typename NonRepatchingFunction> >diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp >index c299bccd61322c2ebbe8136447f34d15f6b97545..ef7557a5fed3e50ae12dc3a542a294db411c2c79 100644 >--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp >+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp >@@ -1995,7 +1995,11 @@ void SpeculativeJIT::compile(Node* node) > compileBitwiseNot(node); > break; > >- case BitRShift: >+ case ValueBitRShift: >+ compileValueBitRShift(node); >+ break; >+ >+ case ArithBitRShift: > case BitLShift: > case BitURShift: > compileShiftOp(node); >diff --git a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp >index 32e08c99f465f006c19731bd2bb0a02b4c1488ba..cc4b69c6de6de6e8014c69a4c8d5be5b9986255d 100644 >--- a/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp >+++ b/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp >@@ -2090,7 +2090,11 @@ void SpeculativeJIT::compile(Node* node) > compileBitwiseOp(node); > break; > >- case BitRShift: >+ case ValueBitRShift: >+ compileValueBitRShift(node); >+ break; >+ >+ case ArithBitRShift: > case BitLShift: > case BitURShift: > compileShiftOp(node); >diff --git a/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp b/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp >index 18bec693e2d0f70cd6dd5e90cb01a7c086d350b9..5020e9e3aaead922c8c329453163c330ae7e761d 100644 >--- a/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp >+++ b/Source/JavaScriptCore/dfg/DFGStrengthReductionPhase.cpp >@@ -93,7 +93,7 @@ private: > break; > > case BitLShift: >- case BitRShift: >+ case ArithBitRShift: > case BitURShift: > if (m_node->child1().useKind() != UntypedUse && m_node->child2()->isInt32Constant() && !(m_node->child2()->asInt32() & 0x1f)) { > convertToIdentityOverChild1(); >diff --git a/Source/JavaScriptCore/ftl/FTLCapabilities.cpp b/Source/JavaScriptCore/ftl/FTLCapabilities.cpp >index 7db5b56d326ddad666ec69cfa4d8d186d224ff4a..a34734f99d277fec02337a51de628c5aaa8b8750 100644 >--- a/Source/JavaScriptCore/ftl/FTLCapabilities.cpp >+++ b/Source/JavaScriptCore/ftl/FTLCapabilities.cpp >@@ -62,7 +62,7 @@ inline CapabilityLevel canCompile(Node* node) > case ArithBitAnd: > case ArithBitOr: > case ArithBitXor: >- case BitRShift: >+ case ArithBitRShift: > case BitLShift: > case BitURShift: > case CheckStructure: >@@ -91,6 +91,7 @@ inline CapabilityLevel canCompile(Node* node) > case ValueBitAnd: > case ValueBitXor: > case ValueBitOr: >+ case ValueBitRShift: > case ValueNegate: > case ValueAdd: > case ValueSub: >diff --git a/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp b/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp >index edc6f0d3bc283510e5879b6ae4efa370f9aff671..7c111ebe364d32fef08723b7ae8444b4ef51c5cc 100644 >--- a/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp >+++ b/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp >@@ -680,8 +680,11 @@ private: > case ValueBitXor: > compileValueBitXor(); > break; >- case BitRShift: >- compileBitRShift(); >+ case ValueBitRShift: >+ compileValueBitRShift(); >+ break; >+ case ArithBitRShift: >+ compileArithBitRShift(); > break; > case BitLShift: > compileBitLShift(); >@@ -2956,12 +2959,22 @@ private: > setInt32(m_out.bitXor(lowInt32(m_node->child1()), lowInt32(m_node->child2()))); > } > >- void compileBitRShift() >+ void compileValueBitRShift() > { >- if (m_node->isBinaryUseKind(UntypedUse)) { >- emitRightShiftSnippet(JITRightShiftGenerator::SignedShift); >+ if (m_node->isBinaryUseKind(BigIntUse)) { >+ LValue left = lowBigInt(m_node->child1()); >+ LValue right = lowBigInt(m_node->child2()); >+ >+ LValue result = vmCall(pointerType(), m_out.operation(operationBitRShiftBigInt), m_callFrame, left, right); >+ setJSValue(result); > return; > } >+ >+ emitRightShiftSnippet(JITRightShiftGenerator::SignedShift); >+ } >+ >+ void compileArithBitRShift() >+ { > setInt32(m_out.aShr( > lowInt32(m_node->child1()), > m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31)))); >diff --git a/JSTests/ChangeLog b/JSTests/ChangeLog >index 777a853bfe709f942ac64f8b41717e0a94ab67b0..b3ec64790f03a6697f91fbfff95d432cb23fabd7 100644 >--- a/JSTests/ChangeLog >+++ b/JSTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-19 Caio Lima <ticaiolima@gmail.com> >+ >+ [BigInt] Add ValueBitRShift into DFG >+ https://bugs.webkit.org/show_bug.cgi?id=192663 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * stress/big-int-right-shift-jit-osr.js: Added. >+ * stress/big-int-right-shift-jit-untyped.js: Added. >+ * stress/big-int-right-shift-jit.js: Added. >+ > 2019-01-17 Saam barati <sbarati@apple.com> > > StringObjectUse should not be a structure check for the original string object structure >diff --git a/JSTests/stress/big-int-right-shift-jit-osr.js b/JSTests/stress/big-int-right-shift-jit-osr.js >new file mode 100644 >index 0000000000000000000000000000000000000000..248fc8d9fe2ec7a14dbd2c56e5c483af98ae765d >--- /dev/null >+++ b/JSTests/stress/big-int-right-shift-jit-osr.js >@@ -0,0 +1,25 @@ >+//@ runBigIntEnabled >+ >+let assert = { >+ sameValue: function(i, e, m) { >+ if (i !== e) >+ throw new Error(m); >+ } >+} >+ >+function bigIntRShift(x, y) { >+ return x >> y; >+} >+noInline(bigIntRShift); >+ >+for (let i = 0; i < 10000; i++) { >+ let r = bigIntRShift(0b100111n, 2n); >+ assert.sameValue(r, 0b1001n, 0b100111n + " >> " + 2n + " = " + r); >+} >+ >+let r = bigIntRShift(3, 10); >+assert.sameValue(r, 0, 3 + " >> " + 10 + " = " + r); >+ >+r = bigIntRShift("3", "10"); >+assert.sameValue(r, 0, 3 + " >> " + 10 + " = " + r); >+ >diff --git a/JSTests/stress/big-int-right-shift-jit-untyped.js b/JSTests/stress/big-int-right-shift-jit-untyped.js >new file mode 100644 >index 0000000000000000000000000000000000000000..b0d61318993725591b3e9bac568f6dd4236daf8b >--- /dev/null >+++ b/JSTests/stress/big-int-right-shift-jit-untyped.js >@@ -0,0 +1,36 @@ >+//@ runBigIntEnabled >+ >+let assert = { >+ sameValue: function(i, e, m) { >+ if (i !== e) >+ throw new Error(m); >+ } >+} >+ >+function bigIntRShift(x, y) { >+ return x >> y; >+} >+noInline(bigIntRShift); >+ >+let o = {valueOf: () => 4n}; >+ >+for (let i = 0; i < 10000; i++) { >+ let r = bigIntRShift(0b10001n, o); >+ assert.sameValue(r, 1n, 0b10001n + " >> {valueOf: () => 4n} = " + r); >+} >+ >+o2 = {valueOf: () => 0b10000n}; >+ >+for (let i = 0; i < 10000; i++) { >+ let r = bigIntRShift(o2, o); >+ assert.sameValue(r, 1n, "{valueOf: () => 0b10000n} >> {valueOf: () => 4n} = " + r); >+} >+ >+o = Object(0b10n); >+let r = bigIntRShift(0b11n, o); >+assert.sameValue(r, 0n, 0b11n + " >> Object(0b10n) = " + r); >+ >+o2 = Object(0b1100001n); >+r = bigIntRShift(o2, o); >+assert.sameValue(r, 0b11000n, "Object(0b1100001n) * Object(10n) = " + r); >+ >diff --git a/JSTests/stress/big-int-right-shift-jit.js b/JSTests/stress/big-int-right-shift-jit.js >new file mode 100644 >index 0000000000000000000000000000000000000000..6bc3f846d0993548279d0def2013aa5df5e2b6e9 >--- /dev/null >+++ b/JSTests/stress/big-int-right-shift-jit.js >@@ -0,0 +1,19 @@ >+//@ runBigIntEnabled >+ >+let assert = { >+ sameValue: function(i, e, m) { >+ if (i !== e) >+ throw new Error(m); >+ } >+} >+ >+function bigIntRShift(x, y) { >+ return x >> y; >+} >+noInline(bigIntRShift); >+ >+for (let i = 0; i < 10000; i++) { >+ let r = bigIntRShift(0b10001n, 4n); >+ assert.sameValue(r, 1n, 0b10001n + " >> " + 4n + " = " + r); >+} >+ >diff --git a/PerformanceTests/BigIntBench/big-int-simple-rshift.js b/PerformanceTests/BigIntBench/big-int-simple-rshift.js >new file mode 100644 >index 0000000000000000000000000000000000000000..a385fe67114cf9c38b1f785d6c3a2d8e1d5e759d >--- /dev/null >+++ b/PerformanceTests/BigIntBench/big-int-simple-rshift.js >@@ -0,0 +1,15 @@ >+function bigInt(a, b) { >+ let c = a >> b; >+ return (a >> c) - b; >+} >+noInline(bigInt); >+ >+for (let i = 0; i < 100000; i++) { >+ bigInt(0b1111n, 2n); >+} >+ >+let out; >+for (let i = 0; i < 100000; i++) { >+ out = bigInt(0xffffffffffffffffffn, 64n); >+} >+ >diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog >index c045c1e094ce3fcf6682fdd145da510ba2f87f51..00115c9fc60964dac2f8e4c13822db20705df072 100644 >--- a/PerformanceTests/ChangeLog >+++ b/PerformanceTests/ChangeLog >@@ -1,3 +1,12 @@ >+2019-01-19 Caio Lima <ticaiolima@gmail.com> >+ >+ [BigInt] Add ValueBitRShift into DFG >+ https://bugs.webkit.org/show_bug.cgi?id=192663 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * BigIntBench/big-int-simple-rshift.js: Added. >+ > 2019-01-18 Saam Barati <sbarati@apple.com> > > Use scores everywhere in JetStream2's UI
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192663
:
358218
|
359607
|
359608
|
374914
|
375408
|
378570
|
378660