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

Unified Diff: src/objects.cc

Issue 2199863002: Clear recorded slots when making a string external. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: clear only if has pointers Created 4 years, 4 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 | « no previous file | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 38deeb825d4b291c707d5e76c1f3cffbf4f1b94a..72b184a568ee83672162094fce0364f26ad6534a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2003,6 +2003,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
Heap* heap = GetHeap();
bool is_one_byte = this->IsOneByteRepresentation();
bool is_internalized = this->IsInternalizedString();
+ bool has_pointers = this->IsConsString() || this->IsSlicedString();
// Morph the string to an external string by replacing the map and
// reinitializing the fields. This won't work if the space the existing
@@ -2031,6 +2032,9 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
int new_size = this->SizeFromMap(new_map);
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size,
ClearRecordedSlots::kNo);
+ if (has_pointers) {
+ heap->ClearRecordedSlotRange(this->address(), this->address() + new_size);
+ }
// We are storing the new map using release store after creating a filler for
// the left-over space to avoid races with the sweeper thread.
@@ -2071,6 +2075,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
if (size < ExternalString::kShortSize) return false;
Heap* heap = GetHeap();
bool is_internalized = this->IsInternalizedString();
+ bool has_pointers = this->IsConsString() || this->IsSlicedString();
// Morph the string to an external string by replacing the map and
// reinitializing the fields. This won't work if the space the existing
@@ -2093,6 +2098,9 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) {
int new_size = this->SizeFromMap(new_map);
heap->CreateFillerObjectAt(this->address() + new_size, size - new_size,
ClearRecordedSlots::kNo);
+ if (has_pointers) {
+ heap->ClearRecordedSlotRange(this->address(), this->address() + new_size);
+ }
// We are storing the new map using release store after creating a filler for
// the left-over space to avoid races with the sweeper thread.
« no previous file with comments | « no previous file | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698