bytecompiler/BytecodeGenerator.cpp
bytecompiler/NodesCodegen.cpp
- heap/AllocationSpace.cpp
heap/Heap.cpp
heap/HandleHeap.cpp
heap/HandleStack.cpp
+2011-09-19 Sheriff Bot <webkit.review.bot@gmail.com>
+
+ Unreviewed, rolling out r95493 and r95496.
+ http://trac.webkit.org/changeset/95493
+ http://trac.webkit.org/changeset/95496
+ https://bugs.webkit.org/show_bug.cgi?id=68418
+
+ Broke Windows build (Requested by rniwa on #webkit).
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * JavaScriptCore.exp:
+ * JavaScriptCore.gypi:
+ * JavaScriptCore.pro:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * debugger/Debugger.cpp:
+ (JSC::Debugger::recompileAllJSFunctions):
+ * heap/AllocationSpace.cpp: Removed.
+ * heap/AllocationSpace.h: Removed.
+ * heap/Heap.cpp:
+ (JSC::CountFunctor::TakeIfEmpty::TakeIfEmpty):
+ (JSC::CountFunctor::TakeIfEmpty::operator()):
+ (JSC::CountFunctor::TakeIfEmpty::returnValue):
+ (JSC::Heap::Heap):
+ (JSC::Heap::reportExtraMemoryCostSlowCase):
+ (JSC::Heap::tryAllocate):
+ (JSC::Heap::allocateSlowCase):
+ (JSC::Heap::getConservativeRegisterRoots):
+ (JSC::Heap::markRoots):
+ (JSC::Heap::clearMarks):
+ (JSC::Heap::sweep):
+ (JSC::Heap::objectCount):
+ (JSC::Heap::size):
+ (JSC::Heap::capacity):
+ (JSC::Heap::globalObjectCount):
+ (JSC::Heap::objectTypeCounts):
+ (JSC::Heap::collect):
+ (JSC::Heap::canonicalizeBlocks):
+ (JSC::Heap::resetAllocator):
+ (JSC::Heap::allocateBlock):
+ (JSC::Heap::freeBlocks):
+ (JSC::Heap::shrink):
+ * heap/Heap.h:
+ (JSC::Heap::markedSpace):
+ (JSC::Heap::forEachCell):
+ (JSC::Heap::forEachBlock):
+ (JSC::Heap::sizeClassFor):
+ (JSC::Heap::allocate):
+ * jit/JITInlineMethods.h:
+ (JSC::JIT::emitAllocateBasicJSObject):
+ * runtime/JSGlobalData.cpp:
+ (JSC::JSGlobalData::recompileAllJSFunctions):
+ (JSC::JSGlobalData::releaseExecutableMemory):
+
2011-09-19 Gavin Barraclough <barraclough@apple.com>
Errrk, missed stylebot comments in last commit.
Source/JavaScriptCore/dfg/DFGScoreBoard.h \
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp \
Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h \
- Source/JavaScriptCore/heap/AllocationSpace.cpp \
- Source/JavaScriptCore/heap/AllocationSpace.h \
Source/JavaScriptCore/heap/ConservativeRoots.cpp \
Source/JavaScriptCore/heap/ConservativeRoots.h \
Source/JavaScriptCore/heap/Handle.h \
__ZN3JSC11JSByteArray13s_defaultInfoE
__ZN3JSC11JSByteArray15createStructureERNS_12JSGlobalDataEPNS_14JSGlobalObjectENS_7JSValueEPKNS_9ClassInfoE
__ZN3JSC11JSByteArrayC1EPNS_9ExecStateEPNS_9StructureEPN3WTF9ByteArrayE
-__ZN3JSC15AllocationSpace16allocateSlowCaseERNS_11MarkedSpace9SizeClassE
__ZN3JSC11ParserArena5resetEv
__ZN3JSC11checkSyntaxEPNS_9ExecStateERKNS_10SourceCodeEPNS_7JSValueE
__ZN3JSC11createErrorEPNS_9ExecStateERKNS_7UStringE
__ZN3JSC41constructFunctionSkippingEvalEnabledCheckEPNS_9ExecStateEPNS_14JSGlobalObjectERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
__ZN3JSC4Heap11objectCountEv
__ZN3JSC4Heap16activityCallbackEv
+__ZN3JSC4Heap16allocateSlowCaseERNS_11MarkedSpace9SizeClassE
__ZN3JSC4Heap16objectTypeCountsEv
__ZN3JSC4Heap17collectAllGarbageEv
__ZN3JSC4Heap17globalObjectCountEv
'API/OpaqueJSString.h',
'assembler/MacroAssemblerCodeRef.h',
'bytecode/Opcode.h',
- 'heap/AllocationSpace.h',
'heap/ConservativeRoots.h',
'heap/Handle.h',
'heap/HandleHeap.h',
'bytecompiler/LabelScope.h',
'bytecompiler/NodesCodegen.cpp',
'bytecompiler/RegisterID.h',
- 'heap/AllocationSpace.cpp',
'heap/ConservativeRoots.cpp',
'heap/HandleHeap.cpp',
'heap/HandleStack.cpp',
bytecode/ValueProfile.cpp \
bytecompiler/BytecodeGenerator.cpp \
bytecompiler/NodesCodegen.cpp \
- heap/AllocationSpace.cpp \
heap/ConservativeRoots.cpp \
heap/HandleHeap.cpp \
heap/HandleStack.cpp \
?addPropertyWithoutTransition@Structure@JSC@@QAEIAAVJSGlobalData@2@ABVIdentifier@2@IPAVJSCell@2@@Z
?addSlowCase@Identifier@JSC@@CA?AV?$PassRefPtr@VStringImpl@WTF@@@WTF@@PAVExecState@2@PAVStringImpl@4@@Z
?addStaticGlobals@JSGlobalObject@JSC@@IAEXPAUGlobalPropertyInfo@12@H@Z
- ?allocate@AllocationSpace@JSC@@QAEPAXAAUSizeClass@MarkedSpace@2@@Z
+ ?allocate@Heap@JSC@@QAEPAXAAUSizeClass@MarkedSpace@2@@Z
?allocatePropertyStorage@JSObject@JSC@@QAEXAAVJSGlobalData@2@II@Z
- ?allocateSlowCase@AllocationSpace@JSC@@AAEPAXAAUSizeClass@MarkedSpace@2@@Z
+ ?allocateSlowCase@Heap@JSC@@AAEPAXAAUSizeClass@MarkedSpace@2@@Z
?append@StringBuilder@WTF@@QAEXPBDI@Z
?append@StringBuilder@WTF@@QAEXPB_WI@Z
?ascii@UString@JSC@@QBE?AVCString@WTF@@XZ
Name="heap"
>
<File
- RelativePath="..\..\heap\AllocationSpace.cpp"
- >
- </File>
- <File
- RelativePath="..\..\heap\AllocationSpace.h"
- >
- </File>
- <File
RelativePath="..\..\heap\ConservativeRoots.cpp"
>
</File>
A1712B3F11C7B228007A5315 /* RegExpCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B3E11C7B228007A5315 /* RegExpCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */ = {isa = PBXBuildFile; fileRef = A1712B4011C7B235007A5315 /* RegExpKey.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1D764521354448B00C5C7C0 /* Alignment.h in Headers */ = {isa = PBXBuildFile; fileRef = A1D764511354448B00C5C7C0 /* Alignment.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A70456B01427FB910037DA68 /* AllocationSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = A70456AF1427FB150037DA68 /* AllocationSpace.h */; settings = {ATTRIBUTES = (Private, ); }; };
- A70456B11427FB950037DA68 /* AllocationSpace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A70456AE1427FB030037DA68 /* AllocationSpace.cpp */; };
A71236E51195F33C00BD2174 /* JITOpcodes32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */; };
A72700900DAC6BBC00E548D7 /* JSNotAnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A72700780DAC605600E548D7 /* JSNotAnObject.cpp */; };
A72701B90DADE94900E548D7 /* ExceptionHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = A72701B30DADE94900E548D7 /* ExceptionHelpers.h */; };
A1712B3E11C7B228007A5315 /* RegExpCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCache.h; sourceTree = "<group>"; };
A1712B4011C7B235007A5315 /* RegExpKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpKey.h; sourceTree = "<group>"; };
A1D764511354448B00C5C7C0 /* Alignment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Alignment.h; sourceTree = "<group>"; };
- A70456AE1427FB030037DA68 /* AllocationSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AllocationSpace.cpp; sourceTree = "<group>"; };
- A70456AF1427FB150037DA68 /* AllocationSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllocationSpace.h; sourceTree = "<group>"; };
A71236E41195F33C00BD2174 /* JITOpcodes32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITOpcodes32_64.cpp; sourceTree = "<group>"; };
A718F61A11754A21002465A7 /* RegExpJitTables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpJitTables.h; sourceTree = "<group>"; };
A718F8211178EB4B002465A7 /* create_regex_tables */ = {isa = PBXFileReference; explicitFileType = text.script.python; fileEncoding = 4; path = create_regex_tables; sourceTree = "<group>"; };
142E312A134FF0A600AFADB5 /* heap */ = {
isa = PBXGroup;
children = (
- A70456AF1427FB150037DA68 /* AllocationSpace.h */,
- A70456AE1427FB030037DA68 /* AllocationSpace.cpp */,
0F242DA513F3B1BB007ADD4C /* WeakReferenceHarvester.h */,
0FC815141405118D00CFA603 /* VTableSpectrum.h */,
0FC815121405118600CFA603 /* VTableSpectrum.cpp */,
A7BC0C82140608B000B1BB71 /* CheckedArithmetic.h in Headers */,
A781E359141970C700094D90 /* StorageBarrier.h in Headers */,
1A08277A142168D70090CCAC /* BinarySemaphore.h in Headers */,
- A70456B01427FB910037DA68 /* AllocationSpace.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C22C52FE13FAF6EF00B7DC0D /* fixed-dtoa.cc in Sources */,
C22C531313FAF6EF00B7DC0D /* strtod.cc in Sources */,
1A082779142168D70090CCAC /* BinarySemaphore.cpp in Sources */,
- A70456B11427FB950037DA68 /* AllocationSpace.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
return;
Recompiler recompiler(this);
- globalData->heap.objectSpace().forEachCell(recompiler);
+ globalData->heap.forEachCell(recompiler);
}
JSValue evaluateInGlobalCallFrame(const UString& script, JSValue& exception, JSGlobalObject* globalObject)
+++ /dev/null
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "AllocationSpace.h"
-
-#include "Heap.h"
-
-#define COLLECT_ON_EVERY_ALLOCATION 0
-
-namespace JSC {
-
-inline void* AllocationSpace::tryAllocate(MarkedSpace::SizeClass& sizeClass)
-{
- m_heap->m_operationInProgress = Allocation;
- void* result = m_markedSpace.allocate(sizeClass);
- m_heap->m_operationInProgress = NoOperation;
- return result;
-}
-
-void* AllocationSpace::allocateSlowCase(MarkedSpace::SizeClass& sizeClass)
-{
-#if COLLECT_ON_EVERY_ALLOCATION
- collectAllGarbage();
- ASSERT(m_heap->m_operationInProgress == NoOperation);
-#endif
-
- void* result = tryAllocate(sizeClass);
-
- if (LIKELY(result != 0))
- return result;
-
- AllocationEffort allocationEffort;
-
- if (m_markedSpace.waterMark() < m_markedSpace.highWaterMark() || !m_heap->m_isSafeToCollect)
- allocationEffort = AllocationMustSucceed;
- else
- allocationEffort = AllocationCanFail;
-
- MarkedBlock* block = allocateBlock(sizeClass.cellSize, allocationEffort);
- if (block) {
- m_markedSpace.addBlock(sizeClass, block);
- void* result = tryAllocate(sizeClass);
- ASSERT(result);
- return result;
- }
-
- m_heap->collect(Heap::DoNotSweep);
-
- result = tryAllocate(sizeClass);
-
- if (result)
- return result;
-
- ASSERT(m_markedSpace.waterMark() < m_markedSpace.highWaterMark());
-
- m_markedSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize, AllocationMustSucceed));
-
- result = tryAllocate(sizeClass);
- ASSERT(result);
- return result;
-}
-
-MarkedBlock* AllocationSpace::allocateBlock(size_t cellSize, AllocationSpace::AllocationEffort allocationEffort)
-{
- MarkedBlock* block;
-
-#if !ENABLE(LAZY_BLOCK_FREEING)
- if (allocationEffort == AllocationCanFail)
- return 0;
-
- block = MarkedBlock::create(m_heap, cellSize);
-#else
- {
- MutexLocker locker(m_heap->m_freeBlockLock);
- if (m_heap->m_numberOfFreeBlocks) {
- block = m_heap->m_freeBlocks.removeHead();
- ASSERT(block);
- m_heap->m_numberOfFreeBlocks--;
- } else
- block = 0;
- }
- if (block)
- block->initForCellSize(cellSize);
- else if (allocationEffort == AllocationCanFail)
- return 0;
- else
- block = MarkedBlock::create(m_heap, cellSize);
-#endif
-
- m_blocks.add(block);
-
- return block;
-}
-
-void AllocationSpace::freeBlocks(MarkedBlock* head)
-{
- MarkedBlock* next;
- for (MarkedBlock* block = head; block; block = next) {
- next = block->next();
-
- m_blocks.remove(block);
- block->reset();
-#if !ENABLE(LAZY_BLOCK_FREEING)
- MarkedBlock::destroy(block);
-#else
- MutexLocker locker(m_heap->m_freeBlockLock);
- m_heap->m_freeBlocks.append(block);
- m_heap->m_numberOfFreeBlocks++;
-#endif
- }
-}
-
-class TakeIfEmpty {
-public:
- typedef MarkedBlock* ReturnType;
-
- TakeIfEmpty(MarkedSpace*);
- void operator()(MarkedBlock*);
- ReturnType returnValue();
-
-private:
- MarkedSpace* m_markedSpace;
- DoublyLinkedList<MarkedBlock> m_empties;
-};
-
-inline TakeIfEmpty::TakeIfEmpty(MarkedSpace* newSpace)
- : m_markedSpace(newSpace)
-{
-}
-
-inline void TakeIfEmpty::operator()(MarkedBlock* block)
-{
- if (!block->isEmpty())
- return;
-
- m_markedSpace->removeBlock(block);
- m_empties.append(block);
-}
-
-inline TakeIfEmpty::ReturnType TakeIfEmpty::returnValue()
-{
- return m_empties.head();
-}
-
-void AllocationSpace::shrink()
-{
- // We record a temporary list of empties to avoid modifying m_blocks while iterating it.
- TakeIfEmpty takeIfEmpty(&m_markedSpace);
- freeBlocks(forEachBlock(takeIfEmpty));
-}
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AllocationSpace_h
-#define AllocationSpace_h
-
-#include "MarkedBlockSet.h"
-#include "MarkedSpace.h"
-
-#include <wtf/HashSet.h>
-
-namespace JSC {
-
-class Heap;
-class MarkedBlock;
-
-class AllocationSpace {
-public:
- AllocationSpace(Heap* heap)
- : m_heap(heap)
- , m_markedSpace(heap)
- {
- }
-
- typedef HashSet<MarkedBlock*>::iterator BlockIterator;
-
- MarkedBlockSet& blocks() { return m_blocks; }
- MarkedSpace::SizeClass& sizeClassFor(size_t bytes) { return m_markedSpace.sizeClassFor(bytes); }
- void setHighWaterMark(size_t bytes) { m_markedSpace.setHighWaterMark(bytes); }
- size_t highWaterMark() { return m_markedSpace.highWaterMark(); }
-
- template<typename Functor> typename Functor::ReturnType forEachCell(Functor&);
- template<typename Functor> typename Functor::ReturnType forEachCell();
- template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);
- template<typename Functor> typename Functor::ReturnType forEachBlock();
-
- void canonicalizeBlocks() { m_markedSpace.canonicalizeBlocks(); }
- void resetAllocator() { m_markedSpace.resetAllocator(); }
-
- void* allocate(size_t);
- void freeBlocks(MarkedBlock*);
- void shrink();
-
-private:
- enum AllocationEffort { AllocationMustSucceed, AllocationCanFail };
-
- void* allocate(MarkedSpace::SizeClass&);
- void* tryAllocate(MarkedSpace::SizeClass&);
- void* allocateSlowCase(MarkedSpace::SizeClass&);
- MarkedBlock* allocateBlock(size_t cellSize, AllocationEffort);
-
- Heap* m_heap;
- MarkedSpace m_markedSpace;
- MarkedBlockSet m_blocks;
-};
-
-template<typename Functor> inline typename Functor::ReturnType AllocationSpace::forEachCell(Functor& functor)
-{
- canonicalizeBlocks();
- BlockIterator end = m_blocks.set().end();
- for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
- (*it)->forEachCell(functor);
- return functor.returnValue();
-}
-
-template<typename Functor> inline typename Functor::ReturnType AllocationSpace::forEachCell()
-{
- Functor functor;
- return forEachCell(functor);
-}
-
-template<typename Functor> inline typename Functor::ReturnType AllocationSpace::forEachBlock(Functor& functor)
-{
- canonicalizeBlocks();
- BlockIterator end = m_blocks.set().end();
- for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
- functor(*it);
- return functor.returnValue();
-}
-
-template<typename Functor> inline typename Functor::ReturnType AllocationSpace::forEachBlock()
-{
- Functor functor;
- return forEachBlock(functor);
-}
-
-inline void* AllocationSpace::allocate(MarkedSpace::SizeClass& sizeClass)
-{
- // This is a light-weight fast path to cover the most common case.
- MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;
- if (UNLIKELY(!firstFreeCell))
- return allocateSlowCase(sizeClass);
-
- sizeClass.firstFreeCell = firstFreeCell->next;
- return firstFreeCell;
-}
-
-inline void* AllocationSpace::allocate(size_t bytes)
-{
- MarkedSpace::SizeClass& sizeClass = sizeClassFor(bytes);
- return allocate(sizeClass);
-}
-
-}
-
-#endif
#include "Tracing.h"
#include <algorithm>
+#define COLLECT_ON_EVERY_ALLOCATION 0
using namespace std;
using namespace JSC;
count(1);
}
+class TakeIfEmpty {
+public:
+ typedef MarkedBlock* ReturnType;
+
+ TakeIfEmpty(MarkedSpace*);
+ void operator()(MarkedBlock*);
+ ReturnType returnValue();
+
+private:
+ MarkedSpace* m_markedSpace;
+ DoublyLinkedList<MarkedBlock> m_empties;
+};
+
+inline TakeIfEmpty::TakeIfEmpty(MarkedSpace* newSpace)
+ : m_markedSpace(newSpace)
+{
+}
+
+inline void TakeIfEmpty::operator()(MarkedBlock* block)
+{
+ if (!block->isEmpty())
+ return;
+
+ m_markedSpace->removeBlock(block);
+ m_empties.append(block);
+}
+
+inline TakeIfEmpty::ReturnType TakeIfEmpty::returnValue()
+{
+ return m_empties.head();
+}
+
class RecordType {
public:
typedef PassOwnPtr<TypeCountSet> ReturnType;
: m_heapSize(heapSize)
, m_minBytesPerCycle(heapSizeForHint(heapSize))
, m_operationInProgress(NoOperation)
- , m_objectSpace(this)
+ , m_markedSpace(this)
, m_extraCost(0)
, m_markListSet(0)
, m_activityCallback(DefaultGCActivityCallback::create(this))
, m_isSafeToCollect(false)
, m_globalData(globalData)
{
- m_objectSpace.setHighWaterMark(m_minBytesPerCycle);
+ m_markedSpace.setHighWaterMark(m_minBytesPerCycle);
(*m_activityCallback)();
#if ENABLE(LAZY_BLOCK_FREEING)
m_numberOfFreeBlocks = 0;
// if a large value survives one garbage collection, there is not much point to
// collecting more frequently as long as it stays alive.
- if (m_extraCost > maxExtraCost && m_extraCost > m_objectSpace.highWaterMark() / 2)
+ if (m_extraCost > maxExtraCost && m_extraCost > m_markedSpace.highWaterMark() / 2)
collectAllGarbage();
m_extraCost += cost;
}
+inline void* Heap::tryAllocate(MarkedSpace::SizeClass& sizeClass)
+{
+ m_operationInProgress = Allocation;
+ void* result = m_markedSpace.allocate(sizeClass);
+ m_operationInProgress = NoOperation;
+ return result;
+}
+
+void* Heap::allocateSlowCase(MarkedSpace::SizeClass& sizeClass)
+{
+#if COLLECT_ON_EVERY_ALLOCATION
+ collectAllGarbage();
+ ASSERT(m_operationInProgress == NoOperation);
+#endif
+
+ void* result = tryAllocate(sizeClass);
+
+ if (LIKELY(result != 0))
+ return result;
+
+ AllocationEffort allocationEffort;
+
+ if (m_markedSpace.waterMark() < m_markedSpace.highWaterMark() || !m_isSafeToCollect)
+ allocationEffort = AllocationMustSucceed;
+ else
+ allocationEffort = AllocationCanFail;
+
+ MarkedBlock* block = allocateBlock(sizeClass.cellSize, allocationEffort);
+ if (block) {
+ m_markedSpace.addBlock(sizeClass, block);
+ void* result = tryAllocate(sizeClass);
+ ASSERT(result);
+ return result;
+ }
+
+ collect(DoNotSweep);
+
+ result = tryAllocate(sizeClass);
+
+ if (result)
+ return result;
+
+ ASSERT(m_markedSpace.waterMark() < m_markedSpace.highWaterMark());
+
+ m_markedSpace.addBlock(sizeClass, allocateBlock(sizeClass.cellSize, AllocationMustSucceed));
+
+ result = tryAllocate(sizeClass);
+ ASSERT(result);
+ return result;
+}
+
void Heap::protect(JSValue k)
{
ASSERT(k);
if (m_operationInProgress != NoOperation)
CRASH();
m_operationInProgress = Collection;
- ConservativeRoots registerFileRoots(&m_objectSpace.blocks());
+ ConservativeRoots registerFileRoots(&m_blocks);
registerFile().gatherConservativeRoots(registerFileRoots);
size_t registerFileRootCount = registerFileRoots.size();
JSCell** registerRoots = registerFileRoots.roots();
// We gather conservative roots before clearing mark bits because conservative
// gathering uses the mark bits to determine whether a reference is valid.
- ConservativeRoots machineThreadRoots(&m_objectSpace.blocks());
+ ConservativeRoots machineThreadRoots(&m_blocks);
m_machineThreads.gatherConservativeRoots(machineThreadRoots, &dummy);
- ConservativeRoots registerFileRoots(&m_objectSpace.blocks());
+ ConservativeRoots registerFileRoots(&m_blocks);
registerFile().gatherConservativeRoots(registerFileRoots);
clearMarks();
void Heap::clearMarks()
{
- m_objectSpace.forEachBlock<ClearMarks>();
+ forEachBlock<ClearMarks>();
}
void Heap::sweep()
{
- m_objectSpace.forEachBlock<Sweep>();
+ forEachBlock<Sweep>();
}
size_t Heap::objectCount()
{
- return m_objectSpace.forEachBlock<MarkCount>();
+ return forEachBlock<MarkCount>();
}
size_t Heap::size()
{
- return m_objectSpace.forEachBlock<Size>();
+ return forEachBlock<Size>();
}
size_t Heap::capacity()
{
- return m_objectSpace.forEachBlock<Capacity>();
+ return forEachBlock<Capacity>();
}
size_t Heap::protectedGlobalObjectCount()
size_t Heap::globalObjectCount()
{
- return m_objectSpace.forEachCell<CountIfGlobalObject>();
+ return forEachCell<CountIfGlobalObject>();
}
size_t Heap::protectedObjectCount()
PassOwnPtr<TypeCountSet> Heap::objectTypeCounts()
{
- return m_objectSpace.forEachCell<RecordType>();
+ return forEachCell<RecordType>();
}
void Heap::collectAllGarbage()
// proportion is a bit arbitrary. A 2X multiplier gives a 1:1 (heap size :
// new bytes allocated) proportion, and seems to work well in benchmarks.
size_t proportionalBytes = 2 * size();
- m_objectSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));
+ m_markedSpace.setHighWaterMark(max(proportionalBytes, m_minBytesPerCycle));
JAVASCRIPTCORE_GC_END();
(*m_activityCallback)();
void Heap::canonicalizeBlocks()
{
- m_objectSpace.canonicalizeBlocks();
+ m_markedSpace.canonicalizeBlocks();
}
void Heap::resetAllocator()
{
m_extraCost = 0;
- m_objectSpace.resetAllocator();
+ m_markedSpace.resetAllocator();
}
void Heap::setActivityCallback(PassOwnPtr<GCActivityCallback> activityCallback)
return true;
}
+MarkedBlock* Heap::allocateBlock(size_t cellSize, Heap::AllocationEffort allocationEffort)
+{
+ MarkedBlock* block;
+
+#if !ENABLE(LAZY_BLOCK_FREEING)
+ if (allocationEffort == AllocationCanFail)
+ return 0;
+
+ block = MarkedBlock::create(this, cellSize);
+#else
+ {
+ MutexLocker locker(m_freeBlockLock);
+ if (m_numberOfFreeBlocks) {
+ block = m_freeBlocks.removeHead();
+ ASSERT(block);
+ m_numberOfFreeBlocks--;
+ } else
+ block = 0;
+ }
+ if (block)
+ block->initForCellSize(cellSize);
+ else if (allocationEffort == AllocationCanFail)
+ return 0;
+ else
+ block = MarkedBlock::create(this, cellSize);
+#endif
+
+ m_blocks.add(block);
+
+ return block;
+}
+
void Heap::freeBlocks(MarkedBlock* head)
{
- m_objectSpace.freeBlocks(head);
+ MarkedBlock* next;
+ for (MarkedBlock* block = head; block; block = next) {
+ next = block->next();
+
+ m_blocks.remove(block);
+ block->reset();
+#if !ENABLE(LAZY_BLOCK_FREEING)
+ MarkedBlock::destroy(block);
+#else
+ MutexLocker locker(m_freeBlockLock);
+ m_freeBlocks.append(block);
+ m_numberOfFreeBlocks++;
+#endif
+ }
}
void Heap::shrink()
{
- m_objectSpace.shrink();
+ // We record a temporary list of empties to avoid modifying m_blocks while iterating it.
+ TakeIfEmpty takeIfEmpty(&m_markedSpace);
+ freeBlocks(forEachBlock(takeIfEmpty));
}
#if ENABLE(LAZY_BLOCK_FREEING)
#ifndef Heap_h
#define Heap_h
-#include "AllocationSpace.h"
#include "HandleHeap.h"
#include "HandleStack.h"
#include "MarkedBlock.h"
class GCActivityCallback;
class GlobalCodeBlock;
- class Heap;
class HeapRootVisitor;
class JSCell;
class JSGlobalData;
// Heap size hint.
enum HeapSize { SmallHeap, LargeHeap };
-
+
class Heap {
WTF_MAKE_NONCOPYABLE(Heap);
public:
- friend class JIT;
static Heap* heap(JSValue); // 0 for immediate values
static Heap* heap(JSCell*);
void destroy(); // JSGlobalData must call destroy() before ~Heap().
JSGlobalData* globalData() const { return m_globalData; }
- AllocationSpace& objectSpace() { return m_objectSpace; }
+ MarkedSpace& markedSpace() { return m_markedSpace; }
MachineThreads& machineThreads() { return m_machineThreads; }
GCActivityCallback* activityCallback();
// true if an allocation or collection is in progress
inline bool isBusy();
-
- MarkedSpace::SizeClass& sizeClassForObject(size_t bytes) { return m_objectSpace.sizeClassFor(bytes); }
- void* allocate(size_t);
+ void* allocate(size_t);
+ MarkedSpace::SizeClass& sizeClassFor(size_t);
+ void* allocate(MarkedSpace::SizeClass&);
void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
void collectAllGarbage();
template<typename Functor> typename Functor::ReturnType forEachProtectedCell(Functor&);
template<typename Functor> typename Functor::ReturnType forEachProtectedCell();
+ template<typename Functor> typename Functor::ReturnType forEachCell(Functor&);
+ template<typename Functor> typename Functor::ReturnType forEachCell();
+ template<typename Functor> typename Functor::ReturnType forEachBlock(Functor&);
+ template<typename Functor> typename Functor::ReturnType forEachBlock();
HandleSlot allocateGlobalHandle() { return m_handleHeap.allocate(); }
HandleSlot allocateLocalHandle() { return m_handleStack.push(); }
private:
friend class MarkedBlock;
- friend class AllocationSpace;
+
+ typedef HashSet<MarkedBlock*>::iterator BlockIterator;
static const size_t minExtraCost = 256;
static const size_t maxExtraCost = 1024 * 1024;
+ enum AllocationEffort { AllocationMustSucceed, AllocationCanFail };
+
#if ENABLE(GGC)
static void writeBarrierFastCase(const JSCell* owner, JSCell*);
#endif
void canonicalizeBlocks();
void resetAllocator();
+ MarkedBlock* allocateBlock(size_t cellSize, AllocationEffort);
void freeBlocks(MarkedBlock*);
void clearMarks();
void markProtectedObjects(HeapRootVisitor&);
void markTempSortVectors(HeapRootVisitor&);
void harvestWeakReferences();
+
+ void* tryAllocate(MarkedSpace::SizeClass&);
+ void* allocateSlowCase(MarkedSpace::SizeClass&);
enum SweepToggle { DoNotSweep, DoSweep };
void collect(SweepToggle);
const size_t m_minBytesPerCycle;
OperationInProgress m_operationInProgress;
- AllocationSpace m_objectSpace;
+ MarkedSpace m_markedSpace;
+ MarkedBlockSet m_blocks;
#if ENABLE(LAZY_BLOCK_FREEING)
DoublyLinkedList<MarkedBlock> m_freeBlocks;
return forEachProtectedCell(functor);
}
+ template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell(Functor& functor)
+ {
+ canonicalizeBlocks();
+ BlockIterator end = m_blocks.set().end();
+ for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
+ (*it)->forEachCell(functor);
+ return functor.returnValue();
+ }
+
+ template<typename Functor> inline typename Functor::ReturnType Heap::forEachCell()
+ {
+ Functor functor;
+ return forEachCell(functor);
+ }
+
+ template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock(Functor& functor)
+ {
+ canonicalizeBlocks();
+ BlockIterator end = m_blocks.set().end();
+ for (BlockIterator it = m_blocks.set().begin(); it != end; ++it)
+ functor(*it);
+ return functor.returnValue();
+ }
+
+ template<typename Functor> inline typename Functor::ReturnType Heap::forEachBlock()
+ {
+ Functor functor;
+ return forEachBlock(functor);
+ }
+
+ inline MarkedSpace::SizeClass& Heap::sizeClassFor(size_t bytes)
+ {
+ return m_markedSpace.sizeClassFor(bytes);
+ }
+
+ inline void* Heap::allocate(MarkedSpace::SizeClass& sizeClass)
+ {
+ // This is a light-weight fast path to cover the most common case.
+ MarkedBlock::FreeCell* firstFreeCell = sizeClass.firstFreeCell;
+ if (UNLIKELY(!firstFreeCell))
+ return allocateSlowCase(sizeClass);
+
+ sizeClass.firstFreeCell = firstFreeCell->next;
+ return firstFreeCell;
+ }
+
inline void* Heap::allocate(size_t bytes)
{
ASSERT(isValidAllocation(bytes));
- return m_objectSpace.allocate(bytes);
+ MarkedSpace::SizeClass& sizeClass = sizeClassFor(bytes);
+ return allocate(sizeClass);
}
} // namespace JSC
template <typename ClassType, typename StructureType> inline void JIT::emitAllocateBasicJSObject(StructureType structure, void* vtable, RegisterID result, RegisterID storagePtr)
{
- MarkedSpace::SizeClass* sizeClass = &m_globalData->heap.sizeClassForObject(sizeof(ClassType));
+ MarkedSpace::SizeClass* sizeClass = &m_globalData->heap.sizeClassFor(sizeof(ClassType));
loadPtr(&sizeClass->firstFreeCell, result);
addSlowCase(branchTestPtr(Zero, result));
// up throwing away code that is live on the stack.
ASSERT(!dynamicGlobalObject);
- heap.objectSpace().forEachCell<Recompiler>();
+ heap.forEachCell<Recompiler>();
}
struct StackPreservingRecompiler : public MarkedBlock::VoidFunctor {
recompiler.currentlyExecutingFunctions.add(static_cast<FunctionExecutable*>(executable));
}
- heap.objectSpace().forEachCell<StackPreservingRecompiler>(recompiler);
+ heap.forEachCell<StackPreservingRecompiler>(recompiler);
}
m_regExpCache->invalidateCode();
heap.collectAllGarbage();
+2011-09-19 Sheriff Bot <webkit.review.bot@gmail.com>
+
+ Unreviewed, rolling out r95493 and r95496.
+ http://trac.webkit.org/changeset/95493
+ http://trac.webkit.org/changeset/95496
+ https://bugs.webkit.org/show_bug.cgi?id=68418
+
+ Broke Windows build (Requested by rniwa on #webkit).
+
+ * ForwardingHeaders/heap/AllocationSpace.h: Removed.
+
2011-09-19 James Robinson <jamesr@chromium.org>
[chromium] ContentLayer's texture updater deleted during paint when compositing turns off in the middle of paint
+++ /dev/null
-#ifndef WebCore_FWD_AllocationSpace_h
-#define WebCore_FWD_AllocationSpace_h
-#include <JavaScriptCore/AllocationSpace.h>
-#endif