|
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 #include "jit/EdgeCaseAnalysis.h" |
|
8 |
|
9 #include "jit/MIR.h" |
|
10 #include "jit/MIRGraph.h" |
|
11 |
|
12 using namespace js; |
|
13 using namespace js::jit; |
|
14 |
|
15 EdgeCaseAnalysis::EdgeCaseAnalysis(MIRGenerator *mir, MIRGraph &graph) |
|
16 : mir(mir), graph(graph) |
|
17 { |
|
18 } |
|
19 |
|
20 bool |
|
21 EdgeCaseAnalysis::analyzeLate() |
|
22 { |
|
23 // Renumber definitions for NeedNegativeZeroCheck under analyzeEdgeCasesBackward. |
|
24 uint32_t nextId = 1; |
|
25 |
|
26 for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) { |
|
27 if (mir->shouldCancel("Analyze Late (first loop)")) |
|
28 return false; |
|
29 for (MDefinitionIterator iter(*block); iter; iter++) { |
|
30 iter->setId(nextId++); |
|
31 iter->analyzeEdgeCasesForward(); |
|
32 } |
|
33 block->lastIns()->setId(nextId++); |
|
34 } |
|
35 |
|
36 for (PostorderIterator block(graph.poBegin()); block != graph.poEnd(); block++) { |
|
37 if (mir->shouldCancel("Analyze Late (second loop)")) |
|
38 return false; |
|
39 for (MInstructionReverseIterator riter(block->rbegin()); riter != block->rend(); riter++) |
|
40 riter->analyzeEdgeCasesBackward(); |
|
41 } |
|
42 |
|
43 return true; |
|
44 } |