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

Unified Diff: src/heap/heap.cc

Issue 1105693002: Implement IdentityMap<V>, a robust, GC-safe object-identity HashMap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « src/heap/heap.h ('k') | src/heap/identity-map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index e5095c8336c9f7d75eb476af501ec55ecbf668d4..6a1aa332c9fb6fc91d4dccf813eed8653f247fb3 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -54,6 +54,13 @@ namespace v8 {
namespace internal {
+struct Heap::StrongRootsList {
+ Object** start;
+ Object** end;
+ StrongRootsList* next;
+};
+
+
Heap::Heap()
: amount_of_external_allocated_memory_(0),
amount_of_external_allocated_memory_at_last_global_gc_(0),
@@ -141,7 +148,8 @@ Heap::Heap()
chunks_queued_for_free_(NULL),
gc_callbacks_depth_(0),
deserialization_complete_(false),
- concurrent_sweeping_enabled_(false) {
+ concurrent_sweeping_enabled_(false),
+ strong_roots_list_(NULL) {
// Allow build-time customization of the max semispace size. Building
// V8 with snapshots and a non-default max semispace size is much
// easier if you can define it as part of the build environment.
@@ -5027,6 +5035,12 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
isolate_->thread_manager()->Iterate(v);
v->Synchronize(VisitorSynchronization::kThreadManager);
+ // Iterate over other strong roots (currently only identity maps).
+ for (StrongRootsList* list = strong_roots_list_; list; list = list->next) {
+ v->VisitPointers(list->start, list->end);
+ }
+ v->Synchronize(VisitorSynchronization::kStrongRoots);
+
// Iterate over the pointers the Serialization/Deserialization code is
// holding.
// During garbage collection this keeps the partial snapshot cache alive.
@@ -5541,6 +5555,13 @@ void Heap::TearDown() {
store_buffer()->TearDown();
isolate_->memory_allocator()->TearDown();
+
+ StrongRootsList* next = NULL;
+ for (StrongRootsList* list = strong_roots_list_; list; list = next) {
+ next = list->next;
+ delete list;
+ }
+ strong_roots_list_ = NULL;
}
@@ -6439,5 +6460,34 @@ void Heap::CheckpointObjectStats() {
MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
ClearObjectStats();
}
+
+
+void Heap::RegisterStrongRoots(Object** start, Object** end) {
+ StrongRootsList* list = new StrongRootsList();
+ list->next = strong_roots_list_;
+ list->start = start;
+ list->end = end;
+ strong_roots_list_ = list;
+}
+
+
+void Heap::UnregisterStrongRoots(Object** start) {
+ StrongRootsList* prev = NULL;
+ StrongRootsList* list = strong_roots_list_;
+ while (list != nullptr) {
+ StrongRootsList* next = list->next;
+ if (list->start == start) {
+ if (prev) {
+ prev->next = next;
+ } else {
+ strong_roots_list_ = next;
+ }
+ delete list;
+ } else {
+ prev = list;
+ }
+ list = next;
+ }
+}
}
} // namespace v8::internal
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/identity-map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698