1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
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_BaselineFrame_inl_h
8 #define jit_BaselineFrame_inl_h
10 #include "jit/BaselineFrame.h"
12 #include "vm/EnvironmentObject.h"
13 #include "vm/JSContext.h"
16 #include "vm/EnvironmentObject-inl.h"
17 #include "vm/JSScript-inl.h"
22 template <typename SpecificEnvironment
>
23 inline void BaselineFrame::pushOnEnvironmentChain(SpecificEnvironment
& env
) {
24 MOZ_ASSERT(*environmentChain() == env
.enclosingEnvironment());
26 if (IsFrameInitialEnvironment(this, env
)) {
27 flags_
|= HAS_INITIAL_ENV
;
31 template <typename SpecificEnvironment
>
32 inline void BaselineFrame::popOffEnvironmentChain() {
33 MOZ_ASSERT(envChain_
->is
<SpecificEnvironment
>());
34 envChain_
= &envChain_
->as
<SpecificEnvironment
>().enclosingEnvironment();
37 inline void BaselineFrame::replaceInnermostEnvironment(EnvironmentObject
& env
) {
38 MOZ_ASSERT(env
.enclosingEnvironment() ==
39 envChain_
->as
<EnvironmentObject
>().enclosingEnvironment());
43 inline bool BaselineFrame::pushLexicalEnvironment(JSContext
* cx
,
44 Handle
<LexicalScope
*> scope
) {
45 LexicalEnvironmentObject
* env
=
46 LexicalEnvironmentObject::createForFrame(cx
, scope
, this);
50 pushOnEnvironmentChain(*env
);
55 inline bool BaselineFrame::freshenLexicalEnvironment(JSContext
* cx
) {
56 Rooted
<LexicalEnvironmentObject
*> current(
57 cx
, &envChain_
->as
<LexicalEnvironmentObject
>());
58 LexicalEnvironmentObject
* clone
=
59 LexicalEnvironmentObject::clone(cx
, current
);
64 replaceInnermostEnvironment(*clone
);
68 inline bool BaselineFrame::recreateLexicalEnvironment(JSContext
* cx
) {
69 Rooted
<LexicalEnvironmentObject
*> current(
70 cx
, &envChain_
->as
<LexicalEnvironmentObject
>());
71 LexicalEnvironmentObject
* clone
=
72 LexicalEnvironmentObject::recreate(cx
, current
);
77 replaceInnermostEnvironment(*clone
);
81 inline CallObject
& BaselineFrame::callObj() const {
82 MOZ_ASSERT(hasInitialEnvironment());
83 MOZ_ASSERT(callee()->needsCallObject());
85 JSObject
* obj
= environmentChain();
86 while (!obj
->is
<CallObject
>()) {
87 obj
= obj
->enclosingEnvironment();
89 return obj
->as
<CallObject
>();
92 inline ICScript
* BaselineFrame::icScript() const {
93 if (JitOptions
.warpBuilder
) {
96 return script()->jitScript()->icScript();
99 inline JSScript
* BaselineFrame::invalidationScript() const {
100 if (!icScript()->isInlined()) {
103 return icScript()->inliningRoot()->owningScript();
106 inline void BaselineFrame::unsetIsDebuggee() {
107 MOZ_ASSERT(!script()->isDebuggee());
114 #endif /* jit_BaselineFrame_inl_h */