aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-10-21 16:47:53 +0200
committerUlf Hermann <ulf.hermann@digia.com>2014-10-30 13:19:33 +0100
commit625dae442419d3f75bcecbafeaca490cdd5413a8 (patch)
tree260ef75b180794ba4d4f8ed5ec4f18221604834e /src/3rdparty
parent970ff81a14c93c4f41f384026220d4baad8eec70 (diff)
Allow page allocations to include guard pages
The PageAllocator is in principle capable of using guard pages. We can expose that functionality to its clients. Change-Id: I919f6f76310feb160d2b26ac1fc64db4e91804bb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/masm/wtf/PageAllocation.h15
-rw-r--r--src/3rdparty/masm/wtf/PageAllocationAligned.cpp7
-rw-r--r--src/3rdparty/masm/wtf/PageBlock.h7
-rw-r--r--src/3rdparty/masm/wtf/PageReservation.h2
4 files changed, 21 insertions, 10 deletions
diff --git a/src/3rdparty/masm/wtf/PageAllocation.h b/src/3rdparty/masm/wtf/PageAllocation.h
index 18d31880c0..95692be3ae 100644
--- a/src/3rdparty/masm/wtf/PageAllocation.h
+++ b/src/3rdparty/masm/wtf/PageAllocation.h
@@ -87,10 +87,15 @@ public:
operator bool() const { return PageBlock::operator bool(); }
#endif
- static PageAllocation allocate(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false)
+ static PageAllocation allocate(size_t size,
+ OSAllocator::Usage usage = OSAllocator::UnknownUsage,
+ bool writable = true, bool executable = false,
+ bool includesGuardPages = false)
{
ASSERT(isPageAligned(size));
- return PageAllocation(OSAllocator::reserveAndCommit(size, usage, writable, executable), size);
+ return PageAllocation(OSAllocator::reserveAndCommit(size, usage, writable, executable,
+ includesGuardPages), size,
+ includesGuardPages);
}
void deallocate()
@@ -103,12 +108,12 @@ public:
ASSERT(tmp);
ASSERT(!*this);
- OSAllocator::decommitAndRelease(tmp.base(), tmp.size());
+ OSAllocator::decommitAndRelease(tmp.realBase(), tmp.realSize());
}
private:
- PageAllocation(void* base, size_t size)
- : PageBlock(base, size, false)
+ PageAllocation(void* base, size_t size, bool includesGuardPages = false)
+ : PageBlock(base, size, includesGuardPages)
{
}
};
diff --git a/src/3rdparty/masm/wtf/PageAllocationAligned.cpp b/src/3rdparty/masm/wtf/PageAllocationAligned.cpp
index bdb976b1b7..1c35653381 100644
--- a/src/3rdparty/masm/wtf/PageAllocationAligned.cpp
+++ b/src/3rdparty/masm/wtf/PageAllocationAligned.cpp
@@ -75,10 +75,11 @@ void PageAllocationAligned::deallocate()
ASSERT(!*this);
#if OS(DARWIN)
- vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(tmp.base()), tmp.size());
+ vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(tmp.realBase()), tmp.realSize());
#else
- ASSERT(tmp.m_reservation.contains(tmp.base(), tmp.size()));
- OSAllocator::decommitAndRelease(tmp.m_reservation.base(), tmp.m_reservation.size(), tmp.base(), tmp.size());
+ ASSERT(tmp.m_reservation.contains(tmp.realBase(), tmp.realSize()));
+ OSAllocator::decommitAndRelease(tmp.m_reservation.realBase(), tmp.m_reservation.realSize(),
+ tmp.realBase(), tmp.realSize());
#endif
}
diff --git a/src/3rdparty/masm/wtf/PageBlock.h b/src/3rdparty/masm/wtf/PageBlock.h
index 56e5570178..4d408e1c91 100644
--- a/src/3rdparty/masm/wtf/PageBlock.h
+++ b/src/3rdparty/masm/wtf/PageBlock.h
@@ -40,8 +40,13 @@ public:
PageBlock(const PageBlock&);
PageBlock(void*, size_t, bool hasGuardPages);
+ void* realBase() const { return m_realBase; }
void* base() const { return m_base; }
- size_t size() const { return m_size; }
+ size_t size() const
+ {
+ return m_size - 2 * (static_cast<char *>(m_base) - static_cast<char *>(m_realBase));
+ }
+ size_t realSize() const { return m_size; }
operator bool() const { return !!m_realBase; }
diff --git a/src/3rdparty/masm/wtf/PageReservation.h b/src/3rdparty/masm/wtf/PageReservation.h
index 77783ebcc4..15be344fa8 100644
--- a/src/3rdparty/masm/wtf/PageReservation.h
+++ b/src/3rdparty/masm/wtf/PageReservation.h
@@ -125,7 +125,7 @@ public:
ASSERT(tmp);
ASSERT(!*this);
- OSAllocator::releaseDecommitted(tmp.base(), tmp.size());
+ OSAllocator::releaseDecommitted(tmp.realBase(), tmp.realSize());
}
private: