mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1873 from jason-simmons/dart_gc_prologue
Remove obsolete Dart GC controller code
This commit is contained in:
commit
38d7147e2e
@ -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"
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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 <utility>
|
||||
|
||||
#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
|
||||
@ -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 <unordered_map>
|
||||
|
||||
#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<const void*, Dart_WeakReferenceSet> references_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DartGCContext);
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // SKY_ENGINE_TONIC_DART_GC_CONTEXT_H_
|
||||
@ -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<DartWrappable*>(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
|
||||
@ -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_
|
||||
@ -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
|
||||
@ -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_
|
||||
@ -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<intptr_t>(&info))));
|
||||
|
||||
info.ref_object(this); // Balanced in FinalizeDartWrapper.
|
||||
dart_wrapper_ = Dart_NewPrologueWeakPersistentHandle(
|
||||
dart_wrapper_ = Dart_NewWeakPersistentHandle(
|
||||
wrapper, this, info.size_in_bytes, &FinalizeDartWrapper);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user