summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/ConservativeRoots.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/heap/ConservativeRoots.cpp')
-rw-r--r--Source/JavaScriptCore/heap/ConservativeRoots.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/Source/JavaScriptCore/heap/ConservativeRoots.cpp b/Source/JavaScriptCore/heap/ConservativeRoots.cpp
index 7fc8eee3f..e1e12002e 100644
--- a/Source/JavaScriptCore/heap/ConservativeRoots.cpp
+++ b/Source/JavaScriptCore/heap/ConservativeRoots.cpp
@@ -30,13 +30,16 @@
#include "CodeBlockSet.h"
#include "CopiedSpace.h"
#include "CopiedSpaceInlines.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,6 +82,7 @@ inline void ConservativeRoots::genericAddPointer(void* p, TinyBloomFilter filter
}
template<typename MarkHook>
+SUPPRESS_ASAN
void ConservativeRoots::genericAddSpan(void* begin, void* end, MarkHook& markHook)
{
if (begin > end) {
@@ -99,9 +91,8 @@ 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.
for (char** it = static_cast<char**>(begin); it != static_cast<char**>(end); ++it)
@@ -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);
}