Enable weak embedded objects in optimized code with a fix for heap verifier.
authorulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 10 Oct 2013 13:14:37 +0000 (13:14 +0000)
committerulan@chromium.org <ulan@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 10 Oct 2013 13:14:37 +0000 (13:14 +0000)
BUG=v8:2073
R=mstarzinger@chromium.org

Review URL: https://chromiumcodereview.appspot.com/25702008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17141 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/flag-definitions.h
src/heap.cc
src/objects.h

index e40ffe4b4169177253b21d24ebe73e0e35647fa7..5b6814ec689ba3a3047bc7caf5e7eff58887edb4 100644 (file)
@@ -511,7 +511,7 @@ DEFINE_bool(collect_maps, true,
             "garbage collect maps from which no objects can be reached")
 DEFINE_bool(weak_embedded_maps_in_optimized_code, true,
             "make maps embedded in optimized code weak")
-DEFINE_bool(weak_embedded_objects_in_optimized_code, false,
+DEFINE_bool(weak_embedded_objects_in_optimized_code, true,
             "make objects embedded in optimized code weak")
 DEFINE_bool(flush_code, true,
             "flush code that we expect not to use again (during full gc)")
index 0a594e77ee3eb95dff3789ed5fb211d54dc7d152..b0335d0efdd5da06accdc84acf018f626cf8fd66 100644 (file)
@@ -6886,6 +6886,9 @@ MaybeObject* Heap::AddWeakObjectToCodeDependency(Object* obj,
       WeakHashTable::cast(weak_object_to_code_table_)->Put(obj, dep);
   WeakHashTable* table;
   if (!maybe_obj->To(&table)) return maybe_obj;
+  if (ShouldZapGarbage() && weak_object_to_code_table_ != table) {
+    WeakHashTable::cast(weak_object_to_code_table_)->Zap(the_hole_value());
+  }
   set_weak_object_to_code_table(table);
   ASSERT_EQ(dep, WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj));
   return weak_object_to_code_table_;
index 4d8a45bb2d58d3066219dfc01d80b03ea64af9c9..e0ab9841cb29e59a00091ae1d02cd0c51632238b 100644 (file)
@@ -4001,6 +4001,15 @@ class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> {
   // key to the hole value causes removal of the whole entry.
   MUST_USE_RESULT MaybeObject* Put(Object* key, Object* value);
 
+  // This function is called when heap verification is turned on.
+  void Zap(Object* value) {
+    int capacity = Capacity();
+    for (int i = 0; i < capacity; i++) {
+      set(EntryToIndex(i), value);
+      set(EntryToValueIndex(i), value);
+    }
+  }
+
  private:
   friend class MarkCompactCollector;