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/. */
6
7 #ifndef vm_FrameIter_inl_h
8 #define vm_FrameIter_inl_h
9
10 #include "vm/FrameIter.h"
11
12 #include "mozilla/Assertions.h" // MOZ_ASSERT, MOZ_CRASH
13
14 #include "jit/JSJitFrameIter.h" // js::jit::{InlineFrameIterator,MaybeReadFallback,ReadFrame_Actuals}
15 #include "vm/Stack.h" // js::InterpreterFrame
16
17 #include "vm/Stack-inl.h" // js::InterpreterFrame::unaliasedForEachActual
18
19 namespace js {
20
21 template <class Op>
unaliasedForEachActual(JSContext * cx,Op op)22 inline void FrameIter::unaliasedForEachActual(JSContext* cx, Op op) {
23 switch (data_.state_) {
24 case DONE:
25 break;
26 case INTERP:
27 interpFrame()->unaliasedForEachActual(op);
28 return;
29 case JIT:
30 MOZ_ASSERT(isJSJit());
31 if (jsJitFrame().isIonJS()) {
32 jit::MaybeReadFallback recover(cx, activation()->asJit(),
33 &jsJitFrame());
34 ionInlineFrames_.unaliasedForEachActual(cx, op, jit::ReadFrame_Actuals,
35 recover);
36 } else if (jsJitFrame().isBailoutJS()) {
37 // :TODO: (Bug 1070962) If we are introspecting the frame which is
38 // being bailed, then we might be in the middle of recovering
39 // instructions. Stacking computeInstructionResults implies that we
40 // might be recovering result twice. In the mean time, to avoid
41 // that, we just return Undefined values for instruction results
42 // which are not yet recovered.
43 jit::MaybeReadFallback fallback;
44 ionInlineFrames_.unaliasedForEachActual(cx, op, jit::ReadFrame_Actuals,
45 fallback);
46 } else {
47 MOZ_ASSERT(jsJitFrame().isBaselineJS());
48 jsJitFrame().unaliasedForEachActual(op, jit::ReadFrame_Actuals);
49 }
50 return;
51 }
52 MOZ_CRASH("Unexpected state");
53 }
54
55 } // namespace js
56
57 #endif // vm_FrameIter_inl_h
58