diff options
Diffstat (limited to 'Source/JavaScriptCore/heap/CodeBlockSet.h')
-rw-r--r-- | Source/JavaScriptCore/heap/CodeBlockSet.h | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/Source/JavaScriptCore/heap/CodeBlockSet.h b/Source/JavaScriptCore/heap/CodeBlockSet.h index 791d18699..56507c052 100644 --- a/Source/JavaScriptCore/heap/CodeBlockSet.h +++ b/Source/JavaScriptCore/heap/CodeBlockSet.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,16 +26,20 @@ #ifndef CodeBlockSet_h #define CodeBlockSet_h +#include "GCSegmentedArray.h" +#include "HeapOperation.h" #include <wtf/HashSet.h> +#include <wtf/Lock.h> #include <wtf/Noncopyable.h> #include <wtf/PassRefPtr.h> +#include <wtf/PrintStream.h> #include <wtf/RefPtr.h> -#include <wtf/Vector.h> namespace JSC { class CodeBlock; class Heap; +class JSCell; class SlotVisitor; // CodeBlockSet tracks all CodeBlocks. Every CodeBlock starts out with one @@ -48,47 +52,61 @@ class CodeBlockSet { public: CodeBlockSet(); ~CodeBlockSet(); + + void lastChanceToFinalize(); // Add a CodeBlock. This is only called by CodeBlock constructors. - void add(PassRefPtr<CodeBlock>); - - // Clear all mark bits associated with DFG code blocks. - void clearMarks(); + void add(CodeBlock*); + // Clear all mark bits for all CodeBlocks. + void clearMarksForFullCollection(); + // Mark a pointer that may be a CodeBlock that belongs to the set of DFG // blocks. This is defined in CodeBlock.h. - void mark(void* candidateCodeBlock); +private: + void mark(const LockHolder&, CodeBlock* candidateCodeBlock); +public: + void mark(const LockHolder&, void* candidateCodeBlock); // Delete all code blocks that are only referenced by this set (i.e. owned // by this set), and that have not been marked. - void deleteUnmarkedAndUnreferenced(); + void deleteUnmarkedAndUnreferenced(HeapOperation); - // Trace all marked code blocks. The CodeBlock is free to make use of - // mayBeExecuting. - void traceMarked(SlotVisitor&); - // Add all currently executing CodeBlocks to the remembered set to be // re-scanned during the next collection. - void rememberCurrentlyExecutingCodeBlocks(Heap*); + void writeBarrierCurrentlyExecutingCodeBlocks(Heap*); + + bool contains(const LockHolder&, void* candidateCodeBlock); + Lock& getLock() { return m_lock; } // Visits each CodeBlock in the heap until the visitor function returns true // to indicate that it is done iterating, or until every CodeBlock has been // visited. template<typename Functor> void iterate(Functor& functor) { - for (auto &codeBlock : m_set) { + LockHolder locker(m_lock); + for (auto& codeBlock : m_oldCodeBlocks) { bool done = functor(codeBlock); if (done) - break; + return; + } + + for (auto& codeBlock : m_newCodeBlocks) { + bool done = functor(codeBlock); + if (done) + return; } } + + void dump(PrintStream&) const; private: - // This is not a set of RefPtr<CodeBlock> because we need to be able to find - // arbitrary bogus pointers. I could have written a thingy that had peek types - // and all, but that seemed like overkill. - HashSet<CodeBlock* > m_set; - Vector<CodeBlock*> m_currentlyExecuting; + void promoteYoungCodeBlocks(const LockHolder&); + + HashSet<CodeBlock*> m_oldCodeBlocks; + HashSet<CodeBlock*> m_newCodeBlocks; + HashSet<CodeBlock*> m_currentlyExecuting; + Lock m_lock; }; } // namespace JSC |