diff options
Diffstat (limited to 'Source/JavaScriptCore/heap/ConservativeRoots.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/ConservativeRoots.cpp | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.cpp b/Source/JavaScriptCore/heap/ConservativeRoots.cpp index 752ce2775..e1e12002e 100644 --- a/Source/JavaScriptCore/heap/ConservativeRoots.cpp +++ b/Source/JavaScriptCore/heap/ConservativeRoots.cpp @@ -27,16 +27,19 @@ #include "ConservativeRoots.h" #include "CodeBlock.h" +#include "CodeBlockSet.h" #include "CopiedSpace.h" #include "CopiedSpaceInlines.h" -#include "DFGCodeBlocks.h" +#include "HeapInlines.h" #include "JSCell.h" #include "JSObject.h" +#include "JSCInlines.h" #include "Structure.h" +#include <wtf/OSAllocator.h> namespace JSC { -ConservativeRoots::ConservativeRoots(const MarkedBlockSet* blocks, CopiedSpace* copiedSpace) +ConservativeRoots::ConservativeRoots(MarkedBlockSet* blocks, CopiedSpace* copiedSpace) : m_roots(m_inlineRoots) , m_size(0) , m_capacity(inlineCapacity) @@ -68,20 +71,8 @@ inline void ConservativeRoots::genericAddPointer(void* p, TinyBloomFilter filter markHook.mark(p); m_copiedSpace->pinIfNecessary(p); - - MarkedBlock* candidate = MarkedBlock::blockFor(p); - if (filter.ruleOut(reinterpret_cast<Bits>(candidate))) { - ASSERT(!candidate || !m_blocks->set().contains(candidate)); - return; - } - - if (!MarkedBlock::isAtomAligned(p)) - return; - if (!m_blocks->set().contains(candidate)) - return; - - if (!candidate->isLiveCell(p)) + if (!Heap::isPointerGCObject(filter, *m_blocks, p)) return; if (m_size == m_capacity) @@ -91,12 +82,17 @@ inline void ConservativeRoots::genericAddPointer(void* p, TinyBloomFilter filter } template<typename MarkHook> +SUPPRESS_ASAN void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook) { - ASSERT(begin <= end); - ASSERT((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000); - ASSERT(isPointerAligned(begin)); - ASSERT(isPointerAligned(end)); + if (begin > end) { + void* swapTemp = begin; + begin = end; + end = swapTemp; + } + + RELEASE_ASSERT(isPointerAligned(begin)); + RELEASE_ASSERT(isPointerAligned(end)); TinyBloomFilter filter = m_blocks->filter(); // Make a local copy of filter to show the compiler it won't alias, and can be register-allocated. for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it) @@ -119,31 +115,32 @@ void ConservativeRoots::add(void* begin, void* end, JITStubRoutineSet& jitStubRo genericAddSpan(begin, end, jitStubRoutines); } -template<typename T, typename U> class CompositeMarkHook { public: - CompositeMarkHook(T& first, U& second) - : m_first(first) - , m_second(second) + CompositeMarkHook(JITStubRoutineSet& stubRoutines, CodeBlockSet& codeBlocks, const LockHolder& locker) + : m_stubRoutines(stubRoutines) + , m_codeBlocks(codeBlocks) + , m_codeBlocksLocker(locker) { } void mark(void* address) { - m_first.mark(address); - m_second.mark(address); + m_stubRoutines.mark(address); + m_codeBlocks.mark(m_codeBlocksLocker, address); } private: - T& m_first; - U& m_second; + JITStubRoutineSet& m_stubRoutines; + CodeBlockSet& m_codeBlocks; + const LockHolder& m_codeBlocksLocker; }; void ConservativeRoots::add( - void* begin, void* end, JITStubRoutineSet& jitStubRoutines, DFGCodeBlocks& dfgCodeBlocks) + void* begin, void* end, JITStubRoutineSet& jitStubRoutines, CodeBlockSet& codeBlocks) { - CompositeMarkHook<JITStubRoutineSet, DFGCodeBlocks> markHook( - jitStubRoutines, dfgCodeBlocks); + LockHolder locker(codeBlocks.getLock()); + CompositeMarkHook markHook(jitStubRoutines, codeBlocks, locker); genericAddSpan(begin, end, markHook); } |