Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Add BoyerMooreHorspool search to DFG / FTL
https://bugs.webkit.org/show_bug.cgi?id=244924 Reviewed by Alexey Shvayka. In DFG / FTL, it is possible that we can find what string is used for searching in String#replace. So, in compiler, we can construct preprocessed table so that we can make String#replace faster. In this patch, we deploy Boyer-Moore-Horspool (BMH) search[1], which allows large skips for matching failures for substring, accelerate the matching significantly. We use BMH since it offers good memory-performance tradeoff. Currently, we deploy it only for pattern which is smaller than or equal to 256 length for table size efficiency. We can extend it to 16bit offset table, 32bit offset table. But we consider it as a future work. In microbenchmarks, we observed 43% improvement. We also found that this is 0.2-0.3% Speedometer2.1 improvement, in particular Vanilla families get 1-2% improvement with high confidence. ToT Patched string-replace-benchmark 121.2814+-0.6856 ^ 84.5948+-0.6012 ^ definitely 1.4337x faster [1]: https://en.wikipedia.org/wiki/Boyer–Moore–Horspool_algorithm * JSTests/microbenchmarks/string-replace-benchmark.js: Added. (fill): (test.template.li.data.id.string_appeared_here.div.input): (test.template.li.data.id.string_appeared_here.div): (test.label.button): * Source/JavaScriptCore/dfg/DFGCommonData.h: * Source/JavaScriptCore/dfg/DFGGraph.h: * Source/JavaScriptCore/dfg/DFGJITCompiler.cpp: (JSC::DFG::JITCompiler::link): * Source/JavaScriptCore/dfg/DFGOperations.cpp: (JSC::DFG::stringReplaceStringString): (JSC::DFG::JSC_DEFINE_JIT_OPERATION): * Source/JavaScriptCore/dfg/DFGOperations.h: * Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp: * Source/JavaScriptCore/ftl/FTLLink.cpp: (JSC::FTL::link): * Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCompareStrictEq): * Source/WTF/WTF.xcodeproj/project.pbxproj: * Source/WTF/wtf/CMakeLists.txt: * Source/WTF/wtf/text/ASCIILiteral.h: (WTF::ASCIILiteral::length const): * Source/WTF/wtf/text/StringSearch.h: Added. (WTF::BoyerMooreHorspoolTable::BoyerMooreHorspoolTable): (WTF::BoyerMooreHorspoolTable::find const): (WTF::BoyerMooreHorspoolTable::findInner const): * Tools/TestWebKitAPI/CMakeLists.txt: * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WTF/StringSearch.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/254342@main
- Loading branch information
1 parent
533f50c
commit d6426c81236a2be90f2454d85ebf155d2e5beb4e
Showing
17 changed files
with
367 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function fill(template, title, completed, checked) | ||
{ | ||
return template.replace("{{title}}", title).replace("{{completed}}", completed).replace("{{checked}}", checked); | ||
} | ||
noInline(fill); | ||
|
||
function test() | ||
{ | ||
for (var i = 55; i < 100; ++i) { | ||
for (var j = 0; j < i; ++j) { | ||
var template = `<li data-id="${j + 1}" class="{{completed}}"><div class="view"><input class="toggle" type="checkbox" {{checked}}><label>{{title}}</label><button class="destroy"></button></div></li>`; | ||
fill(template, `Something to do ${j}`, "", ""); | ||
} | ||
} | ||
} | ||
noInline(test); | ||
|
||
for (var i = 0; i < 100; ++i) | ||
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.