/src/mozilla-central/js/src/jit/BytecodeAnalysis.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef jit_BytecodeAnalysis_h |
8 | | #define jit_BytecodeAnalysis_h |
9 | | |
10 | | #include "jit/JitAllocPolicy.h" |
11 | | #include "js/Vector.h" |
12 | | #include "vm/JSScript.h" |
13 | | |
14 | | namespace js { |
15 | | namespace jit { |
16 | | |
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 | | |
25 | | // If true, this is a JSOP_LOOPENTRY op inside a catch or finally block. |
26 | | bool loopEntryInCatchOrFinally : 1; |
27 | | |
28 | 1.07k | void init(unsigned depth) { |
29 | 1.07k | MOZ_ASSERT(depth <= MAX_STACK_DEPTH); |
30 | 1.07k | MOZ_ASSERT_IF(initialized, stackDepth == depth); |
31 | 1.07k | initialized = true; |
32 | 1.07k | stackDepth = depth; |
33 | 1.07k | } |
34 | | }; |
35 | | |
36 | | class BytecodeAnalysis |
37 | | { |
38 | | JSScript* script_; |
39 | | Vector<BytecodeInfo, 0, JitAllocPolicy> infos_; |
40 | | |
41 | | bool usesEnvironmentChain_; |
42 | | bool hasTryFinally_; |
43 | | |
44 | | public: |
45 | | explicit BytecodeAnalysis(TempAllocator& alloc, JSScript* script); |
46 | | |
47 | | MOZ_MUST_USE bool init(TempAllocator& alloc, GSNCache& gsn); |
48 | | |
49 | 15 | BytecodeInfo& info(jsbytecode* pc) { |
50 | 15 | MOZ_ASSERT(infos_[script_->pcToOffset(pc)].initialized); |
51 | 15 | return infos_[script_->pcToOffset(pc)]; |
52 | 15 | } |
53 | | |
54 | 1.04k | BytecodeInfo* maybeInfo(jsbytecode* pc) { |
55 | 1.04k | if (infos_[script_->pcToOffset(pc)].initialized) { |
56 | 1.02k | return &infos_[script_->pcToOffset(pc)]; |
57 | 1.02k | } |
58 | 17 | return nullptr; |
59 | 17 | } |
60 | | |
61 | 14 | bool usesEnvironmentChain() const { |
62 | 14 | return usesEnvironmentChain_; |
63 | 14 | } |
64 | | |
65 | 0 | bool hasTryFinally() const { |
66 | 0 | return hasTryFinally_; |
67 | 0 | } |
68 | | }; |
69 | | |
70 | | |
71 | | } // namespace jit |
72 | | } // namespace js |
73 | | |
74 | | #endif /* jit_BytecodeAnalysis_h */ |