[heap] ExternalStringTable: Separate Iterate and CleanUp methods
This way we can just process new space strings when needed. BUG=chromium:651354 Review-Url: https://codereview.chromium.org/2515643002 Cr-Commit-Position: refs/heads/master@{#41107}
This commit is contained in:
parent
cfd1dd2f95
commit
80339771e3
@ -702,12 +702,15 @@ void Heap::ExternalStringTable::AddString(String* string) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Heap::ExternalStringTable::Iterate(ObjectVisitor* v) {
|
||||
void Heap::ExternalStringTable::IterateNewSpaceStrings(ObjectVisitor* v) {
|
||||
if (!new_space_strings_.is_empty()) {
|
||||
Object** start = &new_space_strings_[0];
|
||||
v->VisitPointers(start, start + new_space_strings_.length());
|
||||
}
|
||||
}
|
||||
|
||||
void Heap::ExternalStringTable::IterateAll(ObjectVisitor* v) {
|
||||
IterateNewSpaceStrings(v);
|
||||
if (!old_space_strings_.is_empty()) {
|
||||
Object** start = &old_space_strings_[0];
|
||||
v->VisitPointers(start, start + old_space_strings_.length());
|
||||
|
@ -1859,7 +1859,7 @@ void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) {
|
||||
v8::ExternalResourceVisitor* visitor_;
|
||||
} external_string_table_visitor(visitor);
|
||||
|
||||
external_string_table_.Iterate(&external_string_table_visitor);
|
||||
external_string_table_.IterateAll(&external_string_table_visitor);
|
||||
}
|
||||
|
||||
Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor,
|
||||
@ -4817,7 +4817,7 @@ void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) {
|
||||
v->Synchronize(VisitorSynchronization::kStringTable);
|
||||
if (mode != VISIT_ALL_IN_SCAVENGE && mode != VISIT_ALL_IN_SWEEP_NEWSPACE) {
|
||||
// Scavenge collections have special processing for this.
|
||||
external_string_table_.Iterate(v);
|
||||
external_string_table_.IterateAll(v);
|
||||
}
|
||||
v->Synchronize(VisitorSynchronization::kExternalStringsTable);
|
||||
}
|
||||
@ -6308,7 +6308,7 @@ void Heap::UpdateTotalGCTime(double duration) {
|
||||
}
|
||||
}
|
||||
|
||||
void Heap::ExternalStringTable::CleanUp() {
|
||||
void Heap::ExternalStringTable::CleanUpNewSpaceStrings() {
|
||||
int last = 0;
|
||||
Isolate* isolate = heap_->isolate();
|
||||
for (int i = 0; i < new_space_strings_.length(); ++i) {
|
||||
@ -6324,8 +6324,12 @@ void Heap::ExternalStringTable::CleanUp() {
|
||||
}
|
||||
new_space_strings_.Rewind(last);
|
||||
new_space_strings_.Trim();
|
||||
}
|
||||
|
||||
last = 0;
|
||||
void Heap::ExternalStringTable::CleanUpAll() {
|
||||
CleanUpNewSpaceStrings();
|
||||
int last = 0;
|
||||
Isolate* isolate = heap_->isolate();
|
||||
for (int i = 0; i < old_space_strings_.length(); ++i) {
|
||||
if (old_space_strings_[i]->IsTheHole(isolate)) {
|
||||
continue;
|
||||
|
@ -1511,11 +1511,13 @@ class Heap {
|
||||
// Registers an external string.
|
||||
inline void AddString(String* string);
|
||||
|
||||
inline void Iterate(ObjectVisitor* v);
|
||||
inline void IterateAll(ObjectVisitor* v);
|
||||
inline void IterateNewSpaceStrings(ObjectVisitor* v);
|
||||
|
||||
// Restores internal invariant and gets rid of collected strings.
|
||||
// Must be called after each Iterate() that modified the strings.
|
||||
void CleanUp();
|
||||
// Restores internal invariant and gets rid of collected strings. Must be
|
||||
// called after each Iterate*() that modified the strings.
|
||||
void CleanUpAll();
|
||||
void CleanUpNewSpaceStrings();
|
||||
|
||||
// Destroys all allocated memory.
|
||||
void TearDown();
|
||||
|
@ -2514,8 +2514,8 @@ void MarkCompactCollector::ClearNonLiveReferences() {
|
||||
string_table->ElementsRemoved(internalized_visitor.PointersRemoved());
|
||||
|
||||
ExternalStringTableCleaner external_visitor(heap(), nullptr);
|
||||
heap()->external_string_table_.Iterate(&external_visitor);
|
||||
heap()->external_string_table_.CleanUp();
|
||||
heap()->external_string_table_.IterateAll(&external_visitor);
|
||||
heap()->external_string_table_.CleanUpAll();
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user