Wed, 31 Dec 2014 06:09:35 +0100
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_RematerializedFrame_h
8 #define jit_RematerializedFrame_h
10 #ifdef JS_ION
12 #include "jsfun.h"
14 #include "jit/JitFrameIterator.h"
16 #include "vm/Stack.h"
18 namespace js {
19 namespace jit {
21 //
22 // An optimized frame that has been rematerialized with values read out of
23 // Snapshots.
24 //
25 class RematerializedFrame
26 {
27 // See DebugScopes::updateLiveScopes.
28 bool prevUpToDate_;
30 // The fp of the top frame associated with this possibly inlined frame.
31 uint8_t *top_;
33 size_t frameNo_;
34 unsigned numActualArgs_;
36 JSScript *script_;
37 JSObject *scopeChain_;
38 ArgumentsObject *argsObj_;
40 Value returnValue_;
41 Value thisValue_;
42 Value slots_[1];
44 RematerializedFrame(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
46 public:
47 static RematerializedFrame *New(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
49 bool prevUpToDate() const {
50 return prevUpToDate_;
51 }
52 void setPrevUpToDate() {
53 prevUpToDate_ = true;
54 }
56 uint8_t *top() const {
57 return top_;
58 }
59 size_t frameNo() const {
60 return frameNo_;
61 }
62 bool inlined() const {
63 return frameNo_ > 0;
64 }
66 JSObject *scopeChain() const {
67 return scopeChain_;
68 }
69 bool hasCallObj() const {
70 return maybeFun() && fun()->isHeavyweight();
71 }
72 CallObject &callObj() const;
74 bool hasArgsObj() const {
75 return !!argsObj_;
76 }
77 ArgumentsObject &argsObj() const {
78 MOZ_ASSERT(hasArgsObj());
79 MOZ_ASSERT(script()->needsArgsObj());
80 return *argsObj_;
81 }
83 bool isFunctionFrame() const {
84 return !!script_->functionNonDelazifying();
85 }
86 bool isGlobalFrame() const {
87 return !isFunctionFrame();
88 }
89 bool isNonEvalFunctionFrame() const {
90 // Ion doesn't support eval frames.
91 return isFunctionFrame();
92 }
94 JSScript *script() const {
95 return script_;
96 }
97 JSFunction *fun() const {
98 MOZ_ASSERT(isFunctionFrame());
99 return script_->functionNonDelazifying();
100 }
101 JSFunction *maybeFun() const {
102 return isFunctionFrame() ? fun() : nullptr;
103 }
104 JSFunction *callee() const {
105 return fun();
106 }
107 Value calleev() const {
108 return ObjectValue(*fun());
109 }
110 Value &thisValue() {
111 return thisValue_;
112 }
114 unsigned numFormalArgs() const {
115 return maybeFun() ? fun()->nargs() : 0;
116 }
117 unsigned numActualArgs() const {
118 return numActualArgs_;
119 }
121 Value *argv() {
122 return slots_;
123 }
124 Value *locals() {
125 return slots_ + numActualArgs_;
126 }
128 Value &unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
129 JS_ASSERT_IF(checkAliasing, !script()->varIsAliased(i));
130 JS_ASSERT(i < script()->nfixed());
131 return locals()[i];
132 }
133 Value &unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
134 JS_ASSERT(i < script()->nfixed());
135 #ifdef DEBUG
136 CheckLocalUnaliased(checkAliasing, script(), i);
137 #endif
138 return locals()[i];
139 }
140 Value &unaliasedFormal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
141 JS_ASSERT(i < numFormalArgs());
142 JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals() &&
143 !script()->formalIsAliased(i));
144 return argv()[i];
145 }
146 Value &unaliasedActual(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
147 JS_ASSERT(i < numActualArgs());
148 JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals());
149 JS_ASSERT_IF(checkAliasing && i < numFormalArgs(), !script()->formalIsAliased(i));
150 return argv()[i];
151 }
153 Value returnValue() const {
154 return returnValue_;
155 }
157 void mark(JSTracer *trc);
158 void dump();
159 };
161 } // namespace jit
162 } // namespace js
164 #endif // JS_ION
165 #endif // jit_RematerializedFrame_h