Reviewers: Toon Verwaest,

Description:
Put incremental code flushing behind a flag.

This is used to disable incremental code flushing by default for now
until we can stabilize it and make it ready for production.

[email protected]
BUG=chromium:159140


Please review this at https://chromiumcodereview.appspot.com/11367105/

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

Affected files:
  M src/flag-definitions.h
  M src/heap.cc
  M src/mark-compact.cc
  M test/cctest/test-heap.cc


Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 99906ef4b7ff655269e55edd57a3e68c31823a8b..0208ecb1b1180c1b6c9fdec495a56eb12678d752 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -393,7 +393,9 @@ DEFINE_bool(trace_external_memory, false,
 DEFINE_bool(collect_maps, true,
             "garbage collect maps from which no objects can be reached")
 DEFINE_bool(flush_code, true,
-            "flush code that we expect not to use again before full gc")
+            "flush code that we expect not to use again during full gc")
+DEFINE_bool(flush_code_incrementally, false,
+            "flush code that we expect not to use again incrementally")
 DEFINE_bool(incremental_marking, true, "use incremental marking")
DEFINE_bool(incremental_marking_steps, true, "do incremental marking steps")
 DEFINE_bool(trace_incremental_marking, false,
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 76084cfd58ac23b7b3a350049830a80bb9f664ed..9113e7bd4058619526361c01b4482174b463b413 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -420,13 +420,9 @@ void Heap::GarbageCollectionPrologue() {
   gc_count_++;
   unflattened_strings_length_ = 0;

-  bool should_enable_code_flushing = FLAG_flush_code;
-#ifdef ENABLE_DEBUGGER_SUPPORT
- if (isolate_->debug()->IsLoaded() || isolate_->debug()->has_break_points()) {
-    should_enable_code_flushing = false;
+  if (FLAG_flush_code && FLAG_flush_code_incrementally) {
+    mark_compact_collector()->EnableCodeFlushing(true);
   }
-#endif
- mark_compact_collector()->EnableCodeFlushing(should_enable_code_flushing);

 #ifdef VERIFY_HEAP
   if (FLAG_verify_heap) {
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index 641293399e6297d6824c2d07ee1d0ecf6cddd91b..ebba22b44a875b01006d01f0fe790636775ed8bf 100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -1471,6 +1471,11 @@ void MarkCompactCollector::PrepareThreadForCodeFlushing(Isolate* isolate,
 void MarkCompactCollector::PrepareForCodeFlushing() {
   ASSERT(heap() == Isolate::Current()->heap());

+  // Enable code flushing for non-incremental cycles.
+  if (FLAG_flush_code && !FLAG_flush_code_incrementally) {
+    EnableCodeFlushing(!was_marked_incrementally_);
+  }
+
   // If code flushing is disabled, there is no need to prepare for it.
   if (!is_code_flushing_enabled()) return;

@@ -2033,6 +2038,11 @@ void MarkCompactCollector::AfterMarking() {
   // Flush code from collected candidates.
   if (is_code_flushing_enabled()) {
     code_flusher_->ProcessCandidates();
+    // If incremental marker does not support code flushing, we need to
+    // disable it before incremental marking steps for next cycle.
+    if (FLAG_flush_code && !FLAG_flush_code_incrementally) {
+      EnableCodeFlushing(false);
+    }
   }

   if (!FLAG_watch_ic_patching) {
@@ -3607,6 +3617,13 @@ void MarkCompactCollector::SweepSpaces() {


 void MarkCompactCollector::EnableCodeFlushing(bool enable) {
+#ifdef ENABLE_DEBUGGER_SUPPORT
+  if (heap()->isolate()->debug()->IsLoaded() ||
+      heap()->isolate()->debug()->has_break_points()) {
+    enable = false;
+  }
+#endif
+
   if (enable) {
     if (code_flusher_ != NULL) return;
     code_flusher_ = new CodeFlusher(heap()->isolate());
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 696dc864430d2c72250a8ac60be5411080c7c94f..811973b46ad3f87e636b79e39a00180f7c5f8ef2 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -1003,7 +1003,7 @@ TEST(TestCodeFlushing) {

 TEST(TestCodeFlushingIncremental) {
   // If we do not flush code this test is invalid.
-  if (!FLAG_flush_code) return;
+  if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
   v8::HandleScope scope;
@@ -1071,7 +1071,7 @@ TEST(TestCodeFlushingIncremental) {

 TEST(TestCodeFlushingIncrementalScavenge) {
   // If we do not flush code this test is invalid.
-  if (!FLAG_flush_code) return;
+  if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
   v8::HandleScope scope;


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to