js/src/jit/RematerializedFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/RematerializedFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,165 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef jit_RematerializedFrame_h
    1.11 +#define jit_RematerializedFrame_h
    1.12 +
    1.13 +#ifdef JS_ION
    1.14 +
    1.15 +#include "jsfun.h"
    1.16 +
    1.17 +#include "jit/JitFrameIterator.h"
    1.18 +
    1.19 +#include "vm/Stack.h"
    1.20 +
    1.21 +namespace js {
    1.22 +namespace jit {
    1.23 +
    1.24 +//
    1.25 +// An optimized frame that has been rematerialized with values read out of
    1.26 +// Snapshots.
    1.27 +//
    1.28 +class RematerializedFrame
    1.29 +{
    1.30 +    // See DebugScopes::updateLiveScopes.
    1.31 +    bool prevUpToDate_;
    1.32 +
    1.33 +    // The fp of the top frame associated with this possibly inlined frame.
    1.34 +    uint8_t *top_;
    1.35 +
    1.36 +    size_t frameNo_;
    1.37 +    unsigned numActualArgs_;
    1.38 +
    1.39 +    JSScript *script_;
    1.40 +    JSObject *scopeChain_;
    1.41 +    ArgumentsObject *argsObj_;
    1.42 +
    1.43 +    Value returnValue_;
    1.44 +    Value thisValue_;
    1.45 +    Value slots_[1];
    1.46 +
    1.47 +    RematerializedFrame(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
    1.48 +
    1.49 +  public:
    1.50 +    static RematerializedFrame *New(JSContext *cx, uint8_t *top, InlineFrameIterator &iter);
    1.51 +
    1.52 +    bool prevUpToDate() const {
    1.53 +        return prevUpToDate_;
    1.54 +    }
    1.55 +    void setPrevUpToDate() {
    1.56 +        prevUpToDate_ = true;
    1.57 +    }
    1.58 +
    1.59 +    uint8_t *top() const {
    1.60 +        return top_;
    1.61 +    }
    1.62 +    size_t frameNo() const {
    1.63 +        return frameNo_;
    1.64 +    }
    1.65 +    bool inlined() const {
    1.66 +        return frameNo_ > 0;
    1.67 +    }
    1.68 +
    1.69 +    JSObject *scopeChain() const {
    1.70 +        return scopeChain_;
    1.71 +    }
    1.72 +    bool hasCallObj() const {
    1.73 +        return maybeFun() && fun()->isHeavyweight();
    1.74 +    }
    1.75 +    CallObject &callObj() const;
    1.76 +
    1.77 +    bool hasArgsObj() const {
    1.78 +        return !!argsObj_;
    1.79 +    }
    1.80 +    ArgumentsObject &argsObj() const {
    1.81 +        MOZ_ASSERT(hasArgsObj());
    1.82 +        MOZ_ASSERT(script()->needsArgsObj());
    1.83 +        return *argsObj_;
    1.84 +    }
    1.85 +
    1.86 +    bool isFunctionFrame() const {
    1.87 +        return !!script_->functionNonDelazifying();
    1.88 +    }
    1.89 +    bool isGlobalFrame() const {
    1.90 +        return !isFunctionFrame();
    1.91 +    }
    1.92 +    bool isNonEvalFunctionFrame() const {
    1.93 +        // Ion doesn't support eval frames.
    1.94 +        return isFunctionFrame();
    1.95 +    }
    1.96 +
    1.97 +    JSScript *script() const {
    1.98 +        return script_;
    1.99 +    }
   1.100 +    JSFunction *fun() const {
   1.101 +        MOZ_ASSERT(isFunctionFrame());
   1.102 +        return script_->functionNonDelazifying();
   1.103 +    }
   1.104 +    JSFunction *maybeFun() const {
   1.105 +        return isFunctionFrame() ? fun() : nullptr;
   1.106 +    }
   1.107 +    JSFunction *callee() const {
   1.108 +        return fun();
   1.109 +    }
   1.110 +    Value calleev() const {
   1.111 +        return ObjectValue(*fun());
   1.112 +    }
   1.113 +    Value &thisValue() {
   1.114 +        return thisValue_;
   1.115 +    }
   1.116 +
   1.117 +    unsigned numFormalArgs() const {
   1.118 +        return maybeFun() ? fun()->nargs() : 0;
   1.119 +    }
   1.120 +    unsigned numActualArgs() const {
   1.121 +        return numActualArgs_;
   1.122 +    }
   1.123 +
   1.124 +    Value *argv() {
   1.125 +        return slots_;
   1.126 +    }
   1.127 +    Value *locals() {
   1.128 +        return slots_ + numActualArgs_;
   1.129 +    }
   1.130 +
   1.131 +    Value &unaliasedVar(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
   1.132 +        JS_ASSERT_IF(checkAliasing, !script()->varIsAliased(i));
   1.133 +        JS_ASSERT(i < script()->nfixed());
   1.134 +        return locals()[i];
   1.135 +    }
   1.136 +    Value &unaliasedLocal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
   1.137 +        JS_ASSERT(i < script()->nfixed());
   1.138 +#ifdef DEBUG
   1.139 +        CheckLocalUnaliased(checkAliasing, script(), i);
   1.140 +#endif
   1.141 +        return locals()[i];
   1.142 +    }
   1.143 +    Value &unaliasedFormal(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
   1.144 +        JS_ASSERT(i < numFormalArgs());
   1.145 +        JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals() &&
   1.146 +                                    !script()->formalIsAliased(i));
   1.147 +        return argv()[i];
   1.148 +    }
   1.149 +    Value &unaliasedActual(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING) {
   1.150 +        JS_ASSERT(i < numActualArgs());
   1.151 +        JS_ASSERT_IF(checkAliasing, !script()->argsObjAliasesFormals());
   1.152 +        JS_ASSERT_IF(checkAliasing && i < numFormalArgs(), !script()->formalIsAliased(i));
   1.153 +        return argv()[i];
   1.154 +    }
   1.155 +
   1.156 +    Value returnValue() const {
   1.157 +        return returnValue_;
   1.158 +    }
   1.159 +
   1.160 +    void mark(JSTracer *trc);
   1.161 +    void dump();
   1.162 +};
   1.163 +
   1.164 +} // namespace jit
   1.165 +} // namespace js
   1.166 +
   1.167 +#endif // JS_ION
   1.168 +#endif // jit_RematerializedFrame_h

mercurial