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

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

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: forgot one Created 4 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
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index 80cbd7a62e9b2d660b72ae1432d7133a4191ed08..11e12e5f2295d19971be3e3e476bd6c7a6a7775f 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1194,6 +1194,31 @@ class OneByteVectorResource : public v8::String::ExternalOneByteStringResource {
i::Vector<const char> data_;
};
+TEST(InternalizeExternal) {
+ i::Isolate* isolate = CcTest::i_isolate();
+ Factory* factory = isolate->factory();
+ // This won't leak; the external string mechanism will call Dispose() on it.
+ OneByteVectorResource* resource =
+ new OneByteVectorResource(i::Vector<const char>("prop", 4));
+ {
+ v8::HandleScope scope(CcTest::isolate());
+ v8::Local<v8::String> ext_string =
+ v8::String::NewExternalOneByte(CcTest::isolate(), resource)
+ .ToLocalChecked();
+ Handle<String> string = v8::Utils::OpenHandle(*ext_string);
+ CHECK(string->IsExternalString());
+ CHECK(!string->IsInternalizedString());
+ CHECK(isolate->heap()->InNewSpace(*string));
+ factory->InternalizeName(string);
+ CHECK(string->IsThinString());
+ CcTest::CollectGarbage(i::NEW_SPACE);
+ CcTest::CollectGarbage(i::NEW_SPACE);
+ CHECK(string->IsInternalizedString());
+ CHECK(!isolate->heap()->InNewSpace(*string));
+ }
+ CcTest::CollectGarbage(i::OLD_SPACE);
+ CcTest::CollectGarbage(i::OLD_SPACE);
+}
TEST(SliceFromExternal) {
FLAG_string_slices = true;

Powered by Google App Engine
This is Rietveld 408576698