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. |
} |