1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sw=4 et tw=78:
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 :
8 : #ifndef ObjectImpl_inl_h___
9 : #define ObjectImpl_inl_h___
10 :
11 : #include "mozilla/Assertions.h"
12 :
13 : #include "jscell.h"
14 : #include "jscompartment.h"
15 : #include "jsgc.h"
16 : #include "jsgcmark.h"
17 :
18 : #include "js/TemplateLib.h"
19 :
20 : #include "ObjectImpl.h"
21 :
22 : inline bool
23 688463707 : js::ObjectImpl::isNative() const
24 : {
25 688463707 : return lastProperty()->isNative();
26 : }
27 :
28 : inline js::Class *
29 -1254933790 : js::ObjectImpl::getClass() const
30 : {
31 -1254933790 : return lastProperty()->getObjectClass();
32 : }
33 :
34 : inline JSClass *
35 4514852 : js::ObjectImpl::getJSClass() const
36 : {
37 4514852 : return Jsvalify(getClass());
38 : }
39 :
40 : inline bool
41 -1961284281 : js::ObjectImpl::hasClass(const Class *c) const
42 : {
43 -1961284281 : return getClass() == c;
44 : }
45 :
46 : inline const js::ObjectOps *
47 292915465 : js::ObjectImpl::getOps() const
48 : {
49 292915465 : return &getClass()->ops;
50 : }
51 :
52 : inline bool
53 43065765 : js::ObjectImpl::isDelegate() const
54 : {
55 43065765 : return lastProperty()->hasObjectFlag(BaseShape::DELEGATE);
56 : }
57 :
58 : inline bool
59 1249376344 : js::ObjectImpl::inDictionaryMode() const
60 : {
61 1249376344 : return lastProperty()->inDictionary();
62 : }
63 :
64 : /* static */ inline size_t
65 824887862 : js::ObjectImpl::dynamicSlotsCount(size_t nfixed, size_t span)
66 : {
67 824887862 : if (span <= nfixed)
68 354618519 : return 0;
69 470269343 : span -= nfixed;
70 470269343 : if (span <= SLOT_CAPACITY_MIN)
71 121677853 : return SLOT_CAPACITY_MIN;
72 :
73 348591490 : size_t slots = RoundUpPow2(span);
74 348591490 : MOZ_ASSERT(slots >= span);
75 348591490 : return slots;
76 : }
77 :
78 : inline size_t
79 30066688 : js::ObjectImpl::sizeOfThis() const
80 : {
81 30066688 : return arenaHeader()->getThingSize();
82 : }
83 :
84 : /* static */ inline void
85 90929 : js::ObjectImpl::readBarrier(ObjectImpl *obj)
86 : {
87 : #ifdef JSGC_INCREMENTAL
88 90929 : JSCompartment *comp = obj->compartment();
89 90929 : if (comp->needsBarrier()) {
90 153 : MOZ_ASSERT(!comp->rt->gcRunning);
91 153 : JSObject *tmp = obj->asObjectPtr();
92 153 : MarkObjectUnbarriered(comp->barrierTracer(), &tmp, "read barrier");
93 153 : JS_ASSERT(tmp == obj->asObjectPtr());
94 : }
95 : #endif
96 90929 : }
97 :
98 : inline void
99 5762604 : js::ObjectImpl::privateWriteBarrierPre(void **old)
100 : {
101 : #ifdef JSGC_INCREMENTAL
102 5762604 : JSCompartment *comp = compartment();
103 5762604 : if (comp->needsBarrier()) {
104 651 : if (*old && getClass()->trace)
105 160 : getClass()->trace(comp->barrierTracer(), this->asObjectPtr());
106 : }
107 : #endif
108 5762604 : }
109 :
110 : inline void
111 5762604 : js::ObjectImpl::privateWriteBarrierPost(void **old)
112 : {
113 5762604 : }
114 :
115 : /* static */ inline void
116 25461305 : js::ObjectImpl::writeBarrierPre(ObjectImpl *obj)
117 : {
118 : #ifdef JSGC_INCREMENTAL
119 : /*
120 : * This would normally be a null test, but TypeScript::global uses 0x1 as a
121 : * special value.
122 : */
123 25461305 : if (uintptr_t(obj) < 32)
124 20652497 : return;
125 :
126 4808808 : JSCompartment *comp = obj->compartment();
127 4808808 : if (comp->needsBarrier()) {
128 242 : MOZ_ASSERT(!comp->rt->gcRunning);
129 242 : JSObject *tmp = obj->asObjectPtr();
130 242 : MarkObjectUnbarriered(comp->barrierTracer(), &tmp, "write barrier");
131 242 : JS_ASSERT(tmp == obj->asObjectPtr());
132 : }
133 : #endif
134 : }
135 :
136 : /* static */ inline void
137 44090360 : js::ObjectImpl::writeBarrierPost(ObjectImpl *obj, void *addr)
138 : {
139 44090360 : }
140 :
141 : inline bool
142 46990631 : js::ObjectImpl::isExtensible() const
143 : {
144 46990631 : return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE);
145 : }
146 :
147 : #endif /* ObjectImpl_inl_h__ */
|