js/src/vm/ObjectImpl-inl.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef vm_ObjectImpl_inl_h
michael@0 8 #define vm_ObjectImpl_inl_h
michael@0 9
michael@0 10 #include "vm/ObjectImpl.h"
michael@0 11
michael@0 12 #include "jscntxt.h"
michael@0 13 #include "jsproxy.h"
michael@0 14
michael@0 15 #include "vm/ProxyObject.h"
michael@0 16 #include "vm/TypedArrayObject.h"
michael@0 17
michael@0 18 namespace js {
michael@0 19
michael@0 20 /* static */ inline bool
michael@0 21 ObjectImpl::isExtensible(ExclusiveContext *cx, Handle<ObjectImpl*> obj, bool *extensible)
michael@0 22 {
michael@0 23 if (obj->asObjectPtr()->is<ProxyObject>()) {
michael@0 24 if (!cx->shouldBeJSContext())
michael@0 25 return false;
michael@0 26 HandleObject h =
michael@0 27 HandleObject::fromMarkedLocation(reinterpret_cast<JSObject* const*>(obj.address()));
michael@0 28 return Proxy::isExtensible(cx->asJSContext(), h, extensible);
michael@0 29 }
michael@0 30
michael@0 31 *extensible = obj->nonProxyIsExtensible();
michael@0 32 return true;
michael@0 33 }
michael@0 34
michael@0 35 inline bool
michael@0 36 ClassCanHaveFixedData(const Class *clasp)
michael@0 37 {
michael@0 38 // Normally, the number of fixed slots given an object is the maximum
michael@0 39 // permitted for its size class. For array buffers and typed arrays we only
michael@0 40 // use enough to cover the class reserved slots, so that the remaining
michael@0 41 // space in the object's allocation is available for the buffer's data.
michael@0 42 return clasp == &ArrayBufferObject::class_ || IsTypedArrayClass(clasp);
michael@0 43 }
michael@0 44
michael@0 45 inline void *
michael@0 46 ObjectImpl::fixedData(size_t nslots) const
michael@0 47 {
michael@0 48 JS_ASSERT(ClassCanHaveFixedData(getClass()));
michael@0 49 JS_ASSERT(nslots == numFixedSlots() + (hasPrivate() ? 1 : 0));
michael@0 50 return &fixedSlots()[nslots];
michael@0 51 }
michael@0 52
michael@0 53 } // namespace js
michael@0 54
michael@0 55 #endif /* vm_ObjectImpl_inl_h */

mercurial