WebKit Bugzilla
Attachment 343572 Details for
Bug 186322
: Switch to system malloc on iOS when nano malloc is disabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
a-backup.diff (text/plain), 5.21 KB, created by
Saam Barati
on 2018-06-25 18:45:34 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Saam Barati
Created:
2018-06-25 18:45:34 PDT
Size:
5.21 KB
patch
obsolete
>Index: Source/bmalloc/ChangeLog >=================================================================== >--- Source/bmalloc/ChangeLog (revision 233188) >+++ Source/bmalloc/ChangeLog (working copy) >@@ -1,3 +1,26 @@ >+2018-06-25 Saam Barati <sbarati@apple.com> >+ >+ Wasm: Any function argument of type Void should be a validation error >+ https://bugs.webkit.org/show_bug.cgi?id=186794 >+ <rdar://problem/41140257> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We have evidence showing that processes with small heaps using the >+ JS API are more space efficient when using system malloc. Our main >+ hypothesis as to why this is, is that when dealing with small heaps, >+ one malloc can be more efficient at optimizing memory usage than >+ two mallocs. >+ >+ * bmalloc/BPlatform.h: >+ * bmalloc/Environment.cpp: >+ (bmalloc::isNanoMallocEnabled): >+ (bmalloc::Environment::computeIsDebugHeapEnabled): >+ * bmalloc/ProcessCheck.h: >+ (bmalloc::shouldProcessUnconditionallyUseBmalloc): >+ * bmalloc/ProcessCheck.mm: >+ (bmalloc::shouldProcessUnconditionallyUseBmalloc): >+ > 2018-06-24 Yusuke Suzuki <utatane.tea@gmail.com> > > [bmalloc][Linux] Remove static initializers for PerProcess<>::s_object >Index: Source/bmalloc/bmalloc/BPlatform.h >=================================================================== >--- Source/bmalloc/bmalloc/BPlatform.h (revision 233161) >+++ Source/bmalloc/bmalloc/BPlatform.h (working copy) >@@ -71,6 +71,10 @@ > #define BPLATFORM_WATCHOS 1 > #endif > >+#if defined(TARGET_OS_TV) && TARGET_OS_TV >+#define BPLATFORM_APPLETV 1 >+#endif >+ > /* ==== Policy decision macros: these define policy choices for a particular port. ==== */ > > /* BUSE() - use a particular third-party library or optional OS service */ >@@ -233,3 +237,11 @@ > > /* This is used for debugging when hacking on how bmalloc calculates its physical footprint. */ > #define ENABLE_PHYSICAL_PAGE_MAP 0 >+ >+#if ((BPLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (BPLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 50000) || (BPLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 120000)) \ >+ && (BCPU(ARM64) || BCPU(ARM)) >+#define BUSE_CHECK_NANO_MALLOC 1 >+#else >+#define BUSE_CHECK_NANO_MALLOC 0 >+#endif >+ >Index: Source/bmalloc/bmalloc/Environment.cpp >=================================================================== >--- Source/bmalloc/bmalloc/Environment.cpp (revision 233161) >+++ Source/bmalloc/bmalloc/Environment.cpp (working copy) >@@ -25,6 +25,7 @@ > > #include "BPlatform.h" > #include "Environment.h" >+#include "ProcessCheck.h" > #include <cstdlib> > #include <cstring> > #if BOS(DARWIN) >@@ -33,6 +34,15 @@ > #include <dlfcn.h> > #endif > >+#if BUSE(CHECK_NANO_MALLOC) >+extern "C" { >+#if __has_include(<malloc_private.h>) >+#include <malloc_private.h> >+#endif >+int malloc_engaged_nano(void); >+} >+#endif >+ > namespace bmalloc { > > static bool isMallocEnvironmentVariableSet() >@@ -107,6 +117,14 @@ static bool isSanitizerEnabled() > #endif > } > >+#if BUSE(CHECK_NANO_MALLOC) >+static bool isNanoMallocEnabled() >+{ >+ int result = !!malloc_engaged_nano(); >+ return result; >+} >+#endif >+ > Environment::Environment(std::lock_guard<Mutex>&) > : m_isDebugHeapEnabled(computeIsDebugHeapEnabled()) > { >@@ -120,6 +138,10 @@ bool Environment::computeIsDebugHeapEnab > return true; > if (isSanitizerEnabled()) > return true; >+#if BUSE(CHECK_NANO_MALLOC) >+ if (!isNanoMallocEnabled() && !shouldProcessUnconditionallyUseBmalloc()) >+ return true; >+#endif > return false; > } > >Index: Source/bmalloc/bmalloc/ProcessCheck.h >=================================================================== >--- Source/bmalloc/bmalloc/ProcessCheck.h (revision 233161) >+++ Source/bmalloc/bmalloc/ProcessCheck.h (working copy) >@@ -39,4 +39,10 @@ bool gigacageEnabledForProcess(); > inline bool gigacageEnabledForProcess() { return true; } > #endif > >+#if BUSE(CHECK_NANO_MALLOC) >+bool shouldProcessUnconditionallyUseBmalloc(); >+#else >+inline bool shouldProcessUnconditionallyUseBmalloc() { return true; } >+#endif >+ > } >Index: Source/bmalloc/bmalloc/ProcessCheck.mm >=================================================================== >--- Source/bmalloc/bmalloc/ProcessCheck.mm (revision 233161) >+++ Source/bmalloc/bmalloc/ProcessCheck.mm (working copy) >@@ -28,6 +28,7 @@ > #if !BPLATFORM(WATCHOS) > > #import <Foundation/Foundation.h> >+#import <mutex> > > namespace bmalloc { > >@@ -52,6 +53,27 @@ bool gigacageEnabledForProcess() > return isOptInBinary; > } > >+#if BUSE(CHECK_NANO_MALLOC) >+bool shouldProcessUnconditionallyUseBmalloc() >+{ >+ static bool result; >+ static std::once_flag onceFlag; >+ std::call_once(onceFlag, [&] () { >+ if (NSString *appName = [[NSBundle mainBundle] bundleIdentifier]) { >+ auto contains = [&] (NSString *string) { >+ return [appName rangeOfString:string options:NSCaseInsensitiveSearch].location != NSNotFound; >+ }; >+ result = contains(@"com.apple.WebKit") || contains(@"safari"); >+ } else { >+ NSString *processName = [[NSProcessInfo processInfo] processName]; >+ result = [processName isEqualToString:@"jsc"] || [processName isEqualToString:@"wasm"]; >+ } >+ }); >+ >+ return result; >+} >+#endif >+ > } > > #endif
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 186322
: 343572