[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

xan at webkit.org xan at webkit.org
Sun Feb 20 22:54:32 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 74ba663ba213c32d921408780372504fc083bf4b
Author: xan at webkit.org <xan at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 13 11:58:25 2011 +0000

    2011-01-13  Xan Lopez  <xlopez at igalia.com>
    
            Reviewed by Gavin Barraclough.
    
            JIT requires VM overcommit (particularly on x86-64), Linux does not by default support this without swap?
            https://bugs.webkit.org/show_bug.cgi?id=42756
    
            The FixedVMPool Allocator does not work well on systems where
            allocating very large amounts of memory upfront is not reasonable,
            like Linux without overcommit enabled. As a workaround, on Linux,
            default to the values used in embedded environments (in the MB
            range), and only jump to the GB range if we detect at runtime that
            overcommit is enabled. Should fix crashes on Linux/x86_64 with
            less than 3 or 4GB of RAM.
    
            * jit/ExecutableAllocatorFixedVMPool.cpp:
            (JSC::FixedVMPoolAllocator::free): use new variables for VM pool
            size and coalesce limit.
            (JSC::ExecutableAllocator::isValid): swap the variables from
            embedded to generic values at runtime, on linux, if overcommit is
            enabled.
            (JSC::ExecutableAllocator::underMemoryPressure): use new variables
            for VM pool size and coalesce limit.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 871bcb3..3825ff9 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,27 @@
+2011-01-13  Xan Lopez  <xlopez at igalia.com>
+
+        Reviewed by Gavin Barraclough.
+
+        JIT requires VM overcommit (particularly on x86-64), Linux does not by default support this without swap?
+        https://bugs.webkit.org/show_bug.cgi?id=42756
+
+        The FixedVMPool Allocator does not work well on systems where
+        allocating very large amounts of memory upfront is not reasonable,
+        like Linux without overcommit enabled. As a workaround, on Linux,
+        default to the values used in embedded environments (in the MB
+        range), and only jump to the GB range if we detect at runtime that
+        overcommit is enabled. Should fix crashes on Linux/x86_64 with
+        less than 3 or 4GB of RAM.
+
+        * jit/ExecutableAllocatorFixedVMPool.cpp:
+        (JSC::FixedVMPoolAllocator::free): use new variables for VM pool
+        size and coalesce limit.
+        (JSC::ExecutableAllocator::isValid): swap the variables from
+        embedded to generic values at runtime, on linux, if overcommit is
+        enabled.
+        (JSC::ExecutableAllocator::underMemoryPressure): use new variables
+        for VM pool size and coalesce limit.
+
 2011-01-12  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Martin Robinson.
diff --git a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
index e280b2d..45d8297 100644
--- a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
+++ b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
@@ -38,14 +38,29 @@
 #include <wtf/PageReservation.h>
 #include <wtf/VMTags.h>
 
-#if CPU(X86_64)
-    // These limits suitable on 64-bit platforms (particularly x86-64, where we require all jumps to have a 2Gb max range).
-    #define VM_POOL_SIZE (2u * 1024u * 1024u * 1024u) // 2Gb
-    #define COALESCE_LIMIT (16u * 1024u * 1024u) // 16Mb
+#if OS(LINUX)
+#include <stdio.h>
+#endif
+
+static const unsigned vmPoolSizeGeneric = 2u * 1024u * 1024u * 1024u; // 2Gb
+static const unsigned coalesceLimitGeneric = 16u * 1024u * 1024u; // 16Mb
+
+static const unsigned vmPoolSizeEmbedded = 32u * 1024u * 1024u; // 32Mb
+static const unsigned coalesceLimitEmbedded = 4u * 1024u * 1024u; // 4Mb
+
+#if CPU(X86_64) && !OS(LINUX)
+// These limits suitable on 64-bit platforms (particularly x86-64,
+// where we require all jumps to have a 2Gb max range). We don't
+// enable this by default on Linux, since it needs overcommit and
+// distros commonly disable that feature. We'll check the value
+// for the overcommit feature at runtime and re-assign the Generic
+// values if it's enabled.
+static unsigned vmPoolSize = vmPoolSizeGeneric; // 2Gb
+static unsigned coalesceLimit = coalesceLimitGeneric; // 16Mb
 #else
     // These limits are hopefully sensible on embedded platforms.
-    #define VM_POOL_SIZE (32u * 1024u * 1024u) // 32Mb
-    #define COALESCE_LIMIT (4u * 1024u * 1024u) // 4Mb
+static unsigned vmPoolSize = vmPoolSizeEmbedded; // 32Mb
+static unsigned coalesceLimit = coalesceLimitEmbedded; // 4Mb
 #endif
 
 using namespace WTF;
@@ -315,7 +330,7 @@ public:
         // 16MB of allocations have been freed, sweep m_freeList
         // coalescing any neighboring fragments.
         m_countFreedSinceLastCoalesce += size;
-        if (m_countFreedSinceLastCoalesce >= COALESCE_LIMIT) {
+        if (m_countFreedSinceLastCoalesce >= coalesceLimit) {
             m_countFreedSinceLastCoalesce = 0;
             coalesceFreeSpace();
         }
@@ -433,11 +448,33 @@ void ExecutableAllocator::intializePageSize()
 static FixedVMPoolAllocator* allocator = 0;
 static size_t allocatedCount = 0;
 
+#if OS(LINUX)
+static void maybeModifyVMPoolSize()
+{
+    FILE* fp = fopen("/proc/sys/vm/overcommit_memory", "r");
+    if (!fp)
+        return;
+
+    unsigned overcommit = 0;
+    fscanf(fp, "%u", &overcommit);
+    if (overcommit == 1) {
+        vmPoolSize = vmPoolSizeGeneric; // 2Gb
+        coalesceLimit = coalesceLimitGeneric; // 16Mb
+    }
+
+    fclose(fp);
+}
+#endif
+
 bool ExecutableAllocator::isValid() const
 {
     SpinLockHolder lock_holder(&spinlock);
-    if (!allocator)
-        allocator = new FixedVMPoolAllocator(JIT_ALLOCATOR_LARGE_ALLOC_SIZE, VM_POOL_SIZE);
+    if (!allocator) {
+#if OS(LINUX)
+        maybeModifyVMPoolSize();
+#endif
+        allocator = new FixedVMPoolAllocator(JIT_ALLOCATOR_LARGE_ALLOC_SIZE, vmPoolSize);
+    }
     return allocator->isValid();
 }
 
@@ -445,7 +482,7 @@ bool ExecutableAllocator::underMemoryPressure()
 {
     // Technically we should take the spin lock here, but we don't care if we get stale data.
     // This is only really a heuristic anyway.
-    return allocatedCount > (VM_POOL_SIZE / 2);
+    return allocatedCount > (vmPoolSize / 2);
 }
 
 ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t size)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list