Revision: 18001
Author:   [email protected]
Date:     Fri Nov 22 10:52:15 2013 UTC
Log:      Dispose external string resource on heap teardown.

[email protected]

Review URL: https://codereview.chromium.org/83253002
http://code.google.com/p/v8/source/detail?r=18001

Modified:
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/src/heap.cc Thu Nov 21 17:21:00 2013 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri Nov 22 10:52:15 2013 UTC
@@ -7816,7 +7816,13 @@


 void ExternalStringTable::TearDown() {
+  for (int i = 0; i < new_space_strings_.length(); ++i) {
+ heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i]));
+  }
   new_space_strings_.Free();
+  for (int i = 0; i < old_space_strings_.length(); ++i) {
+ heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i]));
+  }
   old_space_strings_.Free();
 }

=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Thu Nov 21 13:47:37 2013 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Fri Nov 22 10:52:15 2013 UTC
@@ -17186,6 +17186,26 @@
   v8::V8::VisitExternalResources(&visitor);
   visitor.CheckVisitedResources();
 }
+
+
+TEST(ExternalStringCollectedAtTearDown) {
+  int destroyed = 0;
+  v8::Isolate* isolate = v8::Isolate::New();
+  { v8::Isolate::Scope isolate_scope(isolate);
+    v8::HandleScope handle_scope(isolate);
+ const char* s = "One string to test them all, one string to find them.";
+    TestAsciiResource* inscription =
+        new TestAsciiResource(i::StrDup(s), &destroyed);
+    v8::Local<v8::String> ring = v8::String::NewExternal(inscription);
+    // Ring is still alive.  Orcs are roaming freely across our lands.
+    CHECK_EQ(0, destroyed);
+    USE(ring);
+  }
+
+  isolate->Dispose();
+  // Ring has been destroyed.  Free Peoples of Middle-earth Rejoice.
+  CHECK_EQ(1, destroyed);
+}


 static double DoubleFromBits(uint64_t value) {

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to