Unreviewed, rolling out r223113 and r223121.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 19:33:48 +0000 (19:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 19:33:48 +0000 (19:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178182

Reintroduced 20% regression on Kraken (Requested by rniwa on
#webkit).

Reverted changesets:

"Enable gigacage on iOS"
https://bugs.webkit.org/show_bug.cgi?id=177586
https://trac.webkit.org/changeset/223113

"Use one virtual allocation for all gigacages and their
runways"
https://bugs.webkit.org/show_bug.cgi?id=178050
https://trac.webkit.org/changeset/223121

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223202 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
JSTests/ChangeLog
JSTests/stress/disable-gigacage-arrays.js [deleted file]
JSTests/stress/disable-gigacage-strings.js [deleted file]
JSTests/stress/disable-gigacage-typed-arrays.js [deleted file]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
Source/JavaScriptCore/jit/AssemblyHelpers.h
Source/JavaScriptCore/offlineasm/arm64.rb
Source/JavaScriptCore/offlineasm/asm.rb
Source/JavaScriptCore/offlineasm/instructions.rb
Source/bmalloc/CMakeLists.txt
Source/bmalloc/ChangeLog
Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
Source/bmalloc/bmalloc/BAssert.h
Source/bmalloc/bmalloc/Cache.cpp
Source/bmalloc/bmalloc/Cache.h
Source/bmalloc/bmalloc/CryptoRandom.cpp [deleted file]
Source/bmalloc/bmalloc/CryptoRandom.h [deleted file]
Source/bmalloc/bmalloc/Gigacage.cpp
Source/bmalloc/bmalloc/Gigacage.h
Source/bmalloc/bmalloc/Heap.cpp
Source/bmalloc/bmalloc/HeapKind.cpp [deleted file]
Source/bmalloc/bmalloc/HeapKind.h
Source/bmalloc/bmalloc/Scavenger.cpp
Source/bmalloc/bmalloc/bmalloc.h
Tools/ChangeLog
Tools/Scripts/run-jsc-stress-tests
Tools/Scripts/webkitruby/jsc-stress-test-writer-default.rb

index 2c215d2..a77c780 100644 (file)
@@ -1,3 +1,22 @@
+2017-10-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r223113 and r223121.
+        https://bugs.webkit.org/show_bug.cgi?id=178182
+
+        Reintroduced 20% regression on Kraken (Requested by rniwa on
+        #webkit).
+
+        Reverted changesets:
+
+        "Enable gigacage on iOS"
+        https://bugs.webkit.org/show_bug.cgi?id=177586
+        https://trac.webkit.org/changeset/223113
+
+        "Use one virtual allocation for all gigacages and their
+        runways"
+        https://bugs.webkit.org/show_bug.cgi?id=178050
+        https://trac.webkit.org/changeset/223121
+
 2017-10-11  Michael Saboff  <msaboff@apple.com>
 
         Disable test262 named capture group tests with direct unicode names and with references before definitions
diff --git a/JSTests/stress/disable-gigacage-arrays.js b/JSTests/stress/disable-gigacage-arrays.js
deleted file mode 100644 (file)
index 212fb1e..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-//@ runNoisyTestWithEnv "disable-gigacage", "GIGACAGE_ENABLED=0"
-
-(function() {
-    function foo(array, i)
-    {
-        return array[i];
-    }
-    
-    noInline(foo);
-    
-    var array = new Array(1000);
-    for (var i = 0; i < array.length; ++i)
-        array[i] = 5 - i;
-    for (var i = 0; i < 1000; ++i) {
-        var result = 0;
-        var expectedResult = 0;
-        for (var j = 0; j < array.length; ++j) {
-            result += foo(array, j);
-            expectedResult += 5 - j;
-        }
-        if (result != expectedResult)
-            throw new Error("Bad result: " + result);
-    }
-})();
diff --git a/JSTests/stress/disable-gigacage-strings.js b/JSTests/stress/disable-gigacage-strings.js
deleted file mode 100644 (file)
index 761d067..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//@ runNoisyTestWithEnv "disable-gigacage", "GIGACAGE_ENABLED=0"
-
-(function() {
-    function foo(array, i)
-    {
-        return array.charCodeAt(i);
-    }
-    
-    noInline(foo);
-    
-    var array = "";
-    for (var i = 0; i < array.length; ++i)
-        array += String.fromCharCode(5 - i);
-    for (var i = 0; i < 1000; ++i) {
-        var result = 0;
-        var expectedResult = 0;
-        for (var j = 0; j < array.length; ++j) {
-            result += foo(array, j);
-            expectedResult += 5 - j;
-        }
-        if (result != expectedResult)
-            throw new Error("Bad result: " + result);
-    }
-})();
-
diff --git a/JSTests/stress/disable-gigacage-typed-arrays.js b/JSTests/stress/disable-gigacage-typed-arrays.js
deleted file mode 100644 (file)
index 3663c1e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//@ runNoisyTestWithEnv "disable-gigacage", "GIGACAGE_ENABLED=0"
-
-(function() {
-    function foo(array, i)
-    {
-        return array[i];
-    }
-    
-    noInline(foo);
-    
-    var array = new Int32Array(1000);
-    for (var i = 0; i < array.length; ++i)
-        array[i] = 5 - i;
-    for (var i = 0; i < 1000; ++i) {
-        var result = 0;
-        var expectedResult = 0;
-        for (var j = 0; j < array.length; ++j) {
-            result += foo(array, j);
-            expectedResult += 5 - j;
-        }
-        if (result != expectedResult)
-            throw new Error("Bad result: " + result);
-    }
-})();
-
index 095bd14..9669f4d 100644 (file)
@@ -1,3 +1,22 @@
+2017-10-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r223113 and r223121.
+        https://bugs.webkit.org/show_bug.cgi?id=178182
+
+        Reintroduced 20% regression on Kraken (Requested by rniwa on
+        #webkit).
+
+        Reverted changesets:
+
+        "Enable gigacage on iOS"
+        https://bugs.webkit.org/show_bug.cgi?id=177586
+        https://trac.webkit.org/changeset/223113
+
+        "Use one virtual allocation for all gigacages and their
+        runways"
+        https://bugs.webkit.org/show_bug.cgi?id=178050
+        https://trac.webkit.org/changeset/223121
+
 2017-10-11  Michael Saboff  <msaboff@apple.com>
 
         Update JavaScriptCore/ucd/CaseFolding.txt to Unicode database 10.0
index 2280215..66b8136 100644 (file)
@@ -11994,7 +11994,7 @@ private:
     
     LValue caged(Gigacage::Kind kind, LValue ptr)
     {
-        if (!Gigacage::isEnabled(kind))
+        if (!Gigacage::shouldBeEnabled())
             return ptr;
         
         if (kind == Gigacage::Primitive && Gigacage::canPrimitiveGigacageBeDisabled()) {
index e1e4a5b..f3b6213 100644 (file)
@@ -1314,7 +1314,7 @@ public:
     void cage(Gigacage::Kind kind, GPRReg storage)
     {
 #if GIGACAGE_ENABLED
-        if (!Gigacage::isEnabled(kind))
+        if (!Gigacage::shouldBeEnabled())
             return;
         
         andPtr(TrustedImmPtr(Gigacage::mask(kind)), storage);
@@ -1328,7 +1328,7 @@ public:
     void cageConditionally(Gigacage::Kind kind, GPRReg storage, GPRReg scratch)
     {
 #if GIGACAGE_ENABLED
-        if (!Gigacage::isEnabled(kind))
+        if (!Gigacage::shouldBeEnabled())
             return;
         
         if (kind != Gigacage::Primitive || Gigacage::isDisablingPrimitiveGigacageDisabled())
index e806f99..ead4891 100644 (file)
@@ -260,31 +260,6 @@ def arm64LowerMalformedLoadStoreAddresses(list)
     newList
 end
 
-def arm64LowerLabelReferences(list)
-    newList = []
-    list.each {
-        | node |
-        if node.is_a? Instruction
-            case node.opcode
-            when "loadi", "loadis", "loadp", "loadq", "loadb", "loadbs", "loadh", "loadhs"
-                labelRef = node.operands[0]
-                if labelRef.is_a? LabelReference
-                    tmp = Tmp.new(node.codeOrigin, :gpr)
-                    newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), tmp])
-                    newList << Instruction.new(codeOrigin, node.opcode, [Address.new(node.codeOrigin, tmp, Immediate.new(node.codeOrigin, labelRef.offset)), node.operands[1]])
-                else
-                    newList << node
-                end
-            else
-                newList << node
-            end
-        else
-            newList << node
-        end
-    }
-    newList
-end
-
 # Workaround for Cortex-A53 erratum (835769)
 def arm64CortexA53Fix835769(list)
     newList = []
@@ -321,7 +296,6 @@ class Sequence
         result = riscLowerHardBranchOps64(result)
         result = riscLowerShiftOps(result)
         result = arm64LowerMalformedLoadStoreAddresses(result)
-        result = arm64LowerLabelReferences(result)
         result = riscLowerMalformedAddresses(result) {
             | node, address |
             case node.opcode
@@ -930,15 +904,6 @@ class Instruction
             $asm.putStr("#if CPU(ARM64_CORTEXA53)")
             $asm.puts "nop"
             $asm.putStr("#endif")
-        when "globaladdr"
-            uid = $asm.newUID
-            $asm.puts "L_offlineasm_loh_adrp_#{uid}:"
-            $asm.puts "adrp #{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGE"
-            $asm.puts "L_offlineasm_loh_ldr_#{uid}:"
-            $asm.puts "ldr #{operands[1].arm64Operand(:ptr)}, [#{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGEOFF]"
-            $asm.deferAction {
-                $asm.puts ".loh AdrpLdrGot L_offlineasm_loh_adrp_#{uid}, L_offlineasm_loh_ldr_#{uid}"
-            }
         else
             lowerDefault
         end
index 024049b..8d76565 100644 (file)
@@ -46,8 +46,6 @@ class Assembler
         @codeOrigin = nil
         @numLocalLabels = 0
         @numGlobalLabels = 0
-        @deferredActions = []
-        @count = 0
 
         @newlineSpacerState = :none
         @lastlabel = ""
@@ -75,23 +73,10 @@ class Assembler
             putsProcEndIfNeeded
         end
         putsLastComment
-        @deferredActions.each {
-            | action |
-            action.call()
-        }
         @outp.puts "OFFLINE_ASM_END" if !$emitWinAsm
         @state = :cpp
     end
     
-    def deferAction(&proc)
-        @deferredActions << proc
-    end
-    
-    def newUID
-        @count += 1
-        @count
-    end
-    
     def inAsm
         enterAsm
         yield
index 9dd4dc7..bbfce71 100644 (file)
@@ -267,8 +267,7 @@ ARM_INSTRUCTIONS =
 ARM64_INSTRUCTIONS =
     [
      "pcrtoaddr",   # Address from PC relative offset - adr instruction
-     "nopFixCortexA53Err835769", # nop on Cortex-A53 (nothing otherwise)
-     "globaladdr"
+     "nopFixCortexA53Err835769" # nop on Cortex-A53 (nothing otherwise)
     ]
 
 RISC_INSTRUCTIONS =
index ee3ab99..3fab69f 100644 (file)
@@ -8,13 +8,11 @@ set(bmalloc_SOURCES
     bmalloc/Allocator.cpp
     bmalloc/AvailableMemory.cpp
     bmalloc/Cache.cpp
-    bmalloc/CryptoRandom.cpp
     bmalloc/Deallocator.cpp
     bmalloc/DebugHeap.cpp
     bmalloc/Environment.cpp
     bmalloc/Gigacage.cpp
     bmalloc/Heap.cpp
-    bmalloc/HeapKind.cpp
     bmalloc/LargeMap.cpp
     bmalloc/Logging.cpp
     bmalloc/ObjectType.cpp
index 67f2a1a..e0806f1 100644 (file)
@@ -1,3 +1,22 @@
+2017-10-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r223113 and r223121.
+        https://bugs.webkit.org/show_bug.cgi?id=178182
+
+        Reintroduced 20% regression on Kraken (Requested by rniwa on
+        #webkit).
+
+        Reverted changesets:
+
+        "Enable gigacage on iOS"
+        https://bugs.webkit.org/show_bug.cgi?id=177586
+        https://trac.webkit.org/changeset/223113
+
+        "Use one virtual allocation for all gigacages and their
+        runways"
+        https://bugs.webkit.org/show_bug.cgi?id=178050
+        https://trac.webkit.org/changeset/223121
+
 2017-10-07  Filip Pizlo  <fpizlo@apple.com>
 
         Use one virtual allocation for all gigacages and their runways
index f64fd9f..c90760a 100644 (file)
@@ -15,9 +15,6 @@
                0F5BF1521F22E1570029D91D /* Scavenger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F5BF1501F22E1570029D91D /* Scavenger.cpp */; };
                0F5BF1531F22E1570029D91D /* Scavenger.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5BF1511F22E1570029D91D /* Scavenger.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F5BF1731F23C5710029D91D /* BExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F5BF1721F23C5710029D91D /* BExport.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               0F74B93E1F89713E00B935D3 /* CryptoRandom.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F74B93C1F89713E00B935D3 /* CryptoRandom.h */; };
-               0F74B93F1F89713E00B935D3 /* CryptoRandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */; };
-               0FD557331F7EDB7B00B1F0A3 /* HeapKind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD557321F7EDB7B00B1F0A3 /* HeapKind.cpp */; };
                1400274918F89C1300115C97 /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14DA320C18875B09007269E0 /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1400274A18F89C2300115C97 /* VMHeap.h in Headers */ = {isa = PBXBuildFile; fileRef = 144F7BFC18BFC517003537F3 /* VMHeap.h */; settings = {ATTRIBUTES = (Private, ); }; };
                140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */ = {isa = PBXBuildFile; fileRef = 140FA00219CE429C00FFD3C8 /* BumpRange.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -93,9 +90,6 @@
                0F5BF1501F22E1570029D91D /* Scavenger.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Scavenger.cpp; path = bmalloc/Scavenger.cpp; sourceTree = "<group>"; };
                0F5BF1511F22E1570029D91D /* Scavenger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Scavenger.h; path = bmalloc/Scavenger.h; sourceTree = "<group>"; };
                0F5BF1721F23C5710029D91D /* BExport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = BExport.h; path = bmalloc/BExport.h; sourceTree = "<group>"; };
-               0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; };
-               0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoRandom.cpp; path = bmalloc/CryptoRandom.cpp; sourceTree = "<group>"; };
-               0FD557321F7EDB7B00B1F0A3 /* HeapKind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HeapKind.cpp; path = bmalloc/HeapKind.cpp; sourceTree = "<group>"; };
                140FA00219CE429C00FFD3C8 /* BumpRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BumpRange.h; path = bmalloc/BumpRange.h; sourceTree = "<group>"; };
                140FA00419CE4B6800FFD3C8 /* LineMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LineMetadata.h; path = bmalloc/LineMetadata.h; sourceTree = "<group>"; };
                14105E8318E14374003A106E /* ObjectType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectType.cpp; path = bmalloc/ObjectType.cpp; sourceTree = "<group>"; };
                                0F5BF1721F23C5710029D91D /* BExport.h */,
                                1413E460189DCE1E00546D68 /* BInline.h */,
                                14C919C818FCC59F0028DB43 /* BPlatform.h */,
-                               0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */,
-                               0F74B93C1F89713E00B935D3 /* CryptoRandom.h */,
                                14D9DB4517F2447100EAAB79 /* FixedVector.h */,
-                               0FD557321F7EDB7B00B1F0A3 /* HeapKind.cpp */,
                                0F5BF1461F22A8B10029D91D /* HeapKind.h */,
                                141D9AFF1C8E51C0000ABBA0 /* List.h */,
                                4426E27E1C838EE0008EB042 /* Logging.cpp */,
                                14C919C918FCC59F0028DB43 /* BPlatform.h in Headers */,
                                4426E2831C839547008EB042 /* BSoftLinking.h in Headers */,
                                14DD789C18F48D4A00950702 /* BumpAllocator.h in Headers */,
-                               0F74B93E1F89713E00B935D3 /* CryptoRandom.h in Headers */,
                                140FA00319CE429C00FFD3C8 /* BumpRange.h in Headers */,
                                14DD789918F48D4A00950702 /* Cache.h in Headers */,
                                147DC6E31CA5B70B00724E8D /* Chunk.h in Headers */,
                        buildActionMask = 2147483647;
                        files = (
                                0F5BF1521F22E1570029D91D /* Scavenger.cpp in Sources */,
-                               0FD557331F7EDB7B00B1F0A3 /* HeapKind.cpp in Sources */,
                                14F271C318EA3978008C152F /* Allocator.cpp in Sources */,
                                6599C5CC1EC3F15900A2F7BB /* AvailableMemory.cpp in Sources */,
                                14F271C418EA397B008C152F /* Cache.cpp in Sources */,
                                142B44361E2839E7001DA6E9 /* DebugHeap.cpp in Sources */,
                                14895D911A3A319C0006235D /* Environment.cpp in Sources */,
                                14F271C718EA3990008C152F /* Heap.cpp in Sources */,
-                               0F74B93F1F89713E00B935D3 /* CryptoRandom.cpp in Sources */,
                                0F5BF14F1F22DEAF0029D91D /* Gigacage.cpp in Sources */,
                                144C07F41C7B70260051BB6A /* LargeMap.cpp in Sources */,
                                4426E2801C838EE0008EB042 /* Logging.cpp in Sources */,
index 6194e18..e162ac4 100644 (file)
 
 #define BCRASH() do { \
     *(int*)0xbbadbeef = 0; \
-} while (0)
+} while (0);
 
 #endif // defined(NDEBUG) && BOS(DARWIN)
 
 #define BASSERT_IMPL(x) do { \
     if (!(x)) \
         BCRASH(); \
-} while (0)
+} while (0);
 
 #define RELEASE_BASSERT(x) BASSERT_IMPL(x)
 
@@ -82,7 +82,7 @@
         BLOG_ERROR("ASSERTION FAILED: " #x " :: " format, ##__VA_ARGS__); \
         BCRASH(); \
     } \
-} while (0)
+} while (0);
 #endif
 
 #define UNUSED(x) ((void)x)
index c97b909..26f4202 100644 (file)
@@ -35,8 +35,6 @@ void Cache::scavenge(HeapKind heapKind)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return;
-    if (!isActiveHeapKind(heapKind))
-        return;
 
     caches->at(heapKind).allocator().scavenge();
     caches->at(heapKind).deallocator().scavenge();
@@ -50,27 +48,27 @@ Cache::Cache(HeapKind heapKind)
 
 BNO_INLINE void* Cache::tryAllocateSlowCaseNullCache(HeapKind heapKind, size_t size)
 {
-    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().tryAllocate(size);
+    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(heapKind).allocator().tryAllocate(size);
 }
 
 BNO_INLINE void* Cache::allocateSlowCaseNullCache(HeapKind heapKind, size_t size)
 {
-    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().allocate(size);
+    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(heapKind).allocator().allocate(size);
 }
 
 BNO_INLINE void* Cache::allocateSlowCaseNullCache(HeapKind heapKind, size_t alignment, size_t size)
 {
-    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().allocate(alignment, size);
+    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(heapKind).allocator().allocate(alignment, size);
 }
 
 BNO_INLINE void Cache::deallocateSlowCaseNullCache(HeapKind heapKind, void* object)
 {
-    PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).deallocator().deallocate(object);
+    PerThread<PerHeapKind<Cache>>::getSlowCase()->at(heapKind).deallocator().deallocate(object);
 }
 
 BNO_INLINE void* Cache::reallocateSlowCaseNullCache(HeapKind heapKind, void* object, size_t newSize)
 {
-    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(mapToActiveHeapKind(heapKind)).allocator().reallocate(object, newSize);
+    return PerThread<PerHeapKind<Cache>>::getSlowCase()->at(heapKind).allocator().reallocate(object, newSize);
 }
 
 } // namespace bmalloc
index c414ec8..f27c04d 100644 (file)
@@ -68,7 +68,7 @@ inline void* Cache::tryAllocate(HeapKind heapKind, size_t size)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return tryAllocateSlowCaseNullCache(heapKind, size);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).allocator().tryAllocate(size);
+    return caches->at(heapKind).allocator().tryAllocate(size);
 }
 
 inline void* Cache::allocate(HeapKind heapKind, size_t size)
@@ -76,7 +76,7 @@ inline void* Cache::allocate(HeapKind heapKind, size_t size)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return allocateSlowCaseNullCache(heapKind, size);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).allocator().allocate(size);
+    return caches->at(heapKind).allocator().allocate(size);
 }
 
 inline void* Cache::tryAllocate(HeapKind heapKind, size_t alignment, size_t size)
@@ -84,7 +84,7 @@ inline void* Cache::tryAllocate(HeapKind heapKind, size_t alignment, size_t size
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return allocateSlowCaseNullCache(heapKind, alignment, size);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).allocator().tryAllocate(alignment, size);
+    return caches->at(heapKind).allocator().tryAllocate(alignment, size);
 }
 
 inline void* Cache::allocate(HeapKind heapKind, size_t alignment, size_t size)
@@ -92,7 +92,7 @@ inline void* Cache::allocate(HeapKind heapKind, size_t alignment, size_t size)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return allocateSlowCaseNullCache(heapKind, alignment, size);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).allocator().allocate(alignment, size);
+    return caches->at(heapKind).allocator().allocate(alignment, size);
 }
 
 inline void Cache::deallocate(HeapKind heapKind, void* object)
@@ -100,7 +100,7 @@ inline void Cache::deallocate(HeapKind heapKind, void* object)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return deallocateSlowCaseNullCache(heapKind, object);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).deallocator().deallocate(object);
+    return caches->at(heapKind).deallocator().deallocate(object);
 }
 
 inline void* Cache::reallocate(HeapKind heapKind, void* object, size_t newSize)
@@ -108,7 +108,7 @@ inline void* Cache::reallocate(HeapKind heapKind, void* object, size_t newSize)
     PerHeapKind<Cache>* caches = PerThread<PerHeapKind<Cache>>::getFastCase();
     if (!caches)
         return reallocateSlowCaseNullCache(heapKind, object, newSize);
-    return caches->at(mapToActiveHeapKindAfterEnsuringGigacage(heapKind)).allocator().reallocate(object, newSize);
+    return caches->at(heapKind).allocator().reallocate(object, newSize);
 }
 
 } // namespace bmalloc
diff --git a/Source/bmalloc/bmalloc/CryptoRandom.cpp b/Source/bmalloc/bmalloc/CryptoRandom.cpp
deleted file mode 100644 (file)
index 3403dd2..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2017 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 "CryptoRandom.h"
-
-#include "BAssert.h"
-#include "BPlatform.h"
-#include <mutex>
-
-#if !BOS(DARWIN)
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#endif
-
-#if BOS(DARWIN)
-typedef struct __CCRandom* CCRandomRef;
-
-extern "C" {
-extern const CCRandomRef kCCRandomDefault;
-int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-}
-#endif
-
-namespace bmalloc {
-
-void cryptoRandom(unsigned char* buffer, size_t length)
-{
-#if BOS(DARWIN)
-    RELEASE_BASSERT(!CCRandomCopyBytes(kCCRandomDefault, buffer, length));
-#else
-    static std::once_flag onceFlag;
-    static int fd;
-    std::call_once(
-        onceFlag,
-        [] {
-            int ret = 0;
-            do {
-                ret = open("/dev/urandom", O_RDONLY, 0);
-            } while (ret == -1 && errno == EINTR);
-            RELEASE_BASSERT(ret >= 0);
-            fd = ret;
-        });
-    ssize_t amountRead = 0;
-    while (static_cast<size_t>(amountRead) < length) {
-        ssize_t currentRead = read(fd, buffer + amountRead, length - amountRead);
-        // We need to check for both EAGAIN and EINTR since on some systems /dev/urandom
-        // is blocking and on others it is non-blocking.
-        if (currentRead == -1)
-            RELEASE_BASSERT(errno == EAGAIN || errno == EINTR);
-        else
-            amountRead += currentRead;
-    }
-#endif
-}
-
-} // namespace bmalloc
-
diff --git a/Source/bmalloc/bmalloc/CryptoRandom.h b/Source/bmalloc/bmalloc/CryptoRandom.h
deleted file mode 100644 (file)
index 16cac5f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2017 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. 
- */
-
-#pragma once
-
-#include <cstddef>
-#include <inttypes.h>
-
-namespace bmalloc {
-
-void cryptoRandom(unsigned char* buffer, size_t length);
-
-}
-
index 6a77282..463ef16 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "Gigacage.h"
 
-#include "CryptoRandom.h"
 #include "Environment.h"
 #include "PerProcess.h"
 #include "VMAllocate.h"
 #include <cstdio>
 #include <mutex>
 
-#if BCPU(ARM64)
-// FIXME: There is no good reason for ARM64 to be special.
-// https://bugs.webkit.org/show_bug.cgi?id=177605
-#define GIGACAGE_RUNWAY 0
-#else
-// FIXME: Consider making this 32GB, in case unsigned 32-bit indices find their way into indexed accesses.
-// https://bugs.webkit.org/show_bug.cgi?id=175062
-#define GIGACAGE_RUNWAY (16llu * 1024 * 1024 * 1024)
-#endif
-
 char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE] __attribute__((aligned(GIGACAGE_BASE_PTRS_SIZE)));
 
 using namespace bmalloc;
 
 namespace Gigacage {
 
-bool g_wasEnabled;
-
 namespace {
 
 bool s_isDisablingPrimitiveGigacageDisabled;
@@ -82,6 +69,8 @@ public:
     }
 };
 
+} // anonymous namespce
+
 struct Callback {
     Callback() { }
     
@@ -101,8 +90,6 @@ struct PrimitiveDisableCallbacks {
     Vector<Callback> callbacks;
 };
 
-} // anonymous namespace
-
 void ensureGigacage()
 {
 #if GIGACAGE_ENABLED
@@ -113,61 +100,20 @@ void ensureGigacage()
             if (!shouldBeEnabled())
                 return;
             
-            Kind shuffledKinds[numKinds];
-            for (unsigned i = 0; i < numKinds; ++i)
-                shuffledKinds[i] = static_cast<Kind>(i);
-            
-            // We just go ahead and assume that 64 bits is enough randomness. That's trivially true right
-            // now, but would stop being true if we went crazy with gigacages. Based on my math, 21 is the
-            // largest value of n so that n! <= 2^64.
-            static_assert(numKinds <= 21, "too many kinds");
-            uint64_t random;
-            cryptoRandom(reinterpret_cast<unsigned char*>(&random), sizeof(random));
-            for (unsigned i = numKinds; i--;) {
-                unsigned limit = i + 1;
-                unsigned j = static_cast<unsigned>(random % limit);
-                random /= limit;
-                std::swap(shuffledKinds[i], shuffledKinds[j]);
-            }
-
-            auto alignTo = [] (Kind kind, size_t totalSize) -> size_t {
-                return roundUpToMultipleOf(alignment(kind), totalSize);
-            };
-            auto bump = [] (Kind kind, size_t totalSize) -> size_t {
-                return totalSize + size(kind);
-            };
-            
-            size_t totalSize = 0;
-            size_t maxAlignment = 0;
-            
-            for (Kind kind : shuffledKinds) {
-                totalSize = bump(kind, alignTo(kind, totalSize));
-                maxAlignment = std::max(maxAlignment, alignment(kind));
-            }
-            totalSize += GIGACAGE_RUNWAY;
-            
-            // FIXME: Randomize where this goes.
-            // https://bugs.webkit.org/show_bug.cgi?id=175245
-            void* base = tryVMAllocate(maxAlignment, totalSize);
-            if (!base) {
-                if (GIGACAGE_ALLOCATION_CAN_FAIL) {
-                    vmDeallocate(base, totalSize);
-                    return;
-                }
-                fprintf(stderr, "FATAL: Could not allocate gigacage memory with maxAlignment = %lu, totalSize = %lu.\n", maxAlignment, totalSize);
-                BCRASH();
-            }
-            vmDeallocatePhysicalPages(base, totalSize);
-            
-            size_t nextCage = 0;
-            for (Kind kind : shuffledKinds) {
-                nextCage = alignTo(kind, nextCage);
-                basePtr(kind) = reinterpret_cast<char*>(base) + nextCage;
-                nextCage = bump(kind, nextCage);
-            }
+            forEachKind(
+                [&] (Kind kind) {
+                    // FIXME: Randomize where this goes.
+                    // https://bugs.webkit.org/show_bug.cgi?id=175245
+                    basePtr(kind) = tryVMAllocate(alignment(kind), totalSize(kind));
+                    if (!basePtr(kind)) {
+                        fprintf(stderr, "FATAL: Could not allocate %s gigacage.\n", name(kind));
+                        BCRASH();
+                    }
+                    
+                    vmDeallocatePhysicalPages(basePtr(kind), totalSize(kind));
+                });
             
             protectGigacageBasePtrs();
-            g_wasEnabled = true;
         });
 #endif // GIGACAGE_ENABLED
 }
@@ -241,27 +187,7 @@ bool isDisablingPrimitiveGigacageDisabled()
 
 bool shouldBeEnabled()
 {
-    static std::once_flag onceFlag;
-    static bool cached;
-    std::call_once(
-        onceFlag,
-        [] {
-            bool result = GIGACAGE_ENABLED && !PerProcess<Environment>::get()->isDebugHeapEnabled();
-            if (!result)
-                return;
-            
-            if (char* gigacageEnabled = getenv("GIGACAGE_ENABLED")) {
-                if (!strcasecmp(gigacageEnabled, "no") || !strcasecmp(gigacageEnabled, "false") || !strcasecmp(gigacageEnabled, "0")) {
-                    fprintf(stderr, "Warning: disabling gigacage because GIGACAGE_ENABLED=%s!\n", gigacageEnabled);
-                    return;
-                } else if (strcasecmp(gigacageEnabled, "yes") && strcasecmp(gigacageEnabled, "true") && strcasecmp(gigacageEnabled, "1"))
-                    fprintf(stderr, "Warning: invalid argument to GIGACAGE_ENABLED: %s\n", gigacageEnabled);
-            }
-            
-            cached = true;
-        });
-    
-    return cached;
+    return GIGACAGE_ENABLED && !PerProcess<Environment>::get()->isDebugHeapEnabled();
 }
 
 } // namespace Gigacage
index 181a7e6..3b7579b 100644 (file)
 #include <cstddef>
 #include <inttypes.h>
 
-#if BCPU(ARM64)
-// FIXME: This can probably be a lot bigger on iOS. I just haven't tried to make it bigger yet.
-// https://bugs.webkit.org/show_bug.cgi?id=177605
-#define PRIMITIVE_GIGACAGE_SIZE 0x40000000llu
-#define JSVALUE_GIGACAGE_SIZE 0x40000000llu
-#define STRING_GIGACAGE_SIZE 0x40000000llu
-#define GIGACAGE_ALLOCATION_CAN_FAIL 1
-#else
 #define PRIMITIVE_GIGACAGE_SIZE 0x800000000llu
 #define JSVALUE_GIGACAGE_SIZE 0x400000000llu
 #define STRING_GIGACAGE_SIZE 0x400000000llu
-#define GIGACAGE_ALLOCATION_CAN_FAIL 0
-#endif
 
 #define GIGACAGE_SIZE_TO_MASK(size) ((size) - 1)
 
 #define JSVALUE_GIGACAGE_MASK GIGACAGE_SIZE_TO_MASK(JSVALUE_GIGACAGE_SIZE)
 #define STRING_GIGACAGE_MASK GIGACAGE_SIZE_TO_MASK(STRING_GIGACAGE_SIZE)
 
-#if (BOS(DARWIN) && (BCPU(ARM64) || BCPU(X86_64))) || (BOS(LINUX) && BCPU(X86_64))
+// FIXME: Consider making this 32GB, in case unsigned 32-bit indices find their way into indexed accesses.
+// https://bugs.webkit.org/show_bug.cgi?id=175062
+#define PRIMITIVE_GIGACAGE_RUNWAY (16llu * 1024 * 1024 * 1024)
+
+// FIXME: Reconsider this.
+// https://bugs.webkit.org/show_bug.cgi?id=175921
+#define JSVALUE_GIGACAGE_RUNWAY 0
+#define STRING_GIGACAGE_RUNWAY 0
+
+#if (BOS(DARWIN) || BOS(LINUX)) && BCPU(X86_64)
 #define GIGACAGE_ENABLED 1
 #else
 #define GIGACAGE_ENABLED 0
 #endif
 
-#if BCPU(ARM64)
-#define GIGACAGE_BASE_PTRS_SIZE 16384
-#else
-#define GIGACAGE_BASE_PTRS_SIZE 4096
-#endif
+#define GIGACAGE_BASE_PTRS_SIZE 8192
 
 extern "C" BEXPORT char g_gigacageBasePtrs[GIGACAGE_BASE_PTRS_SIZE] __attribute__((aligned(GIGACAGE_BASE_PTRS_SIZE)));
 
 namespace Gigacage {
 
-extern BEXPORT bool g_wasEnabled;
-BINLINE bool wasEnabled() { return g_wasEnabled; }
-
 struct BasePtrs {
     void* primitive;
     void* jsValue;
@@ -83,8 +75,6 @@ enum Kind {
     String
 };
 
-static constexpr unsigned numKinds = 3;
-
 BEXPORT void ensureGigacage();
 
 BEXPORT void disablePrimitiveGigacage();
@@ -137,11 +127,6 @@ BINLINE void*& basePtr(Kind kind)
     return basePtr(basePtrs(), kind);
 }
 
-BINLINE bool isEnabled(Kind kind)
-{
-    return !!basePtr(kind);
-}
-
 BINLINE size_t size(Kind kind)
 {
     switch (kind) {
@@ -166,6 +151,25 @@ BINLINE size_t mask(Kind kind)
     return GIGACAGE_SIZE_TO_MASK(size(kind));
 }
 
+BINLINE size_t runway(Kind kind)
+{
+    switch (kind) {
+    case Primitive:
+        return static_cast<size_t>(PRIMITIVE_GIGACAGE_RUNWAY);
+    case JSValue:
+        return static_cast<size_t>(JSVALUE_GIGACAGE_RUNWAY);
+    case String:
+        return static_cast<size_t>(STRING_GIGACAGE_RUNWAY);
+    }
+    BCRASH();
+    return 0;
+}
+
+BINLINE size_t totalSize(Kind kind)
+{
+    return size(kind) + runway(kind);
+}
+
 template<typename Func>
 void forEachKind(const Func& func)
 {
index 4aceb26..1c1710c 100644 (file)
@@ -177,8 +177,6 @@ void Heap::deallocateLineCache(std::lock_guard<StaticMutex>&, LineCache& lineCac
 
 void Heap::allocateSmallChunk(std::lock_guard<StaticMutex>& lock, size_t pageClass)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-    
     size_t pageSize = bmalloc::pageSize(pageClass);
 
     Chunk* chunk = [&]() {
@@ -223,8 +221,6 @@ void Heap::deallocateSmallChunk(Chunk* chunk, size_t pageClass)
 
 SmallPage* Heap::allocateSmallPage(std::lock_guard<StaticMutex>& lock, size_t sizeClass, LineCache& lineCache)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-
     if (!lineCache[sizeClass].isEmpty())
         return lineCache[sizeClass].popFront();
 
@@ -304,8 +300,6 @@ void Heap::allocateSmallBumpRangesByMetadata(
     BumpAllocator& allocator, BumpRangeCache& rangeCache,
     LineCache& lineCache)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-
     SmallPage* page = allocateSmallPage(lock, sizeClass, lineCache);
     SmallLine* lines = page->begin();
     BASSERT(page->hasFreeLines(lock));
@@ -368,8 +362,6 @@ void Heap::allocateSmallBumpRangesByObject(
     BumpAllocator& allocator, BumpRangeCache& rangeCache,
     LineCache& lineCache)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-
     size_t size = allocator.size();
     SmallPage* page = allocateSmallPage(lock, sizeClass, lineCache);
     BASSERT(page->hasFreeLines(lock));
@@ -422,8 +414,6 @@ void Heap::allocateSmallBumpRangesByObject(
 
 LargeRange Heap::splitAndAllocate(LargeRange& range, size_t alignment, size_t size, AllocationKind allocationKind)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-
     LargeRange prev;
     LargeRange next;
 
@@ -471,8 +461,6 @@ LargeRange Heap::splitAndAllocate(LargeRange& range, size_t alignment, size_t si
 
 void* Heap::tryAllocateLarge(std::lock_guard<StaticMutex>&, size_t alignment, size_t size, AllocationKind allocationKind)
 {
-    RELEASE_BASSERT(isActiveHeapKind(m_kind));
-
     BASSERT(isPowerOfTwo(alignment));
     
     if (m_debugHeap)
diff --git a/Source/bmalloc/bmalloc/HeapKind.cpp b/Source/bmalloc/bmalloc/HeapKind.cpp
deleted file mode 100644 (file)
index 2343b95..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2017 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 "HeapKind.h"
-
-namespace bmalloc {
-
-bool isActiveHeapKind(HeapKind kind)
-{
-    Gigacage::ensureGigacage();
-    return isActiveHeapKindAfterEnsuringGigacage(kind);
-}
-
-HeapKind mapToActiveHeapKind(HeapKind kind)
-{
-    Gigacage::ensureGigacage();
-    return mapToActiveHeapKindAfterEnsuringGigacage(kind);
-}
-
-} // namespace bmalloc
index 95afce3..fe8762d 100644 (file)
@@ -85,37 +85,5 @@ BINLINE HeapKind heapKind(Gigacage::Kind kind)
     return HeapKind::Primary;
 }
 
-BINLINE bool isActiveHeapKindAfterEnsuringGigacage(HeapKind kind)
-{
-    switch (kind) {
-    case HeapKind::PrimitiveGigacage:
-    case HeapKind::JSValueGigacage:
-    case HeapKind::StringGigacage:
-        if (Gigacage::wasEnabled())
-            return true;
-        return false;
-    default:
-        return true;
-    }
-}
-
-BEXPORT bool isActiveHeapKind(HeapKind);
-
-BINLINE HeapKind mapToActiveHeapKindAfterEnsuringGigacage(HeapKind kind)
-{
-    switch (kind) {
-    case HeapKind::PrimitiveGigacage:
-    case HeapKind::JSValueGigacage:
-    case HeapKind::StringGigacage:
-        if (Gigacage::wasEnabled())
-            return kind;
-        return HeapKind::Primary;
-    default:
-        return kind;
-    }
-}
-
-BEXPORT HeapKind mapToActiveHeapKind(HeapKind);
-
 } // namespace bmalloc
 
index b11a06c..ac2a668 100644 (file)
@@ -117,11 +117,8 @@ void Scavenger::schedule(size_t bytes)
 void Scavenger::scavenge()
 {
     std::lock_guard<StaticMutex> lock(Heap::mutex());
-    for (unsigned i = numHeaps; i--;) {
-        if (!isActiveHeapKind(static_cast<HeapKind>(i)))
-            continue;
+    for (unsigned i = numHeaps; i--;)
         PerProcess<PerHeapKind<Heap>>::get()->at(i).scavenge(lock);
-    }
 }
 
 void Scavenger::threadEntryPoint(Scavenger* scavenger)
index d131734..5d6dd21 100644 (file)
@@ -68,7 +68,6 @@ inline void* realloc(void* object, size_t newSize, HeapKind kind = HeapKind::Pri
 // Returns null for failure
 inline void* tryLargeMemalignVirtual(size_t alignment, size_t size, HeapKind kind = HeapKind::Primary)
 {
-    kind = mapToActiveHeapKind(kind);
     Heap& heap = PerProcess<PerHeapKind<Heap>>::get()->at(kind);
     std::lock_guard<StaticMutex> lock(Heap::mutex());
     return heap.allocateLarge(lock, alignment, size, AllocationKind::Virtual);
@@ -81,7 +80,6 @@ inline void free(void* object, HeapKind kind = HeapKind::Primary)
 
 inline void freeLargeVirtual(void* object, HeapKind kind = HeapKind::Primary)
 {
-    kind = mapToActiveHeapKind(kind);
     Heap& heap = PerProcess<PerHeapKind<Heap>>::get()->at(kind);
     std::lock_guard<StaticMutex> lock(Heap::mutex());
     heap.deallocateLarge(lock, object, AllocationKind::Virtual);
@@ -102,7 +100,6 @@ inline void scavenge()
 
 inline bool isEnabled(HeapKind kind = HeapKind::Primary)
 {
-    kind = mapToActiveHeapKind(kind);
     std::unique_lock<StaticMutex> lock(Heap::mutex());
     return !PerProcess<PerHeapKind<Heap>>::getFastCase()->at(kind).debugHeap();
 }
index 27f192e..3cbdbc7 100644 (file)
@@ -1,3 +1,22 @@
+2017-10-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r223113 and r223121.
+        https://bugs.webkit.org/show_bug.cgi?id=178182
+
+        Reintroduced 20% regression on Kraken (Requested by rniwa on
+        #webkit).
+
+        Reverted changesets:
+
+        "Enable gigacage on iOS"
+        https://bugs.webkit.org/show_bug.cgi?id=177586
+        https://trac.webkit.org/changeset/223113
+
+        "Use one virtual allocation for all gigacages and their
+        runways"
+        https://bugs.webkit.org/show_bug.cgi?id=178050
+        https://trac.webkit.org/changeset/223121
+
 2017-10-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Sanitize URL in pasteboard for other applications and cross origin content
index 4a707c7..4210964 100755 (executable)
@@ -513,7 +513,7 @@ def baseOutputName(kind)
     "#{$collectionName}/#{$benchmark}.#{kind}"
 end
 
-def addRunCommand(kind, command, outputHandler, errorHandler, *additionalEnv)
+def addRunCommand(kind, command, outputHandler, errorHandler)
     $didAddRunCommand = true
     name = baseOutputName(kind)
     if $filter and name !~ $filter
@@ -522,7 +522,6 @@ def addRunCommand(kind, command, outputHandler, errorHandler, *additionalEnv)
     plan = Plan.new(
         $benchmarkDirectory, command, "#{$collectionName}/#{$benchmark}", name, outputHandler,
         errorHandler)
-    plan.additionalEnv.push(*additionalEnv)
     if $numChildProcesses > 1 and $runCommandOptions[:isSlow]
         $runlist.unshift plan
     else
@@ -1308,16 +1307,8 @@ def defaultRunMozillaTest(mode, *extraFiles)
     end
 end
 
-def runNoisyTestImpl(kind, options, additionalEnv)
-    addRunCommand(kind, [pathToVM.to_s] + BASE_OPTIONS + options + [$benchmark.to_s], noisyOutputHandler, noisyErrorHandler, *additionalEnv)
-end
-
 def runNoisyTest(kind, *options)
-    runNoisyTestImpl(kind, options, [])
-end
-
-def runNoisyTestWithEnv(kind, *additionalEnv)
-    runNoisyTestImpl(kind, [], additionalEnv)
+    addRunCommand(kind, [pathToVM.to_s] + BASE_OPTIONS + options + [$benchmark.to_s], noisyOutputHandler, noisyErrorHandler)
 end
 
 def runNoisyTestDefault
index 0553f2e..aed5736 100644 (file)
@@ -215,7 +215,7 @@ def chakraPassFailErrorHandler
 end
 
 class Plan
-    attr_reader :directory, :arguments, :family, :name, :outputHandler, :errorHandler, :additionalEnv
+    attr_reader :directory, :arguments, :family, :name, :outputHandler, :errorHandler
     attr_accessor :index
     
     def initialize(directory, arguments, family, name, outputHandler, errorHandler)
@@ -226,7 +226,6 @@ class Plan
         @outputHandler = outputHandler
         @errorHandler = errorHandler
         @isSlow = !!$runCommandOptions[:isSlow]
-        @additionalEnv = []
     end
     
     def shellCommand
@@ -234,7 +233,7 @@ class Plan
         # in the subshell when we return we will be in our original directory. This is nice because we don't
         # have to bend over backwards to do things relative to the root.
         script = "(cd ../#{Shellwords.shellescape(@directory.to_s)} && ("
-        ($envVars + additionalEnv).each { |var| script += "export " << var << "; " }
+        $envVars.each { |var| script += "export " << var << "; " }
         script += "\"$@\" " + escapeAll(@arguments) + "))"
         return script
     end