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_BytecodeAnalysis_h michael@0: #define jit_BytecodeAnalysis_h michael@0: michael@0: #include "jsscript.h" michael@0: #include "jit/IonAllocPolicy.h" michael@0: #include "js/Vector.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: // Basic information about bytecodes in the script. Used to help baseline compilation. michael@0: struct BytecodeInfo michael@0: { michael@0: static const uint16_t MAX_STACK_DEPTH = 0xffffU; michael@0: uint16_t stackDepth; michael@0: bool initialized : 1; michael@0: bool jumpTarget : 1; michael@0: bool jumpFallthrough : 1; michael@0: bool fallthrough : 1; michael@0: michael@0: // If true, this is a JSOP_LOOPENTRY op inside a catch or finally block. michael@0: bool loopEntryInCatchOrFinally : 1; michael@0: michael@0: void init(unsigned depth) { michael@0: JS_ASSERT(depth <= MAX_STACK_DEPTH); michael@0: JS_ASSERT_IF(initialized, stackDepth == depth); michael@0: initialized = true; michael@0: stackDepth = depth; michael@0: } michael@0: }; michael@0: michael@0: class BytecodeAnalysis michael@0: { michael@0: JSScript *script_; michael@0: Vector infos_; michael@0: michael@0: bool usesScopeChain_; michael@0: bool hasTryFinally_; michael@0: bool hasSetArg_; michael@0: michael@0: public: michael@0: explicit BytecodeAnalysis(TempAllocator &alloc, JSScript *script); michael@0: michael@0: bool init(TempAllocator &alloc, GSNCache &gsn); michael@0: michael@0: BytecodeInfo &info(jsbytecode *pc) { michael@0: JS_ASSERT(infos_[script_->pcToOffset(pc)].initialized); michael@0: return infos_[script_->pcToOffset(pc)]; michael@0: } michael@0: michael@0: BytecodeInfo *maybeInfo(jsbytecode *pc) { michael@0: if (infos_[script_->pcToOffset(pc)].initialized) michael@0: return &infos_[script_->pcToOffset(pc)]; michael@0: return nullptr; michael@0: } michael@0: michael@0: bool usesScopeChain() const { michael@0: return usesScopeChain_; michael@0: } michael@0: michael@0: bool hasTryFinally() const { michael@0: return hasTryFinally_; michael@0: } michael@0: michael@0: bool hasSetArg() const { michael@0: return hasSetArg_; michael@0: } michael@0: }; michael@0: michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_BytecodeAnalysis_h */