js/src/jit/BytecodeAnalysis.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     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/. */
     7 #ifndef jit_BytecodeAnalysis_h
     8 #define jit_BytecodeAnalysis_h
    10 #include "jsscript.h"
    11 #include "jit/IonAllocPolicy.h"
    12 #include "js/Vector.h"
    14 namespace js {
    15 namespace jit {
    17 // Basic information about bytecodes in the script.  Used to help baseline compilation.
    18 struct BytecodeInfo
    19 {
    20     static const uint16_t MAX_STACK_DEPTH = 0xffffU;
    21     uint16_t stackDepth;
    22     bool initialized : 1;
    23     bool jumpTarget : 1;
    24     bool jumpFallthrough : 1;
    25     bool fallthrough : 1;
    27     // If true, this is a JSOP_LOOPENTRY op inside a catch or finally block.
    28     bool loopEntryInCatchOrFinally : 1;
    30     void init(unsigned depth) {
    31         JS_ASSERT(depth <= MAX_STACK_DEPTH);
    32         JS_ASSERT_IF(initialized, stackDepth == depth);
    33         initialized = true;
    34         stackDepth = depth;
    35     }
    36 };
    38 class BytecodeAnalysis
    39 {
    40     JSScript *script_;
    41     Vector<BytecodeInfo, 0, IonAllocPolicy> infos_;
    43     bool usesScopeChain_;
    44     bool hasTryFinally_;
    45     bool hasSetArg_;
    47   public:
    48     explicit BytecodeAnalysis(TempAllocator &alloc, JSScript *script);
    50     bool init(TempAllocator &alloc, GSNCache &gsn);
    52     BytecodeInfo &info(jsbytecode *pc) {
    53         JS_ASSERT(infos_[script_->pcToOffset(pc)].initialized);
    54         return infos_[script_->pcToOffset(pc)];
    55     }
    57     BytecodeInfo *maybeInfo(jsbytecode *pc) {
    58         if (infos_[script_->pcToOffset(pc)].initialized)
    59             return &infos_[script_->pcToOffset(pc)];
    60         return nullptr;
    61     }
    63     bool usesScopeChain() const {
    64         return usesScopeChain_;
    65     }
    67     bool hasTryFinally() const {
    68         return hasTryFinally_;
    69     }
    71     bool hasSetArg() const {
    72         return hasSetArg_;
    73     }
    74 };
    77 } // namespace jit
    78 } // namespace js
    80 #endif /* jit_BytecodeAnalysis_h */

mercurial