Commit 0ce53903 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[factory] Always tenure external strings

Since external strings are used for things like source strings, we
should tenure them from creation.

Change-Id: I226ab9036836d76d8c17ed168ad97d7f0f824278
Reviewed-on: https://chromium-review.googlesource.com/1006961
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52677}
parent 2eaee5fd
......@@ -1151,7 +1151,7 @@ MaybeHandle<String> Factory::NewExternalStringFromOneByte(
map = external_one_byte_string_map();
}
Handle<ExternalOneByteString> external_string(
ExternalOneByteString::cast(New(map, NOT_TENURED)), isolate());
ExternalOneByteString::cast(New(map, TENURED)), isolate());
external_string->set_length(static_cast<int>(length));
external_string->set_hash_field(String::kEmptyHashField);
external_string->set_resource(resource);
......@@ -1183,7 +1183,7 @@ MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
: external_string_map();
}
Handle<ExternalTwoByteString> external_string(
ExternalTwoByteString::cast(New(map, NOT_TENURED)), isolate());
ExternalTwoByteString::cast(New(map, TENURED)), isolate());
external_string->set_length(static_cast<int>(length));
external_string->set_hash_field(String::kEmptyHashField);
external_string->set_resource(resource);
......
......@@ -788,6 +788,7 @@ THREADED_TEST(NewExternalForVeryLongString) {
THREADED_TEST(ScavengeExternalString) {
ManualGCScope manual_gc_scope;
i::FLAG_stress_compaction = false;
i::FLAG_gc_global = false;
int dispose_count = 0;
......@@ -812,6 +813,7 @@ THREADED_TEST(ScavengeExternalString) {
THREADED_TEST(ScavengeExternalOneByteString) {
ManualGCScope manual_gc_scope;
i::FLAG_stress_compaction = false;
i::FLAG_gc_global = false;
int dispose_count = 0;
......
......@@ -1202,7 +1202,7 @@ TEST(InternalizeExternal) {
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));
new OneByteVectorResource(i::Vector<const char>("prop-1234", 9));
{
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::String> ext_string =
......@@ -1211,11 +1211,13 @@ TEST(InternalizeExternal) {
Handle<String> string = v8::Utils::OpenHandle(*ext_string);
CHECK(string->IsExternalString());
CHECK(!string->IsInternalizedString());
CHECK(isolate->heap()->InNewSpace(*string));
CHECK(!isolate->heap()->InNewSpace(*string));
CHECK_EQ(
isolate->factory()->string_table()->LookupStringIfExists_NoAllocate(
*string),
Smi::FromInt(ResultSentinel::kNotFound));
factory->InternalizeName(string);
CHECK(string->IsThinString());
CcTest::CollectGarbage(i::NEW_SPACE);
CcTest::CollectGarbage(i::NEW_SPACE);
CHECK(string->IsExternalString());
CHECK(string->IsInternalizedString());
CHECK(!isolate->heap()->InNewSpace(*string));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment