Ignore:
Timestamp:
Aug 31, 2017, 9:38:16 AM (8 years ago)
Author:
[email protected]
Message:

JSTests:
Unreviewed, skipping slow tests.

These tests are now timing out. They would have always been slow. The timeouts are probably because OOMs
work differently now.

  • stress/regexp-prototype-exec-on-too-long-rope.js:
  • stress/string-prototype-charCodeAt-on-too-long-rope.js:

Source/bmalloc:
Strings need to be in some kind of gigacage
https://bugs.webkit.org/show_bug.cgi?id=174924

Reviewed by Oliver Hunt.

This adds a StringGigacage.

  • bmalloc/Gigacage.cpp:
  • bmalloc/Gigacage.h:

(Gigacage::name):
(Gigacage::basePtr):
(Gigacage::forEachKind):

  • bmalloc/HeapKind.h:

(bmalloc::isGigacage):
(bmalloc::gigacageKind):
(bmalloc::heapKind):

Source/JavaScriptCore:
Strings need to be in some kind of gigacage
https://bugs.webkit.org/show_bug.cgi?id=174924

Reviewed by Oliver Hunt.

  • runtime/JSString.cpp:

(JSC::JSRopeString::resolveRopeToAtomicString const):
(JSC::JSRopeString::resolveRope const):

  • runtime/JSString.h:

(JSC::JSString::create):
(JSC::JSString::createHasOtherOwner):

  • runtime/JSStringBuilder.h:
  • runtime/VM.h:

(JSC::VM::gigacageAuxiliarySpace):

Source/WebCore:
Strings need to be in some kind of gigacage
https://bugs.webkit.org/show_bug.cgi?id=174924

Reviewed by Oliver Hunt.

No new tests because no new behavior.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::normalizeSpaces):

Source/WTF:
Strings need to be in some kind of gigacage
https://bugs.webkit.org/show_bug.cgi?id=174924

Reviewed by Oliver Hunt.

This makes all strings allocations come from the string gigacage. Because we expect string allocation
to be a hot path, I created specialized allocation paths for the string gigacage. These paths are
accessible via <wtf/text/StringMalloc.h>. However, those paths are equivalent to saying
Gigacage::malloc and friends with the Gigacage::String kind.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/Deque.h:
  • wtf/FastMalloc.cpp:

(WTF::fastFree):

  • wtf/FastMalloc.h:

(WTF::FastMalloc::malloc):
(WTF::FastMalloc::tryMalloc):
(WTF::FastMalloc::realloc):
(WTF::FastMalloc::free):

  • wtf/Forward.h:
  • wtf/Gigacage.cpp:

(Gigacage::tryMalloc):

  • wtf/Gigacage.h:

(Gigacage::name):

  • wtf/Vector.h:

(WTF::VectorBufferBase::allocateBuffer):
(WTF::VectorBufferBase::tryAllocateBuffer):
(WTF::VectorBufferBase::reallocateBuffer):
(WTF::VectorBufferBase::deallocateBuffer):
(WTF::Malloc>::Vector):
(WTF::=):
(WTF::Malloc>::contains const):
(WTF::Malloc>::findMatching const):
(WTF::Malloc>::find const):
(WTF::Malloc>::reverseFind const):
(WTF::Malloc>::appendIfNotContains):
(WTF::Malloc>::fill):
(WTF::Malloc>::appendRange):
(WTF::Malloc>::expandCapacity):
(WTF::Malloc>::tryExpandCapacity):
(WTF::Malloc>::resize):
(WTF::Malloc>::resizeToFit):
(WTF::Malloc>::shrink):
(WTF::Malloc>::grow):
(WTF::Malloc>::asanSetInitialBufferSizeTo):
(WTF::Malloc>::asanSetBufferSizeToFullCapacity):
(WTF::Malloc>::asanBufferSizeWillChangeTo):
(WTF::Malloc>::reserveCapacity):
(WTF::Malloc>::tryReserveCapacity):
(WTF::Malloc>::reserveInitialCapacity):
(WTF::Malloc>::shrinkCapacity):
(WTF::Malloc>::append):
(WTF::Malloc>::tryAppend):
(WTF::Malloc>::constructAndAppend):
(WTF::Malloc>::tryConstructAndAppend):
(WTF::Malloc>::appendSlowCase):
(WTF::Malloc>::constructAndAppendSlowCase):
(WTF::Malloc>::tryConstructAndAppendSlowCase):
(WTF::Malloc>::uncheckedAppend):
(WTF::Malloc>::appendVector):
(WTF::Malloc>::insert):
(WTF::Malloc>::insertVector):
(WTF::Malloc>::remove):
(WTF::Malloc>::removeFirst):
(WTF::Malloc>::removeFirstMatching):
(WTF::Malloc>::removeAll):
(WTF::Malloc>::removeAllMatching):
(WTF::Malloc>::reverse):
(WTF::Malloc>::map const):
(WTF::Malloc>::releaseBuffer):
(WTF::Malloc>::checkConsistency):
(WTF::swap):
(WTF::operator==):
(WTF::operator!=):
(WTF::removeRepeatedElements):
(WTF::minCapacity>::Vector): Deleted.
(WTF::minCapacity>::contains const): Deleted.
(WTF::minCapacity>::findMatching const): Deleted.
(WTF::minCapacity>::find const): Deleted.
(WTF::minCapacity>::reverseFind const): Deleted.
(WTF::minCapacity>::appendIfNotContains): Deleted.
(WTF::minCapacity>::fill): Deleted.
(WTF::minCapacity>::appendRange): Deleted.
(WTF::minCapacity>::expandCapacity): Deleted.
(WTF::minCapacity>::tryExpandCapacity): Deleted.
(WTF::minCapacity>::resize): Deleted.
(WTF::minCapacity>::resizeToFit): Deleted.
(WTF::minCapacity>::shrink): Deleted.
(WTF::minCapacity>::grow): Deleted.
(WTF::minCapacity>::asanSetInitialBufferSizeTo): Deleted.
(WTF::minCapacity>::asanSetBufferSizeToFullCapacity): Deleted.
(WTF::minCapacity>::asanBufferSizeWillChangeTo): Deleted.
(WTF::minCapacity>::reserveCapacity): Deleted.
(WTF::minCapacity>::tryReserveCapacity): Deleted.
(WTF::minCapacity>::reserveInitialCapacity): Deleted.
(WTF::minCapacity>::shrinkCapacity): Deleted.
(WTF::minCapacity>::append): Deleted.
(WTF::minCapacity>::tryAppend): Deleted.
(WTF::minCapacity>::constructAndAppend): Deleted.
(WTF::minCapacity>::tryConstructAndAppend): Deleted.
(WTF::minCapacity>::appendSlowCase): Deleted.
(WTF::minCapacity>::constructAndAppendSlowCase): Deleted.
(WTF::minCapacity>::tryConstructAndAppendSlowCase): Deleted.
(WTF::minCapacity>::uncheckedAppend): Deleted.
(WTF::minCapacity>::appendVector): Deleted.
(WTF::minCapacity>::insert): Deleted.
(WTF::minCapacity>::insertVector): Deleted.
(WTF::minCapacity>::remove): Deleted.
(WTF::minCapacity>::removeFirst): Deleted.
(WTF::minCapacity>::removeFirstMatching): Deleted.
(WTF::minCapacity>::removeAll): Deleted.
(WTF::minCapacity>::removeAllMatching): Deleted.
(WTF::minCapacity>::reverse): Deleted.
(WTF::minCapacity>::map const): Deleted.
(WTF::minCapacity>::releaseBuffer): Deleted.
(WTF::minCapacity>::checkConsistency): Deleted.

  • wtf/text/AtomicStringImpl.h:
  • wtf/text/CString.cpp:

(WTF::CStringBuffer::createUninitialized):

  • wtf/text/CString.h:
  • wtf/text/StringBuffer.h:

(WTF::StringBuffer::StringBuffer):
(WTF::StringBuffer::~StringBuffer):
(WTF::StringBuffer::resize):

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::~StringImpl):
(WTF::StringImpl::destroy):
(WTF::StringImpl::createUninitializedInternalNonEmpty):
(WTF::StringImpl::reallocateInternal):
(WTF::StringImpl::releaseAssertCaged const):

  • wtf/text/StringImpl.h:

(WTF::StringImpl::createSubstringSharingImpl):
(WTF::StringImpl::tryCreateUninitialized):
(WTF::StringImpl::adopt):
(WTF::StringImpl::bufferOwnership const):
(WTF::StringImpl::assertCaged const):

  • wtf/text/StringMalloc.cpp: Added.

(WTF::tryStringMalloc):
(WTF::stringMalloc):
(WTF::stringRealloc):
(WTF::stringFree):

  • wtf/text/StringMalloc.h: Added.

(WTF::StringMalloc::malloc):
(WTF::StringMalloc::tryMalloc):
(WTF::StringMalloc::realloc):
(WTF::StringMalloc::free):

  • wtf/text/StringVector.h: Added.
  • wtf/text/SymbolImpl.h:
  • wtf/text/UniquedStringImpl.h:
  • wtf/text/WTFString.h:

(WTF::String::adopt):
(WTF::String::assertCaged const):
(WTF::String::releaseAssertCaged const):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSString.cpp

    r221402 r221422  
    179179void JSRopeString::resolveRopeToAtomicString(ExecState* exec) const
    180180{
    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();
    205209}
    206210
     
    249253void JSRopeString::resolveRope(ExecState* exec) const
    250254{
    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;
    262281        if (auto newImpl = StringImpl::tryCreateUninitialized(length(), buffer)) {
    263282            Heap::heap(this)->reportExtraMemoryAllocated(newImpl->cost());
     
    267286            return;
    268287        }
    269         resolveRopeInternal8NoSubstring(buffer);
     288       
     289        resolveRopeInternal16NoSubstring(buffer);
    270290        clearFibers();
    271291        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();
    287295}
    288296
Note: See TracChangeset for help on using the changeset viewer.