Title: [214926] trunk/Source/_javascript_Core
- Revision
- 214926
- Author
- [email protected]
- Date
- 2017-04-04 20:43:44 -0700 (Tue, 04 Apr 2017)
Log Message
Air::eliminateDeadCode should not repeatedly process the same live instructions
https://bugs.webkit.org/show_bug.cgi?id=170490
Reviewed by Keith Miller.
This makes the eliminateDeadCode() fixpoint somewhat worklist-based: we track the set
of Insts that might be dead. Every time we detect that one is live, we remove it from
the set. This is a big (>2x) speed-up because lots of Insts are immediately found to
be live.
This is a ~1% wasm -O1 compile time progression.
* b3/air/AirEliminateDeadCode.cpp:
(JSC::B3::Air::eliminateDeadCode):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (214925 => 214926)
--- trunk/Source/_javascript_Core/ChangeLog 2017-04-05 03:26:03 UTC (rev 214925)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-04-05 03:43:44 UTC (rev 214926)
@@ -1,5 +1,22 @@
2017-04-04 Filip Pizlo <[email protected]>
+ Air::eliminateDeadCode should not repeatedly process the same live instructions
+ https://bugs.webkit.org/show_bug.cgi?id=170490
+
+ Reviewed by Keith Miller.
+
+ This makes the eliminateDeadCode() fixpoint somewhat worklist-based: we track the set
+ of Insts that might be dead. Every time we detect that one is live, we remove it from
+ the set. This is a big (>2x) speed-up because lots of Insts are immediately found to
+ be live.
+
+ This is a ~1% wasm -O1 compile time progression.
+
+ * b3/air/AirEliminateDeadCode.cpp:
+ (JSC::B3::Air::eliminateDeadCode):
+
+2017-04-04 Filip Pizlo <[email protected]>
+
Air::eliminateDeadCode() should not use a HashSet
https://bugs.webkit.org/show_bug.cgi?id=170487
Modified: trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp (214925 => 214926)
--- trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp 2017-04-05 03:26:03 UTC (rev 214925)
+++ trunk/Source/_javascript_Core/b3/air/AirEliminateDeadCode.cpp 2017-04-05 03:43:44 UTC (rev 214926)
@@ -44,7 +44,7 @@
TmpSet liveTmps;
IndexSet<StackSlot*> liveStackSlots;
bool changed;
-
+
auto isArgLive = [&] (const Arg& arg) -> bool {
switch (arg.kind()) {
case Arg::Tmp:
@@ -60,21 +60,6 @@
}
};
- auto addLiveArg = [&] (const Arg& arg) -> bool {
- switch (arg.kind()) {
- case Arg::Tmp:
- if (arg.isReg())
- return false;
- return liveTmps.add(arg.tmp());
- case Arg::Stack:
- if (arg.stackSlot()->isLocked())
- return false;
- return liveStackSlots.add(arg.stackSlot());
- default:
- return false;
- }
- };
-
auto isInstLive = [&] (Inst& inst) -> bool {
if (inst.hasNonArgEffects())
return true;
@@ -91,39 +76,55 @@
});
return storesToLive;
};
-
- auto handleInst = [&] (Inst& inst) {
+
+ // Returns true if it's live.
+ auto handleInst = [&] (Inst& inst) -> bool {
if (!isInstLive(inst))
- return;
+ return false;
// We get here if the Inst is live. For simplicity we say that a live instruction forces
// liveness upon everything it mentions.
for (Arg& arg : inst.args) {
- changed |= addLiveArg(arg);
+ if (arg.isStack() && !arg.stackSlot()->isLocked())
+ changed |= liveStackSlots.add(arg.stackSlot());
arg.forEachTmpFast(
[&] (Tmp& tmp) {
- changed |= addLiveArg(tmp);
+ if (!tmp.isReg())
+ changed |= liveTmps.add(tmp);
});
}
+ return true;
};
+ Vector<Inst*> possiblyDead;
+
+ for (BasicBlock* block : code) {
+ for (Inst& inst : *block) {
+ if (!handleInst(inst))
+ possiblyDead.append(&inst);
+ }
+ }
+
auto runForward = [&] () -> bool {
changed = false;
- for (BasicBlock* block : code) {
- for (Inst& inst : *block)
- handleInst(inst);
- }
+ possiblyDead.removeAllMatching(
+ [&] (Inst* inst) -> bool {
+ bool result = handleInst(*inst);
+ changed |= result;
+ return result;
+ });
return changed;
};
auto runBackward = [&] () -> bool {
changed = false;
- for (unsigned blockIndex = code.size(); blockIndex--;) {
- BasicBlock* block = code[blockIndex];
- if (!block)
- continue;
- for (unsigned instIndex = block->size(); instIndex--;)
- handleInst(block->at(instIndex));
+ for (unsigned i = possiblyDead.size(); i--;) {
+ bool result = handleInst(*possiblyDead[i]);
+ if (result) {
+ possiblyDead[i] = possiblyDead.last();
+ possiblyDead.removeLast();
+ changed = true;
+ }
}
return changed;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes