Revision: 8142
Author:   [email protected]
Date:     Wed Jun  1 04:46:14 2011
Log: Ensure strings are never externalized as a side-effect of doing a GC.
Review URL: http://codereview.chromium.org/7105016
http://code.google.com/p/v8/source/detail?r=8142

Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h

=======================================
--- /branches/bleeding_edge/src/api.cc  Mon May 30 07:33:23 2011
+++ /branches/bleeding_edge/src/api.cc  Wed Jun  1 04:46:14 2011
@@ -4264,6 +4264,9 @@
   if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
     return false;
   }
+  if (isolate->heap()->IsInGCPostProcessing()) {
+    return false;
+  }
   bool result = obj->MakeExternal(resource);
   if (result && !obj->IsSymbol()) {
     isolate->heap()->external_string_table()->AddString(*obj);
@@ -4296,6 +4299,9 @@
   if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
     return false;
   }
+  if (isolate->heap()->IsInGCPostProcessing()) {
+    return false;
+  }
   bool result = obj->MakeExternal(resource);
   if (result && !obj->IsSymbol()) {
     isolate->heap()->external_string_table()->AddString(*obj);
=======================================
--- /branches/bleeding_edge/src/heap.cc Wed Jun  1 01:49:18 2011
+++ /branches/bleeding_edge/src/heap.cc Wed Jun  1 04:46:14 2011
@@ -107,6 +107,7 @@
       cell_space_(NULL),
       lo_space_(NULL),
       gc_state_(NOT_IN_GC),
+      gc_post_processing_depth_(0),
       mc_count_(0),
       ms_count_(0),
       gc_count_(0),
@@ -793,12 +794,14 @@
   }

   isolate_->counters()->objs_since_last_young()->Set(0);
-
+
+  gc_post_processing_depth_++;
   { DisableAssertNoAllocation allow_allocation;
     GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
     next_gc_likely_to_collect_more =
isolate_->global_handles()->PostGarbageCollectionProcessing(collector);
   }
+  gc_post_processing_depth_--;

   // Update relocatables.
   Relocatable::PostGarbageCollectionProcessing();
=======================================
--- /branches/bleeding_edge/src/heap.h  Tue May 24 05:16:23 2011
+++ /branches/bleeding_edge/src/heap.h  Wed Jun  1 04:46:14 2011
@@ -1053,6 +1053,8 @@

   enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
   inline HeapState gc_state() { return gc_state_; }
+
+ inline bool IsInGCPostProcessing() { return gc_post_processing_depth_ > 0; }

 #ifdef DEBUG
   bool IsAllocationAllowed() { return allocation_allowed_; }
@@ -1277,6 +1279,7 @@
   CellSpace* cell_space_;
   LargeObjectSpace* lo_space_;
   HeapState gc_state_;
+  int gc_post_processing_depth_;

   // Returns the size of object residing in non new spaces.
   intptr_t PromotedSpaceSize();

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

Reply via email to