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

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: 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 | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »
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 86dbe8fcf0aa13910140a038a3158eba53ddffa4..665fca5ddc3f98d0a4e487601c8fac1bb7dcf6c8 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -221,6 +221,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;
@@ -230,7 +240,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.
}
@@ -238,6 +248,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];
@@ -247,7 +258,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 | « include/v8.h ('k') | src/heap/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698