aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorMaurice Kalinowski <maurice.kalinowski@qt.io>2017-02-28 10:04:11 +0100
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-02-28 09:52:10 +0000
commitd1ae334077aeb948ca191e22231d20b54ea5f956 (patch)
treeac5d840be78f9729eda7792845ed3694d4902cd1 /src/3rdparty
parent0f9b39909fb7023f7936b4311c13dbaa571ddbe6 (diff)
winrt: Switch to always use VirtualAllocFromApp
In latest versions of Windows, one can use VirtualAllocFromApp also without CodeGeneration flag being set. In conjunction with the new garbage collector that let to the situtation that the gc tried to reserve using VirtualAlloc, then the V4Engine constructor checked for JIT availability and disable JIT. This lead to VirtualAllocFromApp alloced memory could not be used anymore and caused to a crash latest when trying to commit or release. With WinRT 8.1 being removed, we do not need the mem_align version anymore and can stick with VirtualAllocFromApp/Free, with the JIT check only testing VirtualProtectFromApp. Task-number: QTBUG-59198 Change-Id: I57f2259c6a6298b8761d00d3abf2589c30de1f63 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/masm/wtf/OSAllocatorWinRT.cpp74
1 files changed, 22 insertions, 52 deletions
diff --git a/src/3rdparty/masm/wtf/OSAllocatorWinRT.cpp b/src/3rdparty/masm/wtf/OSAllocatorWinRT.cpp
index 15703017f6..4cebc35cce 100644
--- a/src/3rdparty/masm/wtf/OSAllocatorWinRT.cpp
+++ b/src/3rdparty/masm/wtf/OSAllocatorWinRT.cpp
@@ -55,78 +55,48 @@ static inline DWORD protection(bool writable, bool executable)
void* OSAllocator::reserveUncommitted(size_t bytes, Usage, bool writable, bool executable)
{
- void *result;
- if (qt_winrt_use_jit) {
- result = VirtualAllocFromApp(0, bytes, MEM_RESERVE, protection(writable, executable));
- if (!result) {
- qt_winrt_use_jit = false;
- return reserveUncommitted(bytes, UnknownUsage, writable, executable);
- }
- } else {
- static const size_t pageSize = getPageSize();
- result = _aligned_malloc(bytes, pageSize);
- if (!result)
- CRASH();
- memset(result, 0, bytes);
- }
+ void *result = VirtualAllocFromApp(0, bytes, MEM_RESERVE, protection(writable, executable));
return result;
}
-void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages)
+void* OSAllocator::reserveAndCommit(size_t bytes, Usage, bool writable, bool executable, bool includesGuardPages)
{
void *result;
- if (qt_winrt_use_jit) {
- result = VirtualAllocFromApp(0, bytes, MEM_RESERVE | MEM_COMMIT,
- protection(writable, executable));
- if (!result) {
- qt_winrt_use_jit = false;
- return reserveAndCommit(bytes, usage, writable, executable, includesGuardPages);
- }
+ result = VirtualAllocFromApp(0, bytes, MEM_RESERVE | MEM_COMMIT,
+ protection(writable, executable));
- if (includesGuardPages) {
- size_t guardSize = pageSize();
- DWORD oldProtect;
- if (!VirtualProtectFromApp(result, guardSize, protection(false, false), &oldProtect) ||
- !VirtualProtectFromApp(static_cast<char*>(result) + bytes - guardSize, guardSize,
- protection(false, false), &oldProtect)) {
- CRASH();
- }
+ if (includesGuardPages && qt_winrt_use_jit) {
+ size_t guardSize = pageSize();
+ DWORD oldProtect;
+ if (!VirtualProtectFromApp(result, guardSize, protection(false, false), &oldProtect) ||
+ !VirtualProtectFromApp(static_cast<char*>(result) + bytes - guardSize, guardSize,
+ protection(false, false), &oldProtect)) {
+ CRASH();
}
- } else {
- result = reserveUncommitted(bytes, usage, writable, executable);
}
return result;
}
void OSAllocator::commit(void *bytes, size_t size, bool writable, bool executable)
{
- if (qt_winrt_use_jit) {
- void *result = VirtualAllocFromApp(bytes, size, MEM_COMMIT,
- protection(writable, executable));
- if (!result)
- CRASH();
- }
+ void *result = VirtualAllocFromApp(bytes, size, MEM_COMMIT,
+ protection(writable, executable));
+ if (!result)
+ CRASH();
}
void OSAllocator::decommit(void* address, size_t bytes)
{
- if (qt_winrt_use_jit) {
- bool result = VirtualFree(address, bytes, MEM_DECOMMIT);
- if (!result)
- CRASH();
- } else
- _aligned_free(address);
+ bool result = VirtualFree(address, bytes, MEM_DECOMMIT);
+ if (!result)
+ CRASH();
}
-void OSAllocator::releaseDecommitted(void* address, size_t bytes)
+void OSAllocator::releaseDecommitted(void* address, size_t)
{
- if (qt_winrt_use_jit) {
- bool result = VirtualFree(address, 0, MEM_RELEASE);
- if (!result)
- CRASH();
- } else {
- decommit(address, bytes);
- }
+ bool result = VirtualFree(address, 0, MEM_RELEASE);
+ if (!result)
+ CRASH();
}
bool OSAllocator::canAllocateExecutableMemory()