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

Unified Diff: src/compiler.cc

Issue 1099473004: Reland "Refactor compilation dependency handling." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/compiler.h ('k') | src/hydrogen.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 38c097e0c5a038637124d8dbd09233dac73a6ec3..ea5660d1e34e1224cee370833ecd2d2669ac6392 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -87,7 +87,7 @@ class CompilationInfoWithZone : public CompilationInfo {
// called when cast as a CompilationInfo.
virtual ~CompilationInfoWithZone() {
DisableFutureOptimization();
- RollbackDependencies();
+ dependencies()->Rollback();
delete parse_info_;
parse_info_ = nullptr;
}
@@ -143,6 +143,7 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
osr_ast_id_(BailoutId::None()),
zone_(zone),
deferred_handles_(nullptr),
+ dependencies_(isolate, zone),
bailout_reason_(kNoReason),
prologue_offset_(Code::kPrologueOffsetNotSet),
no_frame_ranges_(isolate->cpu_profiler()->is_profiling()
@@ -153,10 +154,7 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
opt_count_(has_shared_info() ? shared_info()->opt_count() : 0),
parameter_count_(0),
optimization_id_(-1),
- aborted_due_to_dependency_change_(false),
- osr_expr_stack_height_(0) {
- std::fill_n(dependencies_, DependentCode::kGroupCount, nullptr);
-}
+ osr_expr_stack_height_(0) {}
CompilationInfo::~CompilationInfo() {
@@ -166,60 +164,11 @@ CompilationInfo::~CompilationInfo() {
#ifdef DEBUG
// Check that no dependent maps have been added or added dependent maps have
// been rolled back or committed.
- for (int i = 0; i < DependentCode::kGroupCount; i++) {
- DCHECK(!dependencies_[i]);
- }
+ DCHECK(dependencies()->IsEmpty());
#endif // DEBUG
}
-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;
- 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;
- DCHECK(!object_wrapper_.is_null());
- for (int j = 0; j < group_objects->length(); j++) {
- DependentCode::DependencyGroup group =
- static_cast<DependentCode::DependencyGroup>(i);
- Foreign* info = *object_wrapper();
- DependentCode* dependent_code =
- DependentCode::ForObject(group_objects->at(j), group);
- dependent_code->UpdateToFinishedCode(group, info, cell);
- }
- dependencies_[i] = NULL; // Zone-allocated, no need to delete.
- }
-}
-
-
-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];
- if (group_objects == NULL) continue;
- for (int j = 0; j < group_objects->length(); j++) {
- DependentCode::DependencyGroup group =
- static_cast<DependentCode::DependencyGroup>(i);
- Foreign* info = *object_wrapper();
- DependentCode* dependent_code =
- DependentCode::ForObject(group_objects->at(j), group);
- dependent_code->RemoveCompilationInfo(group, info);
- }
- dependencies_[i] = NULL; // Zone-allocated, no need to delete.
- }
-}
-
-
int CompilationInfo::num_parameters() const {
return has_scope() ? scope()->num_parameters() : parameter_count_;
}
@@ -493,7 +442,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
if (graph_ == NULL) return SetLastStatus(BAILED_OUT);
- if (info()->HasAbortedDueToDependencyChange()) {
+ if (info()->dependencies()->HasAborted()) {
// Dependency has changed during graph creation. Let's try again later.
return RetryOptimization(kBailedOutDueToDependencyChange);
}
@@ -541,7 +490,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() {
return last_status();
}
- DCHECK(!info()->HasAbortedDueToDependencyChange());
+ DCHECK(!info()->dependencies()->HasAborted());
DisallowCodeDependencyChange no_dependency_change;
DisallowJavascriptExecution no_js(isolate());
{ // Scope for timer.
@@ -1522,7 +1471,7 @@ Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) {
if (job->last_status() == OptimizedCompileJob::SUCCEEDED) {
if (shared->optimization_disabled()) {
job->RetryOptimization(kOptimizationDisabled);
- } else if (info->HasAbortedDueToDependencyChange()) {
+ } else if (info->dependencies()->HasAborted()) {
job->RetryOptimization(kBailedOutDueToDependencyChange);
} else if (isolate->debug()->has_break_points()) {
job->RetryOptimization(kDebuggerHasBreakPoints);
« no previous file with comments | « src/compiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698