Begin to remove heap/* This makes Sky never call into the Heap::init/shutdown methods and removes most Heap:: and ThreadState:: calls throughout the rest of Sky. There is a *ton* more to remove after this. R=abarth@chromium.org Review URL: https://codereview.chromium.org/678003003
diff --git a/sky/engine/bindings/core/v8/V8Binding.h b/sky/engine/bindings/core/v8/V8Binding.h index 2e8eda3..bbd141c 100644 --- a/sky/engine/bindings/core/v8/V8Binding.h +++ b/sky/engine/bindings/core/v8/V8Binding.h
@@ -41,7 +41,6 @@ #include "bindings/core/v8/V8StringResource.h" #include "bindings/core/v8/V8ThrowException.h" #include "bindings/core/v8/V8ValueCache.h" -#include "platform/heap/Heap.h" #include "wtf/GetPtr.h" #include "wtf/MathExtras.h" #include "wtf/text/AtomicString.h" @@ -902,29 +901,6 @@ DeleteUnknownProperty }; -class V8IsolateInterruptor : public ThreadState::Interruptor { -public: - explicit V8IsolateInterruptor(v8::Isolate* isolate) : m_isolate(isolate) { } - - static void onInterruptCallback(v8::Isolate* isolate, void* data) - { - reinterpret_cast<V8IsolateInterruptor*>(data)->onInterrupted(); - } - - virtual void requestInterrupt() override - { - m_isolate->RequestInterrupt(&onInterruptCallback, this); - } - - virtual void clearInterrupt() override - { - m_isolate->ClearInterrupt(); - } - -private: - v8::Isolate* m_isolate; -}; - class V8TestingScope { public: explicit V8TestingScope(v8::Isolate*);
diff --git a/sky/engine/bindings/core/v8/V8GCController.cpp b/sky/engine/bindings/core/v8/V8GCController.cpp index b800dca..30dbbbc 100644 --- a/sky/engine/bindings/core/v8/V8GCController.cpp +++ b/sky/engine/bindings/core/v8/V8GCController.cpp
@@ -381,26 +381,6 @@ else if (type == v8::kGCTypeMarkSweepCompact) majorGCEpilogue(isolate); - // Forces a Blink heap garbage collection when a garbage collection - // was forced from V8. This is used for tests that force GCs from - // JavaScript to verify that objects die when expected. - if (flags & v8::kGCCallbackFlagForced) { - // This single GC is not enough for two reasons: - // (1) The GC is not precise because the GC scans on-stack pointers conservatively. - // (2) One GC is not enough to break a chain of persistent handles. It's possible that - // some heap allocated objects own objects that contain persistent handles - // pointing to other heap allocated objects. To break the chain, we need multiple GCs. - // - // Regarding (1), we force a precise GC at the end of the current event loop. So if you want - // to collect all garbage, you need to wait until the next event loop. - // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because - // GCController.collectAll() forces 7 V8's GC. - Heap::collectGarbage(ThreadState::HeapPointersOnStack); - - // Forces a precise GC at the end of the current event loop. - Heap::setForcePreciseGCForTesting(); - } - TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent", "usedHeapSizeAfter", usedHeapSize(isolate)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); }
diff --git a/sky/engine/core/Init.cpp b/sky/engine/core/Init.cpp index ce792b6..3cb60c3 100644 --- a/sky/engine/core/Init.cpp +++ b/sky/engine/core/Init.cpp
@@ -46,7 +46,6 @@ #include "platform/FontFamilyNames.h" #include "platform/Partitions.h" #include "platform/PlatformThreadData.h" -#include "platform/heap/Heap.h" #include "wtf/text/StringStatics.h" namespace blink {
diff --git a/sky/engine/core/animation/AnimationPlayerTest.cpp b/sky/engine/core/animation/AnimationPlayerTest.cpp index 28cd31a..f0a10df 100644 --- a/sky/engine/core/animation/AnimationPlayerTest.cpp +++ b/sky/engine/core/animation/AnimationPlayerTest.cpp
@@ -783,7 +783,6 @@ EXPECT_EQ(1U, element->activeAnimations()->players().find(player.get())->value); player.release(); - Heap::collectAllGarbage(); EXPECT_TRUE(element->activeAnimations()->players().isEmpty()); }
diff --git a/sky/engine/core/animation/AnimationStackTest.cpp b/sky/engine/core/animation/AnimationStackTest.cpp index 8bd19c0..24fb148 100644 --- a/sky/engine/core/animation/AnimationStackTest.cpp +++ b/sky/engine/core/animation/AnimationStackTest.cpp
@@ -126,26 +126,22 @@ WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > interpolations; updateTimeline(11); - Heap::collectAllGarbage(); interpolations = AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equals(AnimatableDouble::create(3).get())); EXPECT_EQ(3u, effects().size()); EXPECT_EQ(1u, interpolations.size()); updateTimeline(13); - Heap::collectAllGarbage(); interpolations = AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equals(AnimatableDouble::create(3).get())); EXPECT_EQ(3u, effects().size()); updateTimeline(15); - Heap::collectAllGarbage(); interpolations = AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equals(AnimatableDouble::create(3).get())); EXPECT_EQ(2u, effects().size()); updateTimeline(17); - Heap::collectAllGarbage(); interpolations = AnimationStack::activeInterpolations(&element->activeAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0); EXPECT_TRUE(interpolationValue(interpolations.get(CSSPropertyFontSize))->equals(AnimatableDouble::create(3).get())); EXPECT_EQ(1u, effects().size());
diff --git a/sky/engine/core/animation/AnimationTimelineTest.cpp b/sky/engine/core/animation/AnimationTimelineTest.cpp index c4a20e7..9edfc65 100644 --- a/sky/engine/core/animation/AnimationTimelineTest.cpp +++ b/sky/engine/core/animation/AnimationTimelineTest.cpp
@@ -101,9 +101,6 @@ document.release(); element.release(); timeline.release(); -#if ENABLE(OILPAN) - Heap::collectAllGarbage(); -#endif } void updateClockAndService(double time)
diff --git a/sky/engine/core/css/RuleSet.cpp b/sky/engine/core/css/RuleSet.cpp index 6227d14..45c4b43 100644 --- a/sky/engine/core/css/RuleSet.cpp +++ b/sky/engine/core/css/RuleSet.cpp
@@ -36,7 +36,6 @@ #include "core/css/StyleSheetContents.h" #include "platform/RuntimeEnabledFeatures.h" #include "platform/TraceEvent.h" -#include "platform/heap/HeapTerminatedArrayBuilder.h" #include "wtf/TerminatedArrayBuilder.h"
diff --git a/sky/engine/core/css/RuleSet.h b/sky/engine/core/css/RuleSet.h index ae6d060..dcfb264 100644 --- a/sky/engine/core/css/RuleSet.h +++ b/sky/engine/core/css/RuleSet.h
@@ -27,8 +27,6 @@ #include "core/css/RuleFeature.h" #include "core/css/StyleRule.h" #include "core/css/resolver/MediaQueryResult.h" -#include "platform/heap/HeapLinkedStack.h" -#include "platform/heap/HeapTerminatedArray.h" #include "wtf/Forward.h" #include "wtf/HashMap.h" #include "wtf/LinkedStack.h"
diff --git a/sky/engine/core/css/StylePropertySet.cpp b/sky/engine/core/css/StylePropertySet.cpp index 3a35fc2..2e53598 100644 --- a/sky/engine/core/css/StylePropertySet.cpp +++ b/sky/engine/core/css/StylePropertySet.cpp
@@ -48,11 +48,7 @@ PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode) { ASSERT(count <= MaxArraySize); -#if ENABLE(OILPAN) - void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertySetWithPropertyCount(count)); -#else void* slot = WTF::fastMalloc(sizeForImmutableStylePropertySetWithPropertyCount(count)); -#endif // ENABLE(OILPAN) return adoptRefWillBeNoop(new (slot) ImmutableStylePropertySet(properties, count, cssParserMode)); }
diff --git a/sky/engine/core/dom/Document.cpp b/sky/engine/core/dom/Document.cpp index fc9f747..0f754b0 100644 --- a/sky/engine/core/dom/Document.cpp +++ b/sky/engine/core/dom/Document.cpp
@@ -2755,17 +2755,6 @@ bool Document::isDelayingLoadEvent() { -#if ENABLE(OILPAN) - // Always delay load events until after garbage collection. - // This way we don't have to explicitly delay load events via - // incrementLoadEventDelayCount and decrementLoadEventDelayCount in - // Node destructors. - if (ThreadState::current()->isSweepInProgress()) { - if (!m_loadEventDelayCount) - checkLoadEventSoon(); - return true; - } -#endif return m_loadEventDelayCount; }
diff --git a/sky/engine/core/dom/DocumentTest.cpp b/sky/engine/core/dom/DocumentTest.cpp index 1c1c529..4cf4dca 100644 --- a/sky/engine/core/dom/DocumentTest.cpp +++ b/sky/engine/core/dom/DocumentTest.cpp
@@ -45,13 +45,6 @@ protected: virtual void SetUp() override; -#if ENABLE(OILPAN) - virtual void TearDown() override - { - Heap::collectAllGarbage(); - } -#endif - Document& document() const { return m_dummyPageHolder->document(); } Page& page() const { return m_dummyPageHolder->page(); }
diff --git a/sky/engine/core/dom/ElementData.cpp b/sky/engine/core/dom/ElementData.cpp index 1fe8024..1443d4b 100644 --- a/sky/engine/core/dom/ElementData.cpp +++ b/sky/engine/core/dom/ElementData.cpp
@@ -156,11 +156,7 @@ PassRefPtrWillBeRawPtr<ShareableElementData> ShareableElementData::createWithAttributes(const Vector<Attribute>& attributes) { -#if ENABLE(OILPAN) - void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttributeCount(attributes.size())); -#else void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(attributes.size())); -#endif return adoptRefWillBeNoop(new (slot) ShareableElementData(attributes)); } @@ -195,11 +191,7 @@ PassRefPtrWillBeRawPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const { -#if ENABLE(OILPAN) - void* slot = Heap::allocate<ElementData>(sizeForShareableElementDataWithAttributeCount(m_attributeVector.size())); -#else void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(m_attributeVector.size())); -#endif return adoptRefWillBeNoop(new (slot) ShareableElementData(*this)); }
diff --git a/sky/engine/core/frame/ImageBitmapTest.cpp b/sky/engine/core/frame/ImageBitmapTest.cpp index d9e08db..5be8163 100644 --- a/sky/engine/core/frame/ImageBitmapTest.cpp +++ b/sky/engine/core/frame/ImageBitmapTest.cpp
@@ -65,11 +65,6 @@ } virtual void TearDown() { - // Garbage collection is required prior to switching out the - // test's memory cache; image resources are released, evicting - // them from the cache. - Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); - replaceMemoryCacheForTesting(m_globalMemoryCache.release()); } @@ -153,9 +148,6 @@ // ImageBitmaps that do not contain any of the source image do not elevate CacheLiveResourcePriority. ASSERT_EQ(memoryCache()->priority(imageOutsideCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow); } - // Force a garbage collection to sweep out the local ImageBitmaps. - Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); - // CacheLiveResourcePriroity should return to CacheLiveResourcePriorityLow when no ImageBitmaps reference the image. ASSERT_EQ(memoryCache()->priority(imageNoCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow); ASSERT_EQ(memoryCache()->priority(imageExteriorCrop->cachedImage()), MemoryCacheLiveResourcePriorityLow);
diff --git a/sky/engine/platform/BUILD.gn b/sky/engine/platform/BUILD.gn index d242400..ddc6805 100644 --- a/sky/engine/platform/BUILD.gn +++ b/sky/engine/platform/BUILD.gn
@@ -160,8 +160,6 @@ "SharedTimer.cpp", "SharedTimer.h", "Supplementable.h", - "TaskSynchronizer.cpp", - "TaskSynchronizer.h", "ThreadTimers.cpp", "ThreadTimers.h", "Timer.cpp", @@ -649,7 +647,6 @@ ] deps = [ - ":heap_asm_stubs", ":make_platform_generated", "//base:base", "//gpu/command_buffer/client:gles2_c_lib", @@ -720,48 +717,6 @@ } } -if (cpu_arch == "x86" || cpu_arch == "x64") { - -import("//third_party/yasm/yasm_assemble.gni") - -yasm_assemble("heap_asm_stubs") { - sources = [ "heap/asm/SaveRegisters_x86.asm" ] - - yasm_flags = [] - if (is_mac) { - # Necessary to ensure symbols end up with a _ prefix; added by - # yasm_compile.gypi for Windows, but not Mac. - yasm_flags += [ "-DPREFIX" ] - } - if (cpu_arch == "x64") { - if (is_win) { - yasm_flags += [ "-DX64WIN=1" ] - } else { - yasm_flags += [ "-DX64POSIX=1" ] - } - } else if (cpu_arch == "x86") { - yasm_flags += [ "-DIA32=1" ] - } -} - -} else { # cpu_arch == "x86" || cpu_arch == "x64" - -source_set("heap_asm_stubs") { - if (cpu_arch == "arm") { - sources = [ "heap/asm/SaveRegisters_arm.S" ] - } else if (cpu_arch == "arm64") { - sources = [ "heap/asm/SaveRegisters_arm64.S" ] - } else if (cpu_arch == "mipsel") { - sources = [ "heap/asm/SaveRegisters_mips.S" ] - } - - if (cpu_arch == "arm") { - defines = [ "ARM=1" ] - } -} - -} - test("platform_unittests") { visibility += ["//sky/*"] output_name = "sky_platform_unittests"
diff --git a/sky/engine/platform/Supplementable.h b/sky/engine/platform/Supplementable.h index 4da76d8..a8c4086 100644 --- a/sky/engine/platform/Supplementable.h +++ b/sky/engine/platform/Supplementable.h
@@ -256,12 +256,6 @@ public: virtual void trace(Visitor* visitor) { - // No tracing of off-heap supplements. We should not have any Supplementable - // object on the heap. Either the object is HeapSupplementable or if it is - // off heap it should use PersistentHeapSupplementable to trace any on-heap - // supplements. - COMPILE_ASSERT(!IsGarbageCollectedType<T>::value, GarbageCollectedObjectMustBeHeapSupplementable); - SupplementableBase<T, false>::trace(visitor); } };
diff --git a/sky/engine/platform/TaskSynchronizer.cpp b/sky/engine/platform/TaskSynchronizer.cpp deleted file mode 100644 index 7cecf74..0000000 --- a/sky/engine/platform/TaskSynchronizer.cpp +++ /dev/null
@@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "platform/TaskSynchronizer.h" - -#include "heap/ThreadState.h" - -namespace blink { - -TaskSynchronizer::TaskSynchronizer() - : m_taskCompleted(false) -#if ENABLE(ASSERT) - , m_hasCheckedForTermination(false) -#endif -{ -} - -void TaskSynchronizer::waitForTaskCompletion() -{ - if (ThreadState::current()) { - // Prevent the deadlock between park request by other threads and blocking - // by m_synchronousCondition. - ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack); - waitForTaskCompletionInternal(); - } else { - // If this thread is already detached, we no longer need to enter a safe point scope. - waitForTaskCompletionInternal(); - } -} - -void TaskSynchronizer::waitForTaskCompletionInternal() -{ - m_synchronousMutex.lock(); - while (!m_taskCompleted) - m_synchronousCondition.wait(m_synchronousMutex); - m_synchronousMutex.unlock(); -} - -void TaskSynchronizer::taskCompleted() -{ - m_synchronousMutex.lock(); - m_taskCompleted = true; - m_synchronousCondition.signal(); - m_synchronousMutex.unlock(); -} - -} // namespace blink
diff --git a/sky/engine/platform/TaskSynchronizer.h b/sky/engine/platform/TaskSynchronizer.h deleted file mode 100644 index 9ffa0eb..0000000 --- a/sky/engine/platform/TaskSynchronizer.h +++ /dev/null
@@ -1,69 +0,0 @@ -/* - * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TaskSynchronizer_h -#define TaskSynchronizer_h - -#include "platform/PlatformExport.h" -#include "wtf/Noncopyable.h" -#include "wtf/Threading.h" -#include "wtf/ThreadingPrimitives.h" - -namespace blink { - -// TaskSynchronizer can be used to wait for task completion. -class PLATFORM_EXPORT TaskSynchronizer { - WTF_MAKE_NONCOPYABLE(TaskSynchronizer); -public: - TaskSynchronizer(); - - // Called from a thread that waits for the task completion. - void waitForTaskCompletion(); - - // Called from a thread that executes the task. - void taskCompleted(); - -#if ENABLE(ASSERT) - bool hasCheckedForTermination() const { return m_hasCheckedForTermination; } - void setHasCheckedForTermination() { m_hasCheckedForTermination = true; } -#endif - -private: - void waitForTaskCompletionInternal(); - - bool m_taskCompleted; - Mutex m_synchronousMutex; - ThreadCondition m_synchronousCondition; -#if ENABLE(ASSERT) - bool m_hasCheckedForTermination; -#endif -}; - -} // namespace blink - -#endif // TaskSynchronizer_h
diff --git a/sky/engine/platform/heap/Handle.h b/sky/engine/platform/heap/Handle.h index 5a650bf..17c05f2 100644 --- a/sky/engine/platform/heap/Handle.h +++ b/sky/engine/platform/heap/Handle.h
@@ -45,70 +45,6 @@ template<typename T> class HeapTerminatedArray; -// Template to determine if a class is a GarbageCollectedMixin by checking if it -// has adjustAndMark and isAlive. We can't check directly if the class is a -// GarbageCollectedMixin because casting to it is potentially ambiguous. -template<typename T> -struct IsGarbageCollectedMixin { - typedef char TrueType; - struct FalseType { - char dummy[2]; - }; - -#if COMPILER(MSVC) - template<typename U> static TrueType hasAdjustAndMark(char[&U::adjustAndMark != 0]); - template<typename U> static TrueType hasIsAlive(char[&U::isAlive != 0]); -#else - template<size_t> struct F; - template<typename U> static TrueType hasAdjustAndMark(F<sizeof(&U::adjustAndMark)>*); - template<typename U> static TrueType hasIsAlive(F<sizeof(&U::isAlive)>*); -#endif - template<typename U> static FalseType hasIsAlive(...); - template<typename U> static FalseType hasAdjustAndMark(...); - - static bool const value = (sizeof(TrueType) == sizeof(hasAdjustAndMark<T>(0))) && (sizeof(TrueType) == sizeof(hasIsAlive<T>(0))); -}; - -template <typename T> -struct IsGarbageCollectedType { - typedef char TrueType; - struct FalseType { - char dummy[2]; - }; - - typedef typename WTF::RemoveConst<T>::Type NonConstType; - typedef WTF::IsSubclassOfTemplate<NonConstType, GarbageCollected> GarbageCollectedSubclass; - typedef IsGarbageCollectedMixin<NonConstType> GarbageCollectedMixinSubclass; - typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashSet> HeapHashSetSubclass; - typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapLinkedHashSet> HeapLinkedHashSetSubclass; - typedef WTF::IsSubclassOfTemplateTypenameSizeTypename<NonConstType, HeapListHashSet> HeapListHashSetSubclass; - typedef WTF::IsSubclassOfTemplate5<NonConstType, HeapHashMap> HeapHashMapSubclass; - typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapVector> HeapVectorSubclass; - typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapDeque> HeapDequeSubclass; - typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashCountedSet> HeapHashCountedSetSubclass; - typedef WTF::IsSubclassOfTemplate<NonConstType, HeapTerminatedArray> HeapTerminatedArraySubclass; - - template<typename U, size_t inlineCapacity> static TrueType listHashSetNodeIsHeapAllocated(WTF::ListHashSetNode<U, HeapListHashSetAllocator<U, inlineCapacity> >*); - static FalseType listHashSetNodeIsHeapAllocated(...); - static const bool isHeapAllocatedListHashSetNode = sizeof(TrueType) == sizeof(listHashSetNodeIsHeapAllocated(reinterpret_cast<NonConstType*>(0))); - - static const bool value = - GarbageCollectedSubclass::value - || GarbageCollectedMixinSubclass::value - || HeapHashSetSubclass::value - || HeapLinkedHashSetSubclass::value - || HeapListHashSetSubclass::value - || HeapHashMapSubclass::value - || HeapVectorSubclass::value - || HeapDequeSubclass::value - || HeapHashCountedSetSubclass::value - || HeapTerminatedArraySubclass::value - || isHeapAllocatedListHashSetNode; -}; - -#define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \ - COMPILE_ASSERT(IsGarbageCollectedType<T>::value, ErrorMessage) - template<typename T> class Member; class PersistentNode { @@ -566,7 +502,6 @@ void trace(Visitor* visitor) { - COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInPersistent); #if ENABLE(GC_PROFILE_MARKING) visitor->setHostInfo(this, m_tracingName.isEmpty() ? "Persistent" : m_tracingName); #endif @@ -839,7 +774,6 @@ protected: void verifyTypeIsGarbageCollected() const { - COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, NonGarbageCollectedObjectInMember); } T* m_raw; @@ -902,7 +836,7 @@ // raw pointer types. To remove these tests, we may need support for // instantiating a template with a RawPtrOrMember'ish template. template<typename T> -struct TraceIfNeeded : public TraceIfEnabled<T, WTF::NeedsTracing<T>::value || blink::IsGarbageCollectedType<typename RemoveHeapPointerWrapperTypes<typename WTF::RemovePointer<T>::Type>::Type>::value> { }; +struct TraceIfNeeded : public TraceIfEnabled<T, false> { }; // This trace trait for std::pair will null weak members if their referent is // collected. If you have a collection that contain weakness it does not remove @@ -1399,11 +1333,11 @@ }; template<typename T> -struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGarbageCollectedType<T>::value> { +struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, false> { }; template<typename T> -struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, blink::IsGarbageCollectedType<T>::value> { +struct ParamStorageTraits<RawPtr<T> > : public PointerParamStorageTraits<T*, false> { }; } // namespace WTF
diff --git a/sky/engine/platform/heap/Heap.cpp b/sky/engine/platform/heap/Heap.cpp index 2597f97..0d0bc31 100644 --- a/sky/engine/platform/heap/Heap.cpp +++ b/sky/engine/platform/heap/Heap.cpp
@@ -354,52 +354,6 @@ MemoryRegion m_writable; }; -class GCScope { -public: - explicit GCScope(ThreadState::StackState stackState) - : m_state(ThreadState::current()) - , m_safePointScope(stackState) - , m_parkedAllThreads(false) - { - TRACE_EVENT0("blink_gc", "Heap::GCScope"); - const char* samplingState = TRACE_EVENT_GET_SAMPLING_STATE(); - if (m_state->isMainThread()) - TRACE_EVENT_SET_SAMPLING_STATE("blink_gc", "BlinkGCWaiting"); - - m_state->checkThread(); - - // FIXME: in an unlikely coincidence that two threads decide - // to collect garbage at the same time, avoid doing two GCs in - // a row. - RELEASE_ASSERT(!m_state->isInGC()); - RELEASE_ASSERT(!m_state->isSweepInProgress()); - if (LIKELY(ThreadState::stopThreads())) { - m_parkedAllThreads = true; - m_state->enterGC(); - } - if (m_state->isMainThread()) - TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); - } - - bool allThreadsParked() { return m_parkedAllThreads; } - - ~GCScope() - { - // Only cleanup if we parked all threads in which case the GC happened - // and we need to resume the other threads. - if (LIKELY(m_parkedAllThreads)) { - m_state->leaveGC(); - ASSERT(!m_state->isInGC()); - ThreadState::resumeThreads(); - } - } - -private: - ThreadState* m_state; - ThreadState::SafePointScope m_safePointScope; - bool m_parkedAllThreads; // False if we fail to park all threads -}; - NO_SANITIZE_ADDRESS bool HeapObjectHeader::isMarked() const { @@ -2208,51 +2162,6 @@ CallbackStack** m_markingStack; }; -void Heap::init() -{ - ThreadState::init(); - CallbackStack::init(&s_markingStack); - CallbackStack::init(&s_postMarkingCallbackStack); - CallbackStack::init(&s_weakCallbackStack); - CallbackStack::init(&s_ephemeronStack); - s_heapDoesNotContainCache = new HeapDoesNotContainCache(); - s_markingVisitor = new MarkingVisitor(&s_markingStack); - s_freePagePool = new FreePagePool(); - s_orphanedPagePool = new OrphanedPagePool(); - s_markingThreads = new Vector<OwnPtr<blink::WebThread> >(); -} - -void Heap::shutdown() -{ - s_shutdownCalled = true; - ThreadState::shutdownHeapIfNecessary(); -} - -void Heap::doShutdown() -{ - // We don't want to call doShutdown() twice. - if (!s_markingVisitor) - return; - - ASSERT(!ThreadState::isAnyThreadInGC()); - ASSERT(!ThreadState::attachedThreads().size()); - delete s_markingThreads; - s_markingThreads = 0; - delete s_markingVisitor; - s_markingVisitor = 0; - delete s_heapDoesNotContainCache; - s_heapDoesNotContainCache = 0; - delete s_freePagePool; - s_freePagePool = 0; - delete s_orphanedPagePool; - s_orphanedPagePool = 0; - CallbackStack::shutdown(&s_weakCallbackStack); - CallbackStack::shutdown(&s_postMarkingCallbackStack); - CallbackStack::shutdown(&s_markingStack); - CallbackStack::shutdown(&s_ephemeronStack); - ThreadState::shutdown(); -} - BaseHeapPage* Heap::contains(Address address) { ASSERT(ThreadState::isAnyThreadInGC()); @@ -2440,114 +2349,10 @@ void Heap::collectGarbage(ThreadState::StackState stackState) { - ThreadState* state = ThreadState::current(); - state->clearGCRequested(); - - GCScope gcScope(stackState); - // Check if we successfully parked the other threads. If not we bail out of the GC. - if (!gcScope.allThreadsParked()) { - ThreadState::current()->setGCRequested(); - return; - } - - if (state->isMainThread()) - ScriptForbiddenScope::enter(); - - s_lastGCWasConservative = false; - - TRACE_EVENT0("blink_gc", "Heap::collectGarbage"); - TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC"); - double timeStamp = WTF::currentTimeMS(); -#if ENABLE(GC_PROFILE_MARKING) - static_cast<MarkingVisitor*>(s_markingVisitor)->objectGraph().clear(); -#endif - - // Disallow allocation during garbage collection (but not - // during the finalization that happens when the gcScope is - // torn down). - NoAllocationScope<AnyThread> noAllocationScope; - - prepareForGC(); - - // 1. trace persistent roots. - ThreadState::visitPersistentRoots(s_markingVisitor); - - // 2. trace objects reachable from the persistent roots including ephemerons. - processMarkingStackInParallel(); - - // 3. trace objects reachable from the stack. We do this independent of the - // given stackState since other threads might have a different stack state. - ThreadState::visitStackRoots(s_markingVisitor); - - // 4. trace objects reachable from the stack "roots" including ephemerons. - // Only do the processing if we found a pointer to an object on one of the - // thread stacks. - if (lastGCWasConservative()) - processMarkingStackInParallel(); - - postMarkingProcessing(); - globalWeakProcessing(); - - // After a global marking we know that any orphaned page that was not reached - // cannot be reached in a subsequent GC. This is due to a thread either having - // swept its heap or having done a "poor mans sweep" in prepareForGC which marks - // objects that are dead, but not swept in the previous GC as dead. In this GC's - // marking we check that any object marked as dead is not traced. E.g. via a - // conservatively found pointer or a programming error with an object containing - // a dangling pointer. - orphanedPagePool()->decommitOrphanedPages(); - -#if ENABLE(GC_PROFILE_MARKING) - static_cast<MarkingVisitor*>(s_markingVisitor)->reportStats(); -#endif - - if (blink::Platform::current()) { - uint64_t objectSpaceSize; - uint64_t allocatedSpaceSize; - getHeapSpaceSize(&objectSpaceSize, &allocatedSpaceSize); - blink::Platform::current()->histogramCustomCounts("BlinkGC.CollectGarbage", WTF::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); - blink::Platform::current()->histogramCustomCounts("BlinkGC.TotalObjectSpace", objectSpaceSize / 1024, 0, 4 * 1024 * 1024, 50); - blink::Platform::current()->histogramCustomCounts("BlinkGC.TotalAllocatedSpace", allocatedSpaceSize / 1024, 0, 4 * 1024 * 1024, 50); - } - - if (state->isMainThread()) - ScriptForbiddenScope::exit(); } void Heap::collectGarbageForTerminatingThread(ThreadState* state) { - // We explicitly do not enter a safepoint while doing thread specific - // garbage collection since we don't want to allow a global GC at the - // same time as a thread local GC. - - { - NoAllocationScope<AnyThread> noAllocationScope; - - state->enterGC(); - state->prepareForGC(); - - // 1. trace the thread local persistent roots. For thread local GCs we - // don't trace the stack (ie. no conservative scanning) since this is - // only called during thread shutdown where there should be no objects - // on the stack. - // We also assume that orphaned pages have no objects reachable from - // persistent handles on other threads or CrossThreadPersistents. The - // only cases where this could happen is if a subsequent conservative - // global GC finds a "pointer" on the stack or due to a programming - // error where an object has a dangling cross-thread pointer to an - // object on this heap. - state->visitPersistents(s_markingVisitor); - - // 2. trace objects reachable from the thread's persistent roots - // including ephemerons. - processMarkingStack<ThreadLocalMarking>(); - - postMarkingProcessing(); - globalWeakProcessing(); - - state->leaveGC(); - } - state->performPendingSweep(); } void Heap::processMarkingStackEntries(int* runningMarkingThreads)
diff --git a/sky/engine/platform/heap/Heap.h b/sky/engine/platform/heap/Heap.h index e1f071c..22cdb20 100644 --- a/sky/engine/platform/heap/Heap.h +++ b/sky/engine/platform/heap/Heap.h
@@ -1050,10 +1050,6 @@ class PLATFORM_EXPORT Heap { public: - static void init(); - static void shutdown(); - static void doShutdown(); - static BaseHeapPage* contains(Address); static BaseHeapPage* contains(void* pointer) { return contains(reinterpret_cast<Address>(pointer)); } static BaseHeapPage* contains(const void* pointer) { return contains(const_cast<void*>(pointer)); }
diff --git a/sky/engine/platform/heap/HeapTerminatedArray.h b/sky/engine/platform/heap/HeapTerminatedArray.h deleted file mode 100644 index de1cd46..0000000 --- a/sky/engine/platform/heap/HeapTerminatedArray.h +++ /dev/null
@@ -1,54 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef HeapTerminatedArray_h -#define HeapTerminatedArray_h - -#include "platform/heap/Heap.h" -#include "wtf/TerminatedArray.h" -#include "wtf/TerminatedArrayBuilder.h" - -namespace blink { - -template<typename T> -class HeapTerminatedArray : public TerminatedArray<T> { - DISALLOW_ALLOCATION(); -public: - using TerminatedArray<T>::begin; - using TerminatedArray<T>::end; - - void trace(Visitor* visitor) - { - for (typename TerminatedArray<T>::iterator it = begin(); it != end(); ++it) - visitor->trace(*it); - } - -private: - // Allocator describes how HeapTerminatedArrayBuilder should create new intances - // of TerminateArray and manage their lifetimes. - struct Allocator { - typedef HeapTerminatedArray* PassPtr; - typedef RawPtr<HeapTerminatedArray> Ptr; - - static PassPtr create(size_t capacity) - { - return reinterpret_cast<HeapTerminatedArray*>(Heap::allocate<HeapTerminatedArray>(capacity * sizeof(T))); - } - - static PassPtr resize(PassPtr ptr, size_t capacity) - { - return reinterpret_cast<HeapTerminatedArray*>(Heap::reallocate<HeapTerminatedArray>(ptr, capacity * sizeof(T))); - } - }; - - // Prohibit construction. Allocator makes HeapTerminatedArray instances for - // HeapTerminatedArrayBuilder by pointer casting. - HeapTerminatedArray(); - - template<typename U, template <typename> class> friend class WTF::TerminatedArrayBuilder; -}; - -} // namespace blink - -#endif // HeapTerminatedArray_h
diff --git a/sky/engine/platform/heap/HeapTerminatedArrayBuilder.h b/sky/engine/platform/heap/HeapTerminatedArrayBuilder.h deleted file mode 100644 index ec5077c..0000000 --- a/sky/engine/platform/heap/HeapTerminatedArrayBuilder.h +++ /dev/null
@@ -1,22 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef HeapTerminatedArrayBuilder_h -#define HeapTerminatedArrayBuilder_h - -#include "platform/heap/Heap.h" -#include "platform/heap/HeapTerminatedArray.h" -#include "wtf/TerminatedArrayBuilder.h" - -namespace blink { - -template<typename T> -class HeapTerminatedArrayBuilder : public TerminatedArrayBuilder<T, HeapTerminatedArray> { -public: - explicit HeapTerminatedArrayBuilder(HeapTerminatedArray<T>* array) : TerminatedArrayBuilder<T, HeapTerminatedArray>(array) { } -}; - -} // namespace blink - -#endif // HeapTerminatedArrayBuilder_h
diff --git a/sky/engine/platform/heap/ThreadState.cpp b/sky/engine/platform/heap/ThreadState.cpp index cb2557a..a80ff00 100644 --- a/sky/engine/platform/heap/ThreadState.cpp +++ b/sky/engine/platform/heap/ThreadState.cpp
@@ -97,16 +97,6 @@ return mutex; } -static double lockingTimeout() -{ - // Wait time for parking all threads is at most 100 MS. - return 0.100; -} - - -typedef void (*PushAllRegistersCallback)(SafePointBarrier*, ThreadState*, intptr_t*); -extern "C" void pushAllRegisters(SafePointBarrier*, ThreadState*, PushAllRegistersCallback); - class SafePointBarrier { public: SafePointBarrier() : m_canResume(1), m_unparkedThreadCount(0) { } @@ -115,97 +105,23 @@ // Request other attached threads that are not at safe points to park themselves on safepoints. bool parkOthers() { - ASSERT(ThreadState::current()->isAtSafePoint()); - - // Lock threadAttachMutex() to prevent threads from attaching. - threadAttachMutex().lock(); - - ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(); - - MutexLocker locker(m_mutex); - atomicAdd(&m_unparkedThreadCount, threads.size()); - releaseStore(&m_canResume, 0); - - ThreadState* current = ThreadState::current(); - for (ThreadState::AttachedThreadStateSet::iterator it = threads.begin(), end = threads.end(); it != end; ++it) { - if (*it == current) - continue; - - const Vector<ThreadState::Interruptor*>& interruptors = (*it)->interruptors(); - for (size_t i = 0; i < interruptors.size(); i++) - interruptors[i]->requestInterrupt(); - } - - while (acquireLoad(&m_unparkedThreadCount) > 0) { - double expirationTime = currentTime() + lockingTimeout(); - if (!m_parked.timedWait(m_mutex, expirationTime)) { - // One of the other threads did not return to a safepoint within the maximum - // time we allow for threads to be parked. Abandon the GC and resume the - // currently parked threads. - resumeOthers(true); - return false; - } - } return true; } void resumeOthers(bool barrierLocked = false) { - ThreadState::AttachedThreadStateSet& threads = ThreadState::attachedThreads(); - atomicSubtract(&m_unparkedThreadCount, threads.size()); - releaseStore(&m_canResume, 1); - - // FIXME: Resumed threads will all contend for m_mutex just to unlock it - // later which is a waste of resources. - if (UNLIKELY(barrierLocked)) { - m_resume.broadcast(); - } else { - // FIXME: Resumed threads will all contend for - // m_mutex just to unlock it later which is a waste of - // resources. - MutexLocker locker(m_mutex); - m_resume.broadcast(); - } - - ThreadState* current = ThreadState::current(); - for (ThreadState::AttachedThreadStateSet::iterator it = threads.begin(), end = threads.end(); it != end; ++it) { - if (*it == current) - continue; - - const Vector<ThreadState::Interruptor*>& interruptors = (*it)->interruptors(); - for (size_t i = 0; i < interruptors.size(); i++) - interruptors[i]->clearInterrupt(); - } - - threadAttachMutex().unlock(); - ASSERT(ThreadState::current()->isAtSafePoint()); } void checkAndPark(ThreadState* state, SafePointAwareMutexLocker* locker = 0) { - ASSERT(!state->isSweepInProgress()); - if (!acquireLoad(&m_canResume)) { - // If we are leaving the safepoint from a SafePointAwareMutexLocker - // call out to release the lock before going to sleep. This enables the - // lock to be acquired in the sweep phase, e.g. during weak processing - // or finalization. The SafePointAwareLocker will reenter the safepoint - // and reacquire the lock after leaving this safepoint. - if (locker) - locker->reset(); - pushAllRegisters(this, state, parkAfterPushRegisters); - } } void enterSafePoint(ThreadState* state) { - ASSERT(!state->isSweepInProgress()); - pushAllRegisters(this, state, enterSafePointAfterPushRegisters); } void leaveSafePoint(ThreadState* state, SafePointAwareMutexLocker* locker = 0) { - if (atomicIncrement(&m_unparkedThreadCount) > 0) - checkAndPark(state, locker); } private: @@ -330,62 +246,6 @@ **s_threadSpecific = 0; } -void ThreadState::init() -{ - s_threadSpecific = new WTF::ThreadSpecific<ThreadState*>(); - s_safePointBarrier = new SafePointBarrier; -} - -void ThreadState::shutdown() -{ - delete s_safePointBarrier; - s_safePointBarrier = 0; - - // Thread-local storage shouldn't be disposed, so we don't call ~ThreadSpecific(). -} - -void ThreadState::attachMainThread() -{ - RELEASE_ASSERT(!Heap::s_shutdownCalled); - MutexLocker locker(threadAttachMutex()); - ThreadState* state = new(s_mainThreadStateStorage) ThreadState(); - attachedThreads().add(state); -} - -void ThreadState::detachMainThread() -{ - // Enter a safe point before trying to acquire threadAttachMutex - // to avoid dead lock if another thread is preparing for GC, has acquired - // threadAttachMutex and waiting for other threads to pause or reach a - // safepoint. - ThreadState* state = mainThreadState(); - - { - SafePointAwareMutexLocker locker(threadAttachMutex(), NoHeapPointersOnStack); - - // First add the main thread's heap pages to the orphaned pool. - state->cleanupPages(); - - // Second detach thread. - ASSERT(attachedThreads().contains(state)); - attachedThreads().remove(state); - state->~ThreadState(); - } - shutdownHeapIfNecessary(); -} - -void ThreadState::shutdownHeapIfNecessary() -{ - // We don't need to enter a safe point before acquiring threadAttachMutex - // because this thread is already detached. - - MutexLocker locker(threadAttachMutex()); - // We start shutting down the heap if there is no running thread - // and Heap::shutdown() is already called. - if (!attachedThreads().size() && Heap::s_shutdownCalled) - Heap::doShutdown(); -} - void ThreadState::attach() { RELEASE_ASSERT(!Heap::s_shutdownCalled); @@ -452,14 +312,6 @@ } -void ThreadState::detach() -{ - ThreadState* state = current(); - state->cleanup(); - delete state; - shutdownHeapIfNecessary(); -} - void ThreadState::visitPersistentRoots(Visitor* visitor) { {
diff --git a/sky/engine/platform/heap/ThreadState.h b/sky/engine/platform/heap/ThreadState.h index 53c0cd0..441f82f 100644 --- a/sky/engine/platform/heap/ThreadState.h +++ b/sky/engine/platform/heap/ThreadState.h
@@ -300,16 +300,8 @@ typedef HashSet<ThreadState*> AttachedThreadStateSet; static AttachedThreadStateSet& attachedThreads(); - // Initialize threading infrastructure. Should be called from the main - // thread. - static void init(); - static void shutdown(); - static void shutdownHeapIfNecessary(); bool isTerminating() { return m_isTerminating; } - static void attachMainThread(); - static void detachMainThread(); - // Trace all persistent roots, called when marking the managed heap objects. static void visitPersistentRoots(Visitor*);
diff --git a/sky/engine/platform/testing/RunAllTests.cpp b/sky/engine/platform/testing/RunAllTests.cpp index eb448a1..8720e21 100644 --- a/sky/engine/platform/testing/RunAllTests.cpp +++ b/sky/engine/platform/testing/RunAllTests.cpp
@@ -33,7 +33,6 @@ #include "platform/EventTracer.h" #include "platform/Partitions.h" #include "platform/TestingPlatformSupport.h" -#include "platform/heap/Heap.h" #include "wtf/CryptographicallyRandomNumber.h" #include "wtf/MainThread.h" #include "wtf/WTF.h" @@ -59,13 +58,9 @@ blink::TestingPlatformSupport::Config platformConfig; blink::TestingPlatformSupport platform(platformConfig); - blink::Heap::init(); - blink::ThreadState::attachMainThread(); blink::Partitions::init(); blink::EventTracer::initialize(); int result = base::RunUnitTestsUsingBaseTestSuite(argc, argv); blink::Partitions::shutdown(); - blink::ThreadState::detachMainThread(); - blink::Heap::shutdown(); return result; }
diff --git a/sky/engine/public/web/WebHeap.h b/sky/engine/public/web/WebHeap.h deleted file mode 100644 index b8d01b3..0000000 --- a/sky/engine/public/web/WebHeap.h +++ /dev/null
@@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebHeap_h -#define WebHeap_h - -#include "public/platform/WebCommon.h" - -namespace blink { - -class WebHeap { -public: - // While this object is active on the stack current thread is marked as - // being at safepoint. It can't manipulate garbage collector managed objects - // until it leaves safepoint, but it can block indefinitely. - // When thread is not at safe-point it must not block indefinitely because - // garbage collector might want to stop it. - class SafePointScope { - public: - BLINK_EXPORT SafePointScope(); - BLINK_EXPORT ~SafePointScope(); - }; -}; - -} // namespace blink - -#endif
diff --git a/sky/engine/web/BUILD.gn b/sky/engine/web/BUILD.gn index cbc7ba2..3caca66 100644 --- a/sky/engine/web/BUILD.gn +++ b/sky/engine/web/BUILD.gn
@@ -83,7 +83,6 @@ "WebFontImpl.h", "WebFrame.cpp", "WebGlyphCache.cpp", - "WebHeap.cpp", "WebHitTestResult.cpp", "WebImageCache.cpp", "WebImageDecoder.cpp",
diff --git a/sky/engine/web/Sky.cpp b/sky/engine/web/Sky.cpp index fe050e7..7b2eb1f 100644 --- a/sky/engine/web/Sky.cpp +++ b/sky/engine/web/Sky.cpp
@@ -47,7 +47,6 @@ #include "platform/RuntimeEnabledFeatures.h" #include "platform/graphics/ImageDecodingStore.h" #include "platform/graphics/media/MediaPlayer.h" -#include "platform/heap/Heap.h" #include "public/platform/Platform.h" #include "web/WebMediaPlayerClientImpl.h" #include "wtf/Assertions.h" @@ -116,8 +115,6 @@ } // namespace -static ThreadState::Interruptor* s_isolateInterruptor = 0; - // Make sure we are not re-initialized in the same address space. // Doing so may cause hard to reproduce crashes. static bool s_webKitInitialized = false; @@ -128,9 +125,6 @@ V8Initializer::initializeMainThreadIfNeeded(); - s_isolateInterruptor = new V8IsolateInterruptor(V8PerIsolateData::mainThreadIsolate()); - ThreadState::current()->addInterruptor(s_isolateInterruptor); - addMessageLoopObservers(); } @@ -170,9 +164,6 @@ WTF::setRandomSource(cryptographicallyRandomValues); WTF::initialize(currentTimeFunction, monotonicallyIncreasingTimeFunction); WTF::initializeMainThread(callOnMainThreadFunction); - Heap::init(); - - ThreadState::attachMainThread(); DEFINE_STATIC_LOCAL(CoreInitializer, initializer, ()); initializer.init(); @@ -193,13 +184,6 @@ { removeMessageLoopObservers(); - ASSERT(s_isolateInterruptor); - ThreadState::current()->removeInterruptor(s_isolateInterruptor); - - // Detach the main thread before starting the shutdown sequence - // so that the main thread won't get involved in a GC during the shutdown. - ThreadState::detachMainThread(); - v8::Isolate* isolate = V8PerIsolateData::mainThreadIsolate(); V8PerIsolateData::dispose(isolate); @@ -209,7 +193,6 @@ void shutdownWithoutV8() { CoreInitializer::shutdown(); - Heap::shutdown(); WTF::shutdown(); Platform::shutdown(); }
diff --git a/sky/engine/web/WebHeap.cpp b/sky/engine/web/WebHeap.cpp deleted file mode 100644 index d814b2d..0000000 --- a/sky/engine/web/WebHeap.cpp +++ /dev/null
@@ -1,48 +0,0 @@ -/* - * Copyright (C) 2014 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "public/web/WebHeap.h" - -#include "platform/heap/ThreadState.h" - -namespace blink { - -WebHeap::SafePointScope::SafePointScope() -{ - ThreadState::current()->enterSafePointWithPointers(this); -} - -WebHeap::SafePointScope::~SafePointScope() -{ - ThreadState::current()->leaveSafePoint(); -} - -} // namespace blink