From: hpayer@chromium.org Date: Thu, 16 Jan 2014 11:54:12 +0000 (+0000) Subject: Deopt marked code at safe deoptimization point when pretenuring. X-Git-Tag: upstream/4.7.83~11132 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76284bdcad5c0cda3c88ea80274d41daecaf56fc;p=platform%2Fupstream%2Fv8.git Deopt marked code at safe deoptimization point when pretenuring. BUG= R=bmeurer@chromium.org, mvstanton@chromium.org Review URL: https://codereview.chromium.org/138033012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18641 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/execution.cc b/src/execution.cc index a9f72b3..da2d880 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -502,6 +502,19 @@ void StackGuard::FullDeopt() { } +bool StackGuard::IsDeoptMarkedCode() { + ExecutionAccess access(isolate_); + return (thread_local_.interrupt_flags_ & DEOPT_MARKED_CODE) != 0; +} + + +void StackGuard::DeoptMarkedCode() { + ExecutionAccess access(isolate_); + thread_local_.interrupt_flags_ |= DEOPT_MARKED_CODE; + set_interrupt_limits(access); +} + + #ifdef ENABLE_DEBUGGER_SUPPORT bool StackGuard::IsDebugBreak() { ExecutionAccess access(isolate_); @@ -1013,6 +1026,10 @@ MaybeObject* Execution::HandleStackGuardInterrupt(Isolate* isolate) { stack_guard->Continue(FULL_DEOPT); Deoptimizer::DeoptimizeAll(isolate); } + if (stack_guard->IsDeoptMarkedCode()) { + stack_guard->Continue(DEOPT_MARKED_CODE); + Deoptimizer::DeoptimizeMarkedCode(isolate); + } if (stack_guard->IsInstallCodeRequest()) { ASSERT(isolate->concurrent_recompilation_enabled()); stack_guard->Continue(INSTALL_CODE); diff --git a/src/execution.h b/src/execution.h index 3e62d87..abf4f1d 100644 --- a/src/execution.h +++ b/src/execution.h @@ -44,7 +44,8 @@ enum InterruptFlag { GC_REQUEST = 1 << 5, FULL_DEOPT = 1 << 6, INSTALL_CODE = 1 << 7, - API_INTERRUPT = 1 << 8 + API_INTERRUPT = 1 << 8, + DEOPT_MARKED_CODE = 1 << 9 }; @@ -221,6 +222,8 @@ class StackGuard { void RequestInstallCode(); bool IsFullDeopt(); void FullDeopt(); + bool IsDeoptMarkedCode(); + void DeoptMarkedCode(); void Continue(InterruptFlag after_what); void RequestInterrupt(InterruptCallback callback, void* data); diff --git a/src/heap.cc b/src/heap.cc index cc9c688..ea3cef8 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -521,6 +521,7 @@ void Heap::ProcessPretenuringFeedback() { int i = 0; Object* list_element = allocation_sites_list(); + bool trigger_deoptimization = false; while (use_scratchpad ? i < allocation_sites_scratchpad_length : list_element->IsAllocationSite()) { @@ -530,12 +531,11 @@ void Heap::ProcessPretenuringFeedback() { if (site->memento_found_count() > 0) { active_allocation_sites++; } - if (site->DigestPretenuringFeedback()) { - if (site->GetPretenureMode() == TENURED) { - tenure_decisions++; - } else { - dont_tenure_decisions++; - } + if (site->DigestPretenuringFeedback()) trigger_deoptimization = true; + if (site->GetPretenureMode() == TENURED) { + tenure_decisions++; + } else { + dont_tenure_decisions++; } allocation_sites++; if (use_scratchpad) { @@ -544,6 +544,9 @@ void Heap::ProcessPretenuringFeedback() { list_element = site->weak_next(); } } + + if (trigger_deoptimization) isolate_->stack_guard()->DeoptMarkedCode(); + allocation_sites_scratchpad_length = 0; // TODO(mvstanton): Pretenure decisions are only made once for an allocation @@ -1998,7 +2001,7 @@ void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) { } cur = casted->weak_next(); } - if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate_); + if (marked) isolate_->stack_guard()->DeoptMarkedCode(); } diff --git a/src/objects-inl.h b/src/objects-inl.h index 49e4d69..21a36d7 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1397,7 +1397,7 @@ inline void AllocationSite::IncrementMementoCreateCount() { inline bool AllocationSite::DigestPretenuringFeedback() { - bool decision_made = false; + bool decision_changed = false; int create_count = memento_create_count(); if (create_count >= kPretenureMinimumCreated) { int found_count = memento_found_count(); @@ -1411,9 +1411,9 @@ inline bool AllocationSite::DigestPretenuringFeedback() { ? kTenure : kDontTenure; set_pretenure_decision(result); - decision_made = true; if (current_mode != GetPretenureMode()) { - dependent_code()->DeoptimizeDependentCodeGroup( + decision_changed = true; + dependent_code()->MarkCodeForDeoptimization( GetIsolate(), DependentCode::kAllocationSiteTenuringChangedGroup); } @@ -1422,7 +1422,7 @@ inline bool AllocationSite::DigestPretenuringFeedback() { // Clear feedback calculation fields until the next gc. set_memento_found_count(0); set_memento_create_count(0); - return decision_made; + return decision_changed; }