Repository navigation
Commit 0c51f43
committed
[JSC] Quick pattern matching for byte-copy loop in OMG
https://bugs.webkit.org/show_bug.cgi?id=321468
rdar://184557364
Reviewed by Keith Miller.
Depending on toolchain, options etc., very naive byte-copy loop is
generated instead of wasm bulk-memory operations like memory.copy /
memory.fill. This patch does quick pattern matching, detecting it and
spreading MemoryCopy / MemoryFill operation with guards before the
actual naive loop. We just prepend the fast path with MemoryCopy
and MemoryFill since we do not know whether src and destination are
overlapping or not at runtime easily. So we need to check them, and we
need to fall back to the normal loop when it is overlapping badly.
The replacement can be turned off with the useWasmByteLoopReplacement
option.
Tests: JSTests/wasm/stress/byte-loop-idiom-recognition.js
JSTests/wasm/stress/byte-loop-idiom-loop-osr.js
* JSTests/wasm/stress/byte-loop-idiom-loop-osr.js: Added.
(async test.seed):
(async test.assertMemoryMatches):
(async test.copyMemmoveLike):
(async test.copyReplicating):
(async test.copyDownwards):
(async test.fillRegion):
(async test):
* JSTests/wasm/stress/byte-loop-idiom-recognition.js: Added.
(access):
(modelCopyForward):
(modelCopyBackward):
(modelFill):
(async test.seedWindow):
(async test.seedEverything):
(async test.assertMemoryMatches):
(async test.checkEveryCase):
(async test.assertTraps):
(async test):
* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/runtime/OptionsList.h:
* Source/JavaScriptCore/wasm/WasmByteLoopIdiom.h: Added.
(JSC::Wasm::ByteLoopIdiom::isFill const):
(JSC::Wasm::ByteLoopIdiom::isBackward const):
(JSC::Wasm::ByteLoopIdiom::match):
(JSC::Wasm::ByteLoopIdiom::localsAreDistinct const):
(JSC::Wasm::ByteLoopIdiom::matchCopyForward):
(JSC::Wasm::ByteLoopIdiom::matchCopyBackward):
(JSC::Wasm::ByteLoopIdiom::matchFill):
* Source/JavaScriptCore/wasm/WasmOMGIRGenerator.cpp:
(JSC::Wasm::OMGIRGenerator::addMemoryFill):
(JSC::Wasm::OMGIRGenerator::emitMemoryFill):
(JSC::Wasm::OMGIRGenerator::addMemoryCopy):
(JSC::Wasm::OMGIRGenerator::emitMemoryCopy):
(JSC::Wasm::OMGIRGenerator::matchByteLoopIdiom):
(JSC::Wasm::OMGIRGenerator::emitByteLoopIdiom):
(JSC::Wasm::OMGIRGenerator::addLoop):
Canonical link: https://commits.webkit.org/319065@main1 parent b7fac90 commit 0c51f43
6 files changed
Lines changed: 808 additions & 10 deletions
File tree
- JSTests/wasm/stress
- Source/JavaScriptCore
- JavaScriptCore.xcodeproj
- runtime
- wasm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
0 commit comments