Bug 1874684 - Part 31: Correctly reject invalid durations in some RoundDuration calls...
[gecko.git] / js / src / jit / EdgeCaseAnalysis.cpp
bloba92ca93ddd00c3ba7ea80ce6b3748b66b2fe3c81
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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 #include "jit/EdgeCaseAnalysis.h"
9 #include "jit/MIR.h"
10 #include "jit/MIRGenerator.h"
11 #include "jit/MIRGraph.h"
13 using namespace js;
14 using namespace js::jit;
16 EdgeCaseAnalysis::EdgeCaseAnalysis(MIRGenerator* mir, MIRGraph& graph)
17 : mir(mir), graph(graph) {}
19 bool EdgeCaseAnalysis::analyzeLate() {
20 // Renumber definitions for NeedNegativeZeroCheck under
21 // analyzeEdgeCasesBackward.
22 uint32_t nextId = 0;
24 for (ReversePostorderIterator block(graph.rpoBegin());
25 block != graph.rpoEnd(); block++) {
26 for (MDefinitionIterator iter(*block); iter; iter++) {
27 if (mir->shouldCancel("Analyze Late (first loop)")) {
28 return false;
31 iter->setId(nextId++);
32 iter->analyzeEdgeCasesForward();
34 block->lastIns()->setId(nextId++);
37 for (PostorderIterator block(graph.poBegin()); block != graph.poEnd();
38 block++) {
39 for (MInstructionReverseIterator riter(block->rbegin());
40 riter != block->rend(); riter++) {
41 if (mir->shouldCancel("Analyze Late (second loop)")) {
42 return false;
45 riter->analyzeEdgeCasesBackward();
49 return true;