Skip to content

Commit 29c41f1

Browse files
committed
[JSC] Use BulkMemoryValue MemoryMove for FTL TypedArraySet
https://bugs.webkit.org/show_bug.cgi?id=327809 rdar://190198931 Reviewed by Sosuke Suzuki. We extended BulkMemoryValue to accept non wasm memory.copy / memory.fill opcodes by generalizing them. Thus we apply it to TypedArraySet since its C++ operation function is memmove. BulkMemoryValue's MemoryMove is B3-aware approach so B3 can do optimization, understanding heap clobbering status, and using the best architecture-specific optimized memmove operation in C++ when necessary. ToT Patched typed-array-set-concat 47.2476+-0.2585 ^ 36.7511+-0.3051 ^ definitely 1.2856x faster typed-array-set-uint8-and-uint8clamped 2.1672+-0.0107 ? 2.1706+-0.0079 ? typed-array-set-small 35.0264+-0.2466 ^ 26.1688+-0.1140 ^ definitely 1.3385x faster * Source/JavaScriptCore/b3/B3AbstractHeapRepository.cpp: (JSC::B3::AbstractHeapRepository::decorateBulkMemoryRead): (JSC::B3::AbstractHeapRepository::decorateBulkMemoryWrite): (JSC::B3::AbstractHeapRepository::computeRangesAndDecorateInstructions): * Source/JavaScriptCore/b3/B3AbstractHeapRepository.h: * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): * Source/JavaScriptCore/ftl/FTLOutput.cpp: (JSC::FTL::Output::memoryMove): * Source/JavaScriptCore/ftl/FTLOutput.h: Canonical link: https://commits.webkit.org/324006@main
1 parent 7a76e97 commit 29c41f1

5 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎Source/JavaScriptCore/b3/B3AbstractHeapRepository.cpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#if ENABLE(B3_JIT)
3030

31+
#include "B3BulkMemoryValue.h"
3132
#include "B3CCallValue.h"
3233
#include "B3FenceValue.h"
3334
#include "B3MemoryValue.h"
@@ -171,6 +172,16 @@ void AbstractHeapRepository::decorateFencedAccess(const AbstractHeap* heap, Valu
171172
m_heapForFencedAccess.append(HeapForValue(heap, value));
172173
}
173174

175+
void AbstractHeapRepository::decorateBulkMemoryRead(const AbstractHeap* heap, Value* value)
176+
{
177+
m_heapForBulkMemoryRead.append(HeapForValue(heap, value));
178+
}
179+
180+
void AbstractHeapRepository::decorateBulkMemoryWrite(const AbstractHeap* heap, Value* value)
181+
{
182+
m_heapForBulkMemoryWrite.append(HeapForValue(heap, value));
183+
}
184+
174185
void AbstractHeapRepository::decorateWasmStructGet(const AbstractHeap* heap, Value* value)
175186
{
176187
m_heapForWasmStructGet.append(HeapForValue(heap, value));
@@ -243,6 +254,10 @@ void AbstractHeapRepository::computeRangesAndDecorateInstructions()
243254
entry.value->as<FenceValue>()->write = rangeFor(entry.heap);
244255
for (HeapForValue entry : m_heapForFencedAccess)
245256
entry.value->as<MemoryValue>()->setFenceRange(rangeFor(entry.heap));
257+
for (HeapForValue entry : m_heapForBulkMemoryRead)
258+
entry.value->as<BulkMemoryValue>()->setReadRange(rangeFor(entry.heap));
259+
for (HeapForValue entry : m_heapForBulkMemoryWrite)
260+
entry.value->as<BulkMemoryValue>()->setWriteRange(rangeFor(entry.heap));
246261
for (HeapForValue entry : m_heapForWasmStructGet) {
247262
auto* wasmStructGet = entry.value->as<WasmStructGetValue>();
248263
wasmStructGet->setRange(rangeFor(entry.heap));

‎Source/JavaScriptCore/b3/B3AbstractHeapRepository.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ class AbstractHeapRepository {
348348
void decorateFenceRead(const AbstractHeap*, Value*);
349349
void decorateFenceWrite(const AbstractHeap*, Value*);
350350
void decorateFencedAccess(const AbstractHeap*, Value*);
351+
void decorateBulkMemoryRead(const AbstractHeap*, Value*);
352+
void decorateBulkMemoryWrite(const AbstractHeap*, Value*);
351353
void decorateWasmStructGet(const AbstractHeap*, Value*);
352354
void decorateWasmStructSet(const AbstractHeap*, Value*);
353355
void decorateWasmStructNew(const AbstractHeap*, Value*);
@@ -383,6 +385,8 @@ class AbstractHeapRepository {
383385
Vector<HeapForValue> m_heapForFenceRead;
384386
Vector<HeapForValue> m_heapForFenceWrite;
385387
Vector<HeapForValue> m_heapForFencedAccess;
388+
Vector<HeapForValue> m_heapForBulkMemoryRead;
389+
Vector<HeapForValue> m_heapForBulkMemoryWrite;
386390
Vector<HeapForValue> m_heapForWasmStructGet;
387391
Vector<HeapForValue> m_heapForWasmStructSet;
388392
Vector<HeapForValue> m_heapForWasmStructNew;

‎Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22462,7 +22462,7 @@ IGNORE_CLANG_WARNINGS_END
2246222462
LValue shift = m_out.constInt32(logElementSize(type));
2246322463
LValue basePointer = m_out.add(caged(Gigacage::Primitive, baseVector, base), m_out.shl(offsetPtr, shift));
2246422464
LValue sourcePointer = caged(Gigacage::Primitive, sourceVector, source);
22465-
vmCall(Void, operationTypedArraySet, basePointer, sourcePointer, m_out.shl(sourceLength, shift));
22465+
m_out.memoryMove(basePointer, sourcePointer, m_out.shl(sourceLength, shift), &m_heaps.TypedArrayProperties, &m_heaps.TypedArrayProperties);
2246622466
ensureStillAliveHere(base);
2246722467
ensureStillAliveHere(source);
2246822468
}

‎Source/JavaScriptCore/ftl/FTLOutput.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "B3AtomicValue.h"
3232
#include "B3BasicBlockInlines.h"
33+
#include "B3BulkMemoryValue.h"
3334
#include "B3Const32Value.h"
3435
#include "B3FenceValue.h"
3536
#include "B3MathExtras.h"
@@ -476,6 +477,13 @@ FenceValue* Output::fence(const AbstractHeap* read, const AbstractHeap* write)
476477
return result;
477478
}
478479

480+
void Output::memoryMove(LValue destination, LValue source, LValue byteCount, const AbstractHeap* read, const AbstractHeap* write)
481+
{
482+
BulkMemoryValue* result = m_block->appendNew<BulkMemoryValue>(m_proc, MemoryMove, origin(), destination, source, byteCount);
483+
m_heaps->decorateBulkMemoryRead(read, result);
484+
m_heaps->decorateBulkMemoryWrite(write, result);
485+
}
486+
479487
LValue Output::store32As8(LValue value, TypedPointer pointer)
480488
{
481489
LValue store = m_block->appendNew<MemoryValue>(m_proc, Store8, origin(), value, pointer.value());

‎Source/JavaScriptCore/ftl/FTLOutput.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ class Output : public CommonValues {
217217
LValue load(TypedPointer, LType);
218218
LValue store(LValue, TypedPointer);
219219
B3::FenceValue* fence(const AbstractHeap* read, const AbstractHeap* write);
220+
void memoryMove(LValue destination, LValue source, LValue byteCount, const AbstractHeap* read, const AbstractHeap* write);
220221

221222
LValue load8SignExt32(TypedPointer);
222223
LValue load8ZeroExt32(TypedPointer);

0 commit comments

Comments
 (0)