Refactor DeoptimizeDependentCodeGroup.
authorhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Jan 2014 10:00:03 +0000 (10:00 +0000)
committerhpayer@chromium.org <hpayer@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 16 Jan 2014 10:00:03 +0000 (10:00 +0000)
BUG=
R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/137783016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18639 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/heap.cc
src/objects.cc
src/objects.h

index 07ba97a..cc9c688 100644 (file)
@@ -1983,14 +1983,22 @@ void Heap::ProcessAllocationSites(WeakObjectRetainer* retainer,
 
 
 void Heap::ResetAllAllocationSitesDependentCode(PretenureFlag flag) {
+  ASSERT(AllowCodeDependencyChange::IsAllowed());
+  DisallowHeapAllocation no_allocation_scope;
   Object* cur = allocation_sites_list();
+  bool marked = false;
   while (cur->IsAllocationSite()) {
     AllocationSite* casted = AllocationSite::cast(cur);
     if (casted->GetPretenureMode() == flag) {
       casted->ResetPretenureDecision();
+      bool got_marked = casted->dependent_code()->MarkCodeForDeoptimization(
+          isolate_,
+          DependentCode::kAllocationSiteTenuringChangedGroup);
+      if (got_marked) marked = true;
     }
     cur = casted->weak_next();
   }
+  if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate_);
 }
 
 
index 6899caa..7e7a3c0 100644 (file)
@@ -11755,7 +11755,7 @@ bool DependentCode::Contains(DependencyGroup group, Code* code) {
 }
 
 
-void DependentCode::DeoptimizeDependentCodeGroup(
+bool DependentCode::MarkCodeForDeoptimization(
     Isolate* isolate,
     DependentCode::DependencyGroup group) {
   ASSERT(AllowCodeDependencyChange::IsAllowed());
@@ -11764,7 +11764,7 @@ void DependentCode::DeoptimizeDependentCodeGroup(
   int start = starts.at(group);
   int end = starts.at(group + 1);
   int code_entries = starts.number_of_entries();
-  if (start == end) return;
+  if (start == end) return false;
 
   // Mark all the code that needs to be deoptimized.
   bool marked = false;
@@ -11790,6 +11790,16 @@ void DependentCode::DeoptimizeDependentCodeGroup(
     clear_at(i);
   }
   set_number_of_entries(group, 0);
+  return marked;
+}
+
+
+void DependentCode::DeoptimizeDependentCodeGroup(
+    Isolate* isolate,
+    DependentCode::DependencyGroup group) {
+  ASSERT(AllowCodeDependencyChange::IsAllowed());
+  DisallowHeapAllocation no_allocation_scope;
+  bool marked = MarkCodeForDeoptimization(isolate, group);
 
   if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate);
 }
@@ -12765,9 +12775,6 @@ const double AllocationSite::kPretenureRatio = 0.60;
 
 
 void AllocationSite::ResetPretenureDecision() {
-  dependent_code()->DeoptimizeDependentCodeGroup(
-      GetIsolate(),
-      DependentCode::kAllocationSiteTenuringChangedGroup);
   set_pretenure_decision(kUndecided);
   set_memento_found_count(0);
   set_memento_create_count(0);
index cdf1e24..94acf50 100644 (file)
@@ -5642,6 +5642,9 @@ class DependentCode: public FixedArray {
   void DeoptimizeDependentCodeGroup(Isolate* isolate,
                                     DependentCode::DependencyGroup group);
 
+  bool MarkCodeForDeoptimization(Isolate* isolate,
+                                 DependentCode::DependencyGroup group);
+
   // The following low-level accessors should only be used by this class
   // and the mark compact collector.
   inline int number_of_entries(DependencyGroup group);