Skip to content

Commit

Permalink
Add a hasTraps() check in B3::Value::effects()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=273648
rdar://127458113

Reviewed by Yusuke Suzuki.

Some profiling of reduceStrength showed we spent a number of samples
in B3::Value::effects() checking traps(). But most B3 Kinds don't
ever have traps(). Since we just switched on the Kind we can use
`hasTraps()` hoist the traps() check into the cases that actually
use it.

* Source/JavaScriptCore/b3/B3EliminateDeadCode.cpp:
(JSC::B3::eliminateDeadCodeImpl):
* Source/JavaScriptCore/b3/B3Value.cpp:
(JSC::B3::Value::effects const):

Canonical link: https://commits.webkit.org/278338@main
  • Loading branch information
kmiller68 committed May 3, 2024
1 parent a464656 commit a649419
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/b3/B3EliminateDeadCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool eliminateDeadCodeImpl(Procedure& proc)
{
bool changed = false;
GraphNodeWorklist<Value*, IndexSet<Value*>> worklist;
Vector<UpsilonValue*, 64> upsilons;
Vector<UpsilonValue*, 128> upsilons;
for (BasicBlock* block : proc) {
for (Value* value : *block) {
Effects effects;
Expand Down
4 changes: 3 additions & 1 deletion Source/JavaScriptCore/b3/B3Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,9 @@ Effects Value::effects() const
result.terminal = true;
break;
}
if (traps()) {
// We check hasTraps() first because most Kinds don't trap and we just switched on the
// Kind above. So in most cases the compiler won't bother loading the traps() bit.
if (kind().hasTraps() && traps()) {
result.exitsSideways = true;
result.reads = HeapRange::top();
}
Expand Down

0 comments on commit a649419

Please sign in to comment.