diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/JavaScriptCore/heap/MarkStack.cpp | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore/heap/MarkStack.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/MarkStack.cpp | 78 |
1 files changed, 12 insertions, 66 deletions
diff --git a/Source/JavaScriptCore/heap/MarkStack.cpp b/Source/JavaScriptCore/heap/MarkStack.cpp index 39907c715..318183a80 100644 --- a/Source/JavaScriptCore/heap/MarkStack.cpp +++ b/Source/JavaScriptCore/heap/MarkStack.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2009, 2011, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,69 +25,14 @@ #include "config.h" #include "MarkStack.h" -#include "MarkStackInlines.h" - -#include "ConservativeRoots.h" -#include "CopiedSpace.h" -#include "CopiedSpaceInlines.h" -#include "Heap.h" -#include "JSArray.h" -#include "JSCell.h" -#include "JSObject.h" - -#include "SlotVisitorInlines.h" -#include "Structure.h" -#include "WriteBarrier.h" -#include <wtf/Atomics.h> -#include <wtf/DataLog.h> -#include <wtf/MainThread.h> -namespace JSC { - -COMPILE_ASSERT(MarkStackSegment::blockSize == WeakBlock::blockSize, blockSizeMatch); - -MarkStackArray::MarkStackArray(BlockAllocator& blockAllocator) - : m_blockAllocator(blockAllocator) - , m_top(0) - , m_numberOfSegments(0) -{ - m_segments.push(MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>())); - m_numberOfSegments++; -} +#include "JSCInlines.h" -MarkStackArray::~MarkStackArray() -{ - ASSERT(m_numberOfSegments == 1 && m_segments.size() == 1); - m_blockAllocator.deallocate(MarkStackSegment::destroy(m_segments.removeHead())); -} - -void MarkStackArray::expand() -{ - ASSERT(m_segments.head()->m_top == s_segmentCapacity); - - MarkStackSegment* nextSegment = MarkStackSegment::create(m_blockAllocator.allocate<MarkStackSegment>()); - m_numberOfSegments++; - -#if !ASSERT_DISABLED - nextSegment->m_top = 0; -#endif - - m_segments.push(nextSegment); - setTopForEmptySegment(); - validatePrevious(); -} +namespace JSC { -bool MarkStackArray::refill() +MarkStackArray::MarkStackArray() + : GCSegmentedArray<const JSCell*>() { - validatePrevious(); - if (top()) - return true; - m_blockAllocator.deallocate(MarkStackSegment::destroy(m_segments.removeHead())); - ASSERT(m_numberOfSegments > 1); - m_numberOfSegments--; - setTopForFullSegment(); - validatePrevious(); - return true; } void MarkStackArray::donateSomeCellsTo(MarkStackArray& other) @@ -112,11 +57,11 @@ void MarkStackArray::donateSomeCellsTo(MarkStackArray& other) // Remove our head and the head of the other list before we start moving segments around. // We'll add them back on once we're done donating. - MarkStackSegment* myHead = m_segments.removeHead(); - MarkStackSegment* otherHead = other.m_segments.removeHead(); + GCArraySegment<const JSCell*>* myHead = m_segments.removeHead(); + GCArraySegment<const JSCell*>* otherHead = other.m_segments.removeHead(); while (segmentsToDonate--) { - MarkStackSegment* current = m_segments.removeHead(); + GCArraySegment<const JSCell*>* current = m_segments.removeHead(); ASSERT(current); ASSERT(m_numberOfSegments > 1); other.m_segments.push(current); @@ -144,8 +89,8 @@ void MarkStackArray::stealSomeCellsFrom(MarkStackArray& other, size_t idleThread // If other has an entire segment, steal it and return. if (other.m_numberOfSegments > 1) { // Move the heads of the lists aside. We'll push them back on after. - MarkStackSegment* otherHead = other.m_segments.removeHead(); - MarkStackSegment* myHead = m_segments.removeHead(); + GCArraySegment<const JSCell*>* otherHead = other.m_segments.removeHead(); + GCArraySegment<const JSCell*>* myHead = m_segments.removeHead(); ASSERT(other.m_segments.head()->m_top == s_segmentCapacity); @@ -162,7 +107,8 @@ void MarkStackArray::stealSomeCellsFrom(MarkStackArray& other, size_t idleThread return; } - size_t numberOfCellsToSteal = (other.size() + idleThreadCount - 1) / idleThreadCount; // Round up to steal 1 / 1. + // Steal ceil(other.size() / idleThreadCount) things. + size_t numberOfCellsToSteal = (other.size() + idleThreadCount - 1) / idleThreadCount; while (numberOfCellsToSteal-- > 0 && other.canRemoveLast()) append(other.removeLast()); } |