Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Unified Diff: test/cctest/test-api.cc

Issue 467037: External string table. (Closed)
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/heap.cc ('K') | « src/v8-counters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 6d6c174fd09e171d2a52e0284e68832839a44645..3e3c9578e3b23cf2641e126a76ae325d5d455bcc 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -447,6 +447,40 @@ THREADED_TEST(UsingExternalAsciiString) {
}
+THREADED_TEST(ScavengeExternalString) {
+ TestResource::dispose_count = 0;
+ {
+ v8::HandleScope scope;
+ uint16_t* two_byte_string = AsciiToTwoByteString("test string");
+ Local<String> string =
+ String::NewExternal(new TestResource(two_byte_string));
+ i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
+ i::Heap::CollectGarbage(0, i::NEW_SPACE);
+ CHECK(i::Heap::InNewSpace(*istring));
+ CHECK_EQ(0, TestResource::dispose_count);
+ }
+ i::Heap::CollectGarbage(0, i::NEW_SPACE);
+ CHECK_EQ(1, TestResource::dispose_count);
+}
+
+
+THREADED_TEST(ScavengeExternalAsciiString) {
+ TestAsciiResource::dispose_count = 0;
+ {
+ v8::HandleScope scope;
+ const char* one_byte_string = "test string";
+ Local<String> string = String::NewExternal(
+ new TestAsciiResource(i::StrDup(one_byte_string)));
+ i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
+ i::Heap::CollectGarbage(0, i::NEW_SPACE);
+ CHECK(i::Heap::InNewSpace(*istring));
+ CHECK_EQ(0, TestAsciiResource::dispose_count);
+ }
+ i::Heap::CollectGarbage(0, i::NEW_SPACE);
+ CHECK_EQ(1, TestAsciiResource::dispose_count);
+}
+
+
THREADED_TEST(StringConcat) {
{
v8::HandleScope scope;
« src/heap.cc ('K') | « src/v8-counters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698