Commit 86a9b4e1 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[cleanup] CSA: Use CStringConstant helper

Change-Id: Id3989d09f6adfb934842a9b0761d811117d69993
Reviewed-on: https://chromium-review.googlesource.com/567003
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46568}
parent c917ecfe
......@@ -183,7 +183,7 @@ void AsyncGeneratorBuiltinsAssembler::AsyncGeneratorEnqueue(
{
Node* const error =
MakeTypeError(MessageTemplate::kIncompatibleMethodReceiver, context,
CStringConstant(method_name), generator);
StringConstant(method_name), generator);
CallBuiltin(Builtins::kRejectNativePromise, context, promise, error,
TrueConstant());
......
......@@ -66,7 +66,7 @@ void AsyncFromSyncBuiltinsAssembler::ThrowIfNotAsyncFromSyncIterator(
// Let badIteratorError be a new TypeError exception.
Node* const error =
MakeTypeError(MessageTemplate::kIncompatibleMethodReceiver, context,
CStringConstant(method_name), object);
StringConstant(method_name), object);
// Perform ! Call(promiseCapability.[[Reject]], undefined,
// « badIteratorError »).
......
......@@ -397,9 +397,8 @@ TF_BUILTIN(ToObject, CodeStubAssembler) {
Return(js_value);
BIND(&if_noconstructor);
TailCallRuntime(
Runtime::kThrowUndefinedOrNullToObject, context,
HeapConstant(factory()->NewStringFromAsciiChecked("ToObject", TENURED)));
TailCallRuntime(Runtime::kThrowUndefinedOrNullToObject, context,
StringConstant("ToObject"));
BIND(&if_jsreceiver);
Return(object);
......
......@@ -249,9 +249,7 @@ TF_BUILTIN(DatePrototypeToPrimitive, CodeStubAssembler) {
BIND(&receiver_is_invalid);
{
CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
HeapConstant(factory()->NewStringFromAsciiChecked(
"Date.prototype [ @@toPrimitive ]", TENURED)),
receiver);
StringConstant("Date.prototype [ @@toPrimitive ]"), receiver);
Unreachable();
}
}
......
......@@ -84,9 +84,7 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
{
// The {receiver} is not a valid JSGeneratorObject.
CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
HeapConstant(
factory()->NewStringFromAsciiChecked(method_name, TENURED)),
receiver);
StringConstant(method_name), receiver);
Unreachable();
}
......
......@@ -39,8 +39,8 @@ void ObjectBuiltinsAssembler::IsString(Node* object, Label* if_string,
void ObjectBuiltinsAssembler::ReturnToStringFormat(Node* context,
Node* string) {
Node* lhs = HeapConstant(factory()->NewStringFromStaticChars("[object "));
Node* rhs = HeapConstant(factory()->NewStringFromStaticChars("]"));
Node* lhs = StringConstant("[object ");
Node* rhs = StringConstant("]");
Callable callable =
CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED);
......
......@@ -757,7 +757,7 @@ Node* RegExpBuiltinsAssembler::ThrowIfNotJSReceiver(
{
Node* const value_str =
CallBuiltin(Builtins::kToString, context, maybe_receiver);
ThrowTypeError(context, msg_template, CStringConstant(method_name),
ThrowTypeError(context, msg_template, StringConstant(method_name),
value_str);
}
......@@ -1493,6 +1493,8 @@ Node* RegExpBuiltinsAssembler::FlagGetter(Node* const context,
void RegExpBuiltinsAssembler::FlagGetter(Node* context, Node* receiver,
JSRegExp::Flag flag, int counter,
const char* method_name) {
Isolate* isolate = this->isolate();
// Check whether we have an unmodified regexp instance.
Label if_isunmodifiedjsregexp(this),
if_isnotunmodifiedjsregexp(this, Label::kDeferred);
......@@ -1531,7 +1533,14 @@ void RegExpBuiltinsAssembler::FlagGetter(Node* context, Node* receiver,
}
BIND(&if_isnotprototype);
ThrowTypeError(context, MessageTemplate::kRegExpNonRegExp, method_name);
{
Node* const message_id = SmiConstant(MessageTemplate::kRegExpNonRegExp);
Node* const method_name_str = HeapConstant(
isolate->factory()->NewStringFromAsciiChecked(method_name));
CallRuntime(Runtime::kThrowTypeError, context, message_id,
method_name_str);
Unreachable();
}
}
}
......
......@@ -997,9 +997,8 @@ void StringBuiltinsAssembler::RequireObjectCoercible(Node* const context,
Branch(IsNullOrUndefined(value), &throw_exception, &out);
BIND(&throw_exception);
TailCallRuntime(
Runtime::kThrowCalledOnNullOrUndefined, context,
HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)));
TailCallRuntime(Runtime::kThrowCalledOnNullOrUndefined, context,
StringConstant(method_name));
BIND(&out);
}
......@@ -1831,9 +1830,7 @@ TF_BUILTIN(StringIteratorPrototypeNext, StringBuiltinsAssembler) {
{
// The {receiver} is not a valid JSGeneratorObject.
CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
HeapConstant(factory()->NewStringFromAsciiChecked(
"String Iterator.prototype.next", TENURED)),
iterator);
StringConstant("String Iterator.prototype.next"), iterator);
Unreachable();
}
}
......
......@@ -488,8 +488,7 @@ TF_BUILTIN(TypedArrayConstructByArrayBuffer, TypedArrayBuiltinsAssembler) {
BIND(&start_offset_error);
{
Node* holder_map = LoadMap(holder);
Node* problem_string = HeapConstant(
factory()->NewStringFromAsciiChecked("start offset", TENURED));
Node* problem_string = StringConstant("start offset");
CallRuntime(Runtime::kThrowInvalidTypedArrayAlignment, context, holder_map,
problem_string);
......@@ -499,8 +498,7 @@ TF_BUILTIN(TypedArrayConstructByArrayBuffer, TypedArrayBuiltinsAssembler) {
BIND(&byte_length_error);
{
Node* holder_map = LoadMap(holder);
Node* problem_string = HeapConstant(
factory()->NewStringFromAsciiChecked("byte length", TENURED));
Node* problem_string = StringConstant("byte length");
CallRuntime(Runtime::kThrowInvalidTypedArrayAlignment, context, holder_map,
problem_string);
......@@ -639,9 +637,7 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeGetter(
{
// The {receiver} is not a valid JSTypedArray.
CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
HeapConstant(
factory()->NewStringFromAsciiChecked(method_name, TENURED)),
receiver);
StringConstant(method_name), receiver);
Unreachable();
}
}
......@@ -706,8 +702,7 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
BIND(&throw_typeerror);
{
Node* method_arg = HeapConstant(
isolate()->factory()->NewStringFromAsciiChecked(method_name, TENURED));
Node* method_arg = StringConstant(method_name);
Node* result = CallRuntime(Runtime::kThrowTypeError, context,
var_message.value(), method_arg);
Return(result);
......
......@@ -2992,8 +2992,7 @@ Node* CodeStubAssembler::ToThisString(Node* context, Node* value,
{
// The {value} is either null or undefined.
CallRuntime(Runtime::kThrowCalledOnNullOrUndefined, context,
HeapConstant(factory()->NewStringFromAsciiChecked(
method_name, TENURED)));
StringConstant(method_name));
Unreachable();
}
}
......@@ -3139,7 +3138,7 @@ void CodeStubAssembler::ThrowIncompatibleMethodReceiver(Node* context,
const char* method_name,
Node* receiver) {
CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
CStringConstant(method_name), receiver);
StringConstant(method_name), receiver);
Unreachable();
}
......@@ -3170,9 +3169,9 @@ void CodeStubAssembler::ThrowTypeError(Node* context,
MessageTemplate::Template message,
char const* arg0, char const* arg1) {
Node* arg0_node = nullptr;
if (arg0) arg0_node = CStringConstant(arg0);
if (arg0) arg0_node = StringConstant(arg0);
Node* arg1_node = nullptr;
if (arg1) arg1_node = CStringConstant(arg1);
if (arg1) arg1_node = StringConstant(arg1);
ThrowTypeError(context, message, arg0_node, arg1_node);
}
......@@ -9460,9 +9459,8 @@ void CodeStubAssembler::Print(const char* s) {
#ifdef DEBUG
std::string formatted(s);
formatted += "\n";
Handle<String> string = isolate()->factory()->NewStringFromAsciiChecked(
formatted.c_str(), TENURED);
CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), HeapConstant(string));
CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
StringConstant(formatted.c_str()));
#endif
}
......
......@@ -221,7 +221,7 @@ Node* CodeAssembler::HeapConstant(Handle<HeapObject> object) {
return raw_assembler()->HeapConstant(object);
}
Node* CodeAssembler::CStringConstant(const char* str) {
Node* CodeAssembler::StringConstant(const char* str) {
return HeapConstant(factory()->NewStringFromAsciiChecked(str, TENURED));
}
......
......@@ -225,7 +225,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* SmiConstant(Smi* value);
Node* SmiConstant(int value);
Node* HeapConstant(Handle<HeapObject> object);
Node* CStringConstant(const char* str);
Node* StringConstant(const char* str);
Node* BooleanConstant(bool value);
Node* ExternalConstant(ExternalReference address);
Node* Float64Constant(double value);
......
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