Changeset 231337 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.cpp
- Timestamp:
- May 3, 2018, 5:40:18 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.cpp
r225117 r231337 179 179 void JSRopeString::resolveRopeToAtomicString(ExecState* exec) const 180 180 { 181 [&] () { 182 if (length() > maxLengthForOnStackResolve) { 183 resolveRope(exec); 184 m_value = AtomicString(m_value); 185 setIs8Bit(m_value.impl()->is8Bit()); 186 return; 187 } 188 189 if (is8Bit()) { 190 LChar buffer[maxLengthForOnStackResolve]; 191 resolveRopeInternal8(buffer); 192 m_value = AtomicString(buffer, length()); 193 setIs8Bit(m_value.impl()->is8Bit()); 194 } else { 195 UChar buffer[maxLengthForOnStackResolve]; 196 resolveRopeInternal16(buffer); 197 m_value = AtomicString(buffer, length()); 198 setIs8Bit(m_value.impl()->is8Bit()); 199 } 200 201 clearFibers(); 202 203 // If we resolved a string that didn't previously exist, notify the heap that we've grown. 204 if (m_value.impl()->hasOneRef()) 205 Heap::heap(this)->reportExtraMemoryAllocated(m_value.impl()->cost()); 206 }(); 207 208 m_value.releaseAssertCaged(); 181 if (length() > maxLengthForOnStackResolve) { 182 resolveRope(exec); 183 m_value = AtomicString(m_value); 184 setIs8Bit(m_value.impl()->is8Bit()); 185 return; 186 } 187 188 if (is8Bit()) { 189 LChar buffer[maxLengthForOnStackResolve]; 190 resolveRopeInternal8(buffer); 191 m_value = AtomicString(buffer, length()); 192 setIs8Bit(m_value.impl()->is8Bit()); 193 } else { 194 UChar buffer[maxLengthForOnStackResolve]; 195 resolveRopeInternal16(buffer); 196 m_value = AtomicString(buffer, length()); 197 setIs8Bit(m_value.impl()->is8Bit()); 198 } 199 200 clearFibers(); 201 202 // If we resolved a string that didn't previously exist, notify the heap that we've grown. 203 if (m_value.impl()->hasOneRef()) 204 Heap::heap(this)->reportExtraMemoryAllocated(m_value.impl()->cost()); 209 205 } 210 206 … … 253 249 void JSRopeString::resolveRope(ExecState* exec) const 254 250 { 255 [&] () { 256 ASSERT(isRope()); 257 258 if (isSubstring()) { 259 ASSERT(!substringBase()->isRope()); 260 m_value = substringBase()->m_value.substringSharingImpl(substringOffset(), length()); 261 substringBase().clear(); 262 return; 263 } 264 265 if (is8Bit()) { 266 LChar* buffer; 267 if (auto newImpl = StringImpl::tryCreateUninitialized(length(), buffer)) { 268 Heap::heap(this)->reportExtraMemoryAllocated(newImpl->cost()); 269 m_value = WTFMove(newImpl); 270 } else { 271 outOfMemory(exec); 272 return; 273 } 274 resolveRopeInternal8NoSubstring(buffer); 275 clearFibers(); 276 ASSERT(!isRope()); 277 return; 278 } 279 280 UChar* buffer; 251 ASSERT(isRope()); 252 253 if (isSubstring()) { 254 ASSERT(!substringBase()->isRope()); 255 m_value = substringBase()->m_value.substringSharingImpl(substringOffset(), length()); 256 substringBase().clear(); 257 return; 258 } 259 260 if (is8Bit()) { 261 LChar* buffer; 281 262 if (auto newImpl = StringImpl::tryCreateUninitialized(length(), buffer)) { 282 263 Heap::heap(this)->reportExtraMemoryAllocated(newImpl->cost()); … … 286 267 return; 287 268 } 288 289 resolveRopeInternal16NoSubstring(buffer); 269 resolveRopeInternal8NoSubstring(buffer); 290 270 clearFibers(); 291 271 ASSERT(!isRope()); 292 }(); 293 294 m_value.releaseAssertCaged(); 272 return; 273 } 274 275 UChar* buffer; 276 if (auto newImpl = StringImpl::tryCreateUninitialized(length(), buffer)) { 277 Heap::heap(this)->reportExtraMemoryAllocated(newImpl->cost()); 278 m_value = WTFMove(newImpl); 279 } else { 280 outOfMemory(exec); 281 return; 282 } 283 284 resolveRopeInternal16NoSubstring(buffer); 285 clearFibers(); 286 ASSERT(!isRope()); 295 287 } 296 288
Note:
See TracChangeset
for help on using the changeset viewer.