Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index 2f1ba2ec8c29bc40a427b61ff7db4db1810915c1..5232a2e939f4de38d17cabde38228350dfce6347 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -6731,6 +6731,7 @@ bool Heap::CreateHeapObjects() { |
native_contexts_list_ = undefined_value(); |
array_buffers_list_ = undefined_value(); |
allocation_sites_list_ = undefined_value(); |
+ weak_object_to_code_table_ = undefined_value(); |
return true; |
} |
@@ -6878,6 +6879,34 @@ void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback) { |
} |
+MaybeObject* Heap::AddWeakObjectToCodeDependency(Object* obj, |
+ DependentCode* dep) { |
+ ASSERT(!InNewSpace(obj)); |
+ ASSERT(!InNewSpace(dep)); |
+ MaybeObject* maybe_obj = |
+ WeakHashTable::cast(weak_object_to_code_table_)->Put(obj, dep); |
+ WeakHashTable* table; |
+ if (!maybe_obj->To(&table)) return maybe_obj; |
+ 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_; |
+} |
+ |
+ |
+DependentCode* Heap::LookupWeakObjectToCodeDependency(Object* obj) { |
+ Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj); |
+ if (dep->IsDependentCode()) return DependentCode::cast(dep); |
+ return DependentCode::cast(empty_fixed_array()); |
+} |
+ |
+ |
+void Heap::EnsureWeakObjectToCodeTable() { |
+ if (!weak_object_to_code_table()->IsHashTable()) { |
+ set_weak_object_to_code_table(*isolate()->factory()->NewWeakHashTable(16)); |
+ } |
+} |
+ |
+ |
#ifdef DEBUG |
class PrintHandleVisitor: public ObjectVisitor { |