js/src/jit/UnreachableCodeElimination.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e6dad7f65640
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef jit_UnreachableCodeElimination_h
8 #define jit_UnreachableCodeElimination_h
9
10 #include "jit/MIRGraph.h"
11
12 namespace js {
13 namespace jit {
14
15 class MIRGraph;
16
17 class UnreachableCodeElimination
18 {
19 typedef Vector<MBasicBlock *, 16, SystemAllocPolicy> BlockList;
20
21 MIRGenerator *mir_;
22 MIRGraph &graph_;
23 uint32_t marked_;
24 bool redundantPhis_;
25 bool rerunAliasAnalysis_;
26 bool disableAliasAnalysis_;
27
28 bool prunePointlessBranchesAndMarkReachableBlocks();
29 void checkDependencyAndRemoveUsesFromUnmarkedBlocks(MDefinition *instr);
30 bool removeUnmarkedBlocksAndClearDominators();
31 bool removeUnmarkedBlocksAndCleanup();
32
33 bool enqueue(MBasicBlock *block, BlockList &list);
34 MBasicBlock *optimizableSuccessor(MBasicBlock *block);
35
36 public:
37 UnreachableCodeElimination(MIRGenerator *mir, MIRGraph &graph)
38 : mir_(mir),
39 graph_(graph),
40 marked_(0),
41 redundantPhis_(false),
42 rerunAliasAnalysis_(false),
43 disableAliasAnalysis_(false)
44 {}
45
46 // Walks the graph and discovers what is reachable. Removes everything else.
47 bool analyze();
48
49 // Removes any blocks that are not marked. Assumes that these blocks are not
50 // reachable. The parameter |marked| should be the number of blocks that
51 // are marked.
52 bool removeUnmarkedBlocks(size_t marked);
53
54 // Call this function to prevent alias analysis to run a second time if we
55 // do not need it.
56 void disableAliasAnalysis() {
57 disableAliasAnalysis_ = true;
58 }
59 };
60
61 } /* namespace jit */
62 } /* namespace js */
63
64 #endif /* jit_UnreachableCodeElimination_h */

mercurial