Changeset 197641 in webkit for trunk/Source/JavaScriptCore/runtime/JSString.h
- Timestamp:
- Mar 6, 2016, 12:11:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSString.h
r197485 r197641 2 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 3 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2014, 2016 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 294 294 } 295 295 296 void finishCreation(ExecState& exec, JSString& base, unsigned offset, unsigned length) 297 { 298 VM& vm = exec.vm(); 296 void finishCreation(VM& vm, ExecState* exec, JSString* base, unsigned offset, unsigned length) 297 { 299 298 Base::finishCreation(vm); 300 299 ASSERT(!sumOverflows<int32_t>(offset, length)); 301 ASSERT(offset + length <= base .length());300 ASSERT(offset + length <= base->length()); 302 301 m_length = length; 303 setIs8Bit(base .is8Bit());302 setIs8Bit(base->is8Bit()); 304 303 setIsSubstring(true); 305 if (base .isSubstring()) {306 JSRopeString & baseRope = static_cast<JSRopeString&>(base);307 substringBase().set(vm, this, baseRope .substringBase().get());308 substringOffset() = baseRope .substringOffset() + offset;304 if (base->isSubstring()) { 305 JSRopeString* baseRope = jsCast<JSRopeString*>(base); 306 substringBase().set(vm, this, baseRope->substringBase().get()); 307 substringOffset() = baseRope->substringOffset() + offset; 309 308 } else { 310 substringBase().set(vm, this, &base);309 substringBase().set(vm, this, base); 311 310 substringOffset() = offset; 312 311 … … 314 313 // Resolve non-substring rope bases so we don't have to deal with it. 315 314 // FIXME: Evaluate if this would be worth adding more branches. 316 if (base .isRope())317 static_cast<JSRopeString&>(base).resolveRope(&exec);315 if (base->isRope()) 316 jsCast<JSRopeString*>(base)->resolveRope(exec); 318 317 } 319 318 } … … 357 356 } 358 357 359 static JSString* create( ExecState& exec, JSString&base, unsigned offset, unsigned length)360 { 361 JSRopeString* newString = new (NotNull, allocateCell<JSRopeString>( exec.vm().heap)) JSRopeString(exec.vm());362 newString->finishCreation( exec, base, offset, length);358 static JSString* create(VM& vm, ExecState* exec, JSString* base, unsigned offset, unsigned length) 359 { 360 JSRopeString* newString = new (NotNull, allocateCell<JSRopeString>(vm.heap)) JSRopeString(vm); 361 newString->finishCreation(vm, exec, base, offset, length); 363 362 return newString; 364 363 } … … 543 542 } 544 543 545 inline JSString* jsSubstring( ExecState* exec, JSString* s, unsigned offset, unsigned length)544 inline JSString* jsSubstring(VM& vm, ExecState* exec, JSString* s, unsigned offset, unsigned length) 546 545 { 547 546 ASSERT(offset <= static_cast<unsigned>(s->length())); 548 547 ASSERT(length <= static_cast<unsigned>(s->length())); 549 548 ASSERT(offset + length <= static_cast<unsigned>(s->length())); 550 VM& vm = exec->vm();551 549 if (!length) 552 550 return vm.smallStrings.emptyString(); 553 551 if (!offset && length == s->length()) 554 552 return s; 555 return JSRopeString::create(*exec, *s, offset, length); 553 return JSRopeString::create(vm, exec, s, offset, length); 554 } 555 556 inline JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length) 557 { 558 return jsSubstring(exec->vm(), exec, s, offset, length); 556 559 } 557 560
Note:
See TracChangeset
for help on using the changeset viewer.