From 41386e9cb918eed93b3f13648cbef387e371e451 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 20 May 2015 09:56:07 +0000 Subject: webkitgtk-2.4.9 --- Source/JavaScriptCore/heap/CodeBlockSet.cpp | 117 +++++++--------------------- 1 file changed, 30 insertions(+), 87 deletions(-) (limited to 'Source/JavaScriptCore/heap/CodeBlockSet.cpp') 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 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::iterator iter = m_set.begin(); + HashSet::iterator end = m_set.end(); + for (; iter != end; ++iter) + (*iter)->deref(); } void CodeBlockSet::add(PassRefPtr 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::iterator iter = m_set.begin(); + HashSet::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& 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(jsDynamicCast(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& 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 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::iterator iter = m_set.begin(); + HashSet::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::iterator iter = m_set.begin(); + HashSet::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 -- cgit v1.2.1