Title: [284716] trunk
Revision
284716
Author
[email protected]
Date
2021-10-22 14:56:00 -0700 (Fri, 22 Oct 2021)

Log Message

[JSC] GetTypedArrayLengthAsInt52 must be inserted only when we ensure that input is TypedArray via array-mode-based filtering
https://bugs.webkit.org/show_bug.cgi?id=232168
rdar://84366658

Reviewed by Robin Morisset.

JSTests:

* stress/gettypedarraylengthasint52-must-be-emitted-for-typedarray.js: Added.
(foo):

Source/_javascript_Core:

GetTypedArrayLengthAsInt52 works only when input is TypedArray, which should be validated via array-mode (and already inserted checks in fixup).
Accidentally we were inserting it without checking typed-array condition in SSA lowering phase. This patch adds a condition which ensures it
is TypedArray.

* dfg/DFGSSALoweringPhase.cpp:
(JSC::DFG::SSALoweringPhase::handleNode):
(JSC::DFG::SSALoweringPhase::lowerBoundsCheck):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (284715 => 284716)


--- trunk/JSTests/ChangeLog	2021-10-22 21:47:34 UTC (rev 284715)
+++ trunk/JSTests/ChangeLog	2021-10-22 21:56:00 UTC (rev 284716)
@@ -1,3 +1,14 @@
+2021-10-22  Yusuke Suzuki  <[email protected]>
+
+        [JSC] GetTypedArrayLengthAsInt52 must be inserted only when we ensure that input is TypedArray via array-mode-based filtering
+        https://bugs.webkit.org/show_bug.cgi?id=232168
+        rdar://84366658
+
+        Reviewed by Robin Morisset.
+
+        * stress/gettypedarraylengthasint52-must-be-emitted-for-typedarray.js: Added.
+        (foo):
+
 2021-10-22  Asumu Takikawa  <[email protected]>
 
         Change WebAssembly module import linking time to evaluate step.

Added: trunk/JSTests/stress/gettypedarraylengthasint52-must-be-emitted-for-typedarray.js (0 => 284716)


--- trunk/JSTests/stress/gettypedarraylengthasint52-must-be-emitted-for-typedarray.js	                        (rev 0)
+++ trunk/JSTests/stress/gettypedarraylengthasint52-must-be-emitted-for-typedarray.js	2021-10-22 21:56:00 UTC (rev 284716)
@@ -0,0 +1,10 @@
+//@ runDefault("--jitPolicyScale=0")
+function foo(arg0) {
+  arg0[0.1] = '';
+  for (let j = 0; j < 100; j++);
+}
+
+foo([0]);
+for (let i = 0; i < 1000; i++) {
+  foo(0);
+}

Modified: trunk/Source/_javascript_Core/ChangeLog (284715 => 284716)


--- trunk/Source/_javascript_Core/ChangeLog	2021-10-22 21:47:34 UTC (rev 284715)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-10-22 21:56:00 UTC (rev 284716)
@@ -1,3 +1,19 @@
+2021-10-22  Yusuke Suzuki  <[email protected]>
+
+        [JSC] GetTypedArrayLengthAsInt52 must be inserted only when we ensure that input is TypedArray via array-mode-based filtering
+        https://bugs.webkit.org/show_bug.cgi?id=232168
+        rdar://84366658
+
+        Reviewed by Robin Morisset.
+
+        GetTypedArrayLengthAsInt52 works only when input is TypedArray, which should be validated via array-mode (and already inserted checks in fixup).
+        Accidentally we were inserting it without checking typed-array condition in SSA lowering phase. This patch adds a condition which ensures it
+        is TypedArray.
+
+        * dfg/DFGSSALoweringPhase.cpp:
+        (JSC::DFG::SSALoweringPhase::handleNode):
+        (JSC::DFG::SSALoweringPhase::lowerBoundsCheck):
+
 2021-10-22  Mark Lam  <[email protected]>
 
         Change Heap::writeBarrier() to do the cheaper check first.

Modified: trunk/Source/_javascript_Core/dfg/DFGSSALoweringPhase.cpp (284715 => 284716)


--- trunk/Source/_javascript_Core/dfg/DFGSSALoweringPhase.cpp	2021-10-22 21:47:34 UTC (rev 284715)
+++ trunk/Source/_javascript_Core/dfg/DFGSSALoweringPhase.cpp	2021-10-22 21:56:00 UTC (rev 284716)
@@ -99,7 +99,7 @@
             if (lowerBoundsCheck(base, index, storage))
                 break;
             
-            if (m_node->arrayMode().typedArrayType() != NotTypedArray && m_node->arrayMode().isOutOfBounds()) {
+            if (m_node->arrayMode().isSomeTypedArrayView() && m_node->arrayMode().isOutOfBounds()) {
 #if USE(LARGE_TYPED_ARRAYS)
                 if (m_node->arrayMode().mayBeLargeTypedArray() || m_graph.hasExitSite(m_node->origin.semantic, Overflow)) {
                     Node* length = m_insertionSet.insertNode(
@@ -149,7 +149,7 @@
 
         Node* checkInBounds;
 #if USE(LARGE_TYPED_ARRAYS)
-        if ((op == GetArrayLength) && (m_node->arrayMode().mayBeLargeTypedArray() || m_graph.hasExitSite(m_node->origin.semantic, Overflow))) {
+        if ((op == GetArrayLength) && m_node->arrayMode().isSomeTypedArrayView() && (m_node->arrayMode().mayBeLargeTypedArray() || m_graph.hasExitSite(m_node->origin.semantic, Overflow))) {
             Node* length = m_insertionSet.insertNode(
                 m_nodeIndex, SpecInt52Any, GetTypedArrayLengthAsInt52, m_node->origin,
                 OpInfo(m_node->arrayMode().asWord()), Edge(base.node(), KnownCellUse), storage);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to