Commit 5ba95354 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Use factory->*string() where possible

Replace several NewStringFromStaticChars calls with the explicit root
string access.

Bug: v8:9396
Change-Id: I381e676fa81de24e892afe703b804b7c724a6083
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1774719Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63429}
parent 888f1b4a
...@@ -4883,7 +4883,7 @@ Local<Value> Function::GetDisplayName() const { ...@@ -4883,7 +4883,7 @@ Local<Value> Function::GetDisplayName() const {
} }
auto func = i::Handle<i::JSFunction>::cast(self); auto func = i::Handle<i::JSFunction>::cast(self);
i::Handle<i::String> property_name = i::Handle<i::String> property_name =
isolate->factory()->NewStringFromStaticChars("displayName"); isolate->factory()->display_name_string();
i::Handle<i::Object> value = i::Handle<i::Object> value =
i::JSReceiver::GetDataProperty(func, property_name); i::JSReceiver::GetDataProperty(func, property_name);
if (value->IsString()) { if (value->IsString()) {
......
...@@ -91,7 +91,7 @@ MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value, ...@@ -91,7 +91,7 @@ MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value,
isolate, isolate,
NewTypeError(MessageTemplate::kNotGeneric, NewTypeError(MessageTemplate::kNotGeneric,
isolate->factory()->NewStringFromAsciiChecked(caller), isolate->factory()->NewStringFromAsciiChecked(caller),
isolate->factory()->NewStringFromStaticChars("BigInt")), isolate->factory()->BigInt_string()),
BigInt); BigInt);
} }
......
...@@ -208,14 +208,10 @@ BUILTIN(StringPrototypeNormalize) { ...@@ -208,14 +208,10 @@ BUILTIN(StringPrototypeNormalize) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form,
Object::ToString(isolate, form_input)); Object::ToString(isolate, form_input));
if (!(String::Equals(isolate, form, if (!(String::Equals(isolate, form, isolate->factory()->NFC_string()) ||
isolate->factory()->NewStringFromStaticChars("NFC")) || String::Equals(isolate, form, isolate->factory()->NFD_string()) ||
String::Equals(isolate, form, String::Equals(isolate, form, isolate->factory()->NFKC_string()) ||
isolate->factory()->NewStringFromStaticChars("NFD")) || String::Equals(isolate, form, isolate->factory()->NFKD_string()))) {
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKC")) ||
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKD")))) {
Handle<String> valid_forms = Handle<String> valid_forms =
isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD"); isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD");
THROW_NEW_ERROR_RETURN_FAILURE( THROW_NEW_ERROR_RETURN_FAILURE(
......
...@@ -992,7 +992,7 @@ ComparisonResult BigInt::CompareToDouble(Handle<BigInt> x, double y) { ...@@ -992,7 +992,7 @@ ComparisonResult BigInt::CompareToDouble(Handle<BigInt> x, double y) {
MaybeHandle<String> BigInt::ToString(Isolate* isolate, Handle<BigInt> bigint, MaybeHandle<String> BigInt::ToString(Isolate* isolate, Handle<BigInt> bigint,
int radix, ShouldThrow should_throw) { int radix, ShouldThrow should_throw) {
if (bigint->is_zero()) { if (bigint->is_zero()) {
return isolate->factory()->NewStringFromStaticChars("0"); return isolate->factory()->zero_string();
} }
if (base::bits::IsPowerOfTwo(radix)) { if (base::bits::IsPowerOfTwo(radix)) {
return MutableBigInt::ToStringBasePowerOfTwo(isolate, bigint, radix, return MutableBigInt::ToStringBasePowerOfTwo(isolate, bigint, radix,
......
...@@ -1036,7 +1036,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate, ...@@ -1036,7 +1036,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
isolate, isolate,
NewTypeError(MessageTemplate::kInvalidUnit, NewTypeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromStaticChars("Intl.NumberFormat"), factory->NewStringFromStaticChars("Intl.NumberFormat"),
factory->NewStringFromStaticChars("")), factory->empty_string()),
JSNumberFormat); JSNumberFormat);
} }
......
...@@ -207,7 +207,7 @@ Maybe<bool> JSSegmentIterator::Following( ...@@ -207,7 +207,7 @@ Maybe<bool> JSSegmentIterator::Following(
THROW_NEW_ERROR_RETURN_VALUE( THROW_NEW_ERROR_RETURN_VALUE(
isolate, isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange, NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"), factory->from_string(),
factory->NewStringFromStaticChars("following"), index), factory->NewStringFromStaticChars("following"), index),
Nothing<bool>()); Nothing<bool>());
} }
...@@ -220,7 +220,7 @@ Maybe<bool> JSSegmentIterator::Following( ...@@ -220,7 +220,7 @@ Maybe<bool> JSSegmentIterator::Following(
THROW_NEW_ERROR_RETURN_VALUE( THROW_NEW_ERROR_RETURN_VALUE(
isolate, isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange, NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"), factory->from_string(),
factory->NewStringFromStaticChars("following"), factory->NewStringFromStaticChars("following"),
from_obj), from_obj),
Nothing<bool>()); Nothing<bool>());
...@@ -260,7 +260,7 @@ Maybe<bool> JSSegmentIterator::Preceding( ...@@ -260,7 +260,7 @@ Maybe<bool> JSSegmentIterator::Preceding(
THROW_NEW_ERROR_RETURN_VALUE( THROW_NEW_ERROR_RETURN_VALUE(
isolate, isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange, NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"), factory->from_string(),
factory->NewStringFromStaticChars("preceding"), index), factory->NewStringFromStaticChars("preceding"), index),
Nothing<bool>()); Nothing<bool>());
} }
...@@ -272,7 +272,7 @@ Maybe<bool> JSSegmentIterator::Preceding( ...@@ -272,7 +272,7 @@ Maybe<bool> JSSegmentIterator::Preceding(
THROW_NEW_ERROR_RETURN_VALUE( THROW_NEW_ERROR_RETURN_VALUE(
isolate, isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange, NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"), factory->from_string(),
factory->NewStringFromStaticChars("preceding"), factory->NewStringFromStaticChars("preceding"),
from_obj), from_obj),
Nothing<bool>()); Nothing<bool>());
......
...@@ -695,7 +695,7 @@ RUNTIME_FUNCTION(Runtime_DebugCollectCoverage) { ...@@ -695,7 +695,7 @@ RUNTIME_FUNCTION(Runtime_DebugCollectCoverage) {
int num_scripts = static_cast<int>(coverage->size()); int num_scripts = static_cast<int>(coverage->size());
// Prepare property keys. // Prepare property keys.
Handle<FixedArray> scripts_array = factory->NewFixedArray(num_scripts); Handle<FixedArray> scripts_array = factory->NewFixedArray(num_scripts);
Handle<String> script_string = factory->NewStringFromStaticChars("script"); Handle<String> script_string = factory->script_string();
for (int i = 0; i < num_scripts; i++) { for (int i = 0; i < num_scripts; i++) {
const auto& script_data = coverage->at(i); const auto& script_data = coverage->at(i);
HandleScope inner_scope(isolate); HandleScope inner_scope(isolate);
......
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