Title: [259866] trunk/Source/_javascript_Core
Revision
259866
Author
ticaiol...@gmail.com
Date
2020-04-10 05:19:40 -0700 (Fri, 10 Apr 2020)

Log Message

[LLInt] Add fast path for TypedArray access on LLInt 32-bits
https://bugs.webkit.org/show_bug.cgi?id=210217

Reviewed by Yusuke Suzuki.

This patch is adding fast path case for in-bound TypedArray access on
32-bits LLInt. Since instructions are the same for both architectures,
we are refactoring this part of code to `LowLevelInterpreter.asm` and
reusing it into `LowLevelInterpreter32_64.asm`.

* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (259865 => 259866)


--- trunk/Source/_javascript_Core/ChangeLog	2020-04-10 11:10:19 UTC (rev 259865)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-04-10 12:19:40 UTC (rev 259866)
@@ -1,3 +1,19 @@
+2020-04-10  Caio Lima  <ticaiol...@gmail.com>
+
+        [LLInt] Add fast path for TypedArray access on LLInt 32-bits
+        https://bugs.webkit.org/show_bug.cgi?id=210217
+
+        Reviewed by Yusuke Suzuki.
+
+        This patch is adding fast path case for in-bound TypedArray access on
+        32-bits LLInt. Since instructions are the same for both architectures,
+        we are refactoring this part of code to `LowLevelInterpreter.asm` and
+        reusing it into `LowLevelInterpreter32_64.asm`.
+
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+
 2020-04-10  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, reverting r259849 and r259851.

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm (259865 => 259866)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2020-04-10 11:10:19 UTC (rev 259865)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2020-04-10 12:19:40 UTC (rev 259866)
@@ -1147,6 +1147,104 @@
     loadb JSCell::m_indexingTypeAndMisc[cell], indexingType
 end
 
+macro getByValTypedArray(base, index, finishIntGetByVal, finishDoubleGetByVal, slowPath)
+    # First lets check if we even have a typed array. This lets us do some boilerplate up front.
+    loadb JSCell::m_type[base], t2
+    subi FirstTypedArrayType, t2
+    biaeq t2, NumberOfTypedArrayTypesExcludingDataView, slowPath
+    
+    # Sweet, now we know that we have a typed array. Do some basic things now.
+
+    if ARM64E
+        const length = t6
+        const scratch = t7
+        loadi JSArrayBufferView::m_length[base], length
+        biaeq index, length, slowPath
+    else
+        # length and scratch are intentionally undefined on this branch because they are not used on other platforms.
+        biaeq index, JSArrayBufferView::m_length[base], slowPath
+    end
+
+    loadp JSArrayBufferView::m_vector[base], t3
+    cagedPrimitive(t3, length, base, scratch)
+
+    # Now bisect through the various types:
+    #    Int8ArrayType,
+    #    Uint8ArrayType,
+    #    Uint8ClampedArrayType,
+    #    Int16ArrayType,
+    #    Uint16ArrayType,
+    #    Int32ArrayType,
+    #    Uint32ArrayType,
+    #    Float32ArrayType,
+    #    Float64ArrayType,
+
+    bia t2, Uint16ArrayType - FirstTypedArrayType, .opGetByValAboveUint16Array
+
+    # We have one of Int8ArrayType .. Uint16ArrayType.
+    bia t2, Uint8ClampedArrayType - FirstTypedArrayType, .opGetByValInt16ArrayOrUint16Array
+
+    # We have one of Int8ArrayType ... Uint8ClampedArrayType
+    bia t2, Int8ArrayType - FirstTypedArrayType, .opGetByValUint8ArrayOrUint8ClampedArray
+
+    # We have Int8ArrayType.
+    loadbsi [t3, index], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValUint8ArrayOrUint8ClampedArray:
+    bia t2, Uint8ArrayType - FirstTypedArrayType, .opGetByValUint8ClampedArray
+
+    # We have Uint8ArrayType.
+    loadb [t3, index], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValUint8ClampedArray:
+    # We have Uint8ClampedArrayType.
+    loadb [t3, index], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValInt16ArrayOrUint16Array:
+    # We have either Int16ArrayType or Uint16ClampedArrayType.
+    bia t2, Int16ArrayType - FirstTypedArrayType, .opGetByValUint16Array
+
+    # We have Int16ArrayType.
+    loadhsi [t3, index, 2], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValUint16Array:
+    # We have Uint16ArrayType.
+    loadh [t3, index, 2], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValAboveUint16Array:
+    # We have one of Int32ArrayType .. Float64ArrayType.
+    bia t2, Uint32ArrayType - FirstTypedArrayType, .opGetByValFloat32ArrayOrFloat64Array
+
+    # We have either Int32ArrayType or Uint32ArrayType
+    bia t2, Int32ArrayType - FirstTypedArrayType, .opGetByValUint32Array
+
+    # We have Int32ArrayType.
+    loadi [t3, index, 4], t0
+    finishIntGetByVal(t0, t1)
+
+.opGetByValUint32Array:
+    # We have Uint32ArrayType.
+    # This is the hardest part because of large unsigned values.
+    loadi [t3, index, 4], t0
+    bilt t0, 0, slowPath # This case is still awkward to implement in LLInt.
+    finishIntGetByVal(t0, t1)
+
+.opGetByValFloat32ArrayOrFloat64Array:
+    # We have one of Float32ArrayType or Float64ArrayType. Sadly, we cannot handle Float32Array
+    # inline yet. That would require some offlineasm changes.
+    bieq t2, Float32ArrayType - FirstTypedArrayType, slowPath
+
+    # We have Float64ArrayType.
+    loadd [t3, index, 8], ft0
+    bdnequn ft0, ft0, slowPath
+    finishDoubleGetByVal(ft0, t0, t1, t2)
+end
+
 macro skipIfIsRememberedOrInEden(cell, slowPath)
     memfence
     bba JSCell::m_cellState[cell], BlackThreshold, .done

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm (259865 => 259866)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2020-04-10 11:10:19 UTC (rev 259865)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter32_64.asm	2020-04-10 12:19:40 UTC (rev 259866)
@@ -147,6 +147,9 @@
     restoreStateAfterCCall()
 end
 
+macro cagedPrimitive(ptr, length, scratch, scratch2)
+end
+
 macro doVMEntry(makeCall)
     functionPrologue()
     pushCalleeSaves()
@@ -1511,6 +1514,23 @@
 
 
 llintOpWithMetadata(op_get_by_val, OpGetByVal, macro (size, get, dispatch, metadata, return)
+    macro finishIntGetByVal(resultPayload, scratch)
+        get(m_dst, scratch)
+        storei Int32Tag, TagOffset[cfr, scratch, 8]
+        storei resultPayload, PayloadOffset[cfr, scratch, 8]
+        valueProfile(OpGetByVal, t5, Int32Tag, resultPayload)
+        dispatch()
+    end
+
+    macro finishDoubleGetByVal(result, scratch1, scratch2, scratch3)
+        get(m_dst, scratch1)
+        fd2ii result, scratch2, scratch3
+        storei scratch3, TagOffset[cfr, scratch1, 8]
+        storei scratch2, PayloadOffset[cfr, scratch1, 8]
+        valueProfile(OpGetByVal, t5, scratch3, scratch2)
+        dispatch()
+    end
+
     metadata(t5, t2)
     get(m_base, t2)
     loadConstantOrVariablePayload(size, t2, CellTag, t0, .opGetByValSlow)
@@ -1541,7 +1561,7 @@
 
 .opGetByValNotDouble:
     subi ArrayStorageShape, t2
-    bia t2, SlowPutArrayStorageShape - ArrayStorageShape, .opGetByValSlow
+    bia t2, SlowPutArrayStorageShape - ArrayStorageShape, .opGetByValNotIndexedStorage
     biaeq t1, -sizeof IndexingHeader + IndexingHeader::u.lengths.vectorLength[t3], .opGetByValSlow
     loadi ArrayStorage::m_vector + TagOffset[t3, t1, 8], t2
     loadi ArrayStorage::m_vector + PayloadOffset[t3, t1, 8], t1
@@ -1555,6 +1575,9 @@
     valueProfile(OpGetByVal, t5, t2, t1)
     dispatch()
 
+.opGetByValNotIndexedStorage:
+    getByValTypedArray(t0, t1, finishIntGetByVal, finishDoubleGetByVal, .opGetByValSlow)
+
 .opGetByValSlow:
     callSlowPath(_llint_slow_path_get_by_val)
     dispatch()

Modified: trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm (259865 => 259866)


--- trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2020-04-10 11:10:19 UTC (rev 259865)
+++ trunk/Source/_javascript_Core/llint/LowLevelInterpreter64.asm	2020-04-10 12:19:40 UTC (rev 259866)
@@ -1506,7 +1506,7 @@
         finishGetByVal(result, scratch)
     end
 
-    macro finishDoubleGetByVal(result, scratch1, scratch2)
+    macro finishDoubleGetByVal(result, scratch1, scratch2, unused)
         fd2q result, scratch1
         subq numberTag, scratch1
         finishGetByVal(scratch1, scratch2)
@@ -1562,102 +1562,8 @@
     dispatch()
 
 .opGetByValNotIndexedStorage:
-    # First lets check if we even have a typed array. This lets us do some boilerplate up front.
-    loadb JSCell::m_type[t0], t2
-    subi FirstTypedArrayType, t2
-    biaeq t2, NumberOfTypedArrayTypesExcludingDataView, .opGetByValSlow
-    
-    # Sweet, now we know that we have a typed array. Do some basic things now.
+    getByValTypedArray(t0, t1, finishIntGetByVal, finishDoubleGetByVal, .opGetByValSlow)
 
-    if ARM64E
-        const length = t6
-        const scratch = t7
-        loadi JSArrayBufferView::m_length[t0], length
-        biaeq t1, length, .opGetByValSlow
-    else
-        # length and scratch are intentionally undefined on this branch because they are not used on other platforms.
-        biaeq t1, JSArrayBufferView::m_length[t0], .opGetByValSlow
-    end
-
-    loadp JSArrayBufferView::m_vector[t0], t3
-    cagedPrimitive(t3, length, t0, scratch)
-
-    # Now bisect through the various types:
-    #    Int8ArrayType,
-    #    Uint8ArrayType,
-    #    Uint8ClampedArrayType,
-    #    Int16ArrayType,
-    #    Uint16ArrayType,
-    #    Int32ArrayType,
-    #    Uint32ArrayType,
-    #    Float32ArrayType,
-    #    Float64ArrayType,
-
-    bia t2, Uint16ArrayType - FirstTypedArrayType, .opGetByValAboveUint16Array
-
-    # We have one of Int8ArrayType .. Uint16ArrayType.
-    bia t2, Uint8ClampedArrayType - FirstTypedArrayType, .opGetByValInt16ArrayOrUint16Array
-
-    # We have one of Int8ArrayType ... Uint8ClampedArrayType
-    bia t2, Int8ArrayType - FirstTypedArrayType, .opGetByValUint8ArrayOrUint8ClampedArray
-
-    # We have Int8ArrayType.
-    loadbsi [t3, t1], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValUint8ArrayOrUint8ClampedArray:
-    bia t2, Uint8ArrayType - FirstTypedArrayType, .opGetByValUint8ClampedArray
-
-    # We have Uint8ArrayType.
-    loadb [t3, t1], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValUint8ClampedArray:
-    # We have Uint8ClampedArrayType.
-    loadb [t3, t1], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValInt16ArrayOrUint16Array:
-    # We have either Int16ArrayType or Uint16ClampedArrayType.
-    bia t2, Int16ArrayType - FirstTypedArrayType, .opGetByValUint16Array
-
-    # We have Int16ArrayType.
-    loadhsi [t3, t1, 2], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValUint16Array:
-    # We have Uint16ArrayType.
-    loadh [t3, t1, 2], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValAboveUint16Array:
-    # We have one of Int32ArrayType .. Float64ArrayType.
-    bia t2, Uint32ArrayType - FirstTypedArrayType, .opGetByValFloat32ArrayOrFloat64Array
-
-    # We have either Int32ArrayType or Uint32ArrayType
-    bia t2, Int32ArrayType - FirstTypedArrayType, .opGetByValUint32Array
-
-    # We have Int32ArrayType.
-    loadi [t3, t1, 4], t0
-    finishIntGetByVal(t0, t1)
-
-.opGetByValUint32Array:
-    # We have Uint32ArrayType.
-    # This is the hardest part because of large unsigned values.
-    loadi [t3, t1, 4], t0
-    bilt t0, 0, .opGetByValSlow # This case is still awkward to implement in LLInt.
-    finishIntGetByVal(t0, t1)
-
-.opGetByValFloat32ArrayOrFloat64Array:
-    # We have one of Float32ArrayType or Float64ArrayType. Sadly, we cannot handle Float32Array
-    # inline yet. That would require some offlineasm changes.
-    bieq t2, Float32ArrayType - FirstTypedArrayType, .opGetByValSlow
-
-    # We have Float64ArrayType.
-    loadd [t3, t1, 8], ft0
-    bdnequn ft0, ft0, .opGetByValSlow
-    finishDoubleGetByVal(ft0, t0, t1)
-
 .opGetByValSlow:
     callSlowPath(_llint_slow_path_get_by_val)
     dispatch()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to