Push version 1.3.8 to trunk.

Changed the handling of idle notifications to allow idle notifications when V8 has not yet been initialized.

Fixed ARM simulator compilation problem on Windows.


git-svn-id: http://v8.googlecode.com/svn/trunk@2759 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/heap.cc b/src/heap.cc
index ef4c2d4..7e73eae 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2785,6 +2785,39 @@
 }
 
 
+bool Heap::IdleNotification() {
+  static const int kIdlesBeforeCollection = 7;
+  static int number_idle_notifications = 0;
+  static int last_gc_count = gc_count_;
+
+  bool finished = false;
+
+  if (last_gc_count == gc_count_) {
+    number_idle_notifications++;
+  } else {
+    number_idle_notifications = 0;
+    last_gc_count = gc_count_;
+  }
+
+  if (number_idle_notifications >= kIdlesBeforeCollection) {
+    // The first time through we collect without forcing compaction.
+    // The second time through we force compaction and quit.
+    bool force_compaction =
+        number_idle_notifications > kIdlesBeforeCollection;
+    CollectAllGarbage(force_compaction);
+    last_gc_count = gc_count_;
+    if (force_compaction) {
+      number_idle_notifications = 0;
+      finished = true;
+    }
+  }
+
+  // Uncommit unused memory in new space.
+  Heap::UncommitFromSpace();
+  return finished;
+}
+
+
 #ifdef DEBUG
 
 void Heap::Print() {