weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved. |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 26 | #ifndef Structure_h |
| 27 | #define Structure_h |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 28 | |
barraclough@apple.com | dfe18a5 | 2011-10-15 01:25:53 +0000 | [diff] [blame] | 29 | #include "ClassInfo.h" |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 30 | #include "IndexingType.h" |
mhahnenberg@apple.com | c1bc9d3 | 2013-01-24 21:39:55 +0000 | [diff] [blame] | 31 | #include "JSCJSValue.h" |
oliver@apple.com | ed66e77 | 2011-04-05 01:33:58 +0000 | [diff] [blame] | 32 | #include "JSCell.h" |
mjs@apple.com | 4fab811 | 2008-09-10 08:42:43 +0000 | [diff] [blame] | 33 | #include "JSType.h" |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 34 | #include "PropertyMapHashTable.h" |
barraclough@apple.com | 38d3c75 | 2012-05-12 00:39:43 +0000 | [diff] [blame] | 35 | #include "PropertyName.h" |
ggaren@apple.com | a850b06 | 2009-10-09 18:14:08 +0000 | [diff] [blame] | 36 | #include "PropertyNameArray.h" |
ggaren@apple.com | 5236be2 | 2009-10-17 05:52:20 +0000 | [diff] [blame] | 37 | #include "Protect.h" |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 38 | #include "StructureTransitionTable.h" |
hausmann@webkit.org | f580f32 | 2009-09-09 14:56:12 +0000 | [diff] [blame] | 39 | #include "JSTypeInfo.h" |
fpizlo@apple.com | 04e4115 | 2012-06-15 22:14:53 +0000 | [diff] [blame] | 40 | #include "Watchpoint.h" |
ggaren@apple.com | f03cbce | 2011-04-10 02:32:07 +0000 | [diff] [blame] | 41 | #include "Weak.h" |
levin@chromium.org | ca509e8 | 2011-04-25 21:48:58 +0000 | [diff] [blame] | 42 | #include <wtf/PassOwnPtr.h> |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 43 | #include <wtf/PassRefPtr.h> |
| 44 | #include <wtf/RefCounted.h> |
benjamin@webkit.org | cff06e4 | 2012-08-30 21:23:51 +0000 | [diff] [blame] | 45 | #include <wtf/text/StringImpl.h> |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 46 | |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 47 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 48 | namespace JSC { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 49 | |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 50 | class LLIntOffsetsExtractor; |
weinig@apple.com | 503d999 | 2008-09-15 07:27:14 +0000 | [diff] [blame] | 51 | class PropertyNameArray; |
weinig@apple.com | 18b17a6 | 2008-09-20 04:35:33 +0000 | [diff] [blame] | 52 | class PropertyNameArrayData; |
oliver@apple.com | 5914421 | 2011-04-04 18:41:15 +0000 | [diff] [blame] | 53 | class StructureChain; |
ggaren@apple.com | 6e1f8c1 | 2011-06-16 22:01:43 +0000 | [diff] [blame] | 54 | class SlotVisitor; |
msaboff@apple.com | 8bbd1b1 | 2012-04-25 00:58:17 +0000 | [diff] [blame] | 55 | class JSString; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 56 | |
fpizlo@apple.com | 1ffdcff | 2012-07-19 00:30:34 +0000 | [diff] [blame] | 57 | // The out-of-line property storage capacity to use when first allocating out-of-line |
| 58 | // storage. Note that all objects start out without having any out-of-line storage; |
| 59 | // this comes into play only on the first property store that exhausts inline storage. |
| 60 | static const unsigned initialOutOfLineCapacity = 4; |
| 61 | |
| 62 | // The factor by which to grow out-of-line storage when it is exhausted, after the |
| 63 | // initial allocation. |
| 64 | static const unsigned outOfLineGrowthFactor = 2; |
| 65 | |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 66 | class Structure : public JSCell { |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 67 | public: |
oliver@apple.com | d32bf7a | 2009-09-10 20:01:57 +0000 | [diff] [blame] | 68 | friend class StructureTransitionTable; |
commit-queue@webkit.org | 6c25c52 | 2011-08-09 20:46:17 +0000 | [diff] [blame] | 69 | |
| 70 | typedef JSCell Base; |
| 71 | |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame^] | 72 | static Structure* create(JSGlobalData&, JSGlobalObject*, JSValue prototype, const TypeInfo&, const ClassInfo*, IndexingType = NonArray, unsigned inlineCapacity = 0); |
weinig@apple.com | 2229430 | 2008-09-09 06:55:39 +0000 | [diff] [blame] | 73 | |
commit-queue@webkit.org | 403bfdf | 2011-08-26 22:32:53 +0000 | [diff] [blame] | 74 | protected: |
| 75 | void finishCreation(JSGlobalData& globalData) |
| 76 | { |
| 77 | Base::finishCreation(globalData); |
| 78 | ASSERT(m_prototype); |
| 79 | ASSERT(m_prototype.isObject() || m_prototype.isNull()); |
| 80 | } |
| 81 | |
| 82 | void finishCreation(JSGlobalData& globalData, CreatingEarlyCellTag) |
| 83 | { |
| 84 | Base::finishCreation(globalData, this, CreatingEarlyCell); |
| 85 | ASSERT(m_prototype); |
| 86 | ASSERT(m_prototype.isNull()); |
| 87 | ASSERT(!globalData.structureStructure); |
| 88 | } |
| 89 | |
| 90 | public: |
weinig@apple.com | 7b21967 | 2008-10-16 05:31:41 +0000 | [diff] [blame] | 91 | static void dumpStatistics(); |
weinig@apple.com | 7b21967 | 2008-10-16 05:31:41 +0000 | [diff] [blame] | 92 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 93 | JS_EXPORT_PRIVATE static Structure* addPropertyTransition(JSGlobalData&, Structure*, PropertyName, unsigned attributes, JSCell* specificValue, PropertyOffset&); |
| 94 | JS_EXPORT_PRIVATE static Structure* addPropertyTransitionToExistingStructure(Structure*, PropertyName, unsigned attributes, JSCell* specificValue, PropertyOffset&); |
| 95 | static Structure* removePropertyTransition(JSGlobalData&, Structure*, PropertyName, PropertyOffset&); |
morrita@google.com | f0dd2d9 | 2012-01-13 07:23:44 +0000 | [diff] [blame] | 96 | JS_EXPORT_PRIVATE static Structure* changePrototypeTransition(JSGlobalData&, Structure*, JSValue prototype); |
barraclough@apple.com | 38d3c75 | 2012-05-12 00:39:43 +0000 | [diff] [blame] | 97 | JS_EXPORT_PRIVATE static Structure* despecifyFunctionTransition(JSGlobalData&, Structure*, PropertyName); |
| 98 | static Structure* attributeChangeTransition(JSGlobalData&, Structure*, PropertyName, unsigned attributes); |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 99 | static Structure* toCacheableDictionaryTransition(JSGlobalData&, Structure*); |
| 100 | static Structure* toUncacheableDictionaryTransition(JSGlobalData&, Structure*); |
| 101 | static Structure* sealTransition(JSGlobalData&, Structure*); |
| 102 | static Structure* freezeTransition(JSGlobalData&, Structure*); |
| 103 | static Structure* preventExtensionsTransition(JSGlobalData&, Structure*); |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 104 | static Structure* nonPropertyTransition(JSGlobalData&, Structure*, NonPropertyTransition); |
barraclough@apple.com | dd99310 | 2011-03-04 22:34:48 +0000 | [diff] [blame] | 105 | |
oliver@apple.com | af134a7 | 2011-04-13 18:48:22 +0000 | [diff] [blame] | 106 | bool isSealed(JSGlobalData&); |
| 107 | bool isFrozen(JSGlobalData&); |
barraclough@apple.com | dd99310 | 2011-03-04 22:34:48 +0000 | [diff] [blame] | 108 | bool isExtensible() const { return !m_preventExtensions; } |
ggaren@apple.com | 21daf64 | 2011-04-26 06:23:14 +0000 | [diff] [blame] | 109 | bool didTransition() const { return m_didTransition; } |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 110 | bool putWillGrowOutOfLineStorage() |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 111 | { |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 112 | ASSERT(outOfLineCapacity() >= outOfLineSize()); |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 113 | |
| 114 | if (!m_propertyTable) { |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 115 | unsigned currentSize = numberOfOutOfLineSlotsForLastOffset(m_offset); |
| 116 | ASSERT(outOfLineCapacity() >= currentSize); |
| 117 | return currentSize == outOfLineCapacity(); |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 118 | } |
| 119 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 120 | ASSERT(totalStorageCapacity() >= m_propertyTable->propertyStorageSize()); |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 121 | if (m_propertyTable->hasDeletedOffset()) |
| 122 | return false; |
| 123 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 124 | ASSERT(totalStorageCapacity() >= m_propertyTable->size()); |
| 125 | return m_propertyTable->size() == totalStorageCapacity(); |
fpizlo@apple.com | 604d38a | 2012-07-01 03:54:49 +0000 | [diff] [blame] | 126 | } |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 127 | JS_EXPORT_PRIVATE size_t suggestedNewOutOfLineStorageCapacity(); |
oliver@apple.com | bd8e770 | 2009-11-10 02:19:04 +0000 | [diff] [blame] | 128 | |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 129 | Structure* flattenDictionaryStructure(JSGlobalData&, JSObject*); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 130 | |
mhahnenberg@apple.com | 30738a7 | 2012-10-03 17:51:28 +0000 | [diff] [blame] | 131 | static const bool needsDestruction = true; |
| 132 | static const bool hasImmortalStructure = true; |
mhahnenberg@apple.com | c58d54d | 2011-12-16 19:06:44 +0000 | [diff] [blame] | 133 | static void destroy(JSCell*); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 134 | |
weinig@apple.com | 5677e04 | 2008-10-20 21:27:44 +0000 | [diff] [blame] | 135 | // These should be used with caution. |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 136 | JS_EXPORT_PRIVATE PropertyOffset addPropertyWithoutTransition(JSGlobalData&, PropertyName, unsigned attributes, JSCell* specificValue); |
| 137 | PropertyOffset removePropertyWithoutTransition(JSGlobalData&, PropertyName); |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 138 | void setPrototypeWithoutTransition(JSGlobalData& globalData, JSValue prototype) { m_prototype.set(globalData, this, prototype); } |
oliver@apple.com | ae86589 | 2009-09-21 15:45:13 +0000 | [diff] [blame] | 139 | |
| 140 | bool isDictionary() const { return m_dictionaryKind != NoneDictionaryKind; } |
| 141 | bool isUncacheableDictionary() const { return m_dictionaryKind == UncachedDictionaryKind; } |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 142 | |
oliver@apple.com | c909f5f | 2012-10-18 23:37:40 +0000 | [diff] [blame] | 143 | bool propertyAccessesAreCacheable() { return m_dictionaryKind != UncachedDictionaryKind && !typeInfo().prohibitsPropertyCaching(); } |
| 144 | |
weinig@apple.com | 58576b2 | 2011-09-16 21:34:20 +0000 | [diff] [blame] | 145 | // Type accessors. |
jberlin@webkit.org | 3d6b468 | 2011-05-03 15:41:28 +0000 | [diff] [blame] | 146 | const TypeInfo& typeInfo() const { ASSERT(structure()->classInfo() == &s_info); return m_typeInfo; } |
weinig@apple.com | 58576b2 | 2011-09-16 21:34:20 +0000 | [diff] [blame] | 147 | bool isObject() const { return typeInfo().isObject(); } |
| 148 | |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 149 | IndexingType indexingType() const { return m_indexingType & AllArrayTypes; } |
| 150 | IndexingType indexingTypeIncludingHistory() const { return m_indexingType; } |
fpizlo@apple.com | 1c4a32c | 2012-09-17 20:56:39 +0000 | [diff] [blame] | 151 | |
| 152 | bool mayInterceptIndexedAccesses() const |
| 153 | { |
| 154 | return !!(indexingTypeIncludingHistory() & MayHaveIndexedAccessors); |
| 155 | } |
| 156 | |
| 157 | bool anyObjectInChainMayInterceptIndexedAccesses() const; |
| 158 | |
fpizlo@apple.com | 0e9910a | 2012-10-09 23:39:53 +0000 | [diff] [blame] | 159 | bool needsSlowPutIndexing() const; |
| 160 | NonPropertyTransition suggestedArrayStorageTransition() const; |
fpizlo@apple.com | 1c4a32c | 2012-09-17 20:56:39 +0000 | [diff] [blame] | 161 | |
oliver@apple.com | 2346a3e | 2011-09-07 19:40:41 +0000 | [diff] [blame] | 162 | JSGlobalObject* globalObject() const { return m_globalObject.get(); } |
oliver@apple.com | ee1bdc8 | 2011-09-06 21:51:00 +0000 | [diff] [blame] | 163 | void setGlobalObject(JSGlobalData& globalData, JSGlobalObject* globalObject) { m_globalObject.set(globalData, this, globalObject); } |
| 164 | |
oliver@apple.com | 168e506 | 2011-01-31 20:07:21 +0000 | [diff] [blame] | 165 | JSValue storedPrototype() const { return m_prototype.get(); } |
ggaren@apple.com | dc067b6 | 2009-05-01 22:43:39 +0000 | [diff] [blame] | 166 | JSValue prototypeForLookup(ExecState*) const; |
fpizlo@apple.com | fd598b9 | 2012-06-08 01:31:21 +0000 | [diff] [blame] | 167 | JSValue prototypeForLookup(JSGlobalObject*) const; |
| 168 | JSValue prototypeForLookup(CodeBlock*) const; |
fpizlo@apple.com | c2c6763 | 2012-11-17 08:37:14 +0000 | [diff] [blame] | 169 | StructureChain* prototypeChain(JSGlobalData&, JSGlobalObject*) const; |
ggaren@apple.com | c8bc3c8 | 2009-02-25 23:44:07 +0000 | [diff] [blame] | 170 | StructureChain* prototypeChain(ExecState*) const; |
mhahnenberg@apple.com | 982c9ea | 2011-09-23 19:40:09 +0000 | [diff] [blame] | 171 | static void visitChildren(JSCell*, SlotVisitor&); |
fpizlo@apple.com | e77cbc8 | 2012-11-15 20:20:02 +0000 | [diff] [blame] | 172 | |
| 173 | // Will just the prototype chain intercept this property access? |
| 174 | bool prototypeChainMayInterceptStoreTo(JSGlobalData&, PropertyName); |
| 175 | |
fpizlo@apple.com | c2c6763 | 2012-11-17 08:37:14 +0000 | [diff] [blame] | 176 | bool transitionDidInvolveSpecificValue() const { return !!m_specificValueInPrevious; } |
| 177 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 178 | Structure* previousID() const |
| 179 | { |
| 180 | ASSERT(structure()->classInfo() == &s_info); |
| 181 | return m_previous.get(); |
| 182 | } |
fpizlo@apple.com | 74d43ae | 2011-09-17 23:33:01 +0000 | [diff] [blame] | 183 | bool transitivelyTransitionedFrom(Structure* structureToFind); |
oliver@apple.com | e3c5d0e | 2008-09-14 08:18:49 +0000 | [diff] [blame] | 184 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 185 | void growOutOfLineCapacity(); |
| 186 | unsigned outOfLineCapacity() const |
| 187 | { |
| 188 | ASSERT(structure()->classInfo() == &s_info); |
| 189 | return m_outOfLineCapacity; |
| 190 | } |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 191 | unsigned outOfLineSize() const |
| 192 | { |
| 193 | ASSERT(structure()->classInfo() == &s_info); |
| 194 | if (m_propertyTable) { |
| 195 | unsigned totalSize = m_propertyTable->propertyStorageSize(); |
| 196 | unsigned inlineCapacity = this->inlineCapacity(); |
| 197 | if (totalSize < inlineCapacity) |
| 198 | return 0; |
| 199 | return totalSize - inlineCapacity; |
| 200 | } |
| 201 | return numberOfOutOfLineSlotsForLastOffset(m_offset); |
| 202 | } |
| 203 | bool hasInlineStorage() const |
| 204 | { |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 205 | return !!m_inlineCapacity; |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 206 | } |
| 207 | unsigned inlineCapacity() const |
| 208 | { |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 209 | return m_inlineCapacity; |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 210 | } |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 211 | unsigned inlineSize() const |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 212 | { |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 213 | unsigned result; |
| 214 | if (m_propertyTable) |
| 215 | result = m_propertyTable->propertyStorageSize(); |
| 216 | else |
| 217 | result = m_offset + 1; |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 218 | return std::min<unsigned>(result, m_inlineCapacity); |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 219 | } |
| 220 | unsigned totalStorageSize() const |
| 221 | { |
| 222 | if (m_propertyTable) |
| 223 | return m_propertyTable->propertyStorageSize(); |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame^] | 224 | return numberOfSlotsForLastOffset(m_offset, m_inlineCapacity); |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 225 | } |
| 226 | unsigned totalStorageCapacity() const |
| 227 | { |
| 228 | ASSERT(structure()->classInfo() == &s_info); |
| 229 | return m_outOfLineCapacity + inlineCapacity(); |
| 230 | } |
weinig@apple.com | a3b7bbb | 2008-10-30 02:44:46 +0000 | [diff] [blame] | 231 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 232 | PropertyOffset firstValidOffset() const |
| 233 | { |
| 234 | if (hasInlineStorage()) |
| 235 | return 0; |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 236 | return firstOutOfLineOffset; |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 237 | } |
| 238 | PropertyOffset lastValidOffset() const |
| 239 | { |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 240 | if (m_propertyTable) |
ggaren@apple.com | efd32fb2 | 2013-01-11 20:13:21 +0000 | [diff] [blame] | 241 | return offsetForPropertyNumber(m_propertyTable->propertyStorageSize() - 1, m_inlineCapacity); |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 242 | return m_offset; |
| 243 | } |
| 244 | bool isValidOffset(PropertyOffset offset) const |
| 245 | { |
| 246 | return offset >= firstValidOffset() |
| 247 | && offset <= lastValidOffset(); |
| 248 | } |
| 249 | |
mhahnenberg@apple.com | 3b9069c | 2012-08-23 23:00:31 +0000 | [diff] [blame] | 250 | bool masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject); |
| 251 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 252 | PropertyOffset get(JSGlobalData&, PropertyName); |
benjamin@webkit.org | cff06e4 | 2012-08-30 21:23:51 +0000 | [diff] [blame] | 253 | PropertyOffset get(JSGlobalData&, const WTF::String& name); |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 254 | JS_EXPORT_PRIVATE PropertyOffset get(JSGlobalData&, PropertyName, unsigned& attributes, JSCell*& specificValue); |
barraclough@apple.com | 0717324 | 2009-05-23 01:48:32 +0000 | [diff] [blame] | 255 | |
weinig@apple.com | 35ba29b | 2008-10-07 23:49:59 +0000 | [diff] [blame] | 256 | bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } |
barraclough@apple.com | 2668db9 | 2012-02-22 23:46:48 +0000 | [diff] [blame] | 257 | bool hasReadOnlyOrGetterSetterPropertiesExcludingProto() const { return m_hasReadOnlyOrGetterSetterPropertiesExcludingProto; } |
barraclough@apple.com | 4f5c0c0 | 2012-02-20 21:14:48 +0000 | [diff] [blame] | 258 | void setHasGetterSetterProperties(bool is__proto__) |
| 259 | { |
| 260 | m_hasGetterSetterProperties = true; |
| 261 | if (!is__proto__) |
barraclough@apple.com | 2668db9 | 2012-02-22 23:46:48 +0000 | [diff] [blame] | 262 | m_hasReadOnlyOrGetterSetterPropertiesExcludingProto = true; |
barraclough@apple.com | 7f154b8 | 2012-02-21 06:17:40 +0000 | [diff] [blame] | 263 | } |
| 264 | void setContainsReadOnlyProperties() |
| 265 | { |
barraclough@apple.com | 2668db9 | 2012-02-22 23:46:48 +0000 | [diff] [blame] | 266 | m_hasReadOnlyOrGetterSetterPropertiesExcludingProto = true; |
barraclough@apple.com | 4f5c0c0 | 2012-02-20 21:14:48 +0000 | [diff] [blame] | 267 | } |
weinig@apple.com | 35ba29b | 2008-10-07 23:49:59 +0000 | [diff] [blame] | 268 | |
oliver@apple.com | 0a4803c | 2009-10-29 01:25:02 +0000 | [diff] [blame] | 269 | bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } |
oliver@apple.com | 0a4803c | 2009-10-29 01:25:02 +0000 | [diff] [blame] | 270 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 271 | bool isEmpty() const |
| 272 | { |
| 273 | if (m_propertyTable) |
| 274 | return m_propertyTable->isEmpty(); |
| 275 | return !JSC::isValidOffset(m_offset); |
| 276 | } |
weinig@apple.com | a3b7bbb | 2008-10-30 02:44:46 +0000 | [diff] [blame] | 277 | |
barraclough@apple.com | 38d3c75 | 2012-05-12 00:39:43 +0000 | [diff] [blame] | 278 | JS_EXPORT_PRIVATE void despecifyDictionaryFunction(JSGlobalData&, PropertyName); |
ggaren@apple.com | d0d58f4 | 2010-01-07 22:07:36 +0000 | [diff] [blame] | 279 | void disableSpecificFunctionTracking() { m_specificFunctionThrashCount = maxSpecificFunctionThrashCount; } |
barraclough@apple.com | 0717324 | 2009-05-23 01:48:32 +0000 | [diff] [blame] | 280 | |
oliver@apple.com | 8d85705 | 2011-02-15 23:54:06 +0000 | [diff] [blame] | 281 | void setEnumerationCache(JSGlobalData&, JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h. |
ggaren@apple.com | 978e3e81 | 2010-02-12 02:51:35 +0000 | [diff] [blame] | 282 | JSPropertyNameIterator* enumerationCache(); // Defined in JSPropertyNameIterator.h. |
mhahnenberg@apple.com | 2358ae1 | 2011-11-04 01:32:18 +0000 | [diff] [blame] | 283 | void getPropertyNamesFromStructure(JSGlobalData&, PropertyNameArray&, EnumerationMode); |
mrowe@apple.com | 30d5b45 | 2010-01-30 05:30:33 +0000 | [diff] [blame] | 284 | |
msaboff@apple.com | 8bbd1b1 | 2012-04-25 00:58:17 +0000 | [diff] [blame] | 285 | JSString* objectToStringValue() { return m_objectToStringValue.get(); } |
| 286 | |
| 287 | void setObjectToStringValue(JSGlobalData& globalData, const JSCell* owner, JSString* value) |
| 288 | { |
| 289 | m_objectToStringValue.set(globalData, owner, value); |
| 290 | } |
| 291 | |
barraclough@apple.com | dfe18a5 | 2011-10-15 01:25:53 +0000 | [diff] [blame] | 292 | bool staticFunctionsReified() |
| 293 | { |
| 294 | return m_staticFunctionReified; |
| 295 | } |
| 296 | |
| 297 | void setStaticFunctionsReified() |
| 298 | { |
| 299 | m_staticFunctionReified = true; |
| 300 | } |
| 301 | |
barraclough@apple.com | a5540da | 2011-02-19 21:55:44 +0000 | [diff] [blame] | 302 | const ClassInfo* classInfo() const { return m_classInfo; } |
| 303 | |
barraclough@apple.com | 66184e2 | 2011-03-13 21:16:29 +0000 | [diff] [blame] | 304 | static ptrdiff_t prototypeOffset() |
| 305 | { |
| 306 | return OBJECT_OFFSETOF(Structure, m_prototype); |
| 307 | } |
| 308 | |
mhahnenberg@apple.com | 3b9069c | 2012-08-23 23:00:31 +0000 | [diff] [blame] | 309 | static ptrdiff_t globalObjectOffset() |
| 310 | { |
| 311 | return OBJECT_OFFSETOF(Structure, m_globalObject); |
| 312 | } |
| 313 | |
barraclough@apple.com | 66184e2 | 2011-03-13 21:16:29 +0000 | [diff] [blame] | 314 | static ptrdiff_t typeInfoFlagsOffset() |
| 315 | { |
| 316 | return OBJECT_OFFSETOF(Structure, m_typeInfo) + TypeInfo::flagsOffset(); |
| 317 | } |
| 318 | |
| 319 | static ptrdiff_t typeInfoTypeOffset() |
| 320 | { |
| 321 | return OBJECT_OFFSETOF(Structure, m_typeInfo) + TypeInfo::typeOffset(); |
| 322 | } |
fpizlo@apple.com | f24804c | 2012-08-15 02:48:35 +0000 | [diff] [blame] | 323 | |
| 324 | static ptrdiff_t classInfoOffset() |
| 325 | { |
| 326 | return OBJECT_OFFSETOF(Structure, m_classInfo); |
| 327 | } |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 328 | |
| 329 | static ptrdiff_t indexingTypeOffset() |
| 330 | { |
| 331 | return OBJECT_OFFSETOF(Structure, m_indexingType); |
| 332 | } |
barraclough@apple.com | 66184e2 | 2011-03-13 21:16:29 +0000 | [diff] [blame] | 333 | |
mhahnenberg@apple.com | b44a7f0 | 2012-07-26 23:27:53 +0000 | [diff] [blame] | 334 | static Structure* createStructure(JSGlobalData&); |
oliver@apple.com | 4103716 | 2011-05-14 22:10:01 +0000 | [diff] [blame] | 335 | |
fpizlo@apple.com | 04e4115 | 2012-06-15 22:14:53 +0000 | [diff] [blame] | 336 | bool transitionWatchpointSetHasBeenInvalidated() const |
| 337 | { |
| 338 | return m_transitionWatchpointSet.hasBeenInvalidated(); |
| 339 | } |
| 340 | |
| 341 | bool transitionWatchpointSetIsStillValid() const |
| 342 | { |
| 343 | return m_transitionWatchpointSet.isStillValid(); |
| 344 | } |
| 345 | |
| 346 | void addTransitionWatchpoint(Watchpoint* watchpoint) const |
| 347 | { |
| 348 | ASSERT(transitionWatchpointSetIsStillValid()); |
| 349 | m_transitionWatchpointSet.add(watchpoint); |
| 350 | } |
| 351 | |
| 352 | void notifyTransitionFromThisStructure() const |
| 353 | { |
| 354 | m_transitionWatchpointSet.notifyWrite(); |
| 355 | } |
| 356 | |
oliver@apple.com | 4103716 | 2011-05-14 22:10:01 +0000 | [diff] [blame] | 357 | static JS_EXPORTDATA const ClassInfo s_info; |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 358 | |
| 359 | private: |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 360 | friend class LLIntOffsetsExtractor; |
barraclough@apple.com | 38d3c75 | 2012-05-12 00:39:43 +0000 | [diff] [blame] | 361 | |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame^] | 362 | JS_EXPORT_PRIVATE Structure(JSGlobalData&, JSGlobalObject*, JSValue prototype, const TypeInfo&, const ClassInfo*, IndexingType, unsigned inlineCapacity); |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 363 | Structure(JSGlobalData&); |
| 364 | Structure(JSGlobalData&, const Structure*); |
| 365 | |
mhahnenberg@apple.com | b44a7f0 | 2012-07-26 23:27:53 +0000 | [diff] [blame] | 366 | static Structure* create(JSGlobalData&, const Structure*); |
oliver@apple.com | 23ce68f | 2011-04-25 21:21:28 +0000 | [diff] [blame] | 367 | |
oliver@apple.com | ae86589 | 2009-09-21 15:45:13 +0000 | [diff] [blame] | 368 | typedef enum { |
| 369 | NoneDictionaryKind = 0, |
| 370 | CachedDictionaryKind = 1, |
| 371 | UncachedDictionaryKind = 2 |
| 372 | } DictionaryKind; |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 373 | static Structure* toDictionaryTransition(JSGlobalData&, Structure*, DictionaryKind); |
weinig@apple.com | a3b7bbb | 2008-10-30 02:44:46 +0000 | [diff] [blame] | 374 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 375 | PropertyOffset putSpecificValue(JSGlobalData&, PropertyName, unsigned attributes, JSCell* specificValue); |
| 376 | PropertyOffset remove(PropertyName); |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 377 | |
barraclough@apple.com | 96cad9f | 2011-03-01 03:53:09 +0000 | [diff] [blame] | 378 | void createPropertyMap(unsigned keyCount = 0); |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 379 | void checkConsistency(); |
| 380 | |
barraclough@apple.com | 38d3c75 | 2012-05-12 00:39:43 +0000 | [diff] [blame] | 381 | bool despecifyFunction(JSGlobalData&, PropertyName); |
oliver@apple.com | af134a7 | 2011-04-13 18:48:22 +0000 | [diff] [blame] | 382 | void despecifyAllFunctions(JSGlobalData&); |
barraclough@apple.com | 0717324 | 2009-05-23 01:48:32 +0000 | [diff] [blame] | 383 | |
levin@chromium.org | ca509e8 | 2011-04-25 21:48:58 +0000 | [diff] [blame] | 384 | PassOwnPtr<PropertyTable> copyPropertyTable(JSGlobalData&, Structure* owner); |
fpizlo@apple.com | 65c4b0d | 2011-10-27 22:19:14 +0000 | [diff] [blame] | 385 | PassOwnPtr<PropertyTable> copyPropertyTableForPinning(JSGlobalData&, Structure* owner); |
morrita@google.com | f0dd2d9 | 2012-01-13 07:23:44 +0000 | [diff] [blame] | 386 | JS_EXPORT_PRIVATE void materializePropertyMap(JSGlobalData&); |
oliver@apple.com | af134a7 | 2011-04-13 18:48:22 +0000 | [diff] [blame] | 387 | void materializePropertyMapIfNecessary(JSGlobalData& globalData) |
weinig@apple.com | 8a86659 | 2008-11-14 23:36:06 +0000 | [diff] [blame] | 388 | { |
jberlin@webkit.org | 3d6b468 | 2011-05-03 15:41:28 +0000 | [diff] [blame] | 389 | ASSERT(structure()->classInfo() == &s_info); |
barraclough@apple.com | 96cad9f | 2011-03-01 03:53:09 +0000 | [diff] [blame] | 390 | if (!m_propertyTable && m_previous) |
oliver@apple.com | af134a7 | 2011-04-13 18:48:22 +0000 | [diff] [blame] | 391 | materializePropertyMap(globalData); |
weinig@apple.com | 8a86659 | 2008-11-14 23:36:06 +0000 | [diff] [blame] | 392 | } |
fpizlo@apple.com | 65c4b0d | 2011-10-27 22:19:14 +0000 | [diff] [blame] | 393 | void materializePropertyMapIfNecessaryForPinning(JSGlobalData& globalData) |
| 394 | { |
| 395 | ASSERT(structure()->classInfo() == &s_info); |
| 396 | if (!m_propertyTable) |
| 397 | materializePropertyMap(globalData); |
| 398 | } |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 399 | |
zherczeg@webkit.org | 3915061 | 2011-10-03 06:49:50 +0000 | [diff] [blame] | 400 | int transitionCount() const |
alice.liu@apple.com | 04456af | 2009-01-05 00:18:53 +0000 | [diff] [blame] | 401 | { |
| 402 | // Since the number of transitions is always the same as m_offset, we keep the size of Structure down by not storing both. |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame^] | 403 | return numberOfSlotsForLastOffset(m_offset, m_inlineCapacity); |
alice.liu@apple.com | 04456af | 2009-01-05 00:18:53 +0000 | [diff] [blame] | 404 | } |
barraclough@apple.com | 39724b8 | 2010-02-15 22:37:43 +0000 | [diff] [blame] | 405 | |
fpizlo@apple.com | c2c6763 | 2012-11-17 08:37:14 +0000 | [diff] [blame] | 406 | bool isValid(JSGlobalObject*, StructureChain* cachedPrototypeChain) const; |
ggaren@apple.com | c8bc3c8 | 2009-02-25 23:44:07 +0000 | [diff] [blame] | 407 | bool isValid(ExecState*, StructureChain* cachedPrototypeChain) const; |
fpizlo@apple.com | 4f0f1d0 | 2011-10-07 00:47:21 +0000 | [diff] [blame] | 408 | |
| 409 | void pin(); |
alice.liu@apple.com | 04456af | 2009-01-05 00:18:53 +0000 | [diff] [blame] | 410 | |
fpizlo@apple.com | 0134791 | 2011-09-29 20:45:52 +0000 | [diff] [blame] | 411 | static const int s_maxTransitionLength = 64; |
alice.liu@apple.com | 04456af | 2009-01-05 00:18:53 +0000 | [diff] [blame] | 412 | |
ggaren@apple.com | d0d58f4 | 2010-01-07 22:07:36 +0000 | [diff] [blame] | 413 | static const unsigned maxSpecificFunctionThrashCount = 3; |
| 414 | |
mjs@apple.com | 52b6760 | 2008-09-22 03:15:52 +0000 | [diff] [blame] | 415 | TypeInfo m_typeInfo; |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 416 | IndexingType m_indexingType; |
oliver@apple.com | ee1bdc8 | 2011-09-06 21:51:00 +0000 | [diff] [blame] | 417 | |
| 418 | WriteBarrier<JSGlobalObject> m_globalObject; |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 419 | WriteBarrier<Unknown> m_prototype; |
| 420 | mutable WriteBarrier<StructureChain> m_cachedPrototypeChain; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 421 | |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 422 | WriteBarrier<Structure> m_previous; |
barraclough@apple.com | ee2085b | 2010-08-11 00:16:38 +0000 | [diff] [blame] | 423 | RefPtr<StringImpl> m_nameInPrevious; |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 424 | WriteBarrier<JSCell> m_specificValueInPrevious; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 425 | |
barraclough@apple.com | a5540da | 2011-02-19 21:55:44 +0000 | [diff] [blame] | 426 | const ClassInfo* m_classInfo; |
| 427 | |
barraclough@apple.com | 07be2aa | 2011-02-22 21:49:59 +0000 | [diff] [blame] | 428 | StructureTransitionTable m_transitionTable; |
weinig@apple.com | 2229430 | 2008-09-09 06:55:39 +0000 | [diff] [blame] | 429 | |
oliver@apple.com | b2fa0dc | 2011-04-15 23:55:42 +0000 | [diff] [blame] | 430 | WriteBarrier<JSPropertyNameIterator> m_enumerationCache; |
weinig@apple.com | 503d999 | 2008-09-15 07:27:14 +0000 | [diff] [blame] | 431 | |
barraclough@apple.com | 96cad9f | 2011-03-01 03:53:09 +0000 | [diff] [blame] | 432 | OwnPtr<PropertyTable> m_propertyTable; |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 433 | |
msaboff@apple.com | 8bbd1b1 | 2012-04-25 00:58:17 +0000 | [diff] [blame] | 434 | WriteBarrier<JSString> m_objectToStringValue; |
fpizlo@apple.com | 04e4115 | 2012-06-15 22:14:53 +0000 | [diff] [blame] | 435 | |
| 436 | mutable InlineWatchpointSet m_transitionWatchpointSet; |
| 437 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 438 | uint32_t m_outOfLineCapacity; |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 439 | uint8_t m_inlineCapacity; |
| 440 | COMPILE_ASSERT(firstOutOfLineOffset < 256, firstOutOfLineOffset_fits); |
msaboff@apple.com | 8bbd1b1 | 2012-04-25 00:58:17 +0000 | [diff] [blame] | 441 | |
oliver@apple.com | 6c9bdeb | 2010-02-03 01:13:47 +0000 | [diff] [blame] | 442 | // m_offset does not account for anonymous slots |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 443 | PropertyOffset m_offset; |
weinig@apple.com | ed15b6d | 2008-10-29 22:27:31 +0000 | [diff] [blame] | 444 | |
oliver@apple.com | ae86589 | 2009-09-21 15:45:13 +0000 | [diff] [blame] | 445 | unsigned m_dictionaryKind : 2; |
weinig@apple.com | 8a86659 | 2008-11-14 23:36:06 +0000 | [diff] [blame] | 446 | bool m_isPinnedPropertyTable : 1; |
weinig@apple.com | ed15b6d | 2008-10-29 22:27:31 +0000 | [diff] [blame] | 447 | bool m_hasGetterSetterProperties : 1; |
barraclough@apple.com | 2668db9 | 2012-02-22 23:46:48 +0000 | [diff] [blame] | 448 | bool m_hasReadOnlyOrGetterSetterPropertiesExcludingProto : 1; |
oliver@apple.com | 0a4803c | 2009-10-29 01:25:02 +0000 | [diff] [blame] | 449 | bool m_hasNonEnumerableProperties : 1; |
fpizlo@apple.com | d8dd053 | 2012-09-13 04:18:52 +0000 | [diff] [blame] | 450 | unsigned m_attributesInPrevious : 22; |
ggaren@apple.com | d0d58f4 | 2010-01-07 22:07:36 +0000 | [diff] [blame] | 451 | unsigned m_specificFunctionThrashCount : 2; |
barraclough@apple.com | dd99310 | 2011-03-04 22:34:48 +0000 | [diff] [blame] | 452 | unsigned m_preventExtensions : 1; |
ggaren@apple.com | 21daf64 | 2011-04-26 06:23:14 +0000 | [diff] [blame] | 453 | unsigned m_didTransition : 1; |
barraclough@apple.com | dfe18a5 | 2011-10-15 01:25:53 +0000 | [diff] [blame] | 454 | unsigned m_staticFunctionReified; |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 455 | }; |
| 456 | |
ggaren@apple.com | c862eac | 2013-01-29 05:48:01 +0000 | [diff] [blame^] | 457 | inline Structure* Structure::create(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype, const TypeInfo& typeInfo, const ClassInfo* classInfo, IndexingType indexingType, unsigned inlineCapacity) |
mhahnenberg@apple.com | b44a7f0 | 2012-07-26 23:27:53 +0000 | [diff] [blame] | 458 | { |
| 459 | ASSERT(globalData.structureStructure); |
| 460 | ASSERT(classInfo); |
ggaren@apple.com | 20b4bfc | 2012-10-04 04:03:14 +0000 | [diff] [blame] | 461 | Structure* structure = new (NotNull, allocateCell<Structure>(globalData.heap)) Structure(globalData, globalObject, prototype, typeInfo, classInfo, indexingType, inlineCapacity); |
mhahnenberg@apple.com | b44a7f0 | 2012-07-26 23:27:53 +0000 | [diff] [blame] | 462 | structure->finishCreation(globalData); |
| 463 | return structure; |
| 464 | } |
| 465 | |
| 466 | inline Structure* Structure::createStructure(JSGlobalData& globalData) |
| 467 | { |
| 468 | ASSERT(!globalData.structureStructure); |
| 469 | Structure* structure = new (NotNull, allocateCell<Structure>(globalData.heap)) Structure(globalData); |
| 470 | structure->finishCreation(globalData, CreatingEarlyCell); |
| 471 | return structure; |
| 472 | } |
| 473 | |
| 474 | inline Structure* Structure::create(JSGlobalData& globalData, const Structure* structure) |
| 475 | { |
| 476 | ASSERT(globalData.structureStructure); |
| 477 | Structure* newStructure = new (NotNull, allocateCell<Structure>(globalData.heap)) Structure(globalData, structure); |
| 478 | newStructure->finishCreation(globalData); |
| 479 | return newStructure; |
| 480 | } |
| 481 | |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 482 | inline PropertyOffset Structure::get(JSGlobalData& globalData, PropertyName propertyName) |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 483 | { |
jberlin@webkit.org | 3d6b468 | 2011-05-03 15:41:28 +0000 | [diff] [blame] | 484 | ASSERT(structure()->classInfo() == &s_info); |
oliver@apple.com | af134a7 | 2011-04-13 18:48:22 +0000 | [diff] [blame] | 485 | materializePropertyMapIfNecessary(globalData); |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 486 | if (!m_propertyTable) |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 487 | return invalidOffset; |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 488 | |
barraclough@apple.com | 6c9b264 | 2012-05-22 00:37:09 +0000 | [diff] [blame] | 489 | PropertyMapEntry* entry = m_propertyTable->find(propertyName.uid()).first; |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 490 | return entry ? entry->offset : invalidOffset; |
weinig@apple.com | c13fb9f | 2008-10-31 00:12:50 +0000 | [diff] [blame] | 491 | } |
oliver@apple.com | 1368a40 | 2009-08-20 23:05:03 +0000 | [diff] [blame] | 492 | |
benjamin@webkit.org | cff06e4 | 2012-08-30 21:23:51 +0000 | [diff] [blame] | 493 | inline PropertyOffset Structure::get(JSGlobalData& globalData, const WTF::String& name) |
barraclough@apple.com | 5d959c7 | 2011-08-07 03:44:45 +0000 | [diff] [blame] | 494 | { |
| 495 | ASSERT(structure()->classInfo() == &s_info); |
| 496 | materializePropertyMapIfNecessary(globalData); |
| 497 | if (!m_propertyTable) |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 498 | return invalidOffset; |
barraclough@apple.com | 5d959c7 | 2011-08-07 03:44:45 +0000 | [diff] [blame] | 499 | |
| 500 | PropertyMapEntry* entry = m_propertyTable->findWithString(name.impl()).first; |
fpizlo@apple.com | d68b1f8 | 2012-07-05 22:55:51 +0000 | [diff] [blame] | 501 | return entry ? entry->offset : invalidOffset; |
barraclough@apple.com | 5d959c7 | 2011-08-07 03:44:45 +0000 | [diff] [blame] | 502 | } |
mhahnenberg@apple.com | 6fb47cf | 2011-10-10 22:32:00 +0000 | [diff] [blame] | 503 | |
mhahnenberg@apple.com | 3b9069c | 2012-08-23 23:00:31 +0000 | [diff] [blame] | 504 | inline bool Structure::masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject) |
| 505 | { |
| 506 | return typeInfo().masqueradesAsUndefined() && globalObject() == lexicalGlobalObject; |
| 507 | } |
| 508 | |
mhahnenberg@apple.com | a57e671 | 2012-09-10 18:41:05 +0000 | [diff] [blame] | 509 | ALWAYS_INLINE void SlotVisitor::internalAppend(JSCell* cell) |
oliver@apple.com | ed66e77 | 2011-04-05 01:33:58 +0000 | [diff] [blame] | 510 | { |
| 511 | ASSERT(!m_isCheckingForDefaultMarkViolation); |
oliver@apple.com | 297e1a5 | 2012-08-24 21:23:51 +0000 | [diff] [blame] | 512 | if (!cell) |
| 513 | return; |
ggaren@apple.com | 3a7b479 | 2011-10-17 20:43:43 +0000 | [diff] [blame] | 514 | #if ENABLE(GC_VALIDATION) |
| 515 | validate(cell); |
| 516 | #endif |
oliver@apple.com | 7747338 | 2011-10-27 00:19:31 +0000 | [diff] [blame] | 517 | if (Heap::testAndSetMarked(cell) || !cell->structure()) |
oliver@apple.com | ed66e77 | 2011-04-05 01:33:58 +0000 | [diff] [blame] | 518 | return; |
msaboff@apple.com | 9d9eab6 | 2012-06-06 23:11:09 +0000 | [diff] [blame] | 519 | |
| 520 | m_visitCount++; |
fpizlo@apple.com | 511aa4b | 2011-12-06 22:12:56 +0000 | [diff] [blame] | 521 | |
msaboff@apple.com | 9d9eab6 | 2012-06-06 23:11:09 +0000 | [diff] [blame] | 522 | MARK_LOG_CHILD(*this, cell); |
| 523 | |
fpizlo@apple.com | 511aa4b | 2011-12-06 22:12:56 +0000 | [diff] [blame] | 524 | // Should never attempt to mark something that is zapped. |
| 525 | ASSERT(!cell->isZapped()); |
| 526 | |
ggaren@apple.com | 3a7b479 | 2011-10-17 20:43:43 +0000 | [diff] [blame] | 527 | m_stack.append(cell); |
oliver@apple.com | ed66e77 | 2011-04-05 01:33:58 +0000 | [diff] [blame] | 528 | } |
| 529 | |
fpizlo@apple.com | 74d43ae | 2011-09-17 23:33:01 +0000 | [diff] [blame] | 530 | inline bool Structure::transitivelyTransitionedFrom(Structure* structureToFind) |
| 531 | { |
| 532 | for (Structure* current = this; current; current = current->previousID()) { |
| 533 | if (current == structureToFind) |
| 534 | return true; |
| 535 | } |
| 536 | return false; |
| 537 | } |
| 538 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 539 | } // namespace JSC |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 540 | |
darin@apple.com | a9778f9 | 2008-11-16 04:40:06 +0000 | [diff] [blame] | 541 | #endif // Structure_h |