diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/heap/CodeBlockSet.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/heap/CodeBlockSet.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/CodeBlockSet.cpp | 117 |
1 files changed, 30 insertions, 87 deletions
diff --git a/Source/JavaScriptCore/heap/CodeBlockSet.cpp b/Source/JavaScriptCore/heap/CodeBlockSet.cpp index 9cfce4f97..c04cbacd6 100644 --- a/Source/JavaScriptCore/heap/CodeBlockSet.cpp +++ b/Source/JavaScriptCore/heap/CodeBlockSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,79 +27,54 @@ #include "CodeBlockSet.h" #include "CodeBlock.h" -#include "JSCInlines.h" #include "SlotVisitor.h" -#include <wtf/CommaPrinter.h> namespace JSC { static const bool verbose = false; -CodeBlockSet::CodeBlockSet() -{ -} +CodeBlockSet::CodeBlockSet() { } CodeBlockSet::~CodeBlockSet() { - for (CodeBlock* codeBlock : m_oldCodeBlocks) - codeBlock->deref(); - - for (CodeBlock* codeBlock : m_newCodeBlocks) - codeBlock->deref(); + HashSet<CodeBlock*>::iterator iter = m_set.begin(); + HashSet<CodeBlock*>::iterator end = m_set.end(); + for (; iter != end; ++iter) + (*iter)->deref(); } void CodeBlockSet::add(PassRefPtr<CodeBlock> codeBlock) { CodeBlock* block = codeBlock.leakRef(); - bool isNewEntry = m_newCodeBlocks.add(block).isNewEntry; + bool isNewEntry = m_set.add(block).isNewEntry; ASSERT_UNUSED(isNewEntry, isNewEntry); } -void CodeBlockSet::promoteYoungCodeBlocks() -{ - m_oldCodeBlocks.add(m_newCodeBlocks.begin(), m_newCodeBlocks.end()); - m_newCodeBlocks.clear(); -} - -void CodeBlockSet::clearMarksForFullCollection() +void CodeBlockSet::clearMarks() { - for (CodeBlock* codeBlock : m_oldCodeBlocks) { + HashSet<CodeBlock*>::iterator iter = m_set.begin(); + HashSet<CodeBlock*>::iterator end = m_set.end(); + for (; iter != end; ++iter) { + CodeBlock* codeBlock = *iter; codeBlock->m_mayBeExecuting = false; - codeBlock->m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); - } - - // We promote after we clear marks on the old generation CodeBlocks because - // none of the young generations CodeBlocks need to be cleared. - promoteYoungCodeBlocks(); -} - -void CodeBlockSet::clearMarksForEdenCollection(const Vector<const JSCell*>& rememberedSet) -{ - // This ensures that we will revisit CodeBlocks in remembered Executables even if they were previously marked. - for (const JSCell* cell : rememberedSet) { - ScriptExecutable* executable = const_cast<ScriptExecutable*>(jsDynamicCast<const ScriptExecutable*>(cell)); - if (!executable) - continue; - executable->forEachCodeBlock([](CodeBlock* codeBlock) { - codeBlock->m_mayBeExecuting = false; - codeBlock->m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); - }); + codeBlock->m_visitAggregateHasBeenCalled = false; } } -void CodeBlockSet::deleteUnmarkedAndUnreferenced(HeapOperation collectionType) +void CodeBlockSet::deleteUnmarkedAndUnreferenced() { - HashSet<CodeBlock*>& set = collectionType == EdenCollection ? m_newCodeBlocks : m_oldCodeBlocks; - // This needs to be a fixpoint because code blocks that are unmarked may // refer to each other. For example, a DFG code block that is owned by // the GC may refer to an FTL for-entry code block that is also owned by // the GC. Vector<CodeBlock*, 16> toRemove; if (verbose) - dataLog("Fixpointing over unmarked, set size = ", set.size(), "...\n"); + dataLog("Fixpointing over unmarked, set size = ", m_set.size(), "...\n"); for (;;) { - for (CodeBlock* codeBlock : set) { + HashSet<CodeBlock*>::iterator iter = m_set.begin(); + HashSet<CodeBlock*>::iterator end = m_set.end(); + for (; iter != end; ++iter) { + CodeBlock* codeBlock = *iter; if (!codeBlock->hasOneRef()) continue; if (codeBlock->m_mayBeExecuting) @@ -111,33 +86,22 @@ void CodeBlockSet::deleteUnmarkedAndUnreferenced(HeapOperation collectionType) dataLog(" Removing ", toRemove.size(), " blocks.\n"); if (toRemove.isEmpty()) break; - for (CodeBlock* codeBlock : toRemove) - set.remove(codeBlock); + for (unsigned i = toRemove.size(); i--;) + m_set.remove(toRemove[i]); toRemove.resize(0); } - - // Any remaining young CodeBlocks are live and need to be promoted to the set of old CodeBlocks. - if (collectionType == EdenCollection) - promoteYoungCodeBlocks(); -} - -void CodeBlockSet::remove(CodeBlock* codeBlock) -{ - codeBlock->deref(); - if (m_oldCodeBlocks.contains(codeBlock)) { - m_oldCodeBlocks.remove(codeBlock); - return; - } - ASSERT(m_newCodeBlocks.contains(codeBlock)); - m_newCodeBlocks.remove(codeBlock); } void CodeBlockSet::traceMarked(SlotVisitor& visitor) { if (verbose) - dataLog("Tracing ", m_currentlyExecuting.size(), " code blocks.\n"); - for (CodeBlock* codeBlock : m_currentlyExecuting) { - ASSERT(codeBlock->m_mayBeExecuting); + dataLog("Tracing ", m_set.size(), " code blocks.\n"); + HashSet<CodeBlock*>::iterator iter = m_set.begin(); + HashSet<CodeBlock*>::iterator end = m_set.end(); + for (; iter != end; ++iter) { + CodeBlock* codeBlock = *iter; + if (!codeBlock->m_mayBeExecuting) + continue; codeBlock->visitAggregate(visitor); } } @@ -145,34 +109,13 @@ void CodeBlockSet::traceMarked(SlotVisitor& visitor) void CodeBlockSet::rememberCurrentlyExecutingCodeBlocks(Heap* heap) { #if ENABLE(GGC) - if (verbose) - dataLog("Remembering ", m_currentlyExecuting.size(), " code blocks.\n"); - for (CodeBlock* codeBlock : m_currentlyExecuting) { - heap->addToRememberedSet(codeBlock->ownerExecutable()); - ASSERT(codeBlock->m_mayBeExecuting); - } + for (size_t i = 0; i < m_currentlyExecuting.size(); ++i) + heap->addToRememberedSet(m_currentlyExecuting[i]->ownerExecutable()); m_currentlyExecuting.clear(); #else UNUSED_PARAM(heap); #endif // ENABLE(GGC) } -void CodeBlockSet::dump(PrintStream& out) const -{ - CommaPrinter comma; - out.print("{old = ["); - for (CodeBlock* codeBlock : m_oldCodeBlocks) - out.print(comma, pointerDump(codeBlock)); - out.print("], new = ["); - comma = CommaPrinter(); - for (CodeBlock* codeBlock : m_newCodeBlocks) - out.print(comma, pointerDump(codeBlock)); - out.print("], currentlyExecuting = ["); - comma = CommaPrinter(); - for (CodeBlock* codeBlock : m_currentlyExecuting) - out.print(comma, pointerDump(codeBlock)); - out.print("]}"); -} - } // namespace JSC |