Title: [233773] trunk/Source/bmalloc
Revision
233773
Author
msab...@apple.com
Date
2018-07-12 11:27:26 -0700 (Thu, 12 Jul 2018)

Log Message

Disable IsoHeaps when Gigacage is off
https://bugs.webkit.org/show_bug.cgi?id=187160

Reviewed by Saam Barati.

Relanding change sets 233547 and 233550 with the added fix that Gigacage is also
enabled for DumpRenderTree.

Updated determineMallocFallbackState to base enabling of Iso Heaps on Gigacage 
being enabled.  We do this because if Gigacage is disabled, it may be due to lack
of address space.

To work around a compiler issue uncovered by the change above, I added explicit
instantiation of PerThread's static variables.  Defined the same explicit
instantiated static variables with export scope in the new file PerThread.cpp
to eliminate separate variables allocations in each linked framework / library.

* CMakeLists.txt:
* bmalloc.xcodeproj/project.pbxproj:
* bmalloc/IsoTLS.cpp:
(bmalloc::IsoTLS::determineMallocFallbackState):
* bmalloc/PerThread.cpp: Added.
* bmalloc/PerThread.h:
* bmalloc/ProcessCheck.mm:
(bmalloc::gigacageEnabledForProcess):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/bmalloc/CMakeLists.txt (233772 => 233773)


--- trunk/Source/bmalloc/CMakeLists.txt	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/CMakeLists.txt	2018-07-12 18:27:26 UTC (rev 233773)
@@ -27,6 +27,7 @@
     bmalloc/Mutex.cpp
     bmalloc/ObjectType.cpp
     bmalloc/PerProcess.cpp
+    bmalloc/PerThread.cpp
     bmalloc/Scavenger.cpp
     bmalloc/VMHeap.cpp
     bmalloc/bmalloc.cpp

Modified: trunk/Source/bmalloc/ChangeLog (233772 => 233773)


--- trunk/Source/bmalloc/ChangeLog	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/ChangeLog	2018-07-12 18:27:26 UTC (rev 233773)
@@ -1,3 +1,31 @@
+2019-07-12  Michael Saboff  <msab...@apple.com>
+
+        Disable IsoHeaps when Gigacage is off
+        https://bugs.webkit.org/show_bug.cgi?id=187160
+
+        Reviewed by Saam Barati.
+
+        Relanding change sets 233547 and 233550 with the added fix that Gigacage is also
+        enabled for DumpRenderTree.
+
+        Updated determineMallocFallbackState to base enabling of Iso Heaps on Gigacage 
+        being enabled.  We do this because if Gigacage is disabled, it may be due to lack
+        of address space.
+
+        To work around a compiler issue uncovered by the change above, I added explicit
+        instantiation of PerThread's static variables.  Defined the same explicit
+        instantiated static variables with export scope in the new file PerThread.cpp
+        to eliminate separate variables allocations in each linked framework / library.
+
+        * CMakeLists.txt:
+        * bmalloc.xcodeproj/project.pbxproj:
+        * bmalloc/IsoTLS.cpp:
+        (bmalloc::IsoTLS::determineMallocFallbackState):
+        * bmalloc/PerThread.cpp: Added.
+        * bmalloc/PerThread.h:
+        * bmalloc/ProcessCheck.mm:
+        (bmalloc::gigacageEnabledForProcess):
+
 2018-07-09  Commit Queue  <commit-qu...@webkit.org>
 
         Unreviewed, rolling out r233547 and r233550.

Modified: trunk/Source/bmalloc/bmalloc/IsoTLS.cpp (233772 => 233773)


--- trunk/Source/bmalloc/bmalloc/IsoTLS.cpp	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/bmalloc/IsoTLS.cpp	2018-07-12 18:27:26 UTC (rev 233773)
@@ -27,6 +27,7 @@
 
 #include "DebugHeap.h"
 #include "Environment.h"
+#include "Gigacage.h"
 #include "IsoTLSEntryInlines.h"
 #include "IsoTLSInlines.h"
 #include "IsoTLSLayout.h"
@@ -201,12 +202,20 @@
         [] {
             if (s_mallocFallbackState != MallocFallbackState::Undecided)
                 return;
-            
+
+#if GIGACAGE_ENABLED
+            if (!Gigacage::shouldBeEnabled()) {
+                s_mallocFallbackState = MallocFallbackState::FallBackToMalloc;
+                return;
+            }
             const char* env = getenv("bmalloc_IsoHeap");
             if (env && (!strcasecmp(env, "false") || !strcasecmp(env, "no") || !strcmp(env, "0")))
                 s_mallocFallbackState = MallocFallbackState::FallBackToMalloc;
             else
                 s_mallocFallbackState = MallocFallbackState::DoNotFallBack;
+#else
+            s_mallocFallbackState = MallocFallbackState::FallBackToMalloc;
+#endif
         });
 }
 

Added: trunk/Source/bmalloc/bmalloc/PerThread.cpp (0 => 233773)


--- trunk/Source/bmalloc/bmalloc/PerThread.cpp	                        (rev 0)
+++ trunk/Source/bmalloc/bmalloc/PerThread.cpp	2018-07-12 18:27:26 UTC (rev 233773)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PerThread.h"
+
+#include "BExport.h"
+#include "Cache.h"
+#include "Heap.h"
+
+namespace bmalloc {
+
+#if !HAVE_PTHREAD_MACHDEP_H
+
+template<> BEXPORT bool PerThreadStorage<PerHeapKind<Cache>>::s_didInitialize = false;
+template<> BEXPORT pthread_key_t PerThreadStorage<PerHeapKind<Cache>>::s_key = 0;
+template<> BEXPORT std::once_flag PerThreadStorage<PerHeapKind<Cache>>::s_onceFlag = { };
+
+template<> BEXPORT bool PerThreadStorage<PerHeapKind<Heap>>::s_didInitialize = false;
+template<> BEXPORT pthread_key_t PerThreadStorage<PerHeapKind<Heap>>::s_key = 0;
+template<> BEXPORT std::once_flag PerThreadStorage<PerHeapKind<Heap>>::s_onceFlag = { };
+
+#endif
+
+} // namespace bmalloc

Modified: trunk/Source/bmalloc/bmalloc/PerThread.h (233772 => 233773)


--- trunk/Source/bmalloc/bmalloc/PerThread.h	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/bmalloc/PerThread.h	2018-07-12 18:27:26 UTC (rev 233773)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -108,10 +108,17 @@
     }
 };
 
-template<typename T> bool PerThreadStorage<T>::s_didInitialize;
-template<typename T> pthread_key_t PerThreadStorage<T>::s_key;
-template<typename T> std::once_flag PerThreadStorage<T>::s_onceFlag;
+class Cache;
+class Heap;
 
+template<> bool PerThreadStorage<PerHeapKind<Cache>>::s_didInitialize;
+template<> pthread_key_t PerThreadStorage<PerHeapKind<Cache>>::s_key;
+template<> std::once_flag PerThreadStorage<PerHeapKind<Cache>>::s_onceFlag;
+
+template<> bool PerThreadStorage<PerHeapKind<Heap>>::s_didInitialize;
+template<> pthread_key_t PerThreadStorage<PerHeapKind<Heap>>::s_key;
+template<> std::once_flag PerThreadStorage<PerHeapKind<Heap>>::s_onceFlag;
+
 #endif
 
 template<typename T>

Modified: trunk/Source/bmalloc/bmalloc/ProcessCheck.mm (233772 => 233773)


--- trunk/Source/bmalloc/bmalloc/ProcessCheck.mm	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/bmalloc/ProcessCheck.mm	2018-07-12 18:27:26 UTC (rev 233773)
@@ -46,6 +46,7 @@
 
     NSString *processName = [[NSProcessInfo processInfo] processName];
     bool isOptInBinary = [processName isEqualToString:@"jsc"]
+        || [processName isEqualToString:@"DumpRenderTree"]
         || [processName isEqualToString:@"wasm"]
         || [processName hasPrefix:@"test"];
 

Modified: trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj (233772 => 233773)


--- trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2018-07-12 17:39:48 UTC (rev 233772)
+++ trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj	2018-07-12 18:27:26 UTC (rev 233773)
@@ -131,6 +131,7 @@
 		4426E2801C838EE0008EB042 /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4426E27E1C838EE0008EB042 /* Logging.cpp */; };
 		4426E2811C838EE0008EB042 /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E27F1C838EE0008EB042 /* Logging.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		4426E2831C839547008EB042 /* BSoftLinking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4426E2821C839547008EB042 /* BSoftLinking.h */; };
+		6543DDB420EEAEF3003B23D8 /* PerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6543DDB320EEAEF3003B23D8 /* PerThread.cpp */; };
 		6599C5CC1EC3F15900A2F7BB /* AvailableMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6599C5CA1EC3F15900A2F7BB /* AvailableMemory.cpp */; };
 		6599C5CD1EC3F15900A2F7BB /* AvailableMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 6599C5CB1EC3F15900A2F7BB /* AvailableMemory.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7939885B2076EEB60074A2E7 /* BulkDecommit.h in Headers */ = {isa = PBXBuildFile; fileRef = 7939885A2076EEB50074A2E7 /* BulkDecommit.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -292,6 +293,7 @@
 		4426E27E1C838EE0008EB042 /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Logging.cpp; path = bmalloc/Logging.cpp; sourceTree = "<group>"; };
 		4426E27F1C838EE0008EB042 /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = bmalloc/Logging.h; sourceTree = "<group>"; };
 		4426E2821C839547008EB042 /* BSoftLinking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSoftLinking.h; path = bmalloc/darwin/BSoftLinking.h; sourceTree = "<group>"; };
+		6543DDB320EEAEF3003B23D8 /* PerThread.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = PerThread.cpp; path = bmalloc/PerThread.cpp; sourceTree = "<group>"; };
 		6599C5CA1EC3F15900A2F7BB /* AvailableMemory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AvailableMemory.cpp; path = bmalloc/AvailableMemory.cpp; sourceTree = "<group>"; };
 		6599C5CB1EC3F15900A2F7BB /* AvailableMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AvailableMemory.h; path = bmalloc/AvailableMemory.h; sourceTree = "<group>"; };
 		7939885A2076EEB50074A2E7 /* BulkDecommit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BulkDecommit.h; path = bmalloc/BulkDecommit.h; sourceTree = "<group>"; };
@@ -536,6 +538,7 @@
 				0F26A7A42054830D0090A141 /* PerProcess.cpp */,
 				14446A0717A61FA400F9EA1D /* PerProcess.h */,
 				144469FD17A61F1F00F9EA1D /* PerThread.h */,
+				6543DDB320EEAEF3003B23D8 /* PerThread.cpp */,
 				145F6878179E3A4400D65598 /* Range.h */,
 				148EFAE61D6B953B008E721E /* ScopeExit.h */,
 				1417F64F18B7280C0076FA3F /* Syscall.h */,
@@ -784,6 +787,7 @@
 				0F5BF14F1F22DEAF0029D91D /* Gigacage.cpp in Sources */,
 				14F271C718EA3990008C152F /* Heap.cpp in Sources */,
 				0FD557331F7EDB7B00B1F0A3 /* HeapKind.cpp in Sources */,
+				6543DDB420EEAEF3003B23D8 /* PerThread.cpp in Sources */,
 				0F7EB83B1F9541B000F1ABCB /* IsoHeapImpl.cpp in Sources */,
 				0F5549EF1FB54704007FF75A /* IsoPage.cpp in Sources */,
 				0F7EB8361F9541B000F1ABCB /* IsoTLS.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to