WebKit Bugzilla
Attachment 362468 Details for
Bug 194837
: [bmalloc] DebugHeap::malloc does not have "try" version.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194837-20190219182154.patch (text/plain), 4.59 KB, created by
Yusuke Suzuki
on 2019-02-19 18:21:55 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-02-19 18:21:55 PST
Size:
4.59 KB
patch
obsolete
>Subversion Revision: 241789 >diff --git a/Source/bmalloc/ChangeLog b/Source/bmalloc/ChangeLog >index ff9a88a69ec5cdcbb051425bb4081414e525f699..7ce7fea4e68d17269f4f0e740408d9108d15d8de 100644 >--- a/Source/bmalloc/ChangeLog >+++ b/Source/bmalloc/ChangeLog >@@ -1,3 +1,22 @@ >+2019-02-19 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [bmalloc] DebugHeap::malloc does not have "try" version. >+ https://bugs.webkit.org/show_bug.cgi?id=194837 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Since DebugHeap::malloc does not have "try" version, our tryAllocate implementation does not work well with DebugHeap. >+ This patch adds crashOnFailure flag to DebugHeap::malloc. >+ >+ * bmalloc/Cache.cpp: >+ (bmalloc::Cache::tryAllocateSlowCaseNullCache): >+ (bmalloc::Cache::allocateSlowCaseNullCache): >+ * bmalloc/DebugHeap.cpp: >+ (bmalloc::DebugHeap::malloc): >+ * bmalloc/DebugHeap.h: >+ * bmalloc/IsoTLS.cpp: >+ (bmalloc::IsoTLS::debugMalloc): >+ > 2019-02-19 Yusuke Suzuki <ysuzuki@apple.com> > > [bmalloc] bmalloc::Cache should not be instantiated if we are using system malloc >diff --git a/Source/bmalloc/bmalloc/Cache.cpp b/Source/bmalloc/bmalloc/Cache.cpp >index 29ad1309866f12d809f6f121d9f6511ed735362a..64292a145bcbb8bd34681e39a05c99e88e2a6641 100644 >--- a/Source/bmalloc/bmalloc/Cache.cpp >+++ b/Source/bmalloc/bmalloc/Cache.cpp >@@ -66,17 +66,19 @@ Cache::Cache(HeapKind heapKind) > > BNO_INLINE void* Cache::tryAllocateSlowCaseNullCache(HeapKind heapKind, size_t size) > { >- // FIXME: DebugHeap does not have tryAllocate feature. >- // https://bugs.webkit.org/show_bug.cgi?id=194837 >- if (auto* heap = debugHeap()) >- return heap->malloc(size); >+ if (auto* heap = debugHeap()) { >+ constexpr bool crashOnFailure = false; >+ return heap->malloc(size, crashOnFailure); >+ } > return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().tryAllocate(size); > } > > BNO_INLINE void* Cache::allocateSlowCaseNullCache(HeapKind heapKind, size_t size) > { >- if (auto* heap = debugHeap()) >- return heap->malloc(size); >+ if (auto* heap = debugHeap()) { >+ constexpr bool crashOnFailure = true; >+ return heap->malloc(size, crashOnFailure); >+ } > return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().allocate(size); > } > >diff --git a/Source/bmalloc/bmalloc/DebugHeap.cpp b/Source/bmalloc/bmalloc/DebugHeap.cpp >index f21f5a52f5c2a65eea0efbe8c6191751b5904990..1ff1780b1ae25d13c3576eb10c3f91687a270138 100644 >--- a/Source/bmalloc/bmalloc/DebugHeap.cpp >+++ b/Source/bmalloc/bmalloc/DebugHeap.cpp >@@ -43,10 +43,10 @@ DebugHeap::DebugHeap(std::lock_guard<Mutex>&) > malloc_set_zone_name(m_zone, "WebKit Using System Malloc"); > } > >-void* DebugHeap::malloc(size_t size) >+void* DebugHeap::malloc(size_t size, bool crashOnFailure) > { > void* result = malloc_zone_malloc(m_zone, size); >- if (!result) >+ if (!result && crashOnFailure) > BCRASH(); > return result; > } >@@ -79,10 +79,10 @@ DebugHeap::DebugHeap(std::lock_guard<Mutex>&) > { > } > >-void* DebugHeap::malloc(size_t size) >+void* DebugHeap::malloc(size_t size, bool crashOnFailure) > { > void* result = ::malloc(size); >- if (!result) >+ if (!result && crashOnFailure) > BCRASH(); > return result; > } >diff --git a/Source/bmalloc/bmalloc/DebugHeap.h b/Source/bmalloc/bmalloc/DebugHeap.h >index 219f8374e579f19c45d8645f0f4e890ddd82b98d..518a645d124bc7d3b3305f16dd93baddd74e6edb 100644 >--- a/Source/bmalloc/bmalloc/DebugHeap.h >+++ b/Source/bmalloc/bmalloc/DebugHeap.h >@@ -39,7 +39,7 @@ class DebugHeap { > public: > DebugHeap(std::lock_guard<Mutex>&); > >- void* malloc(size_t); >+ void* malloc(size_t, bool crashOnFailure); > void* memalign(size_t alignment, size_t, bool crashOnFailure); > void* realloc(void*, size_t, bool crashOnFailure); > void free(void*); >diff --git a/Source/bmalloc/bmalloc/IsoTLS.cpp b/Source/bmalloc/bmalloc/IsoTLS.cpp >index c96f22277767e57bd0dff2ffd854f66f9d6fe265..520565f84ad6ac8994743675a1fc9f14fd25c70a 100644 >--- a/Source/bmalloc/bmalloc/IsoTLS.cpp >+++ b/Source/bmalloc/bmalloc/IsoTLS.cpp >@@ -182,8 +182,10 @@ bool IsoTLS::isUsingDebugHeap() > auto IsoTLS::debugMalloc(size_t size) -> DebugMallocResult > { > DebugMallocResult result; >- if ((result.usingDebugHeap = isUsingDebugHeap())) >- result.ptr = PerProcess<DebugHeap>::get()->malloc(size); >+ if ((result.usingDebugHeap = isUsingDebugHeap())) { >+ constexpr bool crashOnFailure = true; >+ result.ptr = PerProcess<DebugHeap>::get()->malloc(size, crashOnFailure); >+ } > return result; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194837
: 362468