Fix std::make_unique / new[] using system malloc
https://bugs.webkit.org/show_bug.cgi?id=182975
Reviewed by JF Bastien.
Source/JavaScriptCore:
Use Vector, FAST_ALLOCATED, or UniqueArray instead.
(JSStringCreateWithCFString):
- bytecode/BytecodeKills.h:
- bytecode/BytecodeLivenessAnalysis.cpp:
(JSC::BytecodeLivenessAnalysis::computeKills):
(JSC::DFG::Disassembler::dumpDisassembly):
- jit/PolymorphicCallStubRoutine.cpp:
(JSC::PolymorphicCallStubRoutine::PolymorphicCallStubRoutine):
- jit/PolymorphicCallStubRoutine.h:
- jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
(currentWorkingDirectory):
(JSC::LLInt::initialize):
- llint/LLIntData.h:
- runtime/ArgList.h:
- runtime/StructureChain.h:
- runtime/StructureIDTable.cpp:
(JSC::StructureIDTable::StructureIDTable):
(JSC::StructureIDTable::resize):
- runtime/StructureIDTable.h:
- runtime/TypeProfilerLog.cpp:
(JSC::TypeProfilerLog::TypeProfilerLog):
(JSC::TypeProfilerLog::initializeLog): Deleted.
- runtime/TypeProfilerLog.h:
(JSC::TypeProfilerLog::TypeProfilerLog): Deleted.
(JSC::VM::~VM):
(JSC::VM::acquireRegExpPatternContexBuffer):
- runtime/VM.h:
- testRegExp.cpp:
(runFromFiles):
(JSC::HeapVerifier::HeapVerifier):
Source/WebCore:
Use Vector, FAST_ALLOCATED, or UniqueArray instead.
- Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::setBuffer):
- Modules/webaudio/AudioBufferSourceNode.h:
- css/StyleRule.h:
- cssjit/CompiledSelector.h:
- html/HTMLFrameSetElement.h:
- html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::copyTexSubImage2D):
(WebCore::WebGLRenderingContextBase::simulateVertexAttrib0):
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::LRUImageBufferCache):
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::imageBuffer):
(WebCore::WebGLRenderingContextBase::LRUImageBufferCache::bubbleToFront):
- html/canvas/WebGLRenderingContextBase.h:
- platform/Length.cpp:
(WebCore::newCoordsArray):
(WebCore::newLengthArray):
(): Deleted.
- platform/Length.h:
- platform/audio/DynamicsCompressor.cpp:
(WebCore::DynamicsCompressor::setNumberOfChannels):
- platform/audio/DynamicsCompressor.h:
- platform/audio/FFTFrame.h:
- platform/audio/gstreamer/FFTFrameGStreamer.cpp:
(WebCore::FFTFrame::FFTFrame):
- platform/graphics/FormatConverter.h:
(WebCore::FormatConverter::FormatConverter):
- platform/graphics/GraphicsContext3D.cpp:
(WebCore::GraphicsContext3D::texImage2DResourceSafe):
- platform/graphics/GraphicsContext3D.h:
- platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::getDirtyRects):
- platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::flipImageSurfaceVertically):
- platform/graphics/cg/GraphicsContext3DCG.cpp:
(WebCore::GraphicsContext3D::ImageExtractor::extractImage):
- platform/graphics/gpu/Texture.cpp:
(WebCore::Texture::updateSubRect):
- platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
(WebCore::GraphicsContext3D::compileShader):
(WebCore::GraphicsContext3D::getActiveAttribImpl):
(WebCore::GraphicsContext3D::getActiveUniformImpl):
(WebCore::GraphicsContext3D::getProgramInfoLog):
(WebCore::GraphicsContext3D::getShaderInfoLog):
- platform/graphics/texmap/TextureMapperShaderProgram.cpp:
(WebCore::getShaderLog):
(WebCore::getProgramLog):
- platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
- platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageReader::PNGImageReader):
(WebCore::PNGImageReader::close):
(WebCore::PNGImageReader::interlaceBuffer const):
(WebCore::PNGImageReader::createInterlaceBuffer):
- platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::decodeFrame):
- platform/network/curl/SocketStreamHandleImpl.h:
(WebCore::SocketStreamHandleImpl::SocketData::SocketData):
- platform/network/curl/SocketStreamHandleImplCurl.cpp:
(WebCore::createCopy):
(WebCore::SocketStreamHandleImpl::readData):
(): Deleted.
- platform/network/soup/SocketStreamHandleImpl.h:
- platform/network/soup/SocketStreamHandleImplSoup.cpp:
(WebCore::SocketStreamHandleImpl::connected):
- platform/win/LoggingWin.cpp:
(WebCore::logLevelString):
Source/WebCore/PAL:
Use Vector instead.
(PAL::logLevelString):
Source/WebKit:
Use Vector instead.
- NetworkProcess/win/SystemProxyWin.cpp:
(WindowsSystemProxy::getSystemHttpProxy):
- Platform/IPC/unix/ConnectionUnix.cpp:
(IPC::Connection::processMessage):
(IPC::Connection::sendOutputMessage):
- Platform/win/LoggingWin.cpp:
(WebKit::logLevelString):
- Shared/SandboxExtension.h:
- Shared/mac/SandboxExtensionMac.mm:
(WebKit::SandboxExtension::HandleArray::allocate):
(WebKit::SandboxExtension::HandleArray::operator[]):
(WebKit::SandboxExtension::HandleArray::operator[] const):
(WebKit::SandboxExtension::HandleArray::size const):
(WebKit::SandboxExtension::HandleArray::encode const):
Source/WebKitLegacy/win:
Use Vector instead.
(MarshallingHelpers::safeArrayToStringArray):
(MarshallingHelpers::safeArrayToIntArray):
- Plugins/PluginPackageWin.cpp:
(WebCore::PluginPackage::fetchInfo):
(WebPreferences::copyWebKitPreferencesToCFPreferences):
(WebView::onMenuCommand):
Source/WTF:
If we use make_unique<char[]>(num)
or new char[num]
, allocation is
done by the system malloc instead of bmalloc. This patch fixes this issue
by following three changes.
- Introduce UniqueArray<T>. It allocates memory from FastMalloc. While C++
array with new
need to hold the size to call destructor correctly, our
UniqueArray only supports type T which does not have a non trivial destructor.
It reduces the allocation size since we do not need to track the size of the
array compared to standard new T[]
. This is basically usable if we want to
have raw array which pointer won't be changed even if the container is moved.
In addition, we also extend UniqueArray<T> for types which have non trivial
destructors.
- Use Vector<T> instead.
- Annotate allocated types with MAKE_FAST_ALLOCATED. Since it introduces
new[] and delete[] operators, make_unique<T[]>(num) will allocate memory
from FastMalloc.
- WTF.xcodeproj/project.pbxproj:
- wtf/Assertions.cpp:
- wtf/CMakeLists.txt:
- wtf/FastMalloc.h:
(WTF::FastFree::operator() const):
(WTF::FastFree<T::operator() const):
(WTF::MallocPtr::operator bool const):
(WTF::StackShot::StackShot):
(WTF::StackShot::operator=):
(WTF::SystemFree<T::operator() const):
- wtf/UniqueArray.h: Copied from Source/WebKit/Platform/win/LoggingWin.cpp.
(WTF::makeUniqueArray):
(WTF::VectorTypeOperations::forceInitialize):
Tools:
- TestWebKitAPI/CMakeLists.txt:
- TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
- TestWebKitAPI/Tests/WTF/UniqueArray.cpp: Copied from Source/WebKit/Platform/win/LoggingWin.cpp.
(TestWebKitAPI::NonTrivialDestructor::NonTrivialDestructor):
(TestWebKitAPI::NonTrivialDestructor::~NonTrivialDestructor):
(TestWebKitAPI::NonTrivialDestructor::setLog):
(TestWebKitAPI::TEST):