Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 #ifndef vm_ObjectImpl_inl_h
8 #define vm_ObjectImpl_inl_h
10 #include "vm/ObjectImpl.h"
12 #include "jscntxt.h"
13 #include "jsproxy.h"
15 #include "vm/ProxyObject.h"
16 #include "vm/TypedArrayObject.h"
18 namespace js {
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 }
31 *extensible = obj->nonProxyIsExtensible();
32 return true;
33 }
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 }
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 }
53 } // namespace js
55 #endif /* vm_ObjectImpl_inl_h */