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/. */
8 * Shadow definition of |JSObject| innards. (|js::NativeObject| is more
9 * accurate, but portions can sometimes be used in some non-native objects.) Do
10 * not use this directly!
13 #ifndef js_shadow_Object_h
14 #define js_shadow_Object_h
16 #include <stddef.h> // size_t
18 #include "js/shadow/Shape.h" // JS::shadow::Shape
19 #include "js/Value.h" // JS::Value
21 class JS_PUBLIC_API JSObject
;
25 class JS_PUBLIC_API Value
;
30 * This layout is shared by all native objects. For non-native objects, the
31 * shape may always be accessed safely, and other members may be as well,
32 * depending on the object's specific layout.
42 static constexpr size_t MAX_FIXED_SLOTS
= 16;
44 size_t numFixedSlots() const {
45 return (shape
->immutableFlags
& shadow::Shape::FIXED_SLOTS_MASK
) >>
46 shadow::Shape::FIXED_SLOTS_SHIFT
;
49 Value
* fixedSlots() const {
50 auto address
= reinterpret_cast<uintptr_t>(this);
51 return reinterpret_cast<JS::Value
*>(address
+ sizeof(shadow::Object
));
54 Value
& slotRef(size_t slot
) const {
55 size_t nfixed
= numFixedSlots();
57 return fixedSlots()[slot
];
59 return slots
[slot
- nfixed
];
67 #endif // js_shadow_Object_h