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_SavedStacksInl_h
8 #define vm_SavedStacksInl_h
9 
10 #include "vm/SavedStacks.h"
11 
12 // Assert that if the given object is not null, it's Class is the
13 // SavedFrame::class_ or the given object is a cross-compartment or Xray wrapper
14 // around such an object.
15 //
16 // We allow wrappers here because the JSAPI functions for working with
17 // SavedFrame objects and the SavedFrame accessors themselves handle wrappers
18 // and use the original caller's compartment's principals to determine what
19 // level of data to present. Unwrapping and entering the referent's compartment
20 // would mess that up. See the module level documentation in
21 // `js/src/vm/SavedStacks.h` as well as the comments in `js/src/jsapi.h`.
AssertObjectIsSavedFrameOrWrapper(JSContext * cx,HandleObject stack)22 inline void js::AssertObjectIsSavedFrameOrWrapper(JSContext* cx,
23                                                   HandleObject stack) {
24   if (stack) {
25     MOZ_RELEASE_ASSERT(stack->canUnwrapAs<SavedFrame>());
26   }
27 }
28 
29 #endif  // vm_SavedStacksInl_h
30