Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Source/JavaScriptCore:
DFG+FTL should generate efficient code for branching on a string's boolean value. <https://webkit.org/b/144317> Reviewed by Geoff Garen & Filip Pizlo Teach Branch nodes about StringUse and have them generate an efficient zero-length string check instead of dropping out to C++ whenever we branch on a string. The FTL JIT already handled Branch nodes with StringUse through its use of boolify(), so only the DFG JIT gets some new codegen logic in this patch. Test: js/regress/branch-on-string-as-boolean.js (~4.5x speedup) * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::emitStringBranch): * dfg/DFGSpeculativeJIT.h: * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::emitBranch): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::emitBranch): LayoutTests: DFG should generate efficient code for branching on a string's boolean value. <https://webkit.org/b/144317> Reviewed by Geoff Garen & Filip Pizlo. * js/regress/branch-on-string-as-boolean-expected.txt: Added. * js/regress/branch-on-string-as-boolean.html: Added. * js/regress/script-tests/branch-on-string-as-boolean.js: Added. Canonical link: https://commits.webkit.org/162348@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
with
93 additions
and 1 deletion.
- +11 −0 LayoutTests/ChangeLog
- +10 −0 LayoutTests/js/regress/branch-on-string-as-boolean-expected.txt
- +12 −0 LayoutTests/js/regress/branch-on-string-as-boolean.html
- +12 −0 LayoutTests/js/regress/script-tests/branch-on-string-as-boolean.js
- +25 −0 Source/JavaScriptCore/ChangeLog
- +2 −0 Source/JavaScriptCore/dfg/DFGFixupPhase.cpp
- +9 −0 Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp
- +1 −0 Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h
- +6 −1 Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp
- +5 −0 Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
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
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
@@ -0,0 +1,10 @@ | ||
JSRegress/branch-on-string-as-boolean | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS no exception thrown | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script src="../../resources/regress-pre.js"></script> | ||
<script src="script-tests/branch-on-string-as-boolean.js"></script> | ||
<script src="../../resources/regress-post.js"></script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
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
@@ -0,0 +1,12 @@ | ||
// This test branches on the boolean value of a string, which should be fast in the DFG. | ||
|
||
function foo(string) { | ||
var bar; | ||
for (var i = 0; i < 10000000; ++i) { | ||
if (string) | ||
bar++; | ||
} | ||
return bar; | ||
} | ||
|
||
result = foo('hurr im a string'); |
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