Skip to content

Commit 7a76e97

Browse files
committed
[JSC] Extract CheckArray from TypedArraySet
https://bugs.webkit.org/show_bug.cgi?id=327802 rdar://190197037 Reviewed by Sosuke Suzuki. 323823@main introduced TypedArraySet in DFG / FTL. It is using CheckArray for base, but array type checking for source is done in TypedArraySet. But that check is what CheckArray does. CheckArray is having better support in the pipeline like type check hoisting. So this patch extracts this checking part as CheckArray and removing it from TypedArraySet. * Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): * Source/JavaScriptCore/dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * Source/JavaScriptCore/dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileTypedArraySet): * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): Canonical link: https://commits.webkit.org/324005@main
1 parent bde098c commit 7a76e97

6 files changed

Lines changed: 7 additions & 10 deletions

File tree

‎Source/JavaScriptCore/dfg/DFGAbstractInterpreterInlines.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5910,12 +5910,8 @@ bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimi
59105910
break;
59115911
}
59125912

5913-
case DataViewSet: {
5914-
break;
5915-
}
5916-
5913+
case DataViewSet:
59175914
case TypedArraySet: {
5918-
filter(node->child2(), speculationFromTypedArrayType(node->typedArrayType()));
59195915
break;
59205916
}
59215917

‎Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,7 @@ auto ByteCodeParser::handleIntrinsicCall(Node* callee, Operand resultOperand, Ca
31653165
Node* source = get(virtualRegisterForArgumentIncludingThis(1, registerOffset));
31663166
Node* offset = argumentCountIncludingThis > 2 ? get(virtualRegisterForArgumentIncludingThis(2, registerOffset)) : jsConstant(jsNumber(0));
31673167
addToGraph(CheckArray, OpInfo(mode.asWord()), base);
3168+
addToGraph(CheckArray, OpInfo(mode.asWord()), source);
31683169
addToGraph(TypedArraySet, OpInfo(mode.typedArrayType()), base, source, offset);
31693170
setResult(addToGraph(JSConstant, OpInfo(m_constantUndefined)));
31703171
return CallOptimizationResult::Inlined;

‎Source/JavaScriptCore/dfg/DFGFixupPhase.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3745,7 +3745,7 @@ class FixupPhase : public Phase {
37453745

37463746
case TypedArraySet: {
37473747
fixEdge<KnownCellUse>(node->child1());
3748-
fixEdge<CellUse>(node->child2());
3748+
fixEdge<KnownCellUse>(node->child2());
37493749
fixEdge<Int32Use>(node->child3());
37503750
break;
37513751
}

‎Source/JavaScriptCore/dfg/DFGSafeToExecute.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,10 @@ bool safeToExecute(AbstractStateType& state, Graph& graph, Node* node, bool igno
459459
case GetTypedArrayByteOffsetAsInt52:
460460
return !(state.forNode(node->child1()).m_type & ~(SpecTypedArrayView));
461461

462-
case TypedArraySet:
463-
return !(state.forNode(node->child1()).m_type & ~speculationFromTypedArrayType(node->typedArrayType()));
462+
case TypedArraySet: {
463+
SpeculatedType expected = speculationFromTypedArrayType(node->typedArrayType());
464+
return !(state.forNode(node->child1()).m_type & ~expected) && !(state.forNode(node->child2()).m_type & ~expected);
465+
}
464466

465467
case PutByValDirect:
466468
case PutByVal:

‎Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8325,7 +8325,6 @@ void SpeculativeJIT::compileTypedArraySet(Node* node)
83258325
GPRReg sizeGPR = size.gpr();
83268326

83278327
TypedArrayType type = node->typedArrayType();
8328-
speculateCellType(node->child2(), sourceGPR, speculationFromTypedArrayType(type), typeForTypedArrayType(type));
83298328

83308329
if (!m_graph.isNeverResizableOrGrowableSharedTypedArrayIncludingDataView(m_state.forNode(node->child1())))
83318330
speculationCheck(UnexpectedResizableArrayBufferView, JSValueSource(baseGPR), node->child1(), branchTest8(NonZero, Address(baseGPR, JSArrayBufferView::offsetOfMode()), TrustedImm32(isResizableOrGrowableSharedMode)));

‎Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22447,7 +22447,6 @@ IGNORE_CLANG_WARNINGS_END
2244722447
LValue offset = lowInt32(m_node->child3());
2244822448

2244922449
TypedArrayType type = m_node->typedArrayType();
22450-
FTL_TYPE_CHECK(jsValueValue(source), m_node->child2(), speculationFromTypedArrayType(type), isNotType(source, typeForTypedArrayType(type)));
2245122450

2245222451
LValue baseLength = typedArrayLength(base, false, type, m_node->child1());
2245322452
LValue sourceLength = typedArrayLength(source, false, type, m_node->child2());

0 commit comments

Comments
 (0)