diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp')
-rw-r--r-- | Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp index 287668137..8e0b77cfc 100644 --- a/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp +++ b/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,18 +24,14 @@ */ #include "config.h" -#include "ExecutableAllocator.h" -#include "JSCInlines.h" +#include "ExecutableAllocator.h" #if ENABLE(EXECUTABLE_ALLOCATOR_FIXED) #include "CodeProfiling.h" -#include "ExecutableAllocationFuzz.h" #include <errno.h> -#if !PLATFORM(WIN) #include <unistd.h> -#endif #include <wtf/MetaAllocator.h> #include <wtf/PageReservation.h> #include <wtf/VMTags.h> @@ -48,6 +44,11 @@ #include <stdio.h> #endif +#if !PLATFORM(IOS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +// MADV_FREE_REUSABLE does not work for JIT memory on older OSes so use MADV_FREE in that case. +#define WTF_USE_MADV_FREE_FOR_JIT_MEMORY 1 +#endif + using namespace WTF; namespace JSC { @@ -60,15 +61,12 @@ public: FixedVMPoolExecutableAllocator() : MetaAllocator(jitAllocationGranule) // round up all allocations to 32 bytes { - size_t reservationSize; - if (Options::jitMemoryReservationSize()) - reservationSize = Options::jitMemoryReservationSize(); - else - reservationSize = fixedExecutableMemoryPoolSize; - reservationSize = roundUpToMultipleOf(pageSize(), reservationSize); - m_reservation = PageReservation::reserveWithGuardPages(reservationSize, OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); + m_reservation = PageReservation::reserveWithGuardPages(fixedExecutableMemoryPoolSize, OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); +#if !ENABLE(LLINT) + RELEASE_ASSERT(m_reservation); +#endif if (m_reservation) { - ASSERT(m_reservation.size() == reservationSize); + ASSERT(m_reservation.size() == fixedExecutableMemoryPoolSize); addFreshFreeSpace(m_reservation.base(), m_reservation.size()); startOfFixedExecutableMemoryPool = reinterpret_cast<uintptr_t>(m_reservation.base()); @@ -154,49 +152,28 @@ double ExecutableAllocator::memoryPressureMultiplier(size_t addedMemoryUsage) MetaAllocator::Statistics statistics = allocator->currentStatistics(); ASSERT(statistics.bytesAllocated <= statistics.bytesReserved); size_t bytesAllocated = statistics.bytesAllocated + addedMemoryUsage; - size_t bytesAvailable = static_cast<size_t>( - statistics.bytesReserved * (1 - executablePoolReservationFraction)); - if (bytesAllocated >= bytesAvailable) - bytesAllocated = bytesAvailable; + if (bytesAllocated >= statistics.bytesReserved) + bytesAllocated = statistics.bytesReserved; double result = 1.0; - size_t divisor = bytesAvailable - bytesAllocated; + size_t divisor = statistics.bytesReserved - bytesAllocated; if (divisor) - result = static_cast<double>(bytesAvailable) / divisor; + result = static_cast<double>(statistics.bytesReserved) / divisor; if (result < 1.0) result = 1.0; return result; } -RefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM&, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) +PassRefPtr<ExecutableMemoryHandle> ExecutableAllocator::allocate(VM& vm, size_t sizeInBytes, void* ownerUID, JITCompilationEffort effort) { - if (effort != JITCompilationCanFail && Options::reportMustSucceedExecutableAllocations()) { - dataLog("Allocating ", sizeInBytes, " bytes of executable memory with JITCompilationMustSucceed.\n"); - WTFReportBacktrace(); - } - - if (effort == JITCompilationCanFail - && doExecutableAllocationFuzzingIfEnabled() == PretendToFailExecutableAllocation) - return nullptr; - - if (effort == JITCompilationCanFail) { - // Don't allow allocations if we are down to reserve. - MetaAllocator::Statistics statistics = allocator->currentStatistics(); - size_t bytesAllocated = statistics.bytesAllocated + sizeInBytes; - size_t bytesAvailable = static_cast<size_t>( - statistics.bytesReserved * (1 - executablePoolReservationFraction)); - if (bytesAllocated > bytesAvailable) - return nullptr; - } - RefPtr<ExecutableMemoryHandle> result = allocator->allocate(sizeInBytes, ownerUID); if (!result) { - if (effort != JITCompilationCanFail) { - dataLog("Ran out of executable memory while allocating ", sizeInBytes, " bytes.\n"); - CRASH(); - } - return nullptr; + if (effort == JITCompilationCanFail) + return result; + releaseExecutableMemory(vm); + result = allocator->allocate(sizeInBytes, ownerUID); + RELEASE_ASSERT(result); } - return result; + return result.release(); } size_t ExecutableAllocator::committedByteCount() |