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

Side by Side 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, 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/heap/incremental-marking.cc » ('j') | src/heap/mark-compact.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/ast-this-access-visitor.h" 10 #include "src/ast-this-access-visitor.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // Check that no dependent maps have been added or added dependent maps have 207 // Check that no dependent maps have been added or added dependent maps have
208 // been rolled back or committed. 208 // been rolled back or committed.
209 for (int i = 0; i < DependentCode::kGroupCount; i++) { 209 for (int i = 0; i < DependentCode::kGroupCount; i++) {
210 DCHECK_EQ(NULL, dependencies_[i]); 210 DCHECK_EQ(NULL, dependencies_[i]);
211 } 211 }
212 #endif // DEBUG 212 #endif // DEBUG
213 } 213 }
214 214
215 215
216 void CompilationInfo::CommitDependencies(Handle<Code> code) { 216 void CompilationInfo::CommitDependencies(Handle<Code> code) {
217 bool has_dependencies = false;
218 for (int i = 0; i < DependentCode::kGroupCount; i++) {
219 has_dependencies |=
220 dependencies_[i] != NULL && dependencies_[i]->length() > 0;
221 }
222 // Avoid creating a weak cell for code with no dependencies.
223 if (!has_dependencies) return;
224
225 AllowDeferredHandleDereference get_object_wrapper;
226 Handle<WeakCell> cell = Code::WeakCellFor(code);
217 for (int i = 0; i < DependentCode::kGroupCount; i++) { 227 for (int i = 0; i < DependentCode::kGroupCount; i++) {
218 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i]; 228 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i];
219 if (group_objects == NULL) continue; 229 if (group_objects == NULL) continue;
220 DCHECK(!object_wrapper_.is_null()); 230 DCHECK(!object_wrapper_.is_null());
221 for (int j = 0; j < group_objects->length(); j++) { 231 for (int j = 0; j < group_objects->length(); j++) {
222 DependentCode::DependencyGroup group = 232 DependentCode::DependencyGroup group =
223 static_cast<DependentCode::DependencyGroup>(i); 233 static_cast<DependentCode::DependencyGroup>(i);
224 DependentCode* dependent_code = 234 DependentCode* dependent_code =
225 DependentCode::ForObject(group_objects->at(j), group); 235 DependentCode::ForObject(group_objects->at(j), group);
226 dependent_code->UpdateToFinishedCode(group, this, *code); 236 dependent_code->UpdateToFinishedCode(group, *object_wrapper(), *cell);
227 } 237 }
228 dependencies_[i] = NULL; // Zone-allocated, no need to delete. 238 dependencies_[i] = NULL; // Zone-allocated, no need to delete.
229 } 239 }
230 } 240 }
231 241
232 242
233 void CompilationInfo::RollbackDependencies() { 243 void CompilationInfo::RollbackDependencies() {
244 AllowDeferredHandleDereference get_object_wrapper;
234 // Unregister from all dependent maps if not yet committed. 245 // Unregister from all dependent maps if not yet committed.
235 for (int i = 0; i < DependentCode::kGroupCount; i++) { 246 for (int i = 0; i < DependentCode::kGroupCount; i++) {
236 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i]; 247 ZoneList<Handle<HeapObject> >* group_objects = dependencies_[i];
237 if (group_objects == NULL) continue; 248 if (group_objects == NULL) continue;
238 for (int j = 0; j < group_objects->length(); j++) { 249 for (int j = 0; j < group_objects->length(); j++) {
239 DependentCode::DependencyGroup group = 250 DependentCode::DependencyGroup group =
240 static_cast<DependentCode::DependencyGroup>(i); 251 static_cast<DependentCode::DependencyGroup>(i);
241 DependentCode* dependent_code = 252 DependentCode* dependent_code =
242 DependentCode::ForObject(group_objects->at(j), group); 253 DependentCode::ForObject(group_objects->at(j), group);
243 dependent_code->RemoveCompilationInfo(group, this); 254 dependent_code->RemoveCompilationInfo(group, *object_wrapper());
244 } 255 }
245 dependencies_[i] = NULL; // Zone-allocated, no need to delete. 256 dependencies_[i] = NULL; // Zone-allocated, no need to delete.
246 } 257 }
247 } 258 }
248 259
249 260
250 int CompilationInfo::num_parameters() const { 261 int CompilationInfo::num_parameters() const {
251 if (IsStub()) { 262 if (IsStub()) {
252 DCHECK(parameter_count_ > 0); 263 DCHECK(parameter_count_ > 0);
253 return parameter_count_; 264 return parameter_count_;
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 AllowHandleDereference allow_deref; 1594 AllowHandleDereference allow_deref;
1584 bool tracing_on = info()->IsStub() 1595 bool tracing_on = info()->IsStub()
1585 ? FLAG_trace_hydrogen_stubs 1596 ? FLAG_trace_hydrogen_stubs
1586 : (FLAG_trace_hydrogen && 1597 : (FLAG_trace_hydrogen &&
1587 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1598 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1588 return (tracing_on && 1599 return (tracing_on &&
1589 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1600 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1590 } 1601 }
1591 1602
1592 } } // namespace v8::internal 1603 } } // namespace v8::internal
OLDNEW
« 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