Changeset 97872 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Oct 19, 2011, 12:45:35 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r97827 r97872 29 29 #include "PropertyDescriptor.h" 30 30 #include "PropertySlot.h" 31 #include "RopeImpl.h"32 31 #include "Structure.h" 33 32 … … 77 76 : m_globalData(globalData) 78 77 , m_jsString(jsStringBuilder(&globalData)) 78 , m_index(0) 79 79 { 80 80 } … … 82 82 void append(JSString* jsString) 83 83 { 84 if (m_ jsString->m_fiberCount== JSString::s_maxInternalRopeLength)84 if (m_index == JSString::s_maxInternalRopeLength) 85 85 expand(); 86 m_jsString->m_fibers[m_jsString->m_fiberCount].set(m_globalData, m_jsString, jsString); 87 m_jsString->m_fiberCount += 1; 86 m_jsString->m_fibers[m_index++].set(m_globalData, m_jsString, jsString); 88 87 m_jsString->m_length += jsString->m_length; 89 88 } … … 103 102 JSGlobalData& m_globalData; 104 103 JSString* m_jsString; 104 size_t m_index; 105 105 }; 106 106 … … 109 109 : JSCell(globalData, globalData.stringStructure.get()) 110 110 , m_value(value) 111 , m_fiberCount(0)112 111 { 113 112 } … … 115 114 JSString(JSGlobalData& globalData) 116 115 : JSCell(globalData, globalData.stringStructure.get()) 117 , m_fiberCount(0)118 116 { 119 117 } … … 144 142 Base::finishCreation(globalData); 145 143 m_length = s1->length() + s2->length(); 146 m_fiberCount = 2;147 144 m_fibers[0].set(globalData, this, s1); 148 145 m_fibers[1].set(globalData, this, s2); … … 153 150 Base::finishCreation(globalData); 154 151 m_length = s1->length() + s2->length() + s3->length(); 155 m_fiberCount = 3;156 152 m_fibers[0].set(globalData, this, s1); 157 153 m_fibers[1].set(globalData, this, s2); … … 236 232 237 233 static size_t offsetOfLength() { return OBJECT_OFFSETOF(JSString, m_length); } 238 static size_t offsetOfFiberCount() { return OBJECT_OFFSETOF(JSString, m_fiberCount); }239 234 static size_t offsetOfValue() { return OBJECT_OFFSETOF(JSString, m_value); } 240 235 … … 246 241 JSString(VPtrStealingHackType) 247 242 : JSCell(VPtrStealingHack) 248 , m_fiberCount(0)249 243 { 250 244 } … … 265 259 static const unsigned s_maxInternalRopeLength = 3; 266 260 267 // A string is represented either by a UString or a RopeImpl.261 // A string is represented either by a UString or a rope of fibers. 268 262 unsigned m_length; 269 263 mutable UString m_value; 270 mutable unsigned m_fiberCount;271 264 mutable FixedArray<WriteBarrier<JSString>, s_maxInternalRopeLength> m_fibers; 272 265 273 bool isRope() const { return m_ fiberCount; }266 bool isRope() const { return m_value.isNull(); } 274 267 UString& string() { ASSERT(!isRope()); return m_value; } 275 unsigned fiberCount() { return m_fiberCount ? m_fiberCount : 1; } 276 277 friend JSValue jsString(ExecState* exec, JSString* s1, JSString* s2); 278 friend JSValue jsString(ExecState* exec, Register* strings, unsigned count); 279 friend JSValue jsString(ExecState* exec, JSValue thisValue); 280 friend JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length); 268 269 friend JSValue jsString(ExecState*, JSString*, JSString*); 270 friend JSValue jsString(ExecState*, Register*, unsigned count); 271 friend JSValue jsStringFromArguments(ExecState*, JSValue thisValue); 272 friend JSString* jsSubstring(ExecState*, JSString*, unsigned offset, unsigned length); 281 273 }; 282 274
Note:
See TracChangeset
for help on using the changeset viewer.