tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

EdgeCaseAnalysis.cpp (1493B)


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