Commit 28346b1f authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] ExternalStringTable: Less inlining

Except registration all calls should be dominated by actual visiation
and/or copying.

Bug: 
Change-Id: Iccc58253d627ecf4b4525de5824f76c048c35150
Reviewed-on: https://chromium-review.googlesource.com/645128Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47742}
parent 02fdbcc0
......@@ -553,14 +553,6 @@ Isolate* Heap::isolate() {
reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(16)->heap()) + 16);
}
void Heap::ExternalStringTable::PromoteAllNewSpaceStrings() {
old_space_strings_.reserve(old_space_strings_.size() +
new_space_strings_.size());
std::move(std::begin(new_space_strings_), std::end(new_space_strings_),
std::back_inserter(old_space_strings_));
new_space_strings_.clear();
}
void Heap::ExternalStringTable::AddString(String* string) {
DCHECK(string->IsExternalString());
if (heap_->InNewSpace(string)) {
......@@ -570,46 +562,6 @@ void Heap::ExternalStringTable::AddString(String* string) {
}
}
void Heap::ExternalStringTable::IterateNewSpaceStrings(RootVisitor* v) {
if (!new_space_strings_.empty()) {
v->VisitRootPointers(Root::kExternalStringsTable, new_space_strings_.data(),
new_space_strings_.data() + new_space_strings_.size());
}
}
void Heap::ExternalStringTable::IterateAll(RootVisitor* v) {
IterateNewSpaceStrings(v);
if (!old_space_strings_.empty()) {
v->VisitRootPointers(Root::kExternalStringsTable, old_space_strings_.data(),
old_space_strings_.data() + old_space_strings_.size());
}
}
// Verify() is inline to avoid ifdef-s around its calls in release
// mode.
void Heap::ExternalStringTable::Verify() {
#ifdef DEBUG
for (size_t i = 0; i < new_space_strings_.size(); ++i) {
Object* obj = Object::cast(new_space_strings_[i]);
DCHECK(heap_->InNewSpace(obj));
DCHECK(!obj->IsTheHole(heap_->isolate()));
}
for (size_t i = 0; i < old_space_strings_.size(); ++i) {
Object* obj = Object::cast(old_space_strings_[i]);
DCHECK(!heap_->InNewSpace(obj));
DCHECK(!obj->IsTheHole(heap_->isolate()));
}
#endif
}
void Heap::ExternalStringTable::AddOldString(String* string) {
DCHECK(string->IsExternalString());
DCHECK(!heap_->InNewSpace(string));
old_space_strings_.push_back(string);
}
Oddball* Heap::ToBoolean(bool condition) {
return condition ? true_value() : false_value();
}
......
......@@ -2052,6 +2052,21 @@ String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
return string->IsExternalString() ? string : nullptr;
}
void Heap::ExternalStringTable::Verify() {
#ifdef DEBUG
for (size_t i = 0; i < new_space_strings_.size(); ++i) {
Object* obj = Object::cast(new_space_strings_[i]);
DCHECK(heap_->InNewSpace(obj));
DCHECK(!obj->IsTheHole(heap_->isolate()));
}
for (size_t i = 0; i < old_space_strings_.size(); ++i) {
Object* obj = Object::cast(old_space_strings_[i]);
DCHECK(!heap_->InNewSpace(obj));
DCHECK(!obj->IsTheHole(heap_->isolate()));
}
#endif
}
void Heap::ExternalStringTable::UpdateNewSpaceReferences(
Heap::ExternalStringTableUpdaterCallback updater_func) {
if (new_space_strings_.empty()) return;
......@@ -2068,12 +2083,12 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences(
DCHECK(target->IsExternalString());
if (heap_->InNewSpace(target)) {
// String is still in new space. Update the table entry.
// String is still in new space. Update the table entry.
*last = target;
++last;
} else {
// String got promoted. Move it to the old string list.
AddOldString(target);
// String got promoted. Move it to the old string list.
old_space_strings_.push_back(target);
}
}
......@@ -2086,6 +2101,29 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences(
#endif
}
void Heap::ExternalStringTable::PromoteAllNewSpaceStrings() {
old_space_strings_.reserve(old_space_strings_.size() +
new_space_strings_.size());
std::move(std::begin(new_space_strings_), std::end(new_space_strings_),
std::back_inserter(old_space_strings_));
new_space_strings_.clear();
}
void Heap::ExternalStringTable::IterateNewSpaceStrings(RootVisitor* v) {
if (!new_space_strings_.empty()) {
v->VisitRootPointers(Root::kExternalStringsTable, new_space_strings_.data(),
new_space_strings_.data() + new_space_strings_.size());
}
}
void Heap::ExternalStringTable::IterateAll(RootVisitor* v) {
IterateNewSpaceStrings(v);
if (!old_space_strings_.empty()) {
v->VisitRootPointers(Root::kExternalStringsTable, old_space_strings_.data(),
old_space_strings_.data() + old_space_strings_.size());
}
}
void Heap::UpdateNewSpaceReferencesInExternalStringTable(
ExternalStringTableUpdaterCallback updater_func) {
external_string_table_.UpdateNewSpaceReferences(updater_func);
......
......@@ -1559,16 +1559,16 @@ class Heap {
// Registers an external string.
inline void AddString(String* string);
inline void IterateAll(RootVisitor* v);
inline void IterateNewSpaceStrings(RootVisitor* v);
inline void PromoteAllNewSpaceStrings();
void IterateAll(RootVisitor* v);
void IterateNewSpaceStrings(RootVisitor* v);
void PromoteAllNewSpaceStrings();
// 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.
// Finalize all registered external strings and clear tables.
void TearDown();
void UpdateNewSpaceReferences(
......@@ -1577,9 +1577,7 @@ class Heap {
Heap::ExternalStringTableUpdaterCallback updater_func);
private:
inline void Verify();
inline void AddOldString(String* string);
void Verify();
Heap* const heap_;
......
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