Reviewers: Benedikt Meurer,
Description:
Dispose external string resource on heap teardown.
[email protected]
Please review this at https://codereview.chromium.org/83253002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+26, -0 lines):
M src/heap.cc
M test/cctest/test-api.cc
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
b5fe18454e31005d64bb7e611a25dd60449eea67..f28c9260b9d8ebc211381ed971db3bbfaad88977
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -7816,7 +7816,13 @@ void ExternalStringTable::CleanUp() {
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();
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
761b402fa7dfe4d0d6bc3d022c6d54a1f71fd0fc..7803c873a18711126c07310b294ee50aa51415ef
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -17188,6 +17188,26 @@ TEST(VisitExternalStrings) {
}
+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) {
double target;
i::OS::MemCopy(&target, &value, sizeof(target));
--
--
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.