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

Unified Diff: src/heap/heap.cc

Issue 871253005: Use weak cells in dependent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 5 years, 10 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/incremental-marking.cc » ('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 a2f16298a4042688b4eb1864eca5d75dc8eb222d..45a15a246474f0f1c351dd48435a1343c2157195 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -135,9 +135,6 @@ Heap::Heap()
full_codegen_bytes_generated_(0),
crankshaft_codegen_bytes_generated_(0),
gcs_since_last_deopt_(0),
-#ifdef VERIFY_HEAP
- no_weak_object_verification_scope_depth_(0),
-#endif
allocation_sites_scratchpad_length_(0),
promotion_queue_(this),
configured_(false),
@@ -3169,6 +3166,10 @@ void Heap::CreateInitialObjects() {
set_detached_contexts(empty_fixed_array());
+ set_weak_object_to_code_table(
+ *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY,
+ TENURED));
+
Handle<SeededNumberDictionary> slow_element_dictionary =
SeededNumberDictionary::New(isolate(), 0, TENURED);
slow_element_dictionary->set_requires_slow_elements();
@@ -5600,7 +5601,6 @@ bool Heap::CreateHeapObjects() {
set_array_buffers_list(undefined_value());
set_new_array_buffer_views_list(undefined_value());
set_allocation_sites_list(undefined_value());
- weak_object_to_code_table_ = undefined_value();
return true;
}
@@ -5775,41 +5775,25 @@ void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback) {
// TODO(ishell): Find a better place for this.
-void Heap::AddWeakObjectToCodeDependency(Handle<Object> obj,
+void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj,
Handle<DependentCode> dep) {
DCHECK(!InNewSpace(*obj));
DCHECK(!InNewSpace(*dep));
- // This handle scope keeps the table handle local to this function, which
- // allows us to safely skip write barriers in table update operations.
- HandleScope scope(isolate());
- Handle<WeakHashTable> table(WeakHashTable::cast(weak_object_to_code_table_),
- isolate());
+ Handle<WeakHashTable> table(weak_object_to_code_table(), isolate());
table = WeakHashTable::Put(table, obj, dep);
-
- 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);
- DCHECK_EQ(*dep, table->Lookup(obj));
+ if (*table != weak_object_to_code_table())
+ set_weak_object_to_code_table(*table);
+ DCHECK_EQ(*dep, LookupWeakObjectToCodeDependency(obj));
}
-DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<Object> obj) {
- Object* dep = WeakHashTable::cast(weak_object_to_code_table_)->Lookup(obj);
+DependentCode* Heap::LookupWeakObjectToCodeDependency(Handle<HeapObject> obj) {
+ Object* dep = 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(
- *WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY,
- TENURED));
- }
-}
-
-
void Heap::FatalProcessOutOfMemory(const char* location, bool take_snapshot) {
v8::internal::V8::FatalProcessOutOfMemory(location, take_snapshot);
}
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698