Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: runtime/vm/dart_api_state.h

Issue 2809863002: Remove background finalization. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/dart_api_state.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_state.h
diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
index 12f9331c4a3b558ed7fdaa036b099599ee980cdf..b222449b79960f9592741a0e203fcdaf2118e7c8 100644
--- a/runtime/vm/dart_api_state.h
+++ b/runtime/vm/dart_api_state.h
@@ -25,25 +25,6 @@
namespace dart {
-class FinalizablePersistentHandle;
-typedef MallocGrowableArray<FinalizablePersistentHandle*> FinalizationQueue;
-
-
-class BackgroundFinalizer : public ThreadPool::Task {
- public:
- BackgroundFinalizer(Isolate* isolate, FinalizationQueue* queue);
- virtual ~BackgroundFinalizer() {}
-
- void Run();
-
- private:
- Isolate* isolate_;
- FinalizationQueue* queue_;
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(BackgroundFinalizer);
-};
-
-
// Implementation of Zone support for very fast allocation of small chunks
// of memory. The chunks cannot be deallocated individually, but instead
// zones support deallocating all chunks in one fast operation when the
@@ -244,18 +225,9 @@ class FinalizablePersistentHandle {
}
// Called when the referent becomes unreachable.
- void UpdateUnreachable(Isolate* isolate, FinalizationQueue* queue) {
- if (is_queued_for_finalization()) {
- return;
- }
+ void UpdateUnreachable(Isolate* isolate) {
EnsureFreeExternal(isolate);
- if (queue == NULL) {
- Finalize(isolate, this);
- } else {
- MarkForFinalization();
- queue->Add(this);
- set_is_queued_for_finalization(true);
- }
+ Finalize(isolate, this);
}
// Called when the referent has moved, potentially between generations.
@@ -278,9 +250,8 @@ class FinalizablePersistentHandle {
private:
enum {
kExternalNewSpaceBit = 0,
- kQueuedForFinalizationBit = 1,
- kExternalSizeBits = 2,
- kExternalSizeBitsSize = (kBitsPerWord - 2),
+ kExternalSizeBits = 1,
+ kExternalSizeBitsSize = (kBitsPerWord - 1),
};
// This part of external_data_ is the number of externally allocated bytes.
@@ -292,8 +263,6 @@ class FinalizablePersistentHandle {
// space and UpdateRelocated has not yet detected any promotion.
class ExternalNewSpaceBit
: public BitField<uword, bool, kExternalNewSpaceBit, 1> {};
- class QueuedForFinalizationBit
- : public BitField<uword, bool, kQueuedForFinalizationBit, 1> {};
friend class FinalizablePersistentHandles;
@@ -324,11 +293,6 @@ class FinalizablePersistentHandle {
callback_ = NULL;
}
- void MarkForFinalization() {
- raw_ = Object::null();
- ASSERT(callback_ != NULL);
- }
-
void set_raw(RawObject* raw) { raw_ = raw; }
void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); }
void set_raw(const Object& object) { raw_ = object.raw(); }
@@ -346,13 +310,6 @@ class FinalizablePersistentHandle {
ExternalSizeInWordsBits::update(size_in_words, external_data_);
}
- bool is_queued_for_finalization() const {
- return QueuedForFinalizationBit::decode(external_data_);
- }
- void set_is_queued_for_finalization(bool value) {
- external_data_ = QueuedForFinalizationBit::update(value, external_data_);
- }
-
bool IsSetNewSpaceBit() const {
return ExternalNewSpaceBit::decode(external_data_);
}
@@ -372,8 +329,6 @@ class FinalizablePersistentHandle {
: Heap::kOld;
}
- friend class BackgroundFinalizer;
-
RawObject* raw_;
void* peer_;
uword external_data_;
@@ -546,12 +501,9 @@ class FinalizablePersistentHandles
: Handles<kFinalizablePersistentHandleSizeInWords,
kFinalizablePersistentHandlesPerChunk,
kOffsetOfRawPtrInFinalizablePersistentHandle>(),
- free_list_(NULL),
- mutex_(new Mutex()) {}
+ free_list_(NULL) {}
~FinalizablePersistentHandles() {
free_list_ = NULL;
- delete mutex_;
- mutex_ = NULL;
}
// Accessors.
@@ -577,14 +529,11 @@ class FinalizablePersistentHandles
// by calling FreeHandle.
FinalizablePersistentHandle* AllocateHandle() {
FinalizablePersistentHandle* handle;
- {
- MutexLocker ml(mutex_);
- if (free_list_ != NULL) {
- handle = free_list_;
- free_list_ = handle->Next();
- handle->set_raw(Object::null());
- return handle;
- }
+ if (free_list_ != NULL) {
+ handle = free_list_;
+ free_list_ = handle->Next();
+ handle->set_raw(Object::null());
+ return handle;
}
handle =
@@ -594,19 +543,16 @@ class FinalizablePersistentHandles
}
void FreeHandle(FinalizablePersistentHandle* handle) {
- MutexLocker ml(mutex_);
handle->FreeHandle(free_list());
set_free_list(handle);
}
// Validate if passed in handle is a Persistent Handle.
bool IsValidHandle(Dart_WeakPersistentHandle object) const {
- MutexLocker ml(mutex_);
return IsValidScopedHandle(reinterpret_cast<uword>(object));
}
bool IsFreeHandle(Dart_WeakPersistentHandle object) const {
- MutexLocker ml(mutex_);
FinalizablePersistentHandle* handle = free_list_;
while (handle != NULL) {
if (handle == reinterpret_cast<FinalizablePersistentHandle*>(object)) {
@@ -622,7 +568,6 @@ class FinalizablePersistentHandles
private:
FinalizablePersistentHandle* free_list_;
- Mutex* mutex_;
DISALLOW_COPY_AND_ASSIGN(FinalizablePersistentHandles);
};
@@ -861,7 +806,6 @@ inline FinalizablePersistentHandle* FinalizablePersistentHandle::New(
ref->set_raw(object);
ref->set_peer(peer);
ref->set_callback(callback);
- ref->set_is_queued_for_finalization(false);
// This may trigger GC, so it must be called last.
ref->SetExternalSize(external_size, isolate);
return ref;
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/vm/dart_api_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698