Index: src/ast/ast-value-factory.cc |
diff --git a/src/ast/ast-value-factory.cc b/src/ast/ast-value-factory.cc |
index 521962b0233ff5436d3480fa6c2903cefc755151..1e4ef7d37cd1ce5b4a0489b7938669e50c755c16 100644 |
--- a/src/ast/ast-value-factory.cc |
+++ b/src/ast/ast-value-factory.cc |
@@ -97,13 +97,11 @@ 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(); |
+ set_string(isolate->factory()->empty_string()); |
} else { |
AstRawStringInternalizationKey key(this); |
- string_ = StringTable::LookupKey(isolate, &key); |
+ set_string(StringTable::LookupKey(isolate, &key)); |
} |
} |
@@ -133,9 +131,9 @@ bool AstRawString::IsOneByteEqualTo(const char* data) const { |
void AstConsString::Internalize(Isolate* isolate) { |
// AstRawStrings are internalized before AstConsStrings so left and right are |
// already internalized. |
- string_ = isolate->factory() |
- ->NewConsString(left_->string(), right_->string()) |
- .ToHandleChecked(); |
+ set_string(isolate->factory() |
+ ->NewConsString(left_->string(), right_->string()) |
+ .ToHandleChecked()); |
} |
bool AstValue::IsPropertyName() const { |
@@ -179,44 +177,44 @@ bool AstValue::BooleanValue() const { |
void AstValue::Internalize(Isolate* isolate) { |
switch (type_) { |
case STRING: |
- DCHECK(string_ != NULL); |
+ DCHECK_NOT_NULL(string_); |
// Strings are already internalized. |
DCHECK(!string_->string().is_null()); |
break; |
case SYMBOL: |
if (symbol_name_[0] == 'i') { |
DCHECK_EQ(0, strcmp(symbol_name_, "iterator_symbol")); |
- value_ = isolate->factory()->iterator_symbol(); |
+ set_value(isolate->factory()->iterator_symbol()); |
} else if (strcmp(symbol_name_, "hasInstance_symbol") == 0) { |
- value_ = isolate->factory()->has_instance_symbol(); |
+ set_value(isolate->factory()->has_instance_symbol()); |
} else { |
DCHECK_EQ(0, strcmp(symbol_name_, "home_object_symbol")); |
- value_ = isolate->factory()->home_object_symbol(); |
+ set_value(isolate->factory()->home_object_symbol()); |
} |
break; |
case NUMBER_WITH_DOT: |
case NUMBER: |
- value_ = isolate->factory()->NewNumber(number_, TENURED); |
+ set_value(isolate->factory()->NewNumber(number_, TENURED)); |
break; |
case SMI_WITH_DOT: |
case SMI: |
- value_ = handle(Smi::FromInt(smi_), isolate); |
+ set_value(handle(Smi::FromInt(smi_), isolate)); |
break; |
case BOOLEAN: |
if (bool_) { |
- value_ = isolate->factory()->true_value(); |
+ set_value(isolate->factory()->true_value()); |
} else { |
- value_ = isolate->factory()->false_value(); |
+ set_value(isolate->factory()->false_value()); |
} |
break; |
case NULL_TYPE: |
- value_ = isolate->factory()->null_value(); |
+ set_value(isolate->factory()->null_value()); |
break; |
case THE_HOLE: |
- value_ = isolate->factory()->the_hole_value(); |
+ set_value(isolate->factory()->the_hole_value()); |
break; |
case UNDEFINED: |
- value_ = isolate->factory()->undefined_value(); |
+ set_value(isolate->factory()->undefined_value()); |
break; |
} |
} |
@@ -258,7 +256,7 @@ const AstConsString* AstValueFactory::NewConsString( |
// the AstRawString will not be moved). |
AstConsString* new_string = new (zone_) AstConsString(left, right); |
CHECK(new_string != nullptr); |
- AddConsString(new_string); |
+ AddString(new_string); |
return new_string; |
} |
@@ -297,15 +295,9 @@ const AstRawString* AstValueFactory::ConcatStrings(const AstRawString* left, |
void AstValueFactory::Internalize(Isolate* isolate) { |
// Strings need to be internalized before values, because values refer to |
- // 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(); |
+ // strings. |
+ for (AstString* current = strings_; current != nullptr;) { |
+ AstString* next = current->next(); |
current->Internalize(isolate); |
current = next; |
} |
@@ -315,14 +307,14 @@ void AstValueFactory::Internalize(Isolate* isolate) { |
current->Internalize(isolate); |
current = next; |
} |
- ResetConsStrings(); |
+ ResetStrings(); |
values_ = nullptr; |
} |
const AstValue* AstValueFactory::NewString(const AstRawString* string) { |
AstValue* value = new (zone_) AstValue(string); |
- CHECK(string != nullptr); |
+ CHECK_NOT_NULL(string); |
return AddValue(value); |
} |
@@ -392,7 +384,8 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte, |
memcpy(new_literal_bytes, literal_bytes.start(), length); |
AstRawString* new_string = new (zone_) AstRawString( |
is_one_byte, Vector<const byte>(new_literal_bytes, length), hash); |
- CHECK(new_string != nullptr); |
+ CHECK_NOT_NULL(new_string); |
+ AddString(new_string); |
entry->key = new_string; |
entry->value = reinterpret_cast<void*>(1); |
} |