Reviewers: Benedikt Meurer, mvstanton,

Description:
Deopt marked code at safe deoptimization point when pretenuring.

BUG=

Please review this at https://codereview.chromium.org/138033012/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+35, -12 lines):
  M src/execution.h
  M src/execution.cc
  M src/heap.cc
  M src/objects-inl.h


Index: src/execution.cc
diff --git a/src/execution.cc b/src/execution.cc
index a9f72b33a0c6e2ced9cfcd00900c6cbafe096375..da2d880a4941ee88a8521530b5223dda3a1be395 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);
Index: src/execution.h
diff --git a/src/execution.h b/src/execution.h
index 3e62d8730ab471bc71f9d0ce5dc603be0356854e..abf4f1dc654bdcd38fd0ef61b3237931c6b07afa 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);
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index cc9c688e88f1f4e194d033d7881838ca6ce08ba0..ea3cef8c4a5983bea9166278c82662cf95cfd724 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();
 }


Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 49e4d69ac4a9ede533fd9ee41e370e28d5168715..21a36d76896db35da88e06e7a273ecd796244c39 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;
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to