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() { ...@@ -553,14 +553,6 @@ Isolate* Heap::isolate() {
reinterpret_cast<size_t>(reinterpret_cast<Isolate*>(16)->heap()) + 16); 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) { void Heap::ExternalStringTable::AddString(String* string) {
DCHECK(string->IsExternalString()); DCHECK(string->IsExternalString());
if (heap_->InNewSpace(string)) { if (heap_->InNewSpace(string)) {
...@@ -570,46 +562,6 @@ void Heap::ExternalStringTable::AddString(String* 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) { Oddball* Heap::ToBoolean(bool condition) {
return condition ? true_value() : false_value(); return condition ? true_value() : false_value();
} }
......
...@@ -2052,6 +2052,21 @@ String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, ...@@ -2052,6 +2052,21 @@ String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
return string->IsExternalString() ? string : nullptr; 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( void Heap::ExternalStringTable::UpdateNewSpaceReferences(
Heap::ExternalStringTableUpdaterCallback updater_func) { Heap::ExternalStringTableUpdaterCallback updater_func) {
if (new_space_strings_.empty()) return; if (new_space_strings_.empty()) return;
...@@ -2073,7 +2088,7 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences( ...@@ -2073,7 +2088,7 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences(
++last; ++last;
} else { } else {
// String got promoted. Move it to the old string list. // String got promoted. Move it to the old string list.
AddOldString(target); old_space_strings_.push_back(target);
} }
} }
...@@ -2086,6 +2101,29 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences( ...@@ -2086,6 +2101,29 @@ void Heap::ExternalStringTable::UpdateNewSpaceReferences(
#endif #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( void Heap::UpdateNewSpaceReferencesInExternalStringTable(
ExternalStringTableUpdaterCallback updater_func) { ExternalStringTableUpdaterCallback updater_func) {
external_string_table_.UpdateNewSpaceReferences(updater_func); external_string_table_.UpdateNewSpaceReferences(updater_func);
......
...@@ -1559,16 +1559,16 @@ class Heap { ...@@ -1559,16 +1559,16 @@ class Heap {
// Registers an external string. // Registers an external string.
inline void AddString(String* string); inline void AddString(String* string);
inline void IterateAll(RootVisitor* v); void IterateAll(RootVisitor* v);
inline void IterateNewSpaceStrings(RootVisitor* v); void IterateNewSpaceStrings(RootVisitor* v);
inline void PromoteAllNewSpaceStrings(); void PromoteAllNewSpaceStrings();
// Restores internal invariant and gets rid of collected strings. Must be // Restores internal invariant and gets rid of collected strings. Must be
// called after each Iterate*() that modified the strings. // called after each Iterate*() that modified the strings.
void CleanUpAll(); void CleanUpAll();
void CleanUpNewSpaceStrings(); void CleanUpNewSpaceStrings();
// Destroys all allocated memory. // Finalize all registered external strings and clear tables.
void TearDown(); void TearDown();
void UpdateNewSpaceReferences( void UpdateNewSpaceReferences(
...@@ -1577,9 +1577,7 @@ class Heap { ...@@ -1577,9 +1577,7 @@ class Heap {
Heap::ExternalStringTableUpdaterCallback updater_func); Heap::ExternalStringTableUpdaterCallback updater_func);
private: private:
inline void Verify(); void Verify();
inline void AddOldString(String* string);
Heap* const heap_; 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