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

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

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: rebased Created 3 years, 11 months 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
« no previous file with comments | « test/cctest/test-code-stub-assembler.cc ('k') | test/mjsunit/thin-strings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-strings.cc
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index d7b51f8274cbaf35058f14ad7ebb38ac2866d1fb..ff3b7bddaa094edf0e5b68ad15a420378838b74f 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -1195,6 +1195,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;
« no previous file with comments | « test/cctest/test-code-stub-assembler.cc ('k') | test/mjsunit/thin-strings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698