Changeset 253648 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.cpp
- Timestamp:
- Dec 17, 2019, 2:12:00 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.cpp
r252843 r253648 154 154 } 155 155 156 resolveRopeInternal8NoSubstring(buffer); 157 } 158 159 void JSRopeString::resolveRopeInternal8NoSubstring(LChar* buffer) const 160 { 161 for (size_t i = 0; i < s_maxInternalRopeLength && fiber(i); ++i) { 162 if (fiber(i)->isRope()) { 163 resolveRopeSlowCase8(buffer); 164 return; 165 } 166 } 167 168 LChar* position = buffer; 169 for (size_t i = 0; i < s_maxInternalRopeLength && fiber(i); ++i) { 170 const StringImpl& fiberString = *fiber(i)->valueInternal().impl(); 171 unsigned length = fiberString.length(); 172 StringImpl::copyCharacters(position, fiberString.characters8(), length); 173 position += length; 174 } 175 ASSERT((buffer + length()) == position); 156 resolveRopeInternalNoSubstring(buffer); 176 157 } 177 158 … … 184 165 } 185 166 186 resolveRopeInternal16NoSubstring(buffer); 187 } 188 189 void JSRopeString::resolveRopeInternal16NoSubstring(UChar* buffer) const 167 resolveRopeInternalNoSubstring(buffer); 168 } 169 170 template<typename CharacterType> 171 void JSRopeString::resolveRopeInternalNoSubstring(CharacterType* buffer) const 190 172 { 191 173 for (size_t i = 0; i < s_maxInternalRopeLength && fiber(i); ++i) { … … 196 178 } 197 179 198 UChar* position = buffer;180 CharacterType* position = buffer; 199 181 for (size_t i = 0; i < s_maxInternalRopeLength && fiber(i); ++i) { 200 182 const StringImpl& fiberString = *fiber(i)->valueInternal().impl(); … … 307 289 vm.heap.reportExtraMemoryAllocated(newImpl->cost()); 308 290 309 resolveRopeInternal 8NoSubstring(buffer);291 resolveRopeInternalNoSubstring(buffer); 310 292 convertToNonRope(function(newImpl.releaseNonNull())); 311 293 return valueInternal(); … … 320 302 vm.heap.reportExtraMemoryAllocated(newImpl->cost()); 321 303 322 resolveRopeInternal 16NoSubstring(buffer);304 resolveRopeInternalNoSubstring(buffer); 323 305 convertToNonRope(function(newImpl.releaseNonNull())); 324 306 return valueInternal(); … … 342 324 // only fill the queue with the number of substrings at any given level in a 343 325 // rope-of-ropes.) 344 void JSRopeString::resolveRopeSlowCase8(LChar* buffer) const 345 { 346 LChar* position = buffer + length(); // We will be working backwards over the rope. 347 Vector<JSString*, 32, UnsafeVectorOverflow> workQueue; // Putting strings into a Vector is only OK because there are no GC points in this method. 348 349 for (size_t i = 0; i < s_maxInternalRopeLength && fiber(i); ++i) 350 workQueue.append(fiber(i)); 351 352 while (!workQueue.isEmpty()) { 353 JSString* currentFiber = workQueue.last(); 354 workQueue.removeLast(); 355 356 const LChar* characters; 357 358 if (currentFiber->isRope()) { 359 JSRopeString* currentFiberAsRope = static_cast<JSRopeString*>(currentFiber); 360 if (!currentFiberAsRope->isSubstring()) { 361 for (size_t i = 0; i < s_maxInternalRopeLength && currentFiberAsRope->fiber(i); ++i) 362 workQueue.append(currentFiberAsRope->fiber(i)); 363 continue; 364 } 365 ASSERT(!currentFiberAsRope->substringBase()->isRope()); 366 characters = 367 currentFiberAsRope->substringBase()->valueInternal().characters8() + 368 currentFiberAsRope->substringOffset(); 369 } else 370 characters = currentFiber->valueInternal().characters8(); 371 372 unsigned length = currentFiber->length(); 373 position -= length; 374 StringImpl::copyCharacters(position, characters, length); 375 } 376 377 ASSERT(buffer == position); 378 } 379 380 void JSRopeString::resolveRopeSlowCase(UChar* buffer) const 381 { 382 UChar* position = buffer + length(); // We will be working backwards over the rope. 326 template<typename CharacterType> 327 void JSRopeString::resolveRopeSlowCase(CharacterType* buffer) const 328 { 329 CharacterType* position = buffer + length(); // We will be working backwards over the rope. 383 330 Vector<JSString*, 32, UnsafeVectorOverflow> workQueue; // These strings are kept alive by the parent rope, so using a Vector is OK. 384 331
Note:
See TracChangeset
for help on using the changeset viewer.