Reviewers: mstarzinger,
Description:
Remove all encountered weak maps from the list of weak collections when
incremental marking is aborted.
BUG=399527
LOG=n
Please review this at https://codereview.chromium.org/439233002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+28, -3 lines):
M src/gc-tracer.h
M src/gc-tracer.cc
M src/mark-compact.h
M src/mark-compact.cc
A + test/mjsunit/regress/regress-399527.js
Index: src/gc-tracer.cc
diff --git a/src/gc-tracer.cc b/src/gc-tracer.cc
index
8d4c4de3d7d7487fbf40a0992b28e1f3729ab4af..4d9b6d617066f0806139a22c320b4c9b0853ffde
100644
--- a/src/gc-tracer.cc
+++ b/src/gc-tracer.cc
@@ -258,6 +258,8 @@ void GCTracer::PrintNVP() const {
current_.scopes[Scope::MC_WEAKCOLLECTION_PROCESS]);
PrintF("weakcollection_clear=%.1f ",
current_.scopes[Scope::MC_WEAKCOLLECTION_CLEAR]);
+ PrintF("weakcollection_abort=%.1f ",
+ current_.scopes[Scope::MC_WEAKCOLLECTION_ABORT]);
PrintF("total_size_before=%" V8_PTR_PREFIX "d ",
current_.start_object_size);
PrintF("total_size_after=%" V8_PTR_PREFIX "d ",
current_.end_object_size);
Index: src/gc-tracer.h
diff --git a/src/gc-tracer.h b/src/gc-tracer.h
index
d3163f4184a8376c0a7bb7537ca690b456b2cc81..ce1fc2efc963a31b2a8a2d4c0f7eaee6f1faf5f7
100644
--- a/src/gc-tracer.h
+++ b/src/gc-tracer.h
@@ -103,6 +103,7 @@ class GCTracer BASE_EMBEDDED {
MC_UPDATE_MISC_POINTERS,
MC_WEAKCOLLECTION_PROCESS,
MC_WEAKCOLLECTION_CLEAR,
+ MC_WEAKCOLLECTION_ABORT,
MC_FLUSH_CODE,
NUMBER_OF_SCOPES
};
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
9dbadacfb86b49785a7c78c43c8b5087f555fbc8..367b65a9e5fe4042e21fab914d28ceb9d4b09c39
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -968,6 +968,7 @@ void MarkCompactCollector::Prepare() {
if (was_marked_incrementally_ && abort_incremental_marking_) {
heap()->incremental_marking()->Abort();
ClearMarkbits();
+ AbortWeakCollections();
AbortCompaction();
was_marked_incrementally_ = false;
}
@@ -2800,6 +2801,20 @@ void MarkCompactCollector::ClearWeakCollections() {
}
+void MarkCompactCollector::AbortWeakCollections() {
+ GCTracer::Scope gc_scope(heap()->tracer(),
+ GCTracer::Scope::MC_WEAKCOLLECTION_ABORT);
+ Object* weak_collection_obj = heap()->encountered_weak_collections();
+ while (weak_collection_obj != Smi::FromInt(0)) {
+ JSWeakCollection* weak_collection =
+ reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
+ weak_collection_obj = weak_collection->next();
+ weak_collection->set_next(heap()->undefined_value());
+ }
+ heap()->set_encountered_weak_collections(Smi::FromInt(0));
+}
+
+
void MarkCompactCollector::RecordMigratedSlot(Object* value, Address slot)
{
if (heap_->InNewSpace(value)) {
heap_->store_buffer()->Mark(slot);
Index: src/mark-compact.h
diff --git a/src/mark-compact.h b/src/mark-compact.h
index
638076f0b07ac6f63f0e8f5f0390c2e8daa4561a..74ec1064812924b78b866017045ebf1d2e421bdd
100644
--- a/src/mark-compact.h
+++ b/src/mark-compact.h
@@ -858,6 +858,10 @@ class MarkCompactCollector {
// The linked list of all encountered weak maps is destroyed.
void ClearWeakCollections();
+ // We have to remove all encountered weak maps from the list of weak
+ // collections when incremental marking is aborted.
+ void AbortWeakCollections();
+
//
-----------------------------------------------------------------------
// Phase 2: Sweeping to clear mark bits and free non-live objects for
// a non-compacting collection.
Index: test/mjsunit/regress/regress-399527.js
diff --git a/test/mjsunit/regress/regress-361025.js
b/test/mjsunit/regress/regress-399527.js
similarity index 62%
copy from test/mjsunit/regress/regress-361025.js
copy to test/mjsunit/regress/regress-399527.js
index
74f50d86e8db982902b700ad7c1dcc56194710eb..df7d1685d9af8be802f65cb0dcf640ee2fe24f1f
100644
--- a/test/mjsunit/regress/regress-361025.js
+++ b/test/mjsunit/regress/regress-399527.js
@@ -4,7 +4,10 @@
// Flags: --expose-gc
-var x = new Object();
-x.__defineGetter__('a', function() { return 7 });
-JSON.parse('{"a":2600753951}');
+var weak_map = new WeakMap;
+var v = "[1]";
+for (var i = 0; i < 100000; i++) {
+ v = "[1," + v + "]";
+}
+weak_map = {};
gc();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.