Line data Source code
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 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`.
22 : inline void
23 6 : js::AssertObjectIsSavedFrameOrWrapper(JSContext* cx, HandleObject stack)
24 : {
25 6 : if (stack)
26 6 : MOZ_RELEASE_ASSERT(js::SavedFrame::isSavedFrameOrWrapperAndNotProto(*stack));
27 6 : }
28 :
29 : #endif // vm_SavedStacksInl_h
|