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

Unified Diff: src/compiler.cc

Issue 871253005: Use weak cells in dependent code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 5 years, 11 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 | « no previous file | src/heap/incremental-marking.cc » ('j') | src/heap/mark-compact.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 4517b1f8704b19bab2ea2d492d75c5b26c8ace31..f6623bfefab206189a054e7e987dc4aa32beb7a0 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -214,6 +214,16 @@ CompilationInfo::~CompilationInfo() {
void CompilationInfo::CommitDependencies(Handle<Code> code) {
+ bool has_dependencies = false;
+ for (int i = 0; i < DependentCode::kGroupCount; i++) {
+ has_dependencies |=
+ dependencies_[i] != NULL && dependencies_[i]->length() > 0;
+ }
+ // Avoid creating a weak cell for code with no dependencies.
+ if (!has_dependencies) return;
+
+ AllowDeferredHandleDereference get_object_wrapper;
+ Handle<WeakCell> cell = Code::WeakCellFor(code);
for (int i = 0; i < DependentCode::kGroupCount; i++) {
ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i];
if (group_objects == NULL) continue;
@@ -223,7 +233,7 @@ void CompilationInfo::CommitDependencies(Handle<Code> code) {
static_cast<DependentCode::DependencyGroup>(i);
DependentCode* dependent_code =
DependentCode::ForObject(group_objects->at(j), group);
- dependent_code->UpdateToFinishedCode(group, this, *code);
+ dependent_code->UpdateToFinishedCode(group, *object_wrapper(), *cell);
}
dependencies_[i] = NULL; // Zone-allocated, no need to delete.
}
@@ -231,6 +241,7 @@ void CompilationInfo::CommitDependencies(Handle<Code> code) {
void CompilationInfo::RollbackDependencies() {
+ AllowDeferredHandleDereference get_object_wrapper;
// Unregister from all dependent maps if not yet committed.
for (int i = 0; i < DependentCode::kGroupCount; i++) {
ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i];
@@ -240,7 +251,7 @@ void CompilationInfo::RollbackDependencies() {
static_cast<DependentCode::DependencyGroup>(i);
DependentCode* dependent_code =
DependentCode::ForObject(group_objects->at(j), group);
- dependent_code->RemoveCompilationInfo(group, this);
+ dependent_code->RemoveCompilationInfo(group, *object_wrapper());
}
dependencies_[i] = NULL; // Zone-allocated, no need to delete.
}
« no previous file with comments | « no previous file | src/heap/incremental-marking.cc » ('j') | src/heap/mark-compact.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698