From ff9ceebe2f9dc202beada3dda5af56362b7781be Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Tue, 23 Apr 2013 15:21:11 +0000 Subject: [PATCH] Add a flag to deoptimize all functions every n garbage collections. R=mstarzinger@chromium.org Review URL: https://chromiumcodereview.appspot.com/14091013 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14395 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/flag-definitions.h | 3 +++ src/heap.cc | 7 +++++++ src/heap.h | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 9c9362b..bc699dc 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -230,6 +230,9 @@ DEFINE_bool(stress_environments, false, "environment for every instruction") DEFINE_int(deopt_every_n_times, 0, "deoptimize every n times a deopt point is passed") +DEFINE_int(deopt_every_n_garbage_collections, + 0, + "deoptimize every n garbage collections") DEFINE_bool(trap_on_deopt, false, "put a break point before deoptimizing") DEFINE_bool(deoptimize_uncommon_cases, true, "deoptimize uncommon cases") DEFINE_bool(polymorphic_inlining, true, "polymorphic inlining") diff --git a/src/heap.cc b/src/heap.cc index 10cb473..82d586c 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -157,6 +157,7 @@ Heap::Heap() ms_count_at_last_idle_notification_(0), gc_count_at_last_idle_gc_(0), scavenges_since_last_idle_round_(kIdleScavengeThreshold), + gcs_since_last_deopt_(0), #ifdef VERIFY_HEAP no_weak_embedded_maps_verification_scope_depth_(0), #endif @@ -487,6 +488,12 @@ void Heap::GarbageCollectionEpilogue() { if (FLAG_gc_verbose) Print(); if (FLAG_code_stats) ReportCodeStatistics("After GC"); #endif + if (FLAG_deopt_every_n_garbage_collections > 0) { + if (++gcs_since_last_deopt_ == FLAG_deopt_every_n_garbage_collections) { + Deoptimizer::DeoptimizeAll(isolate()); + gcs_since_last_deopt_ = 0; + } + } isolate_->counters()->alive_after_last_gc()->Set( static_cast(SizeOfObjects())); diff --git a/src/heap.h b/src/heap.h index 49cce59..3b8a9ea 100644 --- a/src/heap.h +++ b/src/heap.h @@ -2295,6 +2295,11 @@ class Heap { unsigned int gc_count_at_last_idle_gc_; int scavenges_since_last_idle_round_; + // If the --deopt_every_n_garbage_collections flag is set to a positive value, + // this variable holds the number of garbage collections since the last + // deoptimization triggered by garbage collection. + int gcs_since_last_deopt_; + #ifdef VERIFY_HEAP int no_weak_embedded_maps_verification_scope_depth_; #endif -- 2.7.4