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 688248039 : js::ObjectImpl::isNative() const
24 : {
25 688248039 : return lastProperty()->isNative();
26 : }
27 :
28 : inline js::Class *
29 -1253645659 : js::ObjectImpl::getClass() const
30 : {
31 -1253645659 : return lastProperty()->getObjectClass();
32 : }
33 :
34 : inline JSClass *
35 4514840 : js::ObjectImpl::getJSClass() const
36 : {
37 4514840 : return Jsvalify(getClass());
38 : }
39 :
40 : inline bool
41 -1959774706 : js::ObjectImpl::hasClass(const Class *c) const
42 : {
43 -1959774706 : return getClass() == c;
44 : }
45 :
46 : inline const js::ObjectOps *
47 292838283 : js::ObjectImpl::getOps() const
48 : {
49 292838283 : return &getClass()->ops;
50 : }
51 :
52 : inline bool
53 43064621 : js::ObjectImpl::isDelegate() const
54 : {
55 43064621 : return lastProperty()->hasObjectFlag(BaseShape::DELEGATE);
56 : }
57 :
58 : inline bool
59 1249493977 : js::ObjectImpl::inDictionaryMode() const
60 : {
61 1249493977 : return lastProperty()->inDictionary();
62 : }
63 :
64 : /* static */ inline size_t
65 824529068 : js::ObjectImpl::dynamicSlotsCount(size_t nfixed, size_t span)
66 : {
67 824529068 : if (span <= nfixed)
68 354264865 : return 0;
69 470264203 : span -= nfixed;
70 470264203 : if (span <= SLOT_CAPACITY_MIN)
71 121686967 : return SLOT_CAPACITY_MIN;
72 :
73 348577236 : size_t slots = RoundUpPow2(span);
74 348577236 : MOZ_ASSERT(slots >= span);
75 348577236 : return slots;
76 : }
77 :
78 : inline size_t
79 30064424 : js::ObjectImpl::sizeOfThis() const
80 : {
81 30064424 : return arenaHeader()->getThingSize();
82 : }
83 :
84 : /* static */ inline void
85 90965 : js::ObjectImpl::readBarrier(ObjectImpl *obj)
86 : {
87 : #ifdef JSGC_INCREMENTAL
88 90965 : JSCompartment *comp = obj->compartment();
89 90965 : 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 90965 : }
97 :
98 : inline void
99 5762115 : js::ObjectImpl::privateWriteBarrierPre(void **old)
100 : {
101 : #ifdef JSGC_INCREMENTAL
102 5762115 : JSCompartment *comp = compartment();
103 5762115 : if (comp->needsBarrier()) {
104 651 : if (*old && getClass()->trace)
105 160 : getClass()->trace(comp->barrierTracer(), this->asObjectPtr());
106 : }
107 : #endif
108 5762115 : }
109 :
110 : inline void
111 5762115 : js::ObjectImpl::privateWriteBarrierPost(void **old)
112 : {
113 5762115 : }
114 :
115 : /* static */ inline void
116 25461967 : 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 25461967 : if (uintptr_t(obj) < 32)
124 20653637 : return;
125 :
126 4808330 : JSCompartment *comp = obj->compartment();
127 4808330 : 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 44090667 : js::ObjectImpl::writeBarrierPost(ObjectImpl *obj, void *addr)
138 : {
139 44090667 : }
140 :
141 : inline bool
142 46989218 : js::ObjectImpl::isExtensible() const
143 : {
144 46989218 : return !lastProperty()->hasObjectFlag(BaseShape::NOT_EXTENSIBLE);
145 : }
146 :
147 : #endif /* ObjectImpl_inl_h__ */
|