diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-07-18 12:18:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-07-18 12:18:15 -0700 |
commit | 1335cf78817d993a50c62a1c6395ffb35d0a0c63 (patch) | |
tree | 3340fc3aad5357aa91814d9dc240e5677ed63c8f /src | |
parent | 4fcd68852b622e59da22af02f974ea840ebc92e9 (diff) | |
download | binaryen-1335cf78817d993a50c62a1c6395ffb35d0a0c63.tar.gz binaryen-1335cf78817d993a50c62a1c6395ffb35d0a0c63.tar.bz2 binaryen-1335cf78817d993a50c62a1c6395ffb35d0a0c63.zip |
remove some old code in relooper
Diffstat (limited to 'src')
-rw-r--r-- | src/cfg/Relooper.cpp | 31 | ||||
-rw-r--r-- | src/cfg/Relooper.h | 26 |
2 files changed, 5 insertions, 52 deletions
diff --git a/src/cfg/Relooper.cpp b/src/cfg/Relooper.cpp index 9330be718..dbdaa5507 100644 --- a/src/cfg/Relooper.cpp +++ b/src/cfg/Relooper.cpp @@ -100,7 +100,6 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) { } bool SetLabel = true; // in some cases it is clear we can avoid setting label, see later - bool ForceSetLabel = Shape::IsEmulated(Parent) != nullptr; // A setting of the label variable (label = x) is necessary if it can // cause an impact. The main case is where we set label to x, then elsewhere @@ -170,7 +169,7 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) { Target = DefaultTarget; Details = ProcessedBranchesOut[DefaultTarget]; } - bool SetCurrLabel = (SetLabel && Target->IsCheckedMultipleEntry) || ForceSetLabel; + bool SetCurrLabel = SetLabel && Target->IsCheckedMultipleEntry; bool HasFusedContent = Fused && contains(Fused->InnerMap, Target->Id); wasm::Expression* CurrContent = nullptr; if (SetCurrLabel || Details->Type != Branch::Direct || HasFusedContent || Details->Code) { @@ -239,7 +238,7 @@ wasm::Expression* Block::Render(RelooperBuilder& Builder, bool InLoop) { CurrName = SwitchDefault; } // generate the content for this block - bool SetCurrLabel = (SetLabel && Target->IsCheckedMultipleEntry) || ForceSetLabel; + bool SetCurrLabel = SetLabel && Target->IsCheckedMultipleEntry; bool HasFusedContent = Fused && contains(Fused->InnerMap, Target->Id); wasm::Expression* CurrContent = nullptr; if (SetCurrLabel || Details->Type != Branch::Direct || HasFusedContent || Details->Code) { @@ -347,15 +346,9 @@ wasm::Expression* LoopShape::Render(RelooperBuilder& Builder, bool InLoop) { return Ret; } -// EmulatedShape - -wasm::Expression* EmulatedShape::Render(RelooperBuilder& Builder, bool InLoop) { - abort(); // TODO -} - // Relooper -Relooper::Relooper() : Root(nullptr), Emulate(false), MinSize(false), BlockIdCounter(1), ShapeIdCounter(0) { // block ID 0 is reserved for clearings +Relooper::Relooper() : Root(nullptr), MinSize(false), BlockIdCounter(1), ShapeIdCounter(0) { // block ID 0 is reserved for clearings } Relooper::~Relooper() { @@ -468,21 +461,6 @@ void Relooper::Calculate(Block *Entry) { return Simple; } - Shape *MakeEmulated(BlockSet &Blocks, Block *Entry, BlockSet &NextEntries) { - PrintDebug("creating emulated block with entry #%d and everything it can reach, %d blocks\n", Entry->Id, Blocks.size()); - EmulatedShape *Emulated = new EmulatedShape; - Notice(Emulated); - Emulated->Entry = Entry; - for (BlockSet::iterator iter = Blocks.begin(); iter != Blocks.end(); iter++) { - Block *Curr = *iter; - Emulated->Blocks.insert(Curr); - Curr->Parent = Emulated; - Solipsize(Curr, Branch::Continue, Emulated, Blocks); - } - Blocks.clear(); - return Emulated; - } - Shape *MakeLoop(BlockSet &Blocks, BlockSet& Entries, BlockSet &NextEntries) { // Find the inner blocks in this loop. Proceed backwards from the entries until // you reach a seen block, collecting as you go. @@ -794,9 +772,6 @@ void Relooper::Calculate(Block *Entry) { if (Entries->size() == 0) return Ret; if (Entries->size() == 1) { Block *Curr = *(Entries->begin()); - if (Parent->Emulate) { - Make(MakeEmulated(Blocks, Curr, *NextEntries)); - } if (Curr->BranchesIn.size() == 0) { // One entry, no looping ==> Simple Make(MakeSimple(Blocks, Curr, *NextEntries)); diff --git a/src/cfg/Relooper.h b/src/cfg/Relooper.h index 74a95c8bf..8ac877d08 100644 --- a/src/cfg/Relooper.h +++ b/src/cfg/Relooper.h @@ -218,7 +218,7 @@ struct Block { BlockBranchMap ProcessedBranchesOut; BlockSet ProcessedBranchesIn; Shape *Parent; // The shape we are directly inside - int Id; // A unique identifier, defined when added to relooper. Note that this uniquely identifies a *logical* block - if we split it, the two instances have the same content *and* the same Id + int Id; // A unique identifier, defined when added to relooper wasm::Expression* Code; // The code in this block. This can be arbitrary wasm code, including internal control flow, it should just not branch to the outside wasm::Expression* SwitchCondition; // If nullptr, then this block ends in ifs (or nothing). otherwise, this block ends in a switch, done on this condition bool IsCheckedMultipleEntry; // If true, we are a multiple entry, so reaching us requires setting the label variable @@ -251,16 +251,10 @@ struct Block { // // Loop: An infinite loop. // -// Emulated: Control flow is managed by a switch in a loop. This -// is necessary in some cases, for example when control -// flow is not known until runtime (indirect branches, -// setjmp returns, etc.) -// struct SimpleShape; struct MultipleShape; struct LoopShape; -struct EmulatedShape; struct Shape { int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper @@ -270,8 +264,7 @@ struct Shape { enum ShapeType { Simple, Multiple, - Loop, - Emulated + Loop }; ShapeType Type; @@ -283,7 +276,6 @@ struct Shape { static SimpleShape *IsSimple(Shape *It) { return It && It->Type == Simple ? (SimpleShape*)It : NULL; } static MultipleShape *IsMultiple(Shape *It) { return It && It->Type == Multiple ? (MultipleShape*)It : NULL; } static LoopShape *IsLoop(Shape *It) { return It && It->Type == Loop ? (LoopShape*)It : NULL; } - static EmulatedShape *IsEmulated(Shape *It) { return It && It->Type == Emulated ? (EmulatedShape*)It : NULL; } }; struct SimpleShape : public Shape { @@ -311,16 +303,6 @@ struct LoopShape : public Shape { wasm::Expression* Render(RelooperBuilder& Builder, bool InLoop) override; }; -// TODO EmulatedShape is only partially functional. Currently it can be used for the -// entire set of blocks being relooped, but not subsets. -struct EmulatedShape : public Shape { - Block *Entry; - BlockSet Blocks; - - EmulatedShape() : Shape(Emulated) { } - wasm::Expression* Render(RelooperBuilder& Builder, bool InLoop) override; -}; - // Implements the relooper algorithm for a function's blocks. // // Usage: @@ -336,7 +318,6 @@ struct Relooper { std::deque<Block*> Blocks; std::deque<Shape*> Shapes; Shape *Root; - bool Emulate; bool MinSize; int BlockIdCounter; int ShapeIdCounter; @@ -352,9 +333,6 @@ struct Relooper { // Renders the result. wasm::Expression* Render(RelooperBuilder& Builder); - // Sets whether we must emulate everything with switch-loop code - void SetEmulate(int E) { Emulate = !!E; } - // Sets us to try to minimize size void SetMinSize(bool MinSize_) { MinSize = MinSize_; } }; |