js/src/vm/ObjectImpl-inl.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:1ff51df20770
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_ObjectImpl_inl_h
8 #define vm_ObjectImpl_inl_h
9
10 #include "vm/ObjectImpl.h"
11
12 #include "jscntxt.h"
13 #include "jsproxy.h"
14
15 #include "vm/ProxyObject.h"
16 #include "vm/TypedArrayObject.h"
17
18 namespace js {
19
20 /* static */ inline bool
21 ObjectImpl::isExtensible(ExclusiveContext *cx, Handle<ObjectImpl*> obj, bool *extensible)
22 {
23 if (obj->asObjectPtr()->is<ProxyObject>()) {
24 if (!cx->shouldBeJSContext())
25 return false;
26 HandleObject h =
27 HandleObject::fromMarkedLocation(reinterpret_cast<JSObject* const*>(obj.address()));
28 return Proxy::isExtensible(cx->asJSContext(), h, extensible);
29 }
30
31 *extensible = obj->nonProxyIsExtensible();
32 return true;
33 }
34
35 inline bool
36 ClassCanHaveFixedData(const Class *clasp)
37 {
38 // Normally, the number of fixed slots given an object is the maximum
39 // permitted for its size class. For array buffers and typed arrays we only
40 // use enough to cover the class reserved slots, so that the remaining
41 // space in the object's allocation is available for the buffer's data.
42 return clasp == &ArrayBufferObject::class_ || IsTypedArrayClass(clasp);
43 }
44
45 inline void *
46 ObjectImpl::fixedData(size_t nslots) const
47 {
48 JS_ASSERT(ClassCanHaveFixedData(getClass()));
49 JS_ASSERT(nslots == numFixedSlots() + (hasPrivate() ? 1 : 0));
50 return &fixedSlots()[nslots];
51 }
52
53 } // namespace js
54
55 #endif /* vm_ObjectImpl_inl_h */

mercurial