Structure.h revision 2bde8e466a4451c7319e3a072d118917957d6554
18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 20bf48ef3be53ddaa52bbead65dfd75bf90e7a2b5Ben Murdoch * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 26635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#ifndef Structure_h 27635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#define Structure_h 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 29635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "Identifier.h" 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "JSType.h" 318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "JSValue.h" 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "PropertyMapHashTable.h" 33cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "PropertyNameArray.h" 34cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "Protect.h" 35635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "StructureTransitionTable.h" 36231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "JSTypeInfo.h" 37635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#include "UString.h" 388a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block#include "WeakGCPtr.h" 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/PassRefPtr.h> 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/RefCounted.h> 418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectnamespace JSC { 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 45231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block class MarkStack; 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project class PropertyNameArray; 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project class PropertyNameArrayData; 482bde8e466a4451c7319e3a072d118917957d6554Steve Block class StructureChain; 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 5081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch struct ClassInfo; 5181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 52d0825bca7fe65beaee391d30da42e937db621564Steve Block enum EnumerationMode { 53d0825bca7fe65beaee391d30da42e937db621564Steve Block ExcludeDontEnumProperties, 54d0825bca7fe65beaee391d30da42e937db621564Steve Block IncludeDontEnumProperties 55d0825bca7fe65beaee391d30da42e937db621564Steve Block }; 56d0825bca7fe65beaee391d30da42e937db621564Steve Block 57635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project class Structure : public RefCounted<Structure> { 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project public: 59231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block friend class StructureTransitionTable; 602bde8e466a4451c7319e3a072d118917957d6554Steve Block static PassRefPtr<Structure> create(JSGlobalData&, JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount, const ClassInfo* classInfo) 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project { 6281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return adoptRef(new Structure(prototype, typeInfo, anonymousSlotCount, classInfo)); 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 652bde8e466a4451c7319e3a072d118917957d6554Steve Block enum VPtrStealingHackType { VPtrStealingHack }; 662bde8e466a4451c7319e3a072d118917957d6554Steve Block static PassRefPtr<Structure> create(VPtrStealingHackType, const ClassInfo* classInfo) 672bde8e466a4451c7319e3a072d118917957d6554Steve Block { 682bde8e466a4451c7319e3a072d118917957d6554Steve Block return adoptRef(new Structure(jsNull(), TypeInfo(UnspecifiedType), 0, classInfo)); 692bde8e466a4451c7319e3a072d118917957d6554Steve Block } 702bde8e466a4451c7319e3a072d118917957d6554Steve Block 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project static void startIgnoringLeaks(); 728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project static void stopIgnoringLeaks(); 738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project static void dumpStatistics(); 758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 765f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian static PassRefPtr<Structure> addPropertyTransition(Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset); 775f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian static PassRefPtr<Structure> addPropertyTransitionToExistingStructure(Structure*, const Identifier& propertyName, unsigned attributes, JSCell* specificValue, size_t& offset); 78635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static PassRefPtr<Structure> removePropertyTransition(Structure*, const Identifier& propertyName, size_t& offset); 795f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian static PassRefPtr<Structure> changePrototypeTransition(Structure*, JSValue prototype); 80231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block static PassRefPtr<Structure> despecifyFunctionTransition(Structure*, const Identifier&); 81635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static PassRefPtr<Structure> getterSetterTransition(Structure*); 82231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block static PassRefPtr<Structure> toCacheableDictionaryTransition(Structure*); 83231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block static PassRefPtr<Structure> toUncacheableDictionaryTransition(Structure*); 8481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static PassRefPtr<Structure> sealTransition(Structure*); 8581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static PassRefPtr<Structure> freezeTransition(Structure*); 8681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static PassRefPtr<Structure> preventExtensionsTransition(Structure*); 8781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 8881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool isSealed(); 8981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool isFrozen(); 9081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool isExtensible() const { return !m_preventExtensions; } 91643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 922fc2651226baac27029e38c9d6ef883fa32084dbSteve Block PassRefPtr<Structure> flattenDictionaryStructure(JSGlobalData&, JSObject*); 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 94635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project ~Structure(); 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // These should be used with caution. 975f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes, JSCell* specificValue); 988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project size_t removePropertyWithoutTransition(const Identifier& propertyName); 995f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian void setPrototypeWithoutTransition(JSValue prototype) { m_prototype = prototype; } 100231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 101231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block bool isDictionary() const { return m_dictionaryKind != NoneDictionaryKind; } 102231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block bool isUncacheableDictionary() const { return m_dictionaryKind == UncachedDictionaryKind; } 1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project const TypeInfo& typeInfo() const { return m_typeInfo; } 1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1062fc2651226baac27029e38c9d6ef883fa32084dbSteve Block JSValue storedPrototype() const { return m_prototype.get(); } 1072fc2651226baac27029e38c9d6ef883fa32084dbSteve Block DeprecatedPtr<Unknown>* storedPrototypeSlot() { return &m_prototype; } 1085f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian JSValue prototypeForLookup(ExecState*) const; 1095f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian StructureChain* prototypeChain(ExecState*) const; 1102bde8e466a4451c7319e3a072d118917957d6554Steve Block DeprecatedPtr<StructureChain>* cachedPrototypeChainSlot() { return &m_cachedPrototypeChain; } 1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 112635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project Structure* previousID() const { return m_previous.get(); } 1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void growPropertyStorageCapacity(); 115cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block unsigned propertyStorageCapacity() const { return m_propertyStorageCapacity; } 11681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch unsigned propertyStorageSize() const { return m_anonymousSlotCount + (m_propertyTable ? m_propertyTable->propertyStorageSize() : static_cast<unsigned>(m_offset + 1)); } 1175f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian bool isUsingInlineStorage() const; 1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 119635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project size_t get(const Identifier& propertyName); 12081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch size_t get(StringImpl* propertyName, unsigned& attributes, JSCell*& specificValue); 1215f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian size_t get(const Identifier& propertyName, unsigned& attributes, JSCell*& specificValue) 1225f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian { 1235f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian ASSERT(!propertyName.isNull()); 124f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick return get(propertyName.impl(), attributes, specificValue); 125231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block } 1265f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian 1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } 1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; } 1298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 130cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } 131cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 1325e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block bool hasAnonymousSlots() const { return !!m_anonymousSlotCount; } 1335e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block unsigned anonymousSlotCount() const { return m_anonymousSlotCount; } 134cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 13581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool isEmpty() const { return m_propertyTable ? m_propertyTable->isEmpty() : m_offset == noOffset; } 1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1375f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian void despecifyDictionaryFunction(const Identifier& propertyName); 138d0825bca7fe65beaee391d30da42e937db621564Steve Block void disableSpecificFunctionTracking() { m_specificFunctionThrashCount = maxSpecificFunctionThrashCount; } 1395f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian 14081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void setEnumerationCache(JSGlobalData&, JSPropertyNameIterator* enumerationCache); // Defined in JSPropertyNameIterator.h. 14181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void clearEnumerationCache(); // Defined in JSPropertyNameIterator.h. 1428a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block JSPropertyNameIterator* enumerationCache(); // Defined in JSPropertyNameIterator.h. 143d0825bca7fe65beaee391d30da42e937db621564Steve Block void getPropertyNames(PropertyNameArray&, EnumerationMode mode); 14481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 14581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch const ClassInfo* classInfo() const { return m_classInfo; } 14681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 14781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static void initializeThreading(); 14881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 1492bde8e466a4451c7319e3a072d118917957d6554Steve Block static ptrdiff_t prototypeOffset() 1502bde8e466a4451c7319e3a072d118917957d6554Steve Block { 1512bde8e466a4451c7319e3a072d118917957d6554Steve Block return OBJECT_OFFSETOF(Structure, m_prototype); 1522bde8e466a4451c7319e3a072d118917957d6554Steve Block } 1532bde8e466a4451c7319e3a072d118917957d6554Steve Block 1542bde8e466a4451c7319e3a072d118917957d6554Steve Block static ptrdiff_t typeInfoFlagsOffset() 1552bde8e466a4451c7319e3a072d118917957d6554Steve Block { 1562bde8e466a4451c7319e3a072d118917957d6554Steve Block return OBJECT_OFFSETOF(Structure, m_typeInfo) + TypeInfo::flagsOffset(); 1572bde8e466a4451c7319e3a072d118917957d6554Steve Block } 1582bde8e466a4451c7319e3a072d118917957d6554Steve Block 1592bde8e466a4451c7319e3a072d118917957d6554Steve Block static ptrdiff_t typeInfoTypeOffset() 1602bde8e466a4451c7319e3a072d118917957d6554Steve Block { 1612bde8e466a4451c7319e3a072d118917957d6554Steve Block return OBJECT_OFFSETOF(Structure, m_typeInfo) + TypeInfo::typeOffset(); 1622bde8e466a4451c7319e3a072d118917957d6554Steve Block } 1632bde8e466a4451c7319e3a072d118917957d6554Steve Block 1648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project private: 16581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch Structure(JSValue prototype, const TypeInfo&, unsigned anonymousSlotCount, const ClassInfo*); 16681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch Structure(const Structure*); 167d0825bca7fe65beaee391d30da42e937db621564Steve Block 16881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static PassRefPtr<Structure> create(const Structure* structure) 16981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch { 17081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return adoptRef(new Structure(structure)); 17181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch } 172231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 173231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block typedef enum { 174231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block NoneDictionaryKind = 0, 175231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block CachedDictionaryKind = 1, 176231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block UncachedDictionaryKind = 2 177231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block } DictionaryKind; 178231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block static PassRefPtr<Structure> toDictionaryTransition(Structure*, DictionaryKind); 1798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1805f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian size_t put(const Identifier& propertyName, unsigned attributes, JSCell* specificValue); 1818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project size_t remove(const Identifier& propertyName); 1828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 18381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void createPropertyMap(unsigned keyCount = 0); 1848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project void checkConsistency(); 1858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1865f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian bool despecifyFunction(const Identifier&); 187d0825bca7fe65beaee391d30da42e937db621564Steve Block void despecifyAllFunctions(); 1885f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian 18981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch PropertyTable* copyPropertyTable(); 190635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project void materializePropertyMap(); 191635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project void materializePropertyMapIfNecessary() 192635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project { 19381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch if (!m_propertyTable && m_previous) 19481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch materializePropertyMap(); 195635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project } 1968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 197635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project signed char transitionCount() const 198635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project { 199635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project // Since the number of transitions is always the same as m_offset, we keep the size of Structure down by not storing both. 200635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project return m_offset == noOffset ? 0 : m_offset + 1; 201635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project } 202692e5dbf12901edacf14812a6fae25462920af42Steve Block 2035f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian bool isValid(ExecState*, StructureChain* cachedPrototypeChain) const; 204635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 205635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static const signed char s_maxTransitionLength = 64; 206635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project 207635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project static const signed char noOffset = -1; 2088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 209d0825bca7fe65beaee391d30da42e937db621564Steve Block static const unsigned maxSpecificFunctionThrashCount = 3; 210d0825bca7fe65beaee391d30da42e937db621564Steve Block 2118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project TypeInfo m_typeInfo; 2128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2132fc2651226baac27029e38c9d6ef883fa32084dbSteve Block DeprecatedPtr<Unknown> m_prototype; 2142bde8e466a4451c7319e3a072d118917957d6554Steve Block mutable DeprecatedPtr<StructureChain> m_cachedPrototypeChain; 2158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 216635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project RefPtr<Structure> m_previous; 217f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick RefPtr<StringImpl> m_nameInPrevious; 2185f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian JSCell* m_specificValueInPrevious; 2198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 22081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch const ClassInfo* m_classInfo; 22181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 22281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch StructureTransitionTable m_transitionTable; 223231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 2248a0914b749bbe7da7768e07a7db5c6d4bb09472bSteve Block WeakGCPtr<JSPropertyNameIterator> m_enumerationCache; 2258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 22681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch OwnPtr<PropertyTable> m_propertyTable; 2278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 228cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block uint32_t m_propertyStorageCapacity; 2295e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block 2305e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block // m_offset does not account for anonymous slots 231635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project signed char m_offset; 2328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 233231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block unsigned m_dictionaryKind : 2; 234635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project bool m_isPinnedPropertyTable : 1; 2358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project bool m_hasGetterSetterProperties : 1; 236cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block bool m_hasNonEnumerableProperties : 1; 237231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#if COMPILER(WINSCW) 238231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block // Workaround for Symbian WINSCW compiler that cannot resolve unsigned type of the declared 239231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block // bitfield, when used as argument in make_pair() function calls in structure.ccp. 240231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block // This bitfield optimization is insignificant for the Symbian emulator target. 241231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block unsigned m_attributesInPrevious; 242231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#else 2435f1ab04193ad0130ca8204aadaceae083aca9881Feng Qian unsigned m_attributesInPrevious : 7; 244231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#endif 245d0825bca7fe65beaee391d30da42e937db621564Steve Block unsigned m_specificFunctionThrashCount : 2; 2465e2bc6953fe6923165b8a5d7679939693a1d58d6Steve Block unsigned m_anonymousSlotCount : 5; 24781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch unsigned m_preventExtensions : 1; 248692e5dbf12901edacf14812a6fae25462920af42Steve Block // 4 free bits 2498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project }; 2508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 251635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project inline size_t Structure::get(const Identifier& propertyName) 2528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project { 253635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project materializePropertyMapIfNecessary(); 2548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!m_propertyTable) 25581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return notFound; 2568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 25781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch PropertyMapEntry* entry = m_propertyTable->find(propertyName.impl()).first; 25881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch ASSERT(!entry || entry->offset >= m_anonymousSlotCount); 25981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return entry ? entry->offset : notFound; 2608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 261231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 2628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} // namespace JSC 2638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 264635860845790a19bf50bbc51ba8fb66a96dde068The Android Open Source Project#endif // Structure_h 265