|
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_BaselineFrame_inl_h |
|
8 #define jit_BaselineFrame_inl_h |
|
9 |
|
10 #ifdef JS_ION |
|
11 |
|
12 #include "jit/BaselineFrame.h" |
|
13 |
|
14 #include "jscntxt.h" |
|
15 #include "jscompartment.h" |
|
16 |
|
17 #include "vm/ScopeObject.h" |
|
18 |
|
19 namespace js { |
|
20 namespace jit { |
|
21 |
|
22 inline void |
|
23 BaselineFrame::pushOnScopeChain(ScopeObject &scope) |
|
24 { |
|
25 JS_ASSERT(*scopeChain() == scope.enclosingScope() || |
|
26 *scopeChain() == scope.as<CallObject>().enclosingScope().as<DeclEnvObject>().enclosingScope()); |
|
27 scopeChain_ = &scope; |
|
28 } |
|
29 |
|
30 inline void |
|
31 BaselineFrame::popOffScopeChain() |
|
32 { |
|
33 scopeChain_ = &scopeChain_->as<ScopeObject>().enclosingScope(); |
|
34 } |
|
35 |
|
36 inline void |
|
37 BaselineFrame::popWith(JSContext *cx) |
|
38 { |
|
39 if (MOZ_UNLIKELY(cx->compartment()->debugMode())) |
|
40 DebugScopes::onPopWith(this); |
|
41 |
|
42 JS_ASSERT(scopeChain()->is<DynamicWithObject>()); |
|
43 popOffScopeChain(); |
|
44 } |
|
45 |
|
46 inline bool |
|
47 BaselineFrame::pushBlock(JSContext *cx, Handle<StaticBlockObject *> block) |
|
48 { |
|
49 JS_ASSERT(block->needsClone()); |
|
50 |
|
51 ClonedBlockObject *clone = ClonedBlockObject::create(cx, block, this); |
|
52 if (!clone) |
|
53 return false; |
|
54 pushOnScopeChain(*clone); |
|
55 |
|
56 return true; |
|
57 } |
|
58 |
|
59 inline void |
|
60 BaselineFrame::popBlock(JSContext *cx) |
|
61 { |
|
62 JS_ASSERT(scopeChain_->is<ClonedBlockObject>()); |
|
63 |
|
64 popOffScopeChain(); |
|
65 } |
|
66 |
|
67 inline CallObject & |
|
68 BaselineFrame::callObj() const |
|
69 { |
|
70 JS_ASSERT(hasCallObj()); |
|
71 JS_ASSERT(fun()->isHeavyweight()); |
|
72 |
|
73 JSObject *obj = scopeChain(); |
|
74 while (!obj->is<CallObject>()) |
|
75 obj = obj->enclosingScope(); |
|
76 return obj->as<CallObject>(); |
|
77 } |
|
78 |
|
79 } // namespace jit |
|
80 } // namespace js |
|
81 |
|
82 #endif // JS_ION |
|
83 |
|
84 #endif /* jit_BaselineFrame_inl_h */ |