[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

ggaren at apple.com ggaren at apple.com
Wed Dec 22 17:53:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 13bef259103ca47bbe0270e26e220f7cf0f0d756
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 2 02:13:59 2010 +0000

    Baby step toward a cross-platform virtual memory abstraction: created
    an all-static OSAllocator class and changed MarkStack to use it.
    
    Reviewed by Sam Weinig.
    
    * JavaScriptCore.exp: These functions are inlined now.
    
    * JavaScriptCore.vcproj/WTF/WTF.vcproj: Added OSAllocatorWin.cpp.
    
    * JavaScriptCore.xcodeproj/project.pbxproj: Added OSAllocatorPosix.cpp.
    
    * runtime/MarkStack.h:
    (JSC::MarkStack::allocateStack):
    (JSC::MarkStack::releaseStack): Use OSAllocator instead of rolling our
    own platform-specific code.
    
    * runtime/MarkStackNone.cpp: Removed. Nothing used this.
    
    * runtime/MarkStackPosix.cpp:
    * runtime/MarkStackSymbian.cpp:
    * runtime/MarkStackWin.cpp: Removed custom platform-specific code, since
    we use the OSAllocator abstraction now.
    
    * wtf/OSAllocator.h: Added.
    * wtf/OSAllocatorPosix.cpp: Added.
    (WTF::OSAllocator::reserve):
    (WTF::OSAllocator::reserveAndCommit):
    (WTF::OSAllocator::commit):
    (WTF::OSAllocator::decommit):
    (WTF::OSAllocator::release):
    * wtf/OSAllocatorSymbian.cpp: Added.
    (WTF::OSAllocator::reserve):
    (WTF::OSAllocator::reserveAndCommit):
    (WTF::OSAllocator::commit):
    (WTF::OSAllocator::decommit):
    (WTF::OSAllocator::release):
    * wtf/OSAllocatorWin.cpp: Added.
    (WTF::OSAllocator::reserve):
    (WTF::OSAllocator::reserveAndCommit):
    (WTF::OSAllocator::commit):
    (WTF::OSAllocator::decommit):
    (WTF::OSAllocator::release): The new OSAllocator abstraction.
    
    * wtf/wtf.pri: Added OSAllocatorSymbian.cpp.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 394eda3..4a698ce 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,50 @@
+2010-12-01  Geoffrey Garen  <ggaren at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Baby step toward a cross-platform virtual memory abstraction: created
+        an all-static OSAllocator class and changed MarkStack to use it.
+
+        * JavaScriptCore.exp: These functions are inlined now.
+
+        * JavaScriptCore.vcproj/WTF/WTF.vcproj: Added OSAllocatorWin.cpp.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj: Added OSAllocatorPosix.cpp.
+
+        * runtime/MarkStack.h:
+        (JSC::MarkStack::allocateStack):
+        (JSC::MarkStack::releaseStack): Use OSAllocator instead of rolling our
+        own platform-specific code.
+
+        * runtime/MarkStackNone.cpp: Removed. Nothing used this.
+
+        * runtime/MarkStackPosix.cpp: 
+        * runtime/MarkStackSymbian.cpp:
+        * runtime/MarkStackWin.cpp: Removed custom platform-specific code, since
+        we use the OSAllocator abstraction now.
+
+        * wtf/OSAllocator.h: Added.
+        * wtf/OSAllocatorPosix.cpp: Added.
+        (WTF::OSAllocator::reserve):
+        (WTF::OSAllocator::reserveAndCommit):
+        (WTF::OSAllocator::commit):
+        (WTF::OSAllocator::decommit):
+        (WTF::OSAllocator::release):
+        * wtf/OSAllocatorSymbian.cpp: Added.
+        (WTF::OSAllocator::reserve):
+        (WTF::OSAllocator::reserveAndCommit):
+        (WTF::OSAllocator::commit):
+        (WTF::OSAllocator::decommit):
+        (WTF::OSAllocator::release):
+        * wtf/OSAllocatorWin.cpp: Added.
+        (WTF::OSAllocator::reserve):
+        (WTF::OSAllocator::reserveAndCommit):
+        (WTF::OSAllocator::commit):
+        (WTF::OSAllocator::decommit):
+        (WTF::OSAllocator::release): The new OSAllocator abstraction.
+
+        * wtf/wtf.pri: Added OSAllocatorSymbian.cpp.
+
 2010-12-01  Steve Falkenburg  <sfalken at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index cdb3ce7..7e08b35 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -306,8 +306,6 @@ __ZN3JSC8evaluateEPNS_9ExecStateERNS_10ScopeChainERKNS_10SourceCodeENS_7JSValueE
 __ZN3JSC9CodeBlockD1Ev
 __ZN3JSC9CodeBlockD2Ev
 __ZN3JSC9MarkStack10s_pageSizeE
-__ZN3JSC9MarkStack12releaseStackEPvm
-__ZN3JSC9MarkStack13allocateStackEm
 __ZN3JSC9MarkStack18initializePagesizeEv
 __ZN3JSC9Structure13hasTransitionEPN3WTF10StringImplEj
 __ZN3JSC9Structure17stopIgnoringLeaksEv
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj b/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
index d1c9acf..4a3e859 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
+++ b/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
@@ -673,6 +673,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\wtf\OSAllocatorWin.cpp"
+			>
+		</File>
+		<File
 			RelativePath="..\..\wtf\OwnArrayPtr.h"
 			>
 		</File>
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index b40d74e..c14e01b 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -48,6 +48,8 @@
 		0BDFFAE10FC6193100D69EF4 /* OwnFastMallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0BF28A2911A33DC300638F84 /* SizeLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */; };
 		0F29479C126E698C00B3ABF5 /* DecimalNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F29479B126E698C00B3ABF5 /* DecimalNumber.cpp */; };
+		1400067712A6F7830064D123 /* OSAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400067612A6F7830064D123 /* OSAllocator.h */; };
+		1400069312A6F9E10064D123 /* OSAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */; };
 		14035DB110DBFB2A00FFFFE7 /* WeakGCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		140566C4107EC255005DBC8D /* JSAPIValueWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC0894D50FAFBA2D00001865 /* JSAPIValueWrapper.cpp */; };
 		140566D1107EC267005DBC8D /* JSStaticScopeObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7E42C190E3938830065A544 /* JSStaticScopeObject.cpp */; };
@@ -649,6 +651,8 @@
 		0BDFFAD40FC6171000D69EF4 /* CrossThreadRefCounted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossThreadRefCounted.h; sourceTree = "<group>"; };
 		0BF28A2811A33DC300638F84 /* SizeLimits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SizeLimits.cpp; sourceTree = "<group>"; };
 		0F29479B126E698C00B3ABF5 /* DecimalNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecimalNumber.cpp; sourceTree = "<group>"; };
+		1400067612A6F7830064D123 /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; };
+		1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSAllocatorPosix.cpp; sourceTree = "<group>"; };
 		14035DB010DBFB2A00FFFFE7 /* WeakGCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCPtr.h; sourceTree = "<group>"; };
 		140D17D60E8AD4A9000CD17D /* JSBasePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBasePrivate.h; sourceTree = "<group>"; };
 		141211020A48780900480255 /* minidom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = minidom.c; path = tests/minidom.c; sourceTree = "<group>"; };
@@ -1472,10 +1476,6 @@
 		65162EF108E6A21C007556CD /* wtf */ = {
 			isa = PBXGroup;
 			children = (
-				9714AF2F122F27C60092D9F5 /* url */,
-				06D358A00DAAD9C4003B174E /* mac */,
-				8656573E115BE35200291F40 /* text */,
-				E195678D09E7CF1200B89D13 /* unicode */,
 				93AA4F770957251F0084B3A7 /* AlwaysInline.h */,
 				938C4F690CA06BC700D9310A /* ASCIICType.h */,
 				65E217B808E7EECC0023E5F6 /* Assertions.cpp */,
@@ -1491,8 +1491,8 @@
 				180B9AF00F16C569009BDBC5 /* CurrentTime.h */,
 				41359CF40FDD89CB00206180 /* DateMath.cpp */,
 				41359CF50FDD89CB00206180 /* DateMath.h */,
-				862AF4B512239C7B0024E5B8 /* DecimalNumber.h */,
 				0F29479B126E698C00B3ABF5 /* DecimalNumber.cpp */,
+				862AF4B512239C7B0024E5B8 /* DecimalNumber.h */,
 				5186111D0CC824830081412B /* Deque.h */,
 				938C4F6B0CA06BCE00D9310A /* DisallowCType.h */,
 				651F6412039D5B5F0078395C /* dtoa.cpp */,
@@ -1514,6 +1514,7 @@
 				657EB7450B708F540063461B /* ListHashSet.h */,
 				148A1626095D16BB00666D0D /* ListRefPtr.h */,
 				E1EE79270D6C964500FEA3BA /* Locker.h */,
+				06D358A00DAAD9C4003B174E /* mac */,
 				06D358A20DAAD9C4003B174E /* MainThread.cpp */,
 				06D358A30DAAD9C4003B174E /* MainThread.h */,
 				5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */,
@@ -1521,10 +1522,12 @@
 				511FC4C7117EE23D00425272 /* MD5.cpp */,
 				511FC4CA117EE2A800425272 /* MD5.h */,
 				E1EE798B0D6CA53D00FEA3BA /* MessageQueue.h */,
-				65E1A2F4122B880D00B26097 /* NonCopyingSort.h */,
 				9303F5690991190000AD71B8 /* Noncopyable.h */,
+				65E1A2F4122B880D00B26097 /* NonCopyingSort.h */,
 				C0A2723F0E509F1E00E96E15 /* NotFound.h */,
 				933F5CDB126922690049191E /* NullPtr.h */,
+				1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */,
+				1400067612A6F7830064D123 /* OSAllocator.h */,
 				9303F5A409911A5800AD71B8 /* OwnArrayPtr.h */,
 				BCFBE697122561D200309E9D /* OwnArrayPtrCommon.h */,
 				0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */,
@@ -1558,6 +1561,7 @@
 				6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */,
 				6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */,
 				6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */,
+				8656573E115BE35200291F40 /* text */,
 				18BAB52710DADFCD000D945B /* ThreadIdentifierDataPthreads.cpp */,
 				18BAB52810DADFCD000D945B /* ThreadIdentifierDataPthreads.h */,
 				5D6A566A0F05995500266145 /* Threading.cpp */,
@@ -1568,7 +1572,9 @@
 				E1B7C8BD0DA3A3360074B0DC /* ThreadSpecific.h */,
 				0B330C260F38C62300692DE3 /* TypeTraits.cpp */,
 				0B4D7E620F319AC800AD7E58 /* TypeTraits.h */,
+				E195678D09E7CF1200B89D13 /* unicode */,
 				935AF46B09E9D9DB00ACD1D8 /* UnusedParam.h */,
+				9714AF2F122F27C60092D9F5 /* url */,
 				E17FF770112131D200076A19 /* ValueCheck.h */,
 				6592C316098B7DE10003D4F6 /* Vector.h */,
 				6592C317098B7DE10003D4F6 /* VectorTraits.h */,
@@ -2353,6 +2359,7 @@
 				A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
 				933F5CDC1269229B0049191E /* NullPtr.h in Headers */,
 				F3BD31ED126735770065467F /* TextPosition.h in Headers */,
+				1400067712A6F7830064D123 /* OSAllocator.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2811,6 +2818,7 @@
 				A730B6131250068F009D25B1 /* StrictEvalActivation.cpp in Sources */,
 				86438FC41265503E00E0DFCA /* StringBuilder.cpp in Sources */,
 				0F29479C126E698C00B3ABF5 /* DecimalNumber.cpp in Sources */,
+				1400069312A6F9E10064D123 /* OSAllocatorPosix.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/JavaScriptCore/runtime/MarkStack.h b/JavaScriptCore/runtime/MarkStack.h
index c551bac..c3efc8f 100644
--- a/JavaScriptCore/runtime/MarkStack.h
+++ b/JavaScriptCore/runtime/MarkStack.h
@@ -28,6 +28,7 @@
 
 #include "JSValue.h"
 #include <wtf/Noncopyable.h>
+#include <wtf/OSAllocator.h>
 
 namespace JSC {
 
@@ -85,8 +86,8 @@ namespace JSC {
             MarkSetProperties m_properties;
         };
 
-        static void* allocateStack(size_t size);
-        static void releaseStack(void* addr, size_t size);
+        static void* allocateStack(size_t size) { return OSAllocator::reserveAndCommit(size); }
+        static void releaseStack(void* addr, size_t size) { OSAllocator::release(addr, size); }
 
         static void initializePagesize();
         static size_t pageSize()
diff --git a/JavaScriptCore/runtime/MarkStackNone.cpp b/JavaScriptCore/runtime/MarkStackNone.cpp
deleted file mode 100644
index b1ff48b..0000000
--- a/JavaScriptCore/runtime/MarkStackNone.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2009 Company 100, 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 "config.h"
-
-#include "MarkStack.h"
-
-#include "FastMalloc.h"
-
-namespace JSC {
-
-void MarkStack::initializePagesize()
-{
-    MarkStack::s_pageSize = 4096;
-}
-
-void* MarkStack::allocateStack(size_t size)
-{
-    return fastMalloc(size);
-}
-
-void MarkStack::releaseStack(void* addr, size_t)
-{
-    return fastFree(addr);
-}
-
-}
diff --git a/JavaScriptCore/runtime/MarkStackPosix.cpp b/JavaScriptCore/runtime/MarkStackPosix.cpp
index c28bc0d..2a5b298 100644
--- a/JavaScriptCore/runtime/MarkStackPosix.cpp
+++ b/JavaScriptCore/runtime/MarkStackPosix.cpp
@@ -38,15 +38,6 @@ void MarkStack::initializePagesize()
     MarkStack::s_pageSize = getpagesize();
 }
 
-void* MarkStack::allocateStack(size_t size)
-{
-    return mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
-}
-void MarkStack::releaseStack(void* addr, size_t size)
-{
-    munmap(addr, size);
-}
-
 }
 
 #endif
diff --git a/JavaScriptCore/runtime/MarkStackSymbian.cpp b/JavaScriptCore/runtime/MarkStackSymbian.cpp
index bda14ac..a3893d7 100644
--- a/JavaScriptCore/runtime/MarkStackSymbian.cpp
+++ b/JavaScriptCore/runtime/MarkStackSymbian.cpp
@@ -33,16 +33,6 @@ void MarkStack::initializePagesize()
     MarkStack::s_pageSize = page_size;
 }
 
-void* MarkStack::allocateStack(size_t size)
-{
-    return fastMalloc(size);
-}
-
-void MarkStack::releaseStack(void* addr, size_t size)
-{
-    return fastFree(addr);
-}
-
 }
 
 #endif
diff --git a/JavaScriptCore/runtime/MarkStackWin.cpp b/JavaScriptCore/runtime/MarkStackWin.cpp
index a171c78..2d2a1b3 100644
--- a/JavaScriptCore/runtime/MarkStackWin.cpp
+++ b/JavaScriptCore/runtime/MarkStackWin.cpp
@@ -39,17 +39,6 @@ void MarkStack::initializePagesize()
     MarkStack::s_pageSize = system_info.dwPageSize;
 }
 
-void* MarkStack::allocateStack(size_t size)
-{
-    return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
-}
-void MarkStack::releaseStack(void* addr, size_t)
-{
-    // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx,
-    // dwSize must be 0 if dwFreeType is MEM_RELEASE.
-    VirtualFree(addr, 0, MEM_RELEASE);
-}
-
 }
 
 #endif
diff --git a/JavaScriptCore/wtf/OSAllocator.h b/JavaScriptCore/wtf/OSAllocator.h
new file mode 100644
index 0000000..9d80714
--- /dev/null
+++ b/JavaScriptCore/wtf/OSAllocator.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 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. AND ITS CONTRIBUTORS ``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 ITS 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.
+ */
+
+#ifndef OSAllocator_h
+#define OSAllocator_h
+
+namespace WTF {
+
+class OSAllocator {
+public:
+    static void* reserve(size_t);
+    static void* reserveAndCommit(size_t);
+
+    static void commit(void*, size_t);
+    static void decommit(void*, size_t);
+
+    static void release(void*, size_t);
+};
+
+} // namespace WTF
+
+using WTF::OSAllocator;
+
+#endif // OSAllocator_h
diff --git a/JavaScriptCore/wtf/OSAllocatorPosix.cpp b/JavaScriptCore/wtf/OSAllocatorPosix.cpp
new file mode 100644
index 0000000..aaa0770
--- /dev/null
+++ b/JavaScriptCore/wtf/OSAllocatorPosix.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 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. AND ITS CONTRIBUTORS ``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 ITS 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 "config.h"
+#include "OSAllocator.h"
+
+#include <sys/errno.h>
+#include <sys/mman.h>
+#include <wtf/Assertions.h>
+
+namespace WTF {
+
+void* OSAllocator::reserve(size_t bytes)
+{
+    // From a bookkeeping perspective, POSIX reservations start out in the committed state.
+    void* result = mmap(0, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+    if (result == MAP_FAILED)
+        CRASH();
+#if HAVE(MADV_FREE_REUSE)
+    while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+#endif
+    return result;
+}
+
+void* OSAllocator::reserveAndCommit(size_t bytes)
+{
+    // From a bookkeeping perspective, POSIX reservations start out in the committed state.
+    return reserve(bytes);
+}
+
+void OSAllocator::commit(void* address, size_t bytes)
+{
+#if HAVE(MADV_FREE_REUSE)
+    while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
+#else
+    UNUSED_PARAM(address);
+    UNUSED_PARAM(bytes);
+#endif
+}
+
+void OSAllocator::decommit(void* address, size_t bytes)
+{
+#if HAVE(MADV_FREE_REUSE)
+    while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+#elif HAVE(MADV_FREE)
+    while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { }
+#elif HAVE(MADV_DONTNEED)
+    while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { }
+#else
+    UNUSED_PARAM(address);
+    UNUSED_PARAM(bytes);
+#endif
+}
+
+void OSAllocator::release(void* address, size_t bytes)
+{
+    munmap(address, bytes);
+}
+
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/OSAllocatorSymbian.cpp b/JavaScriptCore/wtf/OSAllocatorSymbian.cpp
new file mode 100644
index 0000000..445b77a
--- /dev/null
+++ b/JavaScriptCore/wtf/OSAllocatorSymbian.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 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. AND ITS CONTRIBUTORS ``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 ITS 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 "config.h"
+#include "OSAllocator.h"
+
+#include <wtf/FastMalloc.h>
+
+namespace WTF {
+
+void* OSAllocator::reserve(size_t bytes)
+{
+    return fastMalloc(bytes);
+}
+
+void* OSAllocator::reserveAndCommit(size_t bytes)
+{
+    return reserve(bytes);
+}
+
+void OSAllocator::commit(void*, size_t)
+{
+}
+
+void OSAllocator::decommit(void*, size_t)
+{
+}
+
+void OSAllocator::release(void* address, size_t)
+{
+    fastFree(address);
+}
+
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/OSAllocatorWin.cpp b/JavaScriptCore/wtf/OSAllocatorWin.cpp
new file mode 100644
index 0000000..d9b6f61
--- /dev/null
+++ b/JavaScriptCore/wtf/OSAllocatorWin.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 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. AND ITS CONTRIBUTORS ``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 ITS 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 "config.h"
+#include "OSAllocator.h"
+
+#include "windows.h"
+
+namespace WTF {
+
+void* OSAllocator::reserve(size_t bytes)
+{
+    return VirtualAlloc(0, bytes, MEM_RESERVE, PAGE_READWRITE);
+}
+
+void* OSAllocator::reserveAndCommit(size_t bytes)
+{
+    return VirtualAlloc(0, bytes, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+}
+
+void OSAllocator::commit(void* address, size_t bytes)
+{
+    return VirtualAlloc(address, bytes, MEM_COMMIT, PAGE_READWRITE);
+}
+
+void OSAllocator::decommit(void* address, size_t bytes)
+{
+    VirtualFree(address, bytes, MEM_DECOMMIT);
+}
+
+void OSAllocator::release(void* address, size_t bytes)
+{
+    // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx,
+    // dwSize must be 0 if dwFreeType is MEM_RELEASE.
+    VirtualFree(address, 0, MEM_RELEASE);
+}
+
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/wtf.pri b/JavaScriptCore/wtf/wtf.pri
index 1780334..77c3113 100644
--- a/JavaScriptCore/wtf/wtf.pri
+++ b/JavaScriptCore/wtf/wtf.pri
@@ -13,6 +13,7 @@ SOURCES += \
     wtf/HashTable.cpp \
     wtf/MD5.cpp \
     wtf/MainThread.cpp \
+    wtf/OSAllocatorSymbian.cpp \
     wtf/qt/MainThreadQt.cpp \
     wtf/qt/StringQt.cpp \
     wtf/qt/ThreadingQt.cpp \

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list