Changeset 221422 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.cpp
- Timestamp:
- Aug 31, 2017, 9:38:16 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.cpp
r221402 r221422 179 179 void JSRopeString::resolveRopeToAtomicString(ExecState* exec) const 180 180 { 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()); 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(); 205 209 } 206 210 … … 249 253 void JSRopeString::resolveRope(ExecState* exec) const 250 254 { 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; 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; 262 281 if (auto newImpl = StringImpl::tryCreateUninitialized(length(), buffer)) { 263 282 Heap::heap(this)->reportExtraMemoryAllocated(newImpl->cost()); … … 267 286 return; 268 287 } 269 resolveRopeInternal8NoSubstring(buffer); 288 289 resolveRopeInternal16NoSubstring(buffer); 270 290 clearFibers(); 271 291 ASSERT(!isRope()); 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()); 292 }(); 293 294 m_value.releaseAssertCaged(); 287 295 } 288 296
Note:
See TracChangeset
for help on using the changeset viewer.