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

Unified Diff: src/ast/ast-value-factory.cc

Issue 2446993002: Internalize AstRawStrings by walking the string_table_ instead of adding them to a list (Closed)
Patch Set: rename Created 4 years, 2 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 | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.cc
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc
index 33ccec7fa893ae93b960df580cfcc565081b110e..521962b0233ff5436d3480fa6c2903cefc755151 100644
--- a/src/ast/ast-value-factory.cc
+++ b/src/ast/ast-value-factory.cc
@@ -97,6 +97,8 @@ void AstString::Internalize(Isolate* isolate) {
}
void AstRawString::Internalize(Isolate* isolate) {
+ // Skip over already internalized strings.
+ if (!string_.is_null()) return;
if (literal_bytes_.length() == 0) {
string_ = isolate->factory()->empty_string();
} else {
@@ -256,7 +258,7 @@ const AstConsString* AstValueFactory::NewConsString(
// the AstRawString will not be moved).
AstConsString* new_string = new (zone_) AstConsString(left, right);
CHECK(new_string != nullptr);
- AddString(new_string);
+ AddConsString(new_string);
return new_string;
}
@@ -295,18 +297,25 @@ const AstRawString* AstValueFactory::ConcatStrings(const AstRawString* left,
void AstValueFactory::Internalize(Isolate* isolate) {
// Strings need to be internalized before values, because values refer to
- // strings.
- for (AstString* current = strings_; current != nullptr;) {
- AstString* next = current->next();
+ // strings. Internalize flat strings before cons strings since cons strings
+ // may point to flat strings.
+ for (base::CustomMatcherHashMap::Entry* entry = string_table_.Start();
+ entry != nullptr; entry = string_table_.Next(entry)) {
+ reinterpret_cast<AstRawString*>(entry->key)->Internalize(isolate);
+ }
+
+ for (AstConsString* current = cons_strings_; current != nullptr;) {
+ AstConsString* next = current->next();
current->Internalize(isolate);
current = next;
}
+
for (AstValue* current = values_; current != nullptr;) {
AstValue* next = current->next();
current->Internalize(isolate);
current = next;
}
- ResetStrings();
+ ResetConsStrings();
values_ = nullptr;
}
@@ -385,7 +394,6 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte,
is_one_byte, Vector<const byte>(new_literal_bytes, length), hash);
CHECK(new_string != nullptr);
entry->key = new_string;
- AddString(new_string);
entry->value = reinterpret_cast<void*>(1);
}
return reinterpret_cast<AstRawString*>(entry->key);
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698