Changeset 185486 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Jun 11, 2015, 9:09:11 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r185368 r185486 187 187 188 188 bool isRope() const { return m_value.isNull(); } 189 bool isSubstring() const; 189 190 bool is8Bit() const { return m_flags & Is8Bit; } 190 191 void setIs8Bit(bool flag) const … … 292 293 } 293 294 294 void finishCreation(VM& vm, JSString* base, unsigned offset, unsigned length) 295 { 295 void finishCreation(ExecState& exec, JSString& base, unsigned offset, unsigned length) 296 { 297 VM& vm = exec.vm(); 296 298 Base::finishCreation(vm); 297 ASSERT(!base->isRope());298 299 ASSERT(!sumOverflows<int32_t>(offset, length)); 299 ASSERT(offset + length <= base ->length());300 ASSERT(offset + length <= base.length()); 300 301 m_length = length; 301 setIs8Bit(base ->is8Bit());302 setIs8Bit(base.is8Bit()); 302 303 setIsSubstring(true); 303 substringBase().set(vm, this, base); 304 substringOffset() = offset; 304 if (base.isSubstring()) { 305 JSRopeString& baseRope = static_cast<JSRopeString&>(base); 306 substringBase().set(vm, this, baseRope.substringBase().get()); 307 substringOffset() = baseRope.substringOffset() + offset; 308 } else { 309 substringBase().set(vm, this, &base); 310 substringOffset() = offset; 311 312 // For now, let's not allow substrings with a rope base. 313 // Resolve non-substring rope bases so we don't have to deal with it. 314 // FIXME: Evaluate if this would be worth adding more branches. 315 if (base.isRope()) 316 static_cast<JSRopeString&>(base).resolveRope(&exec); 317 } 305 318 } 306 319 … … 343 356 } 344 357 345 static JSString* create( VM& vm, JSString*base, unsigned offset, unsigned length)346 { 347 JSRopeString* newString = new (NotNull, allocateCell<JSRopeString>( vm.heap)) JSRopeString(vm);348 newString->finishCreation( vm, base, offset, length);358 static JSString* create(ExecState& exec, JSString& base, unsigned offset, unsigned length) 359 { 360 JSRopeString* newString = new (NotNull, allocateCell<JSRopeString>(exec.vm().heap)) JSRopeString(exec.vm()); 361 newString->finishCreation(exec, base, offset, length); 349 362 return newString; 350 363 } … … 516 529 if (!length) 517 530 return vm.smallStrings.emptyString(); 518 s->value(exec); // For effect. We need to ensure that any string that is used as a substring base is not a rope. 519 return JSRopeString::create(vm, s, offset, length); 531 return JSRopeString::create(*exec, *s, offset, length); 520 532 } 521 533 … … 704 716 } 705 717 718 inline bool JSString::isSubstring() const 719 { 720 return isRope() && static_cast<const JSRopeString*>(this)->isSubstring(); 721 } 722 706 723 } // namespace JSC 707 724
Note:
See TracChangeset
for help on using the changeset viewer.