[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 18:49:43 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 18a081c2597f79e9f4b894531416e66c5be657ce
Author: ggaren at apple.com <ggaren at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Dec 20 20:09:25 2010 +0000
2010-12-17 Geoffrey Garen <ggaren at apple.com>
Reviewed by Sam Weinig.
Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/WTF/WTF.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* interpreter/RegisterFile.h:
(JSC::RegisterFile::RegisterFile):
* jit/ExecutableAllocator.cpp:
(JSC::ExecutableAllocator::intializePageSize):
* wtf/PageAllocation.cpp: Removed.
* wtf/PageAllocation.h:
(WTF::PageAllocation::deallocate):
(WTF::PageAllocation::PageAllocation):
* wtf/PageReservation.h:
(WTF::PageReservation::commit):
(WTF::PageReservation::decommit):
(WTF::PageReservation::deallocate):
(WTF::PageReservation::PageReservation):
* wtf/wtf.pri:
2010-12-20 Geoffrey Garen <ggaren at apple.com>
Reviewed by Sam Weinig.
Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285
* ForwardingHeaders/wtf/PageBlock.h: Added.
2010-12-20 Geoffrey Garen <ggaren at apple.com>
Reviewed by Sam Weinig.
Factored common page set management into a new PageBlock base class
https://bugs.webkit.org/show_bug.cgi?id=51285
* ForwardingHeaders/wtf/PageBlock.h: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/Android.mk b/JavaScriptCore/Android.mk
index e52922f..d2f4863 100644
--- a/JavaScriptCore/Android.mk
+++ b/JavaScriptCore/Android.mk
@@ -162,7 +162,7 @@ LOCAL_SRC_FILES := \
wtf/FastMalloc.cpp \
wtf/HashTable.cpp \
wtf/MainThread.cpp \
- jit/PageAllocation.cpp\
+ wtf/PageBlock.cpp\
wtf/RandomNumber.cpp \
wtf/RefCountedLeakCounter.cpp \
wtf/TCSystemAlloc.cpp \
diff --git a/JavaScriptCore/CMakeLists.txt b/JavaScriptCore/CMakeLists.txt
index 90067a4..79f3dce 100644
--- a/JavaScriptCore/CMakeLists.txt
+++ b/JavaScriptCore/CMakeLists.txt
@@ -171,7 +171,7 @@ SET(JavaScriptCore_SOURCES
yarr/RegexJIT.cpp
wtf/DateMath.cpp
- wtf/PageAllocation.cpp
+ wtf/PageBlock.cpp
)
SET(JavaScriptCore_HEADERS )
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 64316bb..29ce4c8 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,31 @@
+2010-12-17 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Factored common page set management into a new PageBlock base class
+ https://bugs.webkit.org/show_bug.cgi?id=51285
+
+ * Android.mk:
+ * CMakeLists.txt:
+ * GNUmakefile.am:
+ * JavaScriptCore.gypi:
+ * JavaScriptCore.vcproj/WTF/WTF.vcproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * interpreter/RegisterFile.h:
+ (JSC::RegisterFile::RegisterFile):
+ * jit/ExecutableAllocator.cpp:
+ (JSC::ExecutableAllocator::intializePageSize):
+ * wtf/PageAllocation.cpp: Removed.
+ * wtf/PageAllocation.h:
+ (WTF::PageAllocation::deallocate):
+ (WTF::PageAllocation::PageAllocation):
+ * wtf/PageReservation.h:
+ (WTF::PageReservation::commit):
+ (WTF::PageReservation::decommit):
+ (WTF::PageReservation::deallocate):
+ (WTF::PageReservation::PageReservation):
+ * wtf/wtf.pri:
+
2010-12-17 Michael Saboff <msaboff at apple.com>
Reviewed by Oliver Hunt.
diff --git a/JavaScriptCore/GNUmakefile.am b/JavaScriptCore/GNUmakefile.am
index 89f9ab7..05ee93b 100644
--- a/JavaScriptCore/GNUmakefile.am
+++ b/JavaScriptCore/GNUmakefile.am
@@ -475,9 +475,9 @@ javascriptcore_sources += \
JavaScriptCore/wtf/OwnArrayPtrCommon.h \
JavaScriptCore/wtf/OwnPtrCommon.h \
JavaScriptCore/wtf/OwnPtr.h \
- JavaScriptCore/wtf/PageAllocation.cpp \
JavaScriptCore/wtf/PageAllocation.h \
JavaScriptCore/wtf/PageReservation.h \
+ JavaScriptCore/wtf/PageBlock.cpp \
JavaScriptCore/wtf/PassOwnArrayPtr.h \
JavaScriptCore/wtf/PassOwnPtr.h \
JavaScriptCore/wtf/PassRefPtr.h \
diff --git a/JavaScriptCore/JavaScriptCore.gypi b/JavaScriptCore/JavaScriptCore.gypi
index 676a35d..0334ce7 100644
--- a/JavaScriptCore/JavaScriptCore.gypi
+++ b/JavaScriptCore/JavaScriptCore.gypi
@@ -406,7 +406,7 @@
'wtf/OwnFastMallocPtr.h',
'wtf/OwnPtr.h',
'wtf/OwnPtrCommon.h',
- 'wtf/PageAllocation.cpp',
+ 'wtf/PageBlock.cpp',
'wtf/PageAllocation.h',
'wtf/PageReservation',
'wtf/PassOwnPtr.h',
diff --git a/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj b/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
index 4a3e859..4000c78 100644
--- a/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
+++ b/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
@@ -697,7 +697,7 @@
>
</File>
<File
- RelativePath="..\..\wtf\PageAllocation.cpp"
+ RelativePath="..\..\wtf\PageBlock.cpp"
>
</File>
<File
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index 9f214b2..0ef6fdd 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -161,6 +161,8 @@
14A42E3F0F4F60EE00599099 /* TimeoutChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14A42E3D0F4F60EE00599099 /* TimeoutChecker.cpp */; };
14A42E400F4F60EE00599099 /* TimeoutChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 14A42E3E0F4F60EE00599099 /* TimeoutChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */; };
+ 14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 14B3EF0312BC24DD00D29EFF /* PageBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 14B3EF0612BC24DD00D29EFF /* PageBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */; };
14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
14BD59C50A3E8F9F00BAF59C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */; };
@@ -205,7 +207,6 @@
860161E50F3A83C100F84710 /* MacroAssemblerX86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */; };
860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */; };
8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8626BECE11928E3900782FAB /* StringStatics.cpp */; };
- 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8627E5E911F1281900A313B5 /* PageAllocation.cpp */; };
8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8627E5EA11F1281900A313B5 /* PageAllocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
862AF4B612239C7B0024E5B8 /* DecimalNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 862AF4B512239C7B0024E5B8 /* DecimalNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };
863B23E00FC6118900703AA4 /* MacroAssemblerCodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -718,6 +719,8 @@
14ABB454099C2A0F00E2A24F /* JSType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSType.h; sourceTree = "<group>"; };
14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObject.h; sourceTree = "<group>"; };
14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackObject.cpp; sourceTree = "<group>"; };
+ 14B3EF0312BC24DD00D29EFF /* PageBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageBlock.h; sourceTree = "<group>"; };
+ 14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageBlock.cpp; sourceTree = "<group>"; };
14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.exp; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
14BD59BF0A3E8F9000BAF59C /* testapi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testapi; sourceTree = BUILT_PRODUCTS_DIR; };
14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSContextRef.cpp; sourceTree = "<group>"; };
@@ -818,7 +821,6 @@
860161E10F3A83C100F84710 /* MacroAssemblerX86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86_64.h; sourceTree = "<group>"; };
860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; };
8626BECE11928E3900782FAB /* StringStatics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringStatics.cpp; path = text/StringStatics.cpp; sourceTree = "<group>"; };
- 8627E5E911F1281900A313B5 /* PageAllocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAllocation.cpp; sourceTree = "<group>"; };
8627E5EA11F1281900A313B5 /* PageAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocation.h; sourceTree = "<group>"; };
862AF4B512239C7B0024E5B8 /* DecimalNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecimalNumber.h; sourceTree = "<group>"; };
863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerCodeRef.h; sourceTree = "<group>"; };
@@ -1529,15 +1531,16 @@
65E1A2F4122B880D00B26097 /* NonCopyingSort.h */,
C0A2723F0E509F1E00E96E15 /* NotFound.h */,
933F5CDB126922690049191E /* NullPtr.h */,
- 1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */,
1400067612A6F7830064D123 /* OSAllocator.h */,
+ 1400069212A6F9E10064D123 /* OSAllocatorPosix.cpp */,
9303F5A409911A5800AD71B8 /* OwnArrayPtr.h */,
BCFBE697122561D200309E9D /* OwnArrayPtrCommon.h */,
0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */,
9303F567099118FA00AD71B8 /* OwnPtr.h */,
440B7AED0FAF7FCB0073323E /* OwnPtrCommon.h */,
- 8627E5E911F1281900A313B5 /* PageAllocation.cpp */,
8627E5EA11F1281900A313B5 /* PageAllocation.h */,
+ 14B3EF0412BC24DD00D29EFF /* PageBlock.cpp */,
+ 14B3EF0312BC24DD00D29EFF /* PageBlock.h */,
8690231412092D5C00630AF9 /* PageReservation.h */,
BCFBE695122560E800309E9D /* PassOwnArrayPtr.h */,
44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */,
@@ -2364,6 +2367,7 @@
933F5CDC1269229B0049191E /* NullPtr.h in Headers */,
F3BD31ED126735770065467F /* TextPosition.h in Headers */,
1400067712A6F7830064D123 /* OSAllocator.h in Headers */,
+ 14B3EF0512BC24DD00D29EFF /* PageBlock.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2813,7 +2817,6 @@
868BFA17117CF19900B908B1 /* WTFString.cpp in Sources */,
86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */,
DDF7ABD511F60ED200108E36 /* GCActivityCallbackCF.cpp in Sources */,
- 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */,
DDE82AD71209D955005C1756 /* GCHandle.cpp in Sources */,
A74DE1D0120B875600D40D5B /* ARMv7Assembler.cpp in Sources */,
9714AF46122F28850092D9F5 /* URLSegments.cpp in Sources */,
@@ -2823,6 +2826,7 @@
86438FC41265503E00E0DFCA /* StringBuilder.cpp in Sources */,
0F29479C126E698C00B3ABF5 /* DecimalNumber.cpp in Sources */,
1400069312A6F9E10064D123 /* OSAllocatorPosix.cpp in Sources */,
+ 14B3EF0612BC24DD00D29EFF /* PageBlock.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/JavaScriptCore/interpreter/RegisterFile.h b/JavaScriptCore/interpreter/RegisterFile.h
index b29e9b2..51a5bdf 100644
--- a/JavaScriptCore/interpreter/RegisterFile.h
+++ b/JavaScriptCore/interpreter/RegisterFile.h
@@ -159,8 +159,8 @@ namespace JSC {
, m_end(0)
, m_max(0)
{
- ASSERT(maxGlobals && PageAllocation::isPageAligned(maxGlobals));
- ASSERT(capacity && PageAllocation::isPageAligned(capacity));
+ ASSERT(maxGlobals && isPageAligned(maxGlobals));
+ ASSERT(capacity && isPageAligned(capacity));
size_t bufferLength = (capacity + maxGlobals) * sizeof(Register);
m_reservation = PageReservation::reserve(roundUpAllocationSize(bufferLength, commitSize), OSAllocator::JSVMStackPages);
diff --git a/JavaScriptCore/jit/ExecutableAllocator.cpp b/JavaScriptCore/jit/ExecutableAllocator.cpp
index 466ce6e..4ebc8b3 100644
--- a/JavaScriptCore/jit/ExecutableAllocator.cpp
+++ b/JavaScriptCore/jit/ExecutableAllocator.cpp
@@ -45,7 +45,7 @@ void ExecutableAllocator::intializePageSize()
// for moving memory model limitation
ExecutableAllocator::pageSize = 256 * 1024;
#else
- ExecutableAllocator::pageSize = PageAllocation::pageSize();
+ ExecutableAllocator::pageSize = WTF::pageSize();
#endif
}
diff --git a/JavaScriptCore/wtf/PageAllocation.cpp b/JavaScriptCore/wtf/PageAllocation.cpp
deleted file mode 100644
index 01cfbc1..0000000
--- a/JavaScriptCore/wtf/PageAllocation.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
- *
- * 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 "PageAllocation.h"
-#include "PageReservation.h"
-
-namespace WTF {
-
-size_t PageAllocation::s_pageSize = 0;
-
-}
diff --git a/JavaScriptCore/wtf/PageAllocation.h b/JavaScriptCore/wtf/PageAllocation.h
index ef21a73..74590b7 100644
--- a/JavaScriptCore/wtf/PageAllocation.h
+++ b/JavaScriptCore/wtf/PageAllocation.h
@@ -28,6 +28,7 @@
#include <wtf/Assertions.h>
#include <wtf/OSAllocator.h>
+#include <wtf/PageBlock.h>
#include <wtf/UnusedParam.h>
#include <wtf/VMTags.h>
#include <algorithm>
@@ -81,18 +82,9 @@ namespace WTF {
with a specified alignment. PageAllocation::allocateAligned requires that the
size is a power of two that is >= system page size.
*/
-class PageAllocation {
-public:
- PageAllocation()
- : m_base(0)
- , m_size(0)
- {
- }
-
- bool operator!() const { return !m_base; }
- void* base() const { return m_base; }
- size_t size() const { return m_size; }
+class PageAllocation : private PageBlock {
+public:
static PageAllocation allocate(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false)
{
ASSERT(isPageAligned(size));
@@ -108,49 +100,38 @@ public:
}
#endif
- void deallocate()
- {
- ASSERT(m_base);
- void* tmp = 0;
- std::swap(tmp, m_base);
- OSAllocator::release(tmp, m_size);
- }
+ PageAllocation();
+
+ using PageBlock::operator bool;
+ using PageBlock::base;
+ using PageBlock::size;
- static size_t pageSize()
+ void deallocate()
{
- if (!s_pageSize)
- s_pageSize = systemPageSize();
- ASSERT(isPowerOfTwo(s_pageSize));
- return s_pageSize;
+ ASSERT(*this);
+ PageAllocation tmp;
+ std::swap(tmp, *this);
+ OSAllocator::release(tmp.base(), tmp.size());
}
-#ifndef NDEBUG
- static bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
- static bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); }
- static bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); }
-#endif
-
-protected:
+private:
PageAllocation(void* base, size_t size)
- : m_base(base)
- , m_size(size)
+ : PageBlock(base, size)
{
}
#if HAVE(PAGE_ALLOCATE_ALIGNED)
static PageAllocation systemAllocateAligned(size_t, OSAllocator::Usage);
#endif
- static size_t systemPageSize();
-
- void* m_base;
- size_t m_size;
-
- static JS_EXPORTDATA size_t s_pageSize;
};
+inline PageAllocation::PageAllocation()
+ : PageBlock()
+{
+}
-#if HAVE(MMAP)
+#if HAVE(MMAP)
inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, OSAllocator::Usage usage)
{
@@ -195,15 +176,8 @@ inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, OSAlloc
#endif
}
-inline size_t PageAllocation::systemPageSize()
-{
- return getpagesize();
-}
-
-
#elif HAVE(VIRTUALALLOC)
-
#if HAVE(ALIGNED_MALLOC)
inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, OSAllocator::Usage usage)
{
@@ -217,30 +191,8 @@ inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, OSAlloc
}
#endif
-inline size_t PageAllocation::systemPageSize()
-{
- static size_t size = 0;
- SYSTEM_INFO system_info;
- GetSystemInfo(&system_info);
- size = system_info.dwPageSize;
- return size;
-}
-
-
-#elif OS(SYMBIAN)
-
-
-inline size_t PageAllocation::systemPageSize()
-{
- static TInt page_size = 0;
- UserHal::PageSizeInBytes(page_size);
- return page_size;
-}
-
-
#endif
-
}
using WTF::PageAllocation;
diff --git a/JavaScriptCore/wtf/PageBlock.cpp b/JavaScriptCore/wtf/PageBlock.cpp
new file mode 100644
index 0000000..6fb68e5
--- /dev/null
+++ b/JavaScriptCore/wtf/PageBlock.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "PageBlock.h"
+
+#if OS(UNIX) && !OS(SYMBIAN)
+#include <unistd.h>
+#endif
+
+#if OS(WINDOWS)
+#include <malloc.h>
+#include <windows.h>
+#endif
+
+#if OS(SYMBIAN)
+#include <e32hal.h>
+#include <e32std.h>
+#endif
+
+namespace WTF {
+
+static size_t s_pageSize;
+
+#if OS(UNIX) && !OS(SYMBIAN)
+
+inline size_t systemPageSize()
+{
+ return getpagesize();
+}
+
+#elif OS(WINDOWS)
+
+inline size_t systemPageSize()
+{
+ static size_t size = 0;
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ size = system_info.dwPageSize;
+ return size;
+}
+
+#elif OS(SYMBIAN)
+
+inline size_t systemPageSize()
+{
+ static TInt page_size = 0;
+ UserHal::PageSizeInBytes(page_size);
+ return page_size;
+}
+
+#endif
+
+size_t pageSize()
+{
+ if (!s_pageSize)
+ s_pageSize = systemPageSize();
+ ASSERT(isPowerOfTwo(s_pageSize));
+ return s_pageSize;
+}
+
+} // namespace WTF
diff --git a/JavaScriptCore/wtf/PageBlock.h b/JavaScriptCore/wtf/PageBlock.h
new file mode 100644
index 0000000..c810cab
--- /dev/null
+++ b/JavaScriptCore/wtf/PageBlock.h
@@ -0,0 +1,77 @@
+/*
+ * 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 PageBlock_h
+#define PageBlock_h
+
+namespace WTF {
+
+size_t pageSize();
+inline bool isPageAligned(void* address) { return !(reinterpret_cast<intptr_t>(address) & (pageSize() - 1)); }
+inline bool isPageAligned(size_t size) { return !(size & (pageSize() - 1)); }
+inline bool isPowerOfTwo(size_t size) { return !(size & (size - 1)); }
+
+class PageBlock {
+public:
+ PageBlock();
+ PageBlock(const PageBlock&);
+ PageBlock(void*, size_t);
+
+ void* base() const { return m_base; }
+ size_t size() const { return m_size; }
+
+ operator bool() const { return !!m_base; }
+
+private:
+ void* m_base;
+ size_t m_size;
+};
+
+inline PageBlock::PageBlock()
+ : m_base(0)
+ , m_size(0)
+{
+}
+
+inline PageBlock::PageBlock(const PageBlock& other)
+ : m_base(other.m_base)
+ , m_size(other.m_size)
+{
+}
+
+inline PageBlock::PageBlock(void* base, size_t size)
+ : m_base(base)
+ , m_size(size)
+{
+}
+
+} // namespace WTF
+
+using WTF::pageSize;
+using WTF::isPageAligned;
+using WTF::isPageAligned;
+using WTF::isPowerOfTwo;
+
+#endif // PageBlock_h
diff --git a/JavaScriptCore/wtf/PageReservation.h b/JavaScriptCore/wtf/PageReservation.h
index 310b9a2..7c5258a 100644
--- a/JavaScriptCore/wtf/PageReservation.h
+++ b/JavaScriptCore/wtf/PageReservation.h
@@ -53,19 +53,20 @@ namespace WTF {
is changed on memory while it is committed it should be returned to the orignal
protection before decommit is called.
*/
-class PageReservation : private PageAllocation {
+
+class PageReservation : private PageBlock {
public:
PageReservation()
{
}
-
- using PageAllocation::operator!;
- using PageAllocation::base;
- using PageAllocation::size;
+
+ using PageBlock::operator bool;
+ using PageBlock::base;
+ using PageBlock::size;
void commit(void* start, size_t size)
{
- ASSERT(m_base);
+ ASSERT(*this);
ASSERT(isPageAligned(start));
ASSERT(isPageAligned(size));
@@ -77,7 +78,7 @@ public:
void decommit(void* start, size_t size)
{
- ASSERT(m_base);
+ ASSERT(*this);
ASSERT(isPageAligned(start));
ASSERT(isPageAligned(size));
@@ -96,12 +97,15 @@ public:
void deallocate()
{
ASSERT(!m_committed);
- PageAllocation::deallocate();
+ ASSERT(*this);
+ PageReservation tmp;
+ std::swap(tmp, *this);
+ OSAllocator::release(tmp.base(), tmp.size());
}
private:
PageReservation(void* base, size_t size, bool writable, bool executable)
- : PageAllocation(base, size)
+ : PageBlock(base, size)
#ifndef NDEBUG
, m_committed(0)
#endif
diff --git a/JavaScriptCore/wtf/wtf.pri b/JavaScriptCore/wtf/wtf.pri
index 4d50d48..a6af879 100644
--- a/JavaScriptCore/wtf/wtf.pri
+++ b/JavaScriptCore/wtf/wtf.pri
@@ -16,7 +16,7 @@ SOURCES += \
wtf/qt/MainThreadQt.cpp \
wtf/qt/StringQt.cpp \
wtf/qt/ThreadingQt.cpp \
- wtf/PageAllocation.cpp \
+ wtf/PageBlock.cpp \
wtf/RandomNumber.cpp \
wtf/RefCountedLeakCounter.cpp \
wtf/ThreadingNone.cpp \
diff --git a/JavaScriptGlue/ChangeLog b/JavaScriptGlue/ChangeLog
index 9693952..855f7c7 100644
--- a/JavaScriptGlue/ChangeLog
+++ b/JavaScriptGlue/ChangeLog
@@ -1,3 +1,12 @@
+2010-12-20 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Factored common page set management into a new PageBlock base class
+ https://bugs.webkit.org/show_bug.cgi?id=51285
+
+ * ForwardingHeaders/wtf/PageBlock.h: Added.
+
2010-12-01 Geoffrey Garen <ggaren at apple.com>
Build fix: Added a forwarding header.
diff --git a/JavaScriptGlue/ForwardingHeaders/wtf/PageBlock.h b/JavaScriptGlue/ForwardingHeaders/wtf/PageBlock.h
new file mode 100644
index 0000000..49484ff
--- /dev/null
+++ b/JavaScriptGlue/ForwardingHeaders/wtf/PageBlock.h
@@ -0,0 +1 @@
+#include <JavaScriptCore/PageBlock.h>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 56aa211..86f4150 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,12 @@
+2010-12-20 Geoffrey Garen <ggaren at apple.com>
+
+ Reviewed by Sam Weinig.
+
+ Factored common page set management into a new PageBlock base class
+ https://bugs.webkit.org/show_bug.cgi?id=51285
+
+ * ForwardingHeaders/wtf/PageBlock.h: Added.
+
2010-12-20 Steve Block <steveblock at google.com>
Reviewed by Jeremy Orlow.
diff --git a/WebCore/ForwardingHeaders/wtf/PageBlock.h b/WebCore/ForwardingHeaders/wtf/PageBlock.h
new file mode 100644
index 0000000..b616edd
--- /dev/null
+++ b/WebCore/ForwardingHeaders/wtf/PageBlock.h
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_PageBlock_h
+#define WebCore_FWD_PageBlock_h
+#include <JavaScriptCore/PageBlock.h>
+#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list