haikuwebkit/Source/WTF/wtf/PageAllocation.h

113 lines
3.7 KiB
C
Raw Permalink Normal View History

Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
/*
* 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. ``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.
*/
Use pragma once in WTF https://bugs.webkit.org/show_bug.cgi?id=190527 Reviewed by Chris Dumez. Source/WTF: We also need to consistently include wtf headers from within wtf so we can build wtf without symbol redefinition errors from including the copy in Source and the copy in the build directory. * wtf/ASCIICType.h: * wtf/Assertions.cpp: * wtf/Assertions.h: * wtf/Atomics.h: * wtf/AutomaticThread.cpp: * wtf/AutomaticThread.h: * wtf/BackwardsGraph.h: * wtf/Bag.h: * wtf/BagToHashMap.h: * wtf/BitVector.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Box.h: * wtf/BubbleSort.h: * wtf/BumpPointerAllocator.h: * wtf/ByteOrder.h: * wtf/CPUTime.cpp: * wtf/CallbackAggregator.h: * wtf/CheckedArithmetic.h: * wtf/CheckedBoolean.h: * wtf/ClockType.cpp: * wtf/ClockType.h: * wtf/CommaPrinter.h: * wtf/CompilationThread.cpp: * wtf/CompilationThread.h: * wtf/Compiler.h: * wtf/ConcurrentPtrHashSet.cpp: * wtf/ConcurrentVector.h: * wtf/Condition.h: * wtf/CountingLock.cpp: * wtf/CrossThreadTaskHandler.cpp: * wtf/CryptographicUtilities.cpp: * wtf/CryptographicUtilities.h: * wtf/CryptographicallyRandomNumber.cpp: * wtf/CryptographicallyRandomNumber.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DataLog.h: * wtf/DateMath.cpp: * wtf/DateMath.h: * wtf/DecimalNumber.cpp: * wtf/DecimalNumber.h: * wtf/Deque.h: * wtf/DisallowCType.h: * wtf/Dominators.h: * wtf/DoublyLinkedList.h: * wtf/FastBitVector.cpp: * wtf/FastMalloc.cpp: * wtf/FastMalloc.h: * wtf/FeatureDefines.h: * wtf/FilePrintStream.cpp: * wtf/FilePrintStream.h: * wtf/FlipBytes.h: * wtf/FunctionDispatcher.cpp: * wtf/FunctionDispatcher.h: * wtf/GetPtr.h: * wtf/Gigacage.cpp: * wtf/GlobalVersion.cpp: * wtf/GraphNodeWorklist.h: * wtf/GregorianDateTime.cpp: * wtf/GregorianDateTime.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashMethod.h: * wtf/HashSet.h: * wtf/HashTable.cpp: * wtf/HashTraits.h: * wtf/Indenter.h: * wtf/IndexSparseSet.h: * wtf/InlineASM.h: * wtf/Insertion.h: * wtf/IteratorAdaptors.h: * wtf/IteratorRange.h: * wtf/JSONValues.cpp: * wtf/JSValueMalloc.cpp: * wtf/LEBDecoder.h: * wtf/Language.cpp: * wtf/ListDump.h: * wtf/Lock.cpp: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockedPrintStream.cpp: * wtf/Locker.h: * wtf/MD5.cpp: * wtf/MD5.h: * wtf/MainThread.cpp: * wtf/MainThread.h: * wtf/MallocPtr.h: * wtf/MathExtras.h: * wtf/MediaTime.cpp: * wtf/MediaTime.h: * wtf/MemoryPressureHandler.cpp: * wtf/MessageQueue.h: * wtf/MetaAllocator.cpp: * wtf/MetaAllocator.h: * wtf/MetaAllocatorHandle.h: * wtf/MonotonicTime.cpp: * wtf/MonotonicTime.h: * wtf/NakedPtr.h: * wtf/NoLock.h: * wtf/NoTailCalls.h: * wtf/Noncopyable.h: * wtf/NumberOfCores.cpp: * wtf/NumberOfCores.h: * wtf/OSAllocator.h: * wtf/OSAllocatorPosix.cpp: * wtf/OSRandomSource.cpp: * wtf/OSRandomSource.h: * wtf/ObjcRuntimeExtras.h: * wtf/OrderMaker.h: * wtf/PackedIntVector.h: * wtf/PageAllocation.h: * wtf/PageBlock.cpp: * wtf/PageBlock.h: * wtf/PageReservation.h: * wtf/ParallelHelperPool.cpp: * wtf/ParallelHelperPool.h: * wtf/ParallelJobs.h: * wtf/ParallelJobsLibdispatch.h: * wtf/ParallelVectorIterator.h: * wtf/ParkingLot.cpp: * wtf/ParkingLot.h: * wtf/Platform.h: * wtf/PointerComparison.h: * wtf/Poisoned.cpp: * wtf/PrintStream.cpp: * wtf/PrintStream.h: * wtf/ProcessID.h: * wtf/ProcessPrivilege.cpp: * wtf/RAMSize.cpp: * wtf/RAMSize.h: * wtf/RandomDevice.cpp: * wtf/RandomNumber.cpp: * wtf/RandomNumber.h: * wtf/RandomNumberSeed.h: * wtf/RangeSet.h: * wtf/RawPointer.h: * wtf/ReadWriteLock.cpp: * wtf/RedBlackTree.h: * wtf/Ref.h: * wtf/RefCountedArray.h: * wtf/RefCountedLeakCounter.cpp: * wtf/RefCountedLeakCounter.h: * wtf/RefCounter.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/RunLoop.cpp: * wtf/RunLoop.h: * wtf/RunLoopTimer.h: * wtf/RunLoopTimerCF.cpp: * wtf/SHA1.cpp: * wtf/SHA1.h: * wtf/SaturatedArithmetic.h: (saturatedSubtraction): * wtf/SchedulePair.h: * wtf/SchedulePairCF.cpp: * wtf/SchedulePairMac.mm: * wtf/ScopedLambda.h: * wtf/Seconds.cpp: * wtf/Seconds.h: * wtf/SegmentedVector.h: * wtf/SentinelLinkedList.h: * wtf/SharedTask.h: * wtf/SimpleStats.h: * wtf/SingleRootGraph.h: * wtf/SinglyLinkedList.h: * wtf/SixCharacterHash.cpp: * wtf/SixCharacterHash.h: * wtf/SmallPtrSet.h: * wtf/Spectrum.h: * wtf/StackBounds.cpp: * wtf/StackBounds.h: * wtf/StackStats.cpp: * wtf/StackStats.h: * wtf/StackTrace.cpp: * wtf/StdLibExtras.h: * wtf/StreamBuffer.h: * wtf/StringHashDumpContext.h: * wtf/StringPrintStream.cpp: * wtf/StringPrintStream.h: * wtf/ThreadGroup.cpp: * wtf/ThreadMessage.cpp: * wtf/ThreadSpecific.h: * wtf/Threading.cpp: * wtf/Threading.h: * wtf/ThreadingPrimitives.h: * wtf/ThreadingPthreads.cpp: * wtf/TimeWithDynamicClockType.cpp: * wtf/TimeWithDynamicClockType.h: * wtf/TimingScope.cpp: * wtf/TinyLRUCache.h: * wtf/TinyPtrSet.h: * wtf/TriState.h: * wtf/TypeCasts.h: * wtf/UUID.cpp: * wtf/UnionFind.h: * wtf/VMTags.h: * wtf/ValueCheck.h: * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.cpp: * wtf/WallTime.h: * wtf/WeakPtr.h: * wtf/WeakRandom.h: * wtf/WordLock.cpp: * wtf/WordLock.h: * wtf/WorkQueue.cpp: * wtf/WorkQueue.h: * wtf/WorkerPool.cpp: * wtf/cf/LanguageCF.cpp: * wtf/cf/RunLoopCF.cpp: * wtf/cocoa/Entitlements.mm: * wtf/cocoa/MachSendRight.cpp: * wtf/cocoa/MainThreadCocoa.mm: * wtf/cocoa/MemoryFootprintCocoa.cpp: * wtf/cocoa/WorkQueueCocoa.cpp: * wtf/dtoa.cpp: * wtf/dtoa.h: * wtf/ios/WebCoreThread.cpp: * wtf/ios/WebCoreThread.h: * wtf/mac/AppKitCompatibilityDeclarations.h: * wtf/mac/DeprecatedSymbolsUsedBySafari.mm: * wtf/mbmalloc.cpp: * wtf/persistence/PersistentCoders.cpp: * wtf/persistence/PersistentDecoder.cpp: * wtf/persistence/PersistentEncoder.cpp: * wtf/spi/cf/CFBundleSPI.h: * wtf/spi/darwin/CommonCryptoSPI.h: * wtf/text/ASCIIFastPath.h: * wtf/text/ASCIILiteral.cpp: * wtf/text/AtomicString.cpp: * wtf/text/AtomicString.h: * wtf/text/AtomicStringHash.h: * wtf/text/AtomicStringImpl.cpp: * wtf/text/AtomicStringImpl.h: * wtf/text/AtomicStringTable.cpp: * wtf/text/AtomicStringTable.h: * wtf/text/Base64.cpp: * wtf/text/CString.cpp: * wtf/text/CString.h: * wtf/text/ConversionMode.h: * wtf/text/ExternalStringImpl.cpp: * wtf/text/IntegerToStringConversion.h: * wtf/text/LChar.h: * wtf/text/LineEnding.cpp: * wtf/text/StringBuffer.h: * wtf/text/StringBuilder.cpp: * wtf/text/StringBuilder.h: * wtf/text/StringBuilderJSON.cpp: * wtf/text/StringCommon.h: * wtf/text/StringConcatenate.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.cpp: * wtf/text/StringImpl.h: * wtf/text/StringOperators.h: * wtf/text/StringView.cpp: * wtf/text/StringView.h: * wtf/text/SymbolImpl.cpp: * wtf/text/SymbolRegistry.cpp: * wtf/text/SymbolRegistry.h: * wtf/text/TextBreakIterator.cpp: * wtf/text/TextBreakIterator.h: * wtf/text/TextBreakIteratorInternalICU.h: * wtf/text/TextPosition.h: * wtf/text/TextStream.cpp: * wtf/text/UniquedStringImpl.h: * wtf/text/WTFString.cpp: * wtf/text/WTFString.h: * wtf/text/cocoa/StringCocoa.mm: * wtf/text/cocoa/StringViewCocoa.mm: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: * wtf/text/icu/UTextProvider.cpp: * wtf/text/icu/UTextProvider.h: * wtf/text/icu/UTextProviderLatin1.cpp: * wtf/text/icu/UTextProviderLatin1.h: * wtf/text/icu/UTextProviderUTF16.cpp: * wtf/text/icu/UTextProviderUTF16.h: * wtf/threads/BinarySemaphore.cpp: * wtf/threads/BinarySemaphore.h: * wtf/threads/Signals.cpp: * wtf/unicode/CharacterNames.h: * wtf/unicode/Collator.h: * wtf/unicode/CollatorDefault.cpp: * wtf/unicode/UTF8.cpp: * wtf/unicode/UTF8.h: Tools: Put WorkQueue in namespace DRT so it does not conflict with WTF::WorkQueue. * DumpRenderTree/TestRunner.cpp: (TestRunner::queueLoadHTMLString): (TestRunner::queueLoadAlternateHTMLString): (TestRunner::queueBackNavigation): (TestRunner::queueForwardNavigation): (TestRunner::queueLoadingScript): (TestRunner::queueNonLoadingScript): (TestRunner::queueReload): * DumpRenderTree/WorkQueue.cpp: (WorkQueue::singleton): Deleted. (WorkQueue::WorkQueue): Deleted. (WorkQueue::queue): Deleted. (WorkQueue::dequeue): Deleted. (WorkQueue::count): Deleted. (WorkQueue::clear): Deleted. (WorkQueue::processWork): Deleted. * DumpRenderTree/WorkQueue.h: (WorkQueue::setFrozen): Deleted. * DumpRenderTree/WorkQueueItem.h: * DumpRenderTree/mac/DumpRenderTree.mm: (runTest): * DumpRenderTree/mac/FrameLoadDelegate.mm: (-[FrameLoadDelegate processWork:]): (-[FrameLoadDelegate webView:locationChangeDone:forDataSource:]): * DumpRenderTree/mac/TestRunnerMac.mm: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): * DumpRenderTree/win/DumpRenderTree.cpp: (runTest): * DumpRenderTree/win/FrameLoadDelegate.cpp: (FrameLoadDelegate::processWork): (FrameLoadDelegate::locationChangeDone): * DumpRenderTree/win/TestRunnerWin.cpp: (TestRunner::notifyDone): (TestRunner::forceImmediateCompletion): (TestRunner::queueLoad): Canonical link: https://commits.webkit.org/205473@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237099 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-15 14:24:49 +00:00
#pragma once
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
#include <wtf/Assertions.h>
Migrated OS-specific allocation code from PageReservation and PageAllocation to OSAllocator https://bugs.webkit.org/show_bug.cgi?id=50653 Reviewed by Sam Weinig. * JavaScriptCore.exp: Updated for new function signature. * interpreter/RegisterFile.h: (JSC::RegisterFile::RegisterFile): (JSC::RegisterFile::grow): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): Removed checkAllocatedOkay. OSAllocator is now the central location for verifying that allocation succeeds. This allowed me to remove some complicating cross-platform cruft. * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): Updated for code motion. * wtf/OSAllocator.h: Added Usage, writable, and executable parameters, to support VM features required by clients of PageAllocation and PageReservation. * wtf/OSAllocatorPosix.cpp: (WTF::OSAllocator::reserve): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::commit): Moved PageAllocation support for randomizing executable memory here. * wtf/OSAllocatorSymbian.cpp: (WTF::OSAllocator::reserve): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::commit): Updated for new function signatures. * wtf/OSAllocatorWin.cpp: (WTF::protection): (WTF::OSAllocator::reserve): (WTF::OSAllocator::reserveAndCommit): (WTF::OSAllocator::commit): (WTF::OSAllocator::release): Updated for new function signatures. Moved some protection-related and WINCE-related code from PageAllocation here. * wtf/PageAllocation.cpp: Nixed cross-platform lastError abstraction, since it was only used by checkAllocatedOkay, which is now gone. * wtf/PageAllocation.h: (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::isPowerOfTwo): (WTF::PageAllocation::systemAllocateAligned): Removed system* functions, and replaced calls to them with calls to OSAllocator. * wtf/PageReservation.h: (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::deallocate): (WTF::PageReservation::PageReservation): Ditto. Added m_writable and m_executable because these flags are now required when committing memory. Canonical link: https://commits.webkit.org/63979@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73570 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-09 01:30:18 +00:00
#include <wtf/OSAllocator.h>
#include <wtf/PageBlock.h>
#include <algorithm>
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
https://bugs.webkit.org/show_bug.cgi?id=43269 Patch by Nathan Lawrence <nlawrence@apple.com> on 2010-08-03 Reviewed by Gavin Barraclough. Added new allocateAligned methods to PageAllocation. In order to prevent a regress in performance, the function needs to be inlined. Additionally, I ported the symbian block allocator to use PageAllocation and added a new WTF::Bitmap class to support this. * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/AlignedMemoryAllocator.h: Added. (JSC::AlignedMemory::deallocate): (JSC::AlignedMemory::base): (JSC::AlignedMemory::AlignedMemory): (JSC::AlignedMemoryAllocator::destroy): (JSC::AlignedMemoryAllocator::allocate): (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::free): * runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::freeBlocks): (JSC::Heap::allocate): (JSC::Heap::shrinkBlocks): (JSC::Heap::markConservatively): (JSC::Heap::clearMarkBits): (JSC::Heap::markedCells): * runtime/Collector.h: (JSC::CollectorHeap::collectorBlock): * runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*): (JSC::LiveObjectIterator::operator++): (JSC::DeadObjectIterator::operator++): * wtf/Bitmap.h: Added. (WTF::Bitmap::get): (WTF::Bitmap::set): (WTF::Bitmap::clear): (WTF::Bitmap::clearAll): (WTF::Bitmap::advanceToNextFreeBit): (WTF::Bitmap::count): (WTF::Bitmap::isEmpty): (WTF::Bitmap::isFull): * wtf/PageAllocation.h: (WTF::PageAllocation::operator UnspecifiedBoolType): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::reserveAligned): * wtf/Platform.h: * wtf/symbian: Removed. * wtf/symbian/BlockAllocatorSymbian.cpp: Removed. * wtf/symbian/BlockAllocatorSymbian.h: Removed. Canonical link: https://commits.webkit.org/55446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-04 03:27:13 +00:00
#if OS(DARWIN)
#include <mach/mach_init.h>
#include <mach/vm_map.h>
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
#endif
https://bugs.webkit.org/show_bug.cgi?id=43269 Patch by Nathan Lawrence <nlawrence@apple.com> on 2010-08-03 Reviewed by Gavin Barraclough. Added new allocateAligned methods to PageAllocation. In order to prevent a regress in performance, the function needs to be inlined. Additionally, I ported the symbian block allocator to use PageAllocation and added a new WTF::Bitmap class to support this. * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/AlignedMemoryAllocator.h: Added. (JSC::AlignedMemory::deallocate): (JSC::AlignedMemory::base): (JSC::AlignedMemory::AlignedMemory): (JSC::AlignedMemoryAllocator::destroy): (JSC::AlignedMemoryAllocator::allocate): (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::free): * runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::freeBlocks): (JSC::Heap::allocate): (JSC::Heap::shrinkBlocks): (JSC::Heap::markConservatively): (JSC::Heap::clearMarkBits): (JSC::Heap::markedCells): * runtime/Collector.h: (JSC::CollectorHeap::collectorBlock): * runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*): (JSC::LiveObjectIterator::operator++): (JSC::DeadObjectIterator::operator++): * wtf/Bitmap.h: Added. (WTF::Bitmap::get): (WTF::Bitmap::set): (WTF::Bitmap::clear): (WTF::Bitmap::clearAll): (WTF::Bitmap::advanceToNextFreeBit): (WTF::Bitmap::count): (WTF::Bitmap::isEmpty): (WTF::Bitmap::isFull): * wtf/PageAllocation.h: (WTF::PageAllocation::operator UnspecifiedBoolType): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::reserveAligned): * wtf/Platform.h: * wtf/symbian: Removed. * wtf/symbian/BlockAllocatorSymbian.cpp: Removed. * wtf/symbian/BlockAllocatorSymbian.h: Removed. Canonical link: https://commits.webkit.org/55446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-04 03:27:13 +00:00
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
#if OS(WINDOWS)
https://bugs.webkit.org/show_bug.cgi?id=43269 Patch by Nathan Lawrence <nlawrence@apple.com> on 2010-08-03 Reviewed by Gavin Barraclough. Added new allocateAligned methods to PageAllocation. In order to prevent a regress in performance, the function needs to be inlined. Additionally, I ported the symbian block allocator to use PageAllocation and added a new WTF::Bitmap class to support this. * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/AlignedMemoryAllocator.h: Added. (JSC::AlignedMemory::deallocate): (JSC::AlignedMemory::base): (JSC::AlignedMemory::AlignedMemory): (JSC::AlignedMemoryAllocator::destroy): (JSC::AlignedMemoryAllocator::allocate): (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::free): * runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::freeBlocks): (JSC::Heap::allocate): (JSC::Heap::shrinkBlocks): (JSC::Heap::markConservatively): (JSC::Heap::clearMarkBits): (JSC::Heap::markedCells): * runtime/Collector.h: (JSC::CollectorHeap::collectorBlock): * runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*): (JSC::LiveObjectIterator::operator++): (JSC::DeadObjectIterator::operator++): * wtf/Bitmap.h: Added. (WTF::Bitmap::get): (WTF::Bitmap::set): (WTF::Bitmap::clear): (WTF::Bitmap::clearAll): (WTF::Bitmap::advanceToNextFreeBit): (WTF::Bitmap::count): (WTF::Bitmap::isEmpty): (WTF::Bitmap::isFull): * wtf/PageAllocation.h: (WTF::PageAllocation::operator UnspecifiedBoolType): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::reserveAligned): * wtf/Platform.h: * wtf/symbian: Removed. * wtf/symbian/BlockAllocatorSymbian.cpp: Removed. * wtf/symbian/BlockAllocatorSymbian.h: Removed. Canonical link: https://commits.webkit.org/55446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-04 03:27:13 +00:00
#include <malloc.h>
#include <windows.h>
#endif
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
#if HAVE(ERRNO_H)
https://bugs.webkit.org/show_bug.cgi?id=43269 Patch by Nathan Lawrence <nlawrence@apple.com> on 2010-08-03 Reviewed by Gavin Barraclough. Added new allocateAligned methods to PageAllocation. In order to prevent a regress in performance, the function needs to be inlined. Additionally, I ported the symbian block allocator to use PageAllocation and added a new WTF::Bitmap class to support this. * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/AlignedMemoryAllocator.h: Added. (JSC::AlignedMemory::deallocate): (JSC::AlignedMemory::base): (JSC::AlignedMemory::AlignedMemory): (JSC::AlignedMemoryAllocator::destroy): (JSC::AlignedMemoryAllocator::allocate): (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::free): * runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::freeBlocks): (JSC::Heap::allocate): (JSC::Heap::shrinkBlocks): (JSC::Heap::markConservatively): (JSC::Heap::clearMarkBits): (JSC::Heap::markedCells): * runtime/Collector.h: (JSC::CollectorHeap::collectorBlock): * runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*): (JSC::LiveObjectIterator::operator++): (JSC::DeadObjectIterator::operator++): * wtf/Bitmap.h: Added. (WTF::Bitmap::get): (WTF::Bitmap::set): (WTF::Bitmap::clear): (WTF::Bitmap::clearAll): (WTF::Bitmap::advanceToNextFreeBit): (WTF::Bitmap::count): (WTF::Bitmap::isEmpty): (WTF::Bitmap::isFull): * wtf/PageAllocation.h: (WTF::PageAllocation::operator UnspecifiedBoolType): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::reserveAligned): * wtf/Platform.h: * wtf/symbian: Removed. * wtf/symbian/BlockAllocatorSymbian.cpp: Removed. * wtf/symbian/BlockAllocatorSymbian.h: Removed. Canonical link: https://commits.webkit.org/55446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-04 03:27:13 +00:00
#include <errno.h>
#endif
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
#if HAVE(MMAP)
#include <sys/mman.h>
#include <unistd.h>
https://bugs.webkit.org/show_bug.cgi?id=43269 Patch by Nathan Lawrence <nlawrence@apple.com> on 2010-08-03 Reviewed by Gavin Barraclough. Added new allocateAligned methods to PageAllocation. In order to prevent a regress in performance, the function needs to be inlined. Additionally, I ported the symbian block allocator to use PageAllocation and added a new WTF::Bitmap class to support this. * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.xcodeproj/project.pbxproj: * runtime/AlignedMemoryAllocator.h: Added. (JSC::AlignedMemory::deallocate): (JSC::AlignedMemory::base): (JSC::AlignedMemory::AlignedMemory): (JSC::AlignedMemoryAllocator::destroy): (JSC::AlignedMemoryAllocator::allocate): (JSC::AlignedMemoryAllocator::AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::~AlignedMemoryAllocator): (JSC::AlignedMemoryAllocator::free): * runtime/Collector.cpp: (JSC::Heap::Heap): (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::freeBlocks): (JSC::Heap::allocate): (JSC::Heap::shrinkBlocks): (JSC::Heap::markConservatively): (JSC::Heap::clearMarkBits): (JSC::Heap::markedCells): * runtime/Collector.h: (JSC::CollectorHeap::collectorBlock): * runtime/CollectorHeapIterator.h: (JSC::CollectorHeapIterator::operator*): (JSC::LiveObjectIterator::operator++): (JSC::DeadObjectIterator::operator++): * wtf/Bitmap.h: Added. (WTF::Bitmap::get): (WTF::Bitmap::set): (WTF::Bitmap::clear): (WTF::Bitmap::clearAll): (WTF::Bitmap::advanceToNextFreeBit): (WTF::Bitmap::count): (WTF::Bitmap::isEmpty): (WTF::Bitmap::isFull): * wtf/PageAllocation.h: (WTF::PageAllocation::operator UnspecifiedBoolType): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::reserveAligned): * wtf/Platform.h: * wtf/symbian: Removed. * wtf/symbian/BlockAllocatorSymbian.cpp: Removed. * wtf/symbian/BlockAllocatorSymbian.h: Removed. Canonical link: https://commits.webkit.org/55446@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64624 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-04 03:27:13 +00:00
#endif
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
namespace WTF {
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
/*
PageAllocation
The PageAllocation class provides a cross-platform memory allocation interface
with similar capabilities to posix mmap/munmap. Memory is allocated by calling
PageAllocation::allocate, and deallocated by calling deallocate on the
PageAllocation object. The PageAllocation holds the allocation's base pointer
and size.
The allocate method is passed the size required (which must be a multiple of
the system page size, which can be accessed using PageAllocation::pageSize).
Callers may also optinally provide a flag indicating the usage (for use by
system memory usage tracking tools, where implemented), and boolean values
specifying the required protection (defaulting to writable, non-executable).
*/
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
class PageAllocation : private PageBlock {
public:
using PageBlock::PageBlock;
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
using PageBlock::size;
using PageBlock::base;
#ifndef __clang__
using PageBlock::operator bool;
#else
// FIXME: This is a workaround for <rdar://problem/8876150>, wherein Clang incorrectly emits an access
// control warning when a client tries to use operator bool exposed above via "using PageBlock::operator bool".
operator bool() const { return PageBlock::operator bool(); }
#endif
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
static PageAllocation allocate(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false)
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
{
ASSERT(isPageAligned(size));
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
return PageAllocation(OSAllocator::reserveAndCommit(size, usage, writable, executable), size);
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
}
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
void deallocate()
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
{
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
// Clear base & size before calling release; if this is *inside* allocation
// then we won't be able to clear then after deallocating the memory.
PageAllocation tmp;
std::swap(tmp, *this);
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
ASSERT(tmp);
ASSERT(!*this);
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
OSAllocator::decommitAndRelease(tmp.base(), tmp.size());
JavaScriptCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. Reviewed by Sam Weinig. The PageAllocation class has a number of issues: * Changes in bug #43269 accidentally switched SYMBIAN over to use malloc/free to allocate blocks of memory for the GC heap, instead of allocating RChunks. Revert this change in behaviour. * In order for PageAllocation to work correctly on WinCE we should be decommitting memory before deallocating. In order to simplify understanding the expected state at deallocate, split behaviour out into PageAllocation and PageReservation classes. Require that all memory be decommitted before calling deallocate on a PageReservation, add asserts to enforce this. * add many missing asserts. * inline more functions. * remove ability to create sub-PageAllocations from an existing PageAllocations object - this presented an interface that would allow sub regions to be deallocated, which would not have provided expected behaviour. * remove writable/executable arguments to commit, this value can be cached at the point the memory is reserved. * remove writable/executable arguments to allocateAligned, protection other than RW is not supported. * add missing checks for overflow & failed allocation to mmap path through allocateAligned. * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::Allocation::Allocation): (JSC::ExecutablePool::Allocation::base): (JSC::ExecutablePool::Allocation::size): (JSC::ExecutablePool::Allocation::operator!): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::coalesceFreeSpace): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::allocInternal): * runtime/AlignedMemoryAllocator.h: (JSC::::allocate): (JSC::::AlignedMemoryAllocator): * runtime/Collector.cpp: (JSC::Heap::allocateBlock): * runtime/Collector.h: * wtf/PageAllocation.cpp: * wtf/PageAllocation.h: (WTF::PageAllocation::operator!): (WTF::PageAllocation::allocate): (WTF::PageAllocation::allocateAt): (WTF::PageAllocation::allocateAligned): (WTF::PageAllocation::deallocate): (WTF::PageAllocation::pageSize): (WTF::PageAllocation::systemAllocate): (WTF::PageAllocation::systemAllocateAt): (WTF::PageAllocation::systemAllocateAligned): (WTF::PageAllocation::systemDeallocate): (WTF::PageAllocation::systemPageSize): * wtf/PageReservation.h: Copied from JavaScriptCore/wtf/PageAllocation.h. (WTF::PageReservation::PageReservation): (WTF::PageReservation::commit): (WTF::PageReservation::decommit): (WTF::PageReservation::reserve): (WTF::PageReservation::reserveAt): (WTF::PageReservation::deallocate): (WTF::PageReservation::systemCommit): (WTF::PageReservation::systemDecommit): (WTF::PageReservation::systemReserve): (WTF::PageReservation::systemReserveAt): * wtf/Platform.h: JavaScriptGlue: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. WebCore: Bug 43515 - Fix small design issues with PageAllocation, split out PageReservation. (add forwarding headers) Reviewed by Sam Weinig. * ForwardingHeaders/wtf/Bitmap.h: Added. * ForwardingHeaders/wtf/PageReservation.h: Added. Canonical link: https://commits.webkit.org/55513@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-08-05 00:18:58 +00:00
}
private:
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
PageAllocation(void* base, size_t size)
: PageBlock(base, size, false)
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
{
}
};
JavaScriptCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. I think this patch fixes <rdar://problem/8107952> [5.0.1] WER crash in Heap::allocateBlock (1902752929), and some other leaks and crashes as well. * Android.mk: * CMakeLists.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.vcproj/WTF/WTF.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: Updated build files. * runtime/AlignedMemoryAllocator.h: Removed. Supplanted by PageAllocationAligned. * runtime/Collector.cpp: (JSC::Heap::destroy): (JSC::Heap::allocateBlock): (JSC::Heap::freeBlock): (JSC::Heap::addWeakGCHandle): * runtime/Collector.h: Switched from AlignedMemoryAllocator to PageAllocationAligned. * runtime/GCHandle.cpp: * runtime/GCHandle.h: Ditto. * wtf/PageAllocation.h: (WTF::PageAllocation::PageAllocation): Removed aligned memory allocation functions. Supplanted by PageAllocationAligned. * wtf/PageAllocationAligned.cpp: Added. (WTF::PageAllocationAligned::allocate): (WTF::PageAllocationAligned::deallocate): * wtf/PageAllocationAligned.h: Added. (WTF::PageAllocationAligned::PageAllocationAligned): New cross-platform class for doing aligned memory allocation. This class properly matches allocation and deallocation library calls, fixing a long-standing bug in PageAllocation. * wtf/Platform.h: Removed some defunction VM platform defines. * wtf/wtf.pri: Updated build files. JavaScriptGlue: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. WebCore: Added PageAllocationAligned, a cross-platform abstraction for memory allocations with arbitrary alignment requirements https://bugs.webkit.org/show_bug.cgi?id=51359 Patch by Geoffrey Garen <ggaren@apple.com> on 2010-12-21 Reviewed by Gavin Barraclough & Oliver Hunt. * ForwardingHeaders/wtf/PageAllocationAligned.h: Added. Canonical link: https://commits.webkit.org/64773@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74431 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-12-21 23:53:25 +00:00
} // namespace WTF
Bug 43009 - Abstract out page allocation from executable allocators Reviewed by Oliver Hunt. JavaScriptCore: It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. I think this will match current behaviour for the next client we will want to port across (RegisterFile & Collector). * CMakeListsEfl.txt: * GNUmakefile.am: * JavaScriptCore.gypi: * JavaScriptCore.pro: * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: * JavaScriptCore.xcodeproj/project.pbxproj: * jit/ExecutableAllocator.cpp: (JSC::ExecutableAllocator::intializePageSize): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): (JSC::ExecutableAllocator::isValid): * jit/ExecutableAllocator.h: (JSC::ExecutablePool::ExecutablePool): (JSC::ExecutablePool::poolAllocate): * jit/ExecutableAllocatorFixedVMPool.cpp: (JSC::FixedVMPoolAllocator::release): (JSC::FixedVMPoolAllocator::reuse): (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): (JSC::FixedVMPoolAllocator::alloc): (JSC::FixedVMPoolAllocator::free): (JSC::FixedVMPoolAllocator::isValid): (JSC::FixedVMPoolAllocator::isWithinVMPool): (JSC::ExecutablePool::systemAlloc): (JSC::ExecutablePool::systemRelease): * jit/ExecutableAllocatorPosix.cpp: Removed. * jit/ExecutableAllocatorSymbian.cpp: Removed. * jit/ExecutableAllocatorWin.cpp: Removed. * wscript: * wtf/PageAllocator.cpp: Added. (WTF::protection): (WTF::PageAllocation::commit): (WTF::PageAllocation::decommit): (WTF::PageAllocator::allocate): (WTF::PageAllocator::reserve): (WTF::PageAllocator::deallocate): (WTF::PageAllocator::pagesize): * wtf/PageAllocator.h: Added. (WTF::PageAllocation::PageAllocation): (WTF::PageAllocation::base): (WTF::PageAllocation::size): (WTF::PageAllocation::chunk): (WTF::PageAllocation::operator!): (WTF::PageAllocator::): JavaScriptGlue: * ForwardingHeaders/wtf/PageAllocation.h: Added. WebCore: * ForwardingHeaders/wtf/PageAllocation.h: Added. Canonical link: https://commits.webkit.org/54933@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@64105 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-07-27 05:02:09 +00:00
using WTF::PageAllocation;