From 17cfe680155c7310b97a7ba2980fa6f68d8a633a Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Fri, 7 Jun 2013 13:27:03 +0000 Subject: [PATCH] Enable map dependency to in-flight compilation info. R=ulan@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/16542003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15005 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 12 +- src/arm/lithium-codegen-arm.h | 2 - src/compiler.cc | 48 +++++++- src/compiler.h | 53 +++++++-- src/hydrogen-instructions.h | 26 ++-- src/hydrogen.cc | 99 ++++++++-------- src/hydrogen.h | 3 +- src/ia32/lithium-codegen-ia32.cc | 12 +- src/ia32/lithium-codegen-ia32.h | 2 - src/mark-compact.cc | 14 ++- src/mips/lithium-codegen-mips.cc | 12 +- src/mips/lithium-codegen-mips.h | 2 - src/objects-inl.h | 41 ++++--- src/objects.cc | 111 +++++++++++++++--- src/objects.h | 32 +++-- src/runtime.cc | 10 +- src/runtime.h | 2 +- src/x64/lithium-codegen-x64.cc | 12 +- src/x64/lithium-codegen-x64.h | 2 - .../mjsunit/compiler/parallel-proto-change.js | 17 ++- test/mjsunit/manual-parallel-recompile.js | 18 ++- test/mjsunit/parallel-optimize-disabled.js | 2 +- 22 files changed, 359 insertions(+), 173 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index d1be92f134..d1d4fe0534 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -87,10 +87,8 @@ void LCodeGen::FinishCode(Handle code) { RegisterDependentCodeForEmbeddedMaps(code); } PopulateDeoptimizationData(code); - for (int i = 0 ; i < prototype_maps_.length(); i++) { - prototype_maps_.at(i)->AddDependentCode( - DependentCode::kPrototypeCheckGroup, code); - } + info()->CommitDependentMaps(code); + for (int i = 0 ; i < transition_maps_.length(); i++) { transition_maps_.at(i)->AddDependentCode( DependentCode::kTransitionGroup, code); @@ -5399,11 +5397,7 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { ASSERT(prototypes->length() == maps->length()); - if (instr->hydrogen()->CanOmitPrototypeChecks()) { - for (int i = 0; i < maps->length(); i++) { - prototype_maps_.Add(maps->at(i), info()->zone()); - } - } else { + if (!instr->hydrogen()->CanOmitPrototypeChecks()) { for (int i = 0; i < prototypes->length(); i++) { __ LoadHeapObject(prototype_reg, prototypes->at(i)); __ ldr(map_reg, FieldMemOperand(prototype_reg, HeapObject::kMapOffset)); diff --git a/src/arm/lithium-codegen-arm.h b/src/arm/lithium-codegen-arm.h index c7ccdfbb17..45e4af6890 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -56,7 +56,6 @@ class LCodeGen BASE_EMBEDDED { deoptimizations_(4, info->zone()), deopt_jump_table_(4, info->zone()), deoptimization_literals_(8, info->zone()), - prototype_maps_(0, info->zone()), transition_maps_(0, info->zone()), inlined_function_count_(0), scope_(info->scope()), @@ -410,7 +409,6 @@ class LCodeGen BASE_EMBEDDED { ZoneList deoptimizations_; ZoneList deopt_jump_table_; ZoneList > deoptimization_literals_; - ZoneList > prototype_maps_; ZoneList > transition_maps_; int inlined_function_count_; Scope* const scope_; diff --git a/src/compiler.cc b/src/compiler.cc index 5fc107f943..c6b911feec 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -106,6 +106,9 @@ void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) { opt_count_ = shared_info().is_null() ? 0 : shared_info()->opt_count(); no_frame_ranges_ = isolate->cpu_profiler()->is_profiling() ? new List(2) : NULL; + for (int i = 0; i < DependentCode::kGroupCount; i++) { + dependent_maps_[i] = NULL; + } if (mode == STUB) { mode_ = STUB; return; @@ -125,6 +128,41 @@ void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) { CompilationInfo::~CompilationInfo() { delete deferred_handles_; delete no_frame_ranges_; +#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++) { + ASSERT_EQ(NULL, dependent_maps_[i]); + } +#endif // DEBUG +} + + +void CompilationInfo::CommitDependentMaps(Handle code) { + for (int i = 0; i < DependentCode::kGroupCount; i++) { + ZoneList >* group_maps = dependent_maps_[i]; + if (group_maps == NULL) continue; + ASSERT(!object_wrapper_.is_null()); + for (int j = 0; j < group_maps->length(); j++) { + group_maps->at(j)->dependent_code()->UpdateToFinishedCode( + static_cast(i), this, *code); + } + dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. + } +} + + +void CompilationInfo::RollbackDependentMaps() { + // Unregister from all dependent maps if not yet committed. + for (int i = 0; i < DependentCode::kGroupCount; i++) { + ZoneList >* group_maps = dependent_maps_[i]; + if (group_maps == NULL) continue; + for (int j = 0; j < group_maps->length(); j++) { + group_maps->at(j)->dependent_code()->RemoveCompilationInfo( + static_cast(i), this); + } + dependent_maps_[i] = NULL; // Zone-allocated, no need to delete. + } } @@ -982,7 +1020,7 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { // The function may have already been optimized by OSR. Simply continue. // Except when OSR already disabled optimization for some reason. if (info->shared_info()->optimization_disabled()) { - info->SetCode(Handle(info->shared_info()->code())); + info->AbortOptimization(); InstallFullCode(*info); if (FLAG_trace_parallel_recompilation) { PrintF(" ** aborting optimization for "); @@ -1000,9 +1038,11 @@ void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) { // If crankshaft succeeded, install the optimized code else install // the unoptimized code. OptimizingCompiler::Status status = optimizing_compiler->last_status(); - if (status != OptimizingCompiler::SUCCEEDED) { - optimizing_compiler->info()->set_bailout_reason( - "failed/bailed out last time"); + if (info->HasAbortedDueToDependentMap()) { + info->set_bailout_reason("bailed out due to dependent map"); + status = optimizing_compiler->AbortOptimization(); + } else if (status != OptimizingCompiler::SUCCEEDED) { + info->set_bailout_reason("failed/bailed out last time"); status = optimizing_compiler->AbortOptimization(); } else { status = optimizing_compiler->GenerateAndInstallCode(); diff --git a/src/compiler.h b/src/compiler.h index 8e6d295996..f53feb954a 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -57,12 +57,8 @@ struct OffsetRange { // is constructed based on the resources available at compile-time. class CompilationInfo { public: - CompilationInfo(Handle