Changeset 55943 in webkit for trunk/JavaScriptCore/runtime/UStringImpl.h
- Timestamp:
- Mar 12, 2010, 3:49:05 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UStringImpl.h
r55881 r55943 73 73 enum StaticStringConstructType { ConstructStaticString }; 74 74 UStringOrRopeImpl(unsigned length, StaticStringConstructType) 75 : m_refCountAndFlags(s_refCountFlagStatic | BufferOwned)75 : m_refCountAndFlags(s_refCountFlagStatic | s_refCountFlagIsIdentifier | BufferOwned) 76 76 , m_length(length) 77 77 { … … 126 126 { 127 127 hash(); 128 checkConsistency();129 128 } 130 129 … … 138 137 ASSERT(m_data); 139 138 ASSERT(m_length); 140 checkConsistency();141 139 } 142 140 … … 150 148 ASSERT(m_data); 151 149 ASSERT(m_length); 152 checkConsistency();153 150 } 154 151 … … 162 159 ASSERT(m_data); 163 160 ASSERT(m_length); 164 checkConsistency();161 ASSERT(m_substringBuffer->bufferOwnership() != BufferSubstring); 165 162 } 166 163 … … 174 171 ASSERT(m_data); 175 172 ASSERT(m_length); 176 checkConsistency();177 173 } 178 174 … … 180 176 void setHash(unsigned hash) 181 177 { 178 ASSERT(!isStatic()); 182 179 ASSERT(!m_hash); 183 180 ASSERT(hash == computeHash(m_data, m_length)); … … 194 191 static PassRefPtr<UStringImpl> create(PassRefPtr<UStringImpl> rep, unsigned offset, unsigned length) 195 192 { 193 ASSERT(rep); 194 ASSERT(length <= rep->length()); 195 196 196 if (!length) 197 197 return empty(); 198 ASSERT(rep); 199 rep->checkConsistency(); 198 200 199 UStringImpl* ownerRep = (rep->bufferOwnership() == BufferSubstring) ? rep->m_substringBuffer : rep.get(); 201 200 return adoptRef(new UStringImpl(rep->m_data + offset, length, ownerRep)); … … 248 247 void setIsIdentifier(bool isIdentifier) 249 248 { 249 ASSERT(!isStatic()); 250 250 if (isIdentifier) 251 251 m_refCountAndFlags |= s_refCountFlagIsIdentifier; … … 273 273 } 274 274 275 ALWAYS_INLINE void checkConsistency() const276 {277 // There is no recursion of substrings.278 ASSERT((bufferOwnership() != BufferSubstring) || (m_substringBuffer->bufferOwnership() != BufferSubstring));279 // Static strings cannot be put in identifier tables, because they are globally shared.280 ASSERT(!isStatic() || !isIdentifier());281 }282 283 275 private: 284 276 // This number must be at least 2 to avoid sharing empty, null as well as 1 character strings from SmallStrings. … … 288 280 bool isStatic() const { return m_refCountAndFlags & s_refCountFlagStatic; } 289 281 290 // unshared data291 282 const UChar* m_data; 292 283 union {
Note:
See TracChangeset
for help on using the changeset viewer.