Reviewers: Vitaly Repeshko, Vyacheslav Egorov,

Description:
Ensure strings are never externalized as a side-effect of doing a GC.

Please review this at http://codereview.chromium.org/7105016/

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

Affected files:
  M     src/api.cc
  M     src/heap.h
  M     src/heap.cc


Index: src/api.cc
===================================================================
--- src/api.cc  (revision 8139)
+++ src/api.cc  (working copy)
@@ -4264,6 +4264,9 @@
   if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
     return false;
   }
+  if (isolate->heap()->gc_post_process_count() > 0) {
+    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()->gc_post_process_count() > 0) {
+    return false;
+  }
   bool result = obj->MakeExternal(resource);
   if (result && !obj->IsSymbol()) {
     isolate->heap()->external_string_table()->AddString(*obj);
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 8139)
+++ src/heap.cc (working copy)
@@ -107,6 +107,7 @@
       cell_space_(NULL),
       lo_space_(NULL),
       gc_state_(NOT_IN_GC),
+      gc_post_process_count_(0),
       mc_count_(0),
       ms_count_(0),
       gc_count_(0),
@@ -793,12 +794,14 @@
   }

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

   // Update relocatables.
   Relocatable::PostGarbageCollectionProcessing();
Index: src/heap.h
===================================================================
--- src/heap.h  (revision 8139)
+++ src/heap.h  (working copy)
@@ -1053,7 +1053,10 @@

   enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
   inline HeapState gc_state() { return gc_state_; }
+
+  inline int gc_post_process_count() { return gc_post_process_count_; }

+
 #ifdef DEBUG
   bool IsAllocationAllowed() { return allocation_allowed_; }
   inline bool allow_allocation(bool enable);
@@ -1277,6 +1280,7 @@
   CellSpace* cell_space_;
   LargeObjectSpace* lo_space_;
   HeapState gc_state_;
+  int gc_post_process_count_;

   // 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