michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_IonAnalysis_h michael@0: #define jit_IonAnalysis_h michael@0: michael@0: #ifdef JS_ION michael@0: michael@0: // This file declares various analysis passes that operate on MIR. michael@0: michael@0: #include "jit/IonAllocPolicy.h" michael@0: #include "jit/MIR.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class MIRGenerator; michael@0: class MIRGraph; michael@0: michael@0: bool michael@0: SplitCriticalEdges(MIRGraph &graph); michael@0: michael@0: enum Observability { michael@0: ConservativeObservability, michael@0: AggressiveObservability michael@0: }; michael@0: michael@0: bool michael@0: EliminatePhis(MIRGenerator *mir, MIRGraph &graph, Observability observe); michael@0: michael@0: bool michael@0: EliminateDeadResumePointOperands(MIRGenerator *mir, MIRGraph &graph); michael@0: michael@0: bool michael@0: EliminateDeadCode(MIRGenerator *mir, MIRGraph &graph); michael@0: michael@0: bool michael@0: ApplyTypeInformation(MIRGenerator *mir, MIRGraph &graph); michael@0: michael@0: bool michael@0: MakeMRegExpHoistable(MIRGraph &graph); michael@0: michael@0: bool michael@0: RenumberBlocks(MIRGraph &graph); michael@0: michael@0: bool michael@0: BuildDominatorTree(MIRGraph &graph); michael@0: michael@0: bool michael@0: BuildPhiReverseMapping(MIRGraph &graph); michael@0: michael@0: void michael@0: AssertBasicGraphCoherency(MIRGraph &graph); michael@0: michael@0: void michael@0: AssertGraphCoherency(MIRGraph &graph); michael@0: michael@0: void michael@0: AssertExtendedGraphCoherency(MIRGraph &graph); michael@0: michael@0: bool michael@0: EliminateRedundantChecks(MIRGraph &graph); michael@0: michael@0: bool michael@0: UnsplitEdges(LIRGraph *lir); michael@0: michael@0: class MDefinition; michael@0: michael@0: // Simple linear sum of the form 'n' or 'x + n'. michael@0: struct SimpleLinearSum michael@0: { michael@0: MDefinition *term; michael@0: int32_t constant; michael@0: michael@0: SimpleLinearSum(MDefinition *term, int32_t constant) michael@0: : term(term), constant(constant) michael@0: {} michael@0: }; michael@0: michael@0: SimpleLinearSum michael@0: ExtractLinearSum(MDefinition *ins); michael@0: michael@0: bool michael@0: ExtractLinearInequality(MTest *test, BranchDirection direction, michael@0: SimpleLinearSum *plhs, MDefinition **prhs, bool *plessEqual); michael@0: michael@0: struct LinearTerm michael@0: { michael@0: MDefinition *term; michael@0: int32_t scale; michael@0: michael@0: LinearTerm(MDefinition *term, int32_t scale) michael@0: : term(term), scale(scale) michael@0: { michael@0: } michael@0: }; michael@0: michael@0: // General linear sum of the form 'x1*n1 + x2*n2 + ... + n' michael@0: class LinearSum michael@0: { michael@0: public: michael@0: LinearSum(TempAllocator &alloc) michael@0: : terms_(alloc), michael@0: constant_(0) michael@0: { michael@0: } michael@0: michael@0: LinearSum(const LinearSum &other) michael@0: : terms_(other.terms_.allocPolicy()), michael@0: constant_(other.constant_) michael@0: { michael@0: terms_.appendAll(other.terms_); michael@0: } michael@0: michael@0: bool multiply(int32_t scale); michael@0: bool add(const LinearSum &other); michael@0: bool add(MDefinition *term, int32_t scale); michael@0: bool add(int32_t constant); michael@0: michael@0: int32_t constant() const { return constant_; } michael@0: size_t numTerms() const { return terms_.length(); } michael@0: LinearTerm term(size_t i) const { return terms_[i]; } michael@0: michael@0: void print(Sprinter &sp) const; michael@0: void dump(FILE *) const; michael@0: void dump() const; michael@0: michael@0: private: michael@0: Vector terms_; michael@0: int32_t constant_; michael@0: }; michael@0: michael@0: bool michael@0: AnalyzeNewScriptProperties(JSContext *cx, JSFunction *fun, michael@0: types::TypeObject *type, HandleObject baseobj, michael@0: Vector *initializerList); michael@0: michael@0: bool michael@0: AnalyzeArgumentsUsage(JSContext *cx, JSScript *script); michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif // JS_ION michael@0: michael@0: #endif /* jit_IonAnalysis_h */