From: yangguo@chromium.org Date: Wed, 12 Jun 2013 09:43:22 +0000 (+0000) Subject: Reland "Enable map dependency to in-flight compilation info." X-Git-Tag: upstream/4.7.83~13898 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=74556569d1cca582622125a6415507e949282133;p=platform%2Fupstream%2Fv8.git Reland "Enable map dependency to in-flight compilation info." BUG=248076 R=ulan@chromium.org Review URL: https://chromiumcodereview.appspot.com/16782004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15077 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 96befb0..ed7e779 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -87,20 +87,7 @@ 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); - } - for (int i = 0 ; i < transition_maps_.length(); i++) { - transition_maps_.at(i)->AddDependentCode( - DependentCode::kTransitionGroup, code); - } - if (graph()->depends_on_empty_array_proto_elements()) { - isolate()->initial_object_prototype()->map()->AddDependentCode( - DependentCode::kElementsCantBeAddedGroup, code); - isolate()->initial_array_prototype()->map()->AddDependentCode( - DependentCode::kElementsCantBeAddedGroup, code); - } + info()->CommitDependentMaps(code); } @@ -4267,9 +4254,6 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } if (!transition.is_null()) { - if (transition->CanBeDeprecated()) { - transition_maps_.Add(transition, info()->zone()); - } __ mov(scratch, Operand(transition)); __ str(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); if (instr->hydrogen()->NeedsWriteBarrierForMap()) { @@ -5382,11 +5366,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 f264259..cecf152 100644 --- a/src/arm/lithium-codegen-arm.h +++ b/src/arm/lithium-codegen-arm.h @@ -56,8 +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()), status_(UNUSED), @@ -406,8 +404,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_; Status status_; diff --git a/src/compiler.cc b/src/compiler.cc index b1f8234..e8781c7 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 8e6d295..f53feb9 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