js/src/jit/IonAnalysis.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/IonAnalysis.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,149 @@
     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 +#ifndef jit_IonAnalysis_h
    1.11 +#define jit_IonAnalysis_h
    1.12 +
    1.13 +#ifdef JS_ION
    1.14 +
    1.15 +// This file declares various analysis passes that operate on MIR.
    1.16 +
    1.17 +#include "jit/IonAllocPolicy.h"
    1.18 +#include "jit/MIR.h"
    1.19 +
    1.20 +namespace js {
    1.21 +namespace jit {
    1.22 +
    1.23 +class MIRGenerator;
    1.24 +class MIRGraph;
    1.25 +
    1.26 +bool
    1.27 +SplitCriticalEdges(MIRGraph &graph);
    1.28 +
    1.29 +enum Observability {
    1.30 +    ConservativeObservability,
    1.31 +    AggressiveObservability
    1.32 +};
    1.33 +
    1.34 +bool
    1.35 +EliminatePhis(MIRGenerator *mir, MIRGraph &graph, Observability observe);
    1.36 +
    1.37 +bool
    1.38 +EliminateDeadResumePointOperands(MIRGenerator *mir, MIRGraph &graph);
    1.39 +
    1.40 +bool
    1.41 +EliminateDeadCode(MIRGenerator *mir, MIRGraph &graph);
    1.42 +
    1.43 +bool
    1.44 +ApplyTypeInformation(MIRGenerator *mir, MIRGraph &graph);
    1.45 +
    1.46 +bool
    1.47 +MakeMRegExpHoistable(MIRGraph &graph);
    1.48 +
    1.49 +bool
    1.50 +RenumberBlocks(MIRGraph &graph);
    1.51 +
    1.52 +bool
    1.53 +BuildDominatorTree(MIRGraph &graph);
    1.54 +
    1.55 +bool
    1.56 +BuildPhiReverseMapping(MIRGraph &graph);
    1.57 +
    1.58 +void
    1.59 +AssertBasicGraphCoherency(MIRGraph &graph);
    1.60 +
    1.61 +void
    1.62 +AssertGraphCoherency(MIRGraph &graph);
    1.63 +
    1.64 +void
    1.65 +AssertExtendedGraphCoherency(MIRGraph &graph);
    1.66 +
    1.67 +bool
    1.68 +EliminateRedundantChecks(MIRGraph &graph);
    1.69 +
    1.70 +bool
    1.71 +UnsplitEdges(LIRGraph *lir);
    1.72 +
    1.73 +class MDefinition;
    1.74 +
    1.75 +// Simple linear sum of the form 'n' or 'x + n'.
    1.76 +struct SimpleLinearSum
    1.77 +{
    1.78 +    MDefinition *term;
    1.79 +    int32_t constant;
    1.80 +
    1.81 +    SimpleLinearSum(MDefinition *term, int32_t constant)
    1.82 +        : term(term), constant(constant)
    1.83 +    {}
    1.84 +};
    1.85 +
    1.86 +SimpleLinearSum
    1.87 +ExtractLinearSum(MDefinition *ins);
    1.88 +
    1.89 +bool
    1.90 +ExtractLinearInequality(MTest *test, BranchDirection direction,
    1.91 +                        SimpleLinearSum *plhs, MDefinition **prhs, bool *plessEqual);
    1.92 +
    1.93 +struct LinearTerm
    1.94 +{
    1.95 +    MDefinition *term;
    1.96 +    int32_t scale;
    1.97 +
    1.98 +    LinearTerm(MDefinition *term, int32_t scale)
    1.99 +      : term(term), scale(scale)
   1.100 +    {
   1.101 +    }
   1.102 +};
   1.103 +
   1.104 +// General linear sum of the form 'x1*n1 + x2*n2 + ... + n'
   1.105 +class LinearSum
   1.106 +{
   1.107 +  public:
   1.108 +    LinearSum(TempAllocator &alloc)
   1.109 +      : terms_(alloc),
   1.110 +        constant_(0)
   1.111 +    {
   1.112 +    }
   1.113 +
   1.114 +    LinearSum(const LinearSum &other)
   1.115 +      : terms_(other.terms_.allocPolicy()),
   1.116 +        constant_(other.constant_)
   1.117 +    {
   1.118 +        terms_.appendAll(other.terms_);
   1.119 +    }
   1.120 +
   1.121 +    bool multiply(int32_t scale);
   1.122 +    bool add(const LinearSum &other);
   1.123 +    bool add(MDefinition *term, int32_t scale);
   1.124 +    bool add(int32_t constant);
   1.125 +
   1.126 +    int32_t constant() const { return constant_; }
   1.127 +    size_t numTerms() const { return terms_.length(); }
   1.128 +    LinearTerm term(size_t i) const { return terms_[i]; }
   1.129 +
   1.130 +    void print(Sprinter &sp) const;
   1.131 +    void dump(FILE *) const;
   1.132 +    void dump() const;
   1.133 +
   1.134 +  private:
   1.135 +    Vector<LinearTerm, 2, IonAllocPolicy> terms_;
   1.136 +    int32_t constant_;
   1.137 +};
   1.138 +
   1.139 +bool
   1.140 +AnalyzeNewScriptProperties(JSContext *cx, JSFunction *fun,
   1.141 +                           types::TypeObject *type, HandleObject baseobj,
   1.142 +                           Vector<types::TypeNewScript::Initializer> *initializerList);
   1.143 +
   1.144 +bool
   1.145 +AnalyzeArgumentsUsage(JSContext *cx, JSScript *script);
   1.146 +
   1.147 +} // namespace jit
   1.148 +} // namespace js
   1.149 +
   1.150 +#endif // JS_ION
   1.151 +
   1.152 +#endif /* jit_IonAnalysis_h */

mercurial