Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 #ifndef jit_UnreachableCodeElimination_h
8 #define jit_UnreachableCodeElimination_h
10 #include "jit/MIRGraph.h"
12 namespace js {
13 namespace jit {
15 class MIRGraph;
17 class UnreachableCodeElimination
18 {
19 typedef Vector<MBasicBlock *, 16, SystemAllocPolicy> BlockList;
21 MIRGenerator *mir_;
22 MIRGraph &graph_;
23 uint32_t marked_;
24 bool redundantPhis_;
25 bool rerunAliasAnalysis_;
26 bool disableAliasAnalysis_;
28 bool prunePointlessBranchesAndMarkReachableBlocks();
29 void checkDependencyAndRemoveUsesFromUnmarkedBlocks(MDefinition *instr);
30 bool removeUnmarkedBlocksAndClearDominators();
31 bool removeUnmarkedBlocksAndCleanup();
33 bool enqueue(MBasicBlock *block, BlockList &list);
34 MBasicBlock *optimizableSuccessor(MBasicBlock *block);
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 {}
46 // Walks the graph and discovers what is reachable. Removes everything else.
47 bool analyze();
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);
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 };
61 } /* namespace jit */
62 } /* namespace js */
64 #endif /* jit_UnreachableCodeElimination_h */