diff --git a/sky/engine/core/script/dart_controller.cc b/sky/engine/core/script/dart_controller.cc index ceb6ec950b8..5048a3c3894 100644 --- a/sky/engine/core/script/dart_controller.cc +++ b/sky/engine/core/script/dart_controller.cc @@ -23,7 +23,6 @@ #include "sky/engine/tonic/dart_class_library.h" #include "sky/engine/tonic/dart_dependency_catcher.h" #include "sky/engine/tonic/dart_error.h" -#include "sky/engine/tonic/dart_gc_controller.h" #include "sky/engine/tonic/dart_invoke.h" #include "sky/engine/tonic/dart_io.h" #include "sky/engine/tonic/dart_isolate_scope.h" diff --git a/sky/engine/core/script/dart_init.cc b/sky/engine/core/script/dart_init.cc index a29c4e91a4b..3c52a837461 100644 --- a/sky/engine/core/script/dart_init.cc +++ b/sky/engine/core/script/dart_init.cc @@ -23,7 +23,6 @@ #include "sky/engine/tonic/dart_class_library.h" #include "sky/engine/tonic/dart_dependency_catcher.h" #include "sky/engine/tonic/dart_error.h" -#include "sky/engine/tonic/dart_gc_controller.h" #include "sky/engine/tonic/dart_invoke.h" #include "sky/engine/tonic/dart_io.h" #include "sky/engine/tonic/dart_isolate_scope.h" diff --git a/sky/engine/tonic/BUILD.gn b/sky/engine/tonic/BUILD.gn index d20386d533e..2f284bbd2ce 100644 --- a/sky/engine/tonic/BUILD.gn +++ b/sky/engine/tonic/BUILD.gn @@ -17,12 +17,6 @@ source_set("tonic") { "dart_error.h", "dart_exception_factory.cc", "dart_exception_factory.h", - "dart_gc_context.cc", - "dart_gc_context.h", - "dart_gc_controller.cc", - "dart_gc_controller.h", - "dart_gc_visitor.cc", - "dart_gc_visitor.h", "dart_invoke.cc", "dart_invoke.h", "dart_io.cc", diff --git a/sky/engine/tonic/dart_gc_context.cc b/sky/engine/tonic/dart_gc_context.cc deleted file mode 100644 index 5d3b79103a0..00000000000 --- a/sky/engine/tonic/dart_gc_context.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2015 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. - -#include - -#include "sky/engine/tonic/dart_gc_context.h" - -namespace blink { - -DartGCContext::DartGCContext() : builder_(Dart_NewWeakReferenceSetBuilder()) { -} - -DartGCContext::~DartGCContext() { -} - -Dart_WeakReferenceSet DartGCContext::AddToSetForRoot( - const void* root, - Dart_WeakPersistentHandle handle) { - const auto& result = references_.insert(std::make_pair(root, nullptr)); - if (!result.second) { - // Already present. - Dart_AppendToWeakReferenceSet(result.first->second, handle, handle); - return result.first->second; - } - result.first->second = Dart_NewWeakReferenceSet(builder_, handle, handle); - return result.first->second; -} - -} // namespace blink diff --git a/sky/engine/tonic/dart_gc_context.h b/sky/engine/tonic/dart_gc_context.h deleted file mode 100644 index ad1f266220a..00000000000 --- a/sky/engine/tonic/dart_gc_context.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 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 SKY_ENGINE_TONIC_DART_GC_CONTEXT_H_ -#define SKY_ENGINE_TONIC_DART_GC_CONTEXT_H_ - -#include - -#include "base/macros.h" -#include "dart/runtime/include/dart_api.h" - -namespace blink { - -class DartGCContext { - public: - DartGCContext(); - ~DartGCContext(); - - Dart_WeakReferenceSet AddToSetForRoot(const void* root, - Dart_WeakPersistentHandle handle); - - private: - Dart_WeakReferenceSetBuilder builder_; - std::unordered_map references_; - - DISALLOW_COPY_AND_ASSIGN(DartGCContext); -}; - -} // namespace blink - -#endif // SKY_ENGINE_TONIC_DART_GC_CONTEXT_H_ diff --git a/sky/engine/tonic/dart_gc_controller.cc b/sky/engine/tonic/dart_gc_controller.cc deleted file mode 100644 index 2494b10d4c4..00000000000 --- a/sky/engine/tonic/dart_gc_controller.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 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. - -#include "sky/engine/tonic/dart_gc_controller.h" - -#include "base/trace_event/trace_event.h" -#include "dart/runtime/include/dart_api.h" -#include "sky/engine/tonic/dart_gc_context.h" -#include "sky/engine/tonic/dart_gc_visitor.h" -#include "sky/engine/tonic/dart_wrappable.h" - -namespace blink { -namespace { - -DartGCContext* g_gc_context = nullptr; - -DartWrappable* GetWrappable(intptr_t* fields) { - return reinterpret_cast(fields[DartWrappable::kPeerIndex]); -} - -void Visit(void* isolate_callback_data, - Dart_WeakPersistentHandle handle, - intptr_t native_field_count, - intptr_t* native_fields) { - if (!native_field_count) - return; - DCHECK(native_field_count == DartWrappable::kNumberOfNativeFields); - DartGCVisitor visitor(g_gc_context); - GetWrappable(native_fields)->AcceptDartGCVisitor(visitor); -} - -} // namespace - -void DartGCPrologue() { - TRACE_EVENT_ASYNC_BEGIN0("sky", "DartGC", 0); - - Dart_EnterScope(); - DCHECK(!g_gc_context); - g_gc_context = new DartGCContext(); - Dart_VisitPrologueWeakHandles(Visit); -} - -void DartGCEpilogue() { - delete g_gc_context; - g_gc_context = nullptr; - Dart_ExitScope(); - - TRACE_EVENT_ASYNC_END0("sky", "DartGC", 0); -} - -} // namespace blink diff --git a/sky/engine/tonic/dart_gc_controller.h b/sky/engine/tonic/dart_gc_controller.h deleted file mode 100644 index 196d9333431..00000000000 --- a/sky/engine/tonic/dart_gc_controller.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 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 SKY_ENGINE_TONIC_DART_GC_CONTROLLER_H_ -#define SKY_ENGINE_TONIC_DART_GC_CONTROLLER_H_ - -namespace blink { - -void DartGCPrologue(); -void DartGCEpilogue(); - -} // namespace blink - -#endif // SKY_ENGINE_TONIC_DART_GC_CONTROLLER_H_ diff --git a/sky/engine/tonic/dart_gc_visitor.cc b/sky/engine/tonic/dart_gc_visitor.cc deleted file mode 100644 index d6206e05240..00000000000 --- a/sky/engine/tonic/dart_gc_visitor.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 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. - -#include "sky/engine/tonic/dart_gc_visitor.h" - -#include "sky/engine/tonic/dart_gc_context.h" - -namespace blink { - -DartGCVisitor::DartGCVisitor(DartGCContext* context) - : context_(context), current_set_(nullptr) { -} - -DartGCVisitor::~DartGCVisitor() { -} - -void DartGCVisitor::AddToSetForRoot(const void* root, - Dart_WeakPersistentHandle handle) { - Dart_WeakReferenceSet set = context_->AddToSetForRoot(root, handle); - DCHECK(!current_set_ || current_set_ == set); - current_set_ = set; -} - -} // namespace blink diff --git a/sky/engine/tonic/dart_gc_visitor.h b/sky/engine/tonic/dart_gc_visitor.h deleted file mode 100644 index 05b09feec30..00000000000 --- a/sky/engine/tonic/dart_gc_visitor.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 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 SKY_ENGINE_TONIC_DART_GC_VISITOR_H_ -#define SKY_ENGINE_TONIC_DART_GC_VISITOR_H_ - -#include "base/logging.h" -#include "dart/runtime/include/dart_api.h" - -namespace blink { -class DartGCContext; - -class DartGCVisitor { - public: - explicit DartGCVisitor(DartGCContext* context); - ~DartGCVisitor(); - - bool have_found_set() const { - return !!current_set_; - } - - Dart_WeakReferenceSet current_set() const { - DCHECK(have_found_set()); - return current_set_; - } - - void AddToSetForRoot(const void* root, Dart_WeakPersistentHandle handle); - - private: - DartGCContext* context_; - Dart_WeakReferenceSet current_set_; - - DISALLOW_COPY_AND_ASSIGN(DartGCVisitor); -}; - -} // namespace blink - -#endif // SKY_ENGINE_TONIC_DART_GC_VISITOR_H_ diff --git a/sky/engine/tonic/dart_wrappable.cc b/sky/engine/tonic/dart_wrappable.cc index 57ae3dcd835..f4640c0c7b8 100644 --- a/sky/engine/tonic/dart_wrappable.cc +++ b/sky/engine/tonic/dart_wrappable.cc @@ -34,7 +34,7 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) { DCHECK(!LogIfError(wrapper)); info.ref_object(this); // Balanced in FinalizeDartWrapper. - dart_wrapper_ = Dart_NewPrologueWeakPersistentHandle( + dart_wrapper_ = Dart_NewWeakPersistentHandle( wrapper, this, info.size_in_bytes, &FinalizeDartWrapper); return wrapper; @@ -59,7 +59,7 @@ void DartWrappable::AssociateWithDartWrapper(Dart_NativeArguments args) { wrapper, kWrapperInfoIndex, reinterpret_cast(&info)))); info.ref_object(this); // Balanced in FinalizeDartWrapper. - dart_wrapper_ = Dart_NewPrologueWeakPersistentHandle( + dart_wrapper_ = Dart_NewWeakPersistentHandle( wrapper, this, info.size_in_bytes, &FinalizeDartWrapper); }