diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/heap/ConservativeRoots.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/heap/ConservativeRoots.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/ConservativeRoots.cpp | 87 |
1 files changed, 40 insertions, 47 deletions
diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.cpp b/Source/JavaScriptCore/heap/ConservativeRoots.cpp index 7fc8eee3f..554c9c230 100644 --- a/Source/JavaScriptCore/heap/ConservativeRoots.cpp +++ b/Source/JavaScriptCore/heap/ConservativeRoots.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2016 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,70 +27,61 @@ #include "ConservativeRoots.h" #include "CodeBlock.h" -#include "CodeBlockSet.h" -#include "CopiedSpace.h" -#include "CopiedSpaceInlines.h" +#include "CodeBlockSetInlines.h" +#include "HeapInlines.h" +#include "HeapUtil.h" +#include "JITStubRoutineSet.h" #include "JSCell.h" #include "JSObject.h" +#include "JSCInlines.h" +#include "MarkedBlockInlines.h" #include "Structure.h" +#include <wtf/OSAllocator.h> namespace JSC { -ConservativeRoots::ConservativeRoots(const MarkedBlockSet* blocks, CopiedSpace* copiedSpace) +ConservativeRoots::ConservativeRoots(Heap& heap) : m_roots(m_inlineRoots) , m_size(0) , m_capacity(inlineCapacity) - , m_blocks(blocks) - , m_copiedSpace(copiedSpace) + , m_heap(heap) { } ConservativeRoots::~ConservativeRoots() { if (m_roots != m_inlineRoots) - OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*)); + OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(HeapCell*)); } void ConservativeRoots::grow() { size_t newCapacity = m_capacity == inlineCapacity ? nonInlineCapacity : m_capacity * 2; - JSCell** newRoots = static_cast<JSCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(JSCell*))); - memcpy(newRoots, m_roots, m_size * sizeof(JSCell*)); + HeapCell** newRoots = static_cast<HeapCell**>(OSAllocator::reserveAndCommit(newCapacity * sizeof(HeapCell*))); + memcpy(newRoots, m_roots, m_size * sizeof(HeapCell*)); if (m_roots != m_inlineRoots) - OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(JSCell*)); + OSAllocator::decommitAndRelease(m_roots, m_capacity * sizeof(HeapCell*)); m_capacity = newCapacity; m_roots = newRoots; } template<typename MarkHook> -inline void ConservativeRoots::genericAddPointer(void* p, TinyBloomFilter filter, MarkHook& markHook) +inline void ConservativeRoots::genericAddPointer(void* p, HeapVersion markingVersion, TinyBloomFilter filter, MarkHook& markHook) { 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)) - return; - - if (m_size == m_capacity) - grow(); - - m_roots[m_size++] = static_cast<JSCell*>(p); + HeapUtil::findGCObjectPointersForMarking( + m_heap, markingVersion, filter, p, + [&] (void* p) { + if (m_size == m_capacity) + grow(); + + m_roots[m_size++] = bitwise_cast<HeapCell*>(p); + }); } template<typename MarkHook> +SUPPRESS_ASAN void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook) { if (begin > end) { @@ -99,13 +90,13 @@ void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHoo end = swapTemp; } - ASSERT((static_cast<char*>(end) - static_cast<char*>(begin)) < 0x1000000); - ASSERT(isPointerAligned(begin)); - ASSERT(isPointerAligned(end)); + 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. + TinyBloomFilter filter = m_heap.objectSpace().blocks().filter(); // Make a local copy of filter to show the compiler it won't alias, and can be register-allocated. + HeapVersion markingVersion = m_heap.objectSpace().markingVersion(); for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it) - genericAddPointer(*it, filter, markHook); + genericAddPointer(*it, markingVersion, filter, markHook); } class DummyMarkHook { @@ -124,30 +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, CodeBlockSet& codeBlocks) { - CompositeMarkHook<JITStubRoutineSet, CodeBlockSet> markHook(jitStubRoutines, codeBlocks); + LockHolder locker(codeBlocks.getLock()); + CompositeMarkHook markHook(jitStubRoutines, codeBlocks, locker); genericAddSpan(begin, end, markHook); } |