js/src/jit/RematerializedFrame.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.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_RematerializedFrame_h
michael@0 8 #define jit_RematerializedFrame_h
michael@0 9
michael@0 10 #ifdef JS_ION
michael@0 11
michael@0 12 #include "jsfun.h"
michael@0 13
michael@0 14 #include "jit/JitFrameIterator.h"
michael@0 15
michael@0 16 #include "vm/Stack.h"
michael@0 17
michael@0 18 namespace js {
michael@0 19 namespace jit {
michael@0 20
michael@0 21 //
michael@0 22 // An optimized frame that has been rematerialized with values read out of
michael@0 23 // Snapshots.
michael@0 24 //
michael@0 25 class RematerializedFrame
michael@0 26 {
michael@0 27 // See DebugScopes::updateLiveScopes.
michael@0 28 bool prevUpToDate_;
michael@0 29
michael@0 30 // The fp of the top frame associated with this possibly inlined frame.
michael@0 31 uint8_t *top_;
michael@0 32
michael@0 33 size_t frameNo_;
michael@0 34 unsigned numActualArgs_;
michael@0 35
michael@0 36 JSScript *script_;
michael@0 37 JSObject *scopeChain_;
michael@0 38 ArgumentsObject *argsObj_;
michael@0 39
michael@0 40 Value returnValue_;
michael@0 41 Value thisValue_;
michael@0 42 Value slots_[1];
michael@0 43
michael@0 44 RematerializedFrame(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
michael@0 45
michael@0 46 public:
michael@0 47 static RematerializedFrame *New(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
michael@0 48
michael@0 49 bool prevUpToDate() const {
michael@0 50 return prevUpToDate_;
michael@0 51 }
michael@0 52 void setPrevUpToDate() {
michael@0 53 prevUpToDate_ = true;
michael@0 54 }
michael@0 55
michael@0 56 uint8_t *top() const {
michael@0 57 return top_;
michael@0 58 }
michael@0 59 size_t frameNo() const {
michael@0 60 return frameNo_;
michael@0 61 }
michael@0 62 bool inlined() const {
michael@0 63 return frameNo_ > 0;
michael@0 64 }
michael@0 65
michael@0 66 JSObject *scopeChain() const {
michael@0 67 return scopeChain_;
michael@0 68 }
michael@0 69 bool hasCallObj() const {
michael@0 70 return maybeFun() && fun()->isHeavyweight();
michael@0 71 }
michael@0 72 CallObject &callObj() const;
michael@0 73
michael@0 74 bool hasArgsObj() const {
michael@0 75 return !!argsObj_;
michael@0 76 }
michael@0 77 ArgumentsObject &argsObj() const {
michael@0 78 MOZ_ASSERT(hasArgsObj());
michael@0 79 MOZ_ASSERT(script()->needsArgsObj());
michael@0 80 return *argsObj_;
michael@0 81 }
michael@0 82
michael@0 83 bool isFunctionFrame() const {
michael@0 84 return !!script_->functionNonDelazifying();
michael@0 85 }
michael@0 86 bool isGlobalFrame() const {
michael@0 87 return !isFunctionFrame();
michael@0 88 }
michael@0 89 bool isNonEvalFunctionFrame() const {
michael@0 90 // Ion doesn't support eval frames.
michael@0 91 return isFunctionFrame();
michael@0 92 }
michael@0 93
michael@0 94 JSScript *script() const {
michael@0 95 return script_;
michael@0 96 }
michael@0 97 JSFunction *fun() const {
michael@0 98 MOZ_ASSERT(isFunctionFrame());
michael@0 99 return script_->functionNonDelazifying();
michael@0 100 }
michael@0 101 JSFunction *maybeFun() const {
michael@0 102 return isFunctionFrame() ? fun() : nullptr;
michael@0 103 }
michael@0 104 JSFunction *callee() const {
michael@0 105 return fun();
michael@0 106 }
michael@0 107 Value calleev() const {
michael@0 108 return ObjectValue(*fun());
michael@0 109 }
michael@0 110 Value &thisValue() {
michael@0 111 return thisValue_;
michael@0 112 }
michael@0 113
michael@0 114 unsigned numFormalArgs() const {
michael@0 115 return maybeFun() ? fun()->nargs() : 0;
michael@0 116 }
michael@0 117 unsigned numActualArgs() const {
michael@0 118 return numActualArgs_;
michael@0 119 }
michael@0 120
michael@0 121 Value *argv() {
michael@0 122 return slots_;
michael@0 123 }
michael@0 124 Value *locals() {
michael@0 125 return slots_ + numActualArgs_;
michael@0 126 }
michael@0 127
michael@0 128 Value &unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
michael@0 129 JS_ASSERT_IF(checkAliasing, !script()->varIsAliased(i));
michael@0 130 JS_ASSERT(i < script()->nfixed());
michael@0 131 return locals()[i];
michael@0 132 }
michael@0 133 Value &unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
michael@0 134 JS_ASSERT(i < script()->nfixed());
michael@0 135 #ifdef DEBUG
michael@0 136 CheckLocalUnaliased(checkAliasing, script(), i);
michael@0 137 #endif
michael@0 138 return locals()[i];
michael@0 139 }
michael@0 140 Value &unaliasedFormal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
michael@0 141 JS_ASSERT(i < numFormalArgs());
michael@0 142 JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals() &&
michael@0 143 !script()->formalIsAliased(i));
michael@0 144 return argv()[i];
michael@0 145 }
michael@0 146 Value &unaliasedActual(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
michael@0 147 JS_ASSERT(i < numActualArgs());
michael@0 148 JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals());
michael@0 149 JS_ASSERT_IF(checkAliasing && i < numFormalArgs(), !script()->formalIsAliased(i));
michael@0 150 return argv()[i];
michael@0 151 }
michael@0 152
michael@0 153 Value returnValue() const {
michael@0 154 return returnValue_;
michael@0 155 }
michael@0 156
michael@0 157 void mark(JSTracer *trc);
michael@0 158 void dump();
michael@0 159 };
michael@0 160
michael@0 161 } // namespace jit
michael@0 162 } // namespace js
michael@0 163
michael@0 164 #endif // JS_ION
michael@0 165 #endif // jit_RematerializedFrame_h

mercurial