Revert "[heap, runtime] Fix conversion of large strings to thin strings."
This reverts commit b35a0789bc
.
Reason for revert: Roll blocker for https://chromium-review.googlesource.com/c/607193
Original change's description:
> [heap, runtime] Fix conversion of large strings to thin strings.
>
> This patch removes creation of fillers in the middle of a large page and
> fixes assert in Heap::NotifyObjectLayoutChange.
>
> The fillers in large pages are useless since we do not sweep large
> object space.
>
> Bug: chromium:752426
> Change-Id: I01c230223f28d6d54b7362ee70e9d83de50678fd
> Reviewed-on: https://chromium-review.googlesource.com/601994
> Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#47221}
TBR=ulan@chromium.org,jkummerow@chromium.org,mlippautz@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:752426
Change-Id: I58a632af37fa018d82693099a7a395ca5db5af0f
Reviewed-on: https://chromium-review.googlesource.com/609404
Reviewed-by: Michael Hablich <hablich@chromium.org>
Commit-Queue: Michael Hablich <hablich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47262}
This commit is contained in:
parent
58bbc6bf77
commit
dfb4f08489
@ -3307,11 +3307,6 @@ AllocationResult Heap::AllocateBytecodeArray(int length,
|
||||
|
||||
HeapObject* Heap::CreateFillerObjectAt(Address addr, int size,
|
||||
ClearRecordedSlots mode) {
|
||||
// In large object space fillers can be created only at the beginning
|
||||
// of the large page.
|
||||
DCHECK_IMPLIES(
|
||||
lo_space_->ContainsSlow(addr),
|
||||
HeapObject::cast(lo_space_->FindObject(addr))->address() == addr);
|
||||
if (size == 0) return nullptr;
|
||||
HeapObject* filler = HeapObject::FromAddress(addr);
|
||||
if (size == kPointerSize) {
|
||||
@ -3518,15 +3513,6 @@ void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) {
|
||||
}
|
||||
}
|
||||
|
||||
void Heap::RightTrimString(String* string, int old_size, int new_size) {
|
||||
if (old_size == new_size) return;
|
||||
DCHECK_LE(new_size, old_size);
|
||||
if (!lo_space_->Contains(string)) {
|
||||
Address filler = string->address() + new_size;
|
||||
CreateFillerObjectAt(filler, old_size - new_size, ClearRecordedSlots::kNo);
|
||||
}
|
||||
AdjustLiveBytes(string, -(old_size - new_size));
|
||||
}
|
||||
|
||||
AllocationResult Heap::AllocateFixedTypedArrayWithExternalPointer(
|
||||
int length, ExternalArrayType array_type, void* external_pointer,
|
||||
@ -4625,8 +4611,7 @@ void Heap::RegisterDeserializedObjectsForBlackAllocation(
|
||||
|
||||
void Heap::NotifyObjectLayoutChange(HeapObject* object, int size,
|
||||
const DisallowHeapAllocation&) {
|
||||
DCHECK(InOldSpace(object) || InNewSpace(object) ||
|
||||
(lo_space()->Contains(object) && object->IsString()));
|
||||
DCHECK(InOldSpace(object) || InNewSpace(object));
|
||||
if (FLAG_incremental_marking && incremental_marking()->IsMarking()) {
|
||||
incremental_marking()->MarkBlackAndPush(object);
|
||||
if (InOldSpace(object) && incremental_marking()->IsCompacting()) {
|
||||
|
@ -721,8 +721,6 @@ class Heap {
|
||||
// Trim the given array from the right.
|
||||
void RightTrimFixedArray(FixedArrayBase* obj, int elements_to_trim);
|
||||
|
||||
void RightTrimString(String* string, int old_size, int new_size);
|
||||
|
||||
// Converts the given boolean condition to JavaScript boolean value.
|
||||
inline Oddball* ToBoolean(bool condition);
|
||||
|
||||
|
@ -2625,7 +2625,8 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
|
||||
|
||||
// Byte size of the external String object.
|
||||
int new_size = this->SizeFromMap(new_map);
|
||||
heap->RightTrimString(this, size, new_size);
|
||||
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size,
|
||||
ClearRecordedSlots::kNo);
|
||||
if (has_pointers) {
|
||||
heap->ClearRecordedSlotRange(this->address(), this->address() + new_size);
|
||||
}
|
||||
@ -2637,6 +2638,8 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
|
||||
ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
|
||||
self->set_resource(resource);
|
||||
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
|
||||
|
||||
heap->AdjustLiveBytes(this, new_size - size);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2693,7 +2696,8 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
|
||||
|
||||
// Byte size of the external String object.
|
||||
int new_size = this->SizeFromMap(new_map);
|
||||
heap->RightTrimString(this, size, new_size);
|
||||
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size,
|
||||
ClearRecordedSlots::kNo);
|
||||
if (has_pointers) {
|
||||
heap->ClearRecordedSlotRange(this->address(), this->address() + new_size);
|
||||
}
|
||||
@ -2705,6 +2709,8 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
|
||||
ExternalOneByteString* self = ExternalOneByteString::cast(this);
|
||||
self->set_resource(resource);
|
||||
if (is_internalized) self->Hash(); // Force regeneration of the hash value.
|
||||
|
||||
heap->AdjustLiveBytes(this, new_size - size);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -17080,7 +17086,13 @@ void MakeStringThin(String* string, String* internalized, Isolate* isolate) {
|
||||
string->synchronized_set_map(*map);
|
||||
ThinString* thin = ThinString::cast(string);
|
||||
thin->set_actual(internalized);
|
||||
isolate->heap()->RightTrimString(thin, old_size, ThinString::kSize);
|
||||
Address thin_end = thin->address() + ThinString::kSize;
|
||||
int size_delta = old_size - ThinString::kSize;
|
||||
if (size_delta != 0) {
|
||||
Heap* heap = isolate->heap();
|
||||
heap->CreateFillerObjectAt(thin_end, size_delta, ClearRecordedSlots::kNo);
|
||||
heap->AdjustLiveBytes(thin, -size_delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1220,33 +1220,6 @@ TEST(InternalizeExternal) {
|
||||
CcTest::CollectGarbage(i::OLD_SPACE);
|
||||
}
|
||||
|
||||
TEST(LargeThinString) {
|
||||
CcTest::InitializeVM();
|
||||
i::Isolate* isolate = CcTest::i_isolate();
|
||||
Heap* heap = isolate->heap();
|
||||
v8::HandleScope handle_scope(CcTest::isolate());
|
||||
const char* string_generator =
|
||||
"var result = 'a';"
|
||||
"for (var i = 0; i < 20; i++) { result += result;}"
|
||||
"result;";
|
||||
v8::Local<v8::String> v8_string1 =
|
||||
CompileRun(string_generator)
|
||||
->ToString(CcTest::isolate()->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
Handle<String> string1 = v8::Utils::OpenHandle(*v8_string1);
|
||||
isolate->factory()->InternalizeName(string1);
|
||||
v8::Local<v8::String> v8_string2 =
|
||||
CompileRun(string_generator)
|
||||
->ToString(CcTest::isolate()->GetCurrentContext())
|
||||
.ToLocalChecked();
|
||||
Handle<String> string2 = v8::Utils::OpenHandle(*v8_string2);
|
||||
string2 = String::Flatten(string2);
|
||||
isolate->factory()->InternalizeName(string2);
|
||||
CHECK(heap->lo_space()->Contains(*string2));
|
||||
CHECK(string2->IsThinString());
|
||||
CcTest::CollectGarbage(i::OLD_SPACE);
|
||||
}
|
||||
|
||||
TEST(SliceFromExternal) {
|
||||
FLAG_string_slices = true;
|
||||
CcTest::InitializeVM();
|
||||
|
Loading…
Reference in New Issue
Block a user