js/src/jit/EdgeCaseAnalysis.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/EdgeCaseAnalysis.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "jit/EdgeCaseAnalysis.h"
    1.11 +
    1.12 +#include "jit/MIR.h"
    1.13 +#include "jit/MIRGraph.h"
    1.14 +
    1.15 +using namespace js;
    1.16 +using namespace js::jit;
    1.17 +
    1.18 +EdgeCaseAnalysis::EdgeCaseAnalysis(MIRGenerator *mir, MIRGraph &graph)
    1.19 +  : mir(mir), graph(graph)
    1.20 +{
    1.21 +}
    1.22 +
    1.23 +bool
    1.24 +EdgeCaseAnalysis::analyzeLate()
    1.25 +{
    1.26 +    // Renumber definitions for NeedNegativeZeroCheck under analyzeEdgeCasesBackward.
    1.27 +    uint32_t nextId = 1;
    1.28 +
    1.29 +    for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) {
    1.30 +        if (mir->shouldCancel("Analyze Late (first loop)"))
    1.31 +            return false;
    1.32 +        for (MDefinitionIterator iter(*block); iter; iter++) {
    1.33 +            iter->setId(nextId++);
    1.34 +            iter->analyzeEdgeCasesForward();
    1.35 +        }
    1.36 +        block->lastIns()->setId(nextId++);
    1.37 +    }
    1.38 +
    1.39 +    for (PostorderIterator block(graph.poBegin()); block != graph.poEnd(); block++) {
    1.40 +        if (mir->shouldCancel("Analyze Late (second loop)"))
    1.41 +            return false;
    1.42 +        for (MInstructionReverseIterator riter(block->rbegin()); riter != block->rend(); riter++)
    1.43 +            riter->analyzeEdgeCasesBackward();
    1.44 +    }
    1.45 +
    1.46 +    return true;
    1.47 +}

mercurial