Commit 20d77ad7 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] Removing unneeded contexts arguments

The following methods didn't need the use of context, and could
be replaced by NoContextConstant():
 * AllocateSeqOneByteString
 * AllocateSeqTwoByteString
 * StringBuiltinsAssembler::GenerateStringEqual
 * StringBuiltinsAssembler::StringEqual_Core
 * StringBuiltinsAssembler::GenerateStringRelationalComparison

Change-Id: I98068980377450daef7c999e3d413e839f66fda9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1758321Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63246}
parent d43de6c0
......@@ -3001,10 +3001,8 @@ transitioning macro GetMethod(implicit context: Context)(
extern macro NumberToString(Number): String;
extern macro IsOneByteStringInstanceType(InstanceType): bool;
extern macro AllocateSeqOneByteString(implicit context: Context)(uint32):
String;
extern macro AllocateSeqTwoByteString(implicit context: Context)(uint32):
String;
extern macro AllocateSeqOneByteString(uint32): String;
extern macro AllocateSeqTwoByteString(uint32): String;
extern macro ConvertToRelativeIndex(implicit context: Context)(
Object, intptr): intptr;
......
......@@ -1166,9 +1166,9 @@ void ArrayIncludesIndexofAssembler::GenerateSmiOrObject(
BIND(&slow_compare);
StringBuiltinsAssembler string_asm(state());
string_asm.StringEqual_Core(context, search_element_string, search_type,
element_k, element_k_type, search_length,
&return_found, &continue_loop, &runtime);
string_asm.StringEqual_Core(search_element_string, search_type, element_k,
element_k_type, search_length, &return_found,
&continue_loop, &runtime);
BIND(&runtime);
TNode<Object> result = CallRuntime(Runtime::kStringEqual, context,
search_element_string, element_k);
......
......@@ -34,7 +34,6 @@ class IntlBuiltinsAssembler : public CodeStubAssembler {
TF_BUILTIN(StringToLowerCaseIntl, IntlBuiltinsAssembler) {
Node* const string = Parameter(Descriptor::kString);
Node* const context = Parameter(Descriptor::kContext);
CSA_ASSERT(this, IsString(string));
......@@ -57,7 +56,7 @@ TF_BUILTIN(StringToLowerCaseIntl, IntlBuiltinsAssembler) {
// For short strings, do the conversion in CSA through the lookup table.
Node* const dst = AllocateSeqOneByteString(context, length);
Node* const dst = AllocateSeqOneByteString(length);
const int kMaxShortStringLength = 24; // Determined empirically.
GotoIf(Uint32GreaterThan(length, Uint32Constant(kMaxShortStringLength)),
......
......@@ -1269,7 +1269,7 @@ Node* RegExpBuiltinsAssembler::FlagsGetter(Node* const context,
// char for each set flag.
{
Node* const result = AllocateSeqOneByteString(context, var_length.value());
Node* const result = AllocateSeqOneByteString(var_length.value());
VARIABLE(var_offset, MachineType::PointerRepresentation(),
IntPtrConstant(SeqOneByteString::kHeaderSize - kHeapObjectTag));
......
......@@ -128,8 +128,7 @@ Node* StringBuiltinsAssembler::PointerToStringDataAtIndex(
return IntPtrAdd(string_data, offset_in_bytes);
}
void StringBuiltinsAssembler::GenerateStringEqual(Node* context, Node* left,
Node* right) {
void StringBuiltinsAssembler::GenerateStringEqual(Node* left, Node* right) {
VARIABLE(var_left, MachineRepresentation::kTagged, left);
VARIABLE(var_right, MachineRepresentation::kTagged, right);
Label if_equal(this), if_notequal(this), if_indirect(this, Label::kDeferred),
......@@ -149,8 +148,8 @@ void StringBuiltinsAssembler::GenerateStringEqual(Node* context, Node* left,
Node* lhs_instance_type = LoadInstanceType(lhs);
Node* rhs_instance_type = LoadInstanceType(rhs);
StringEqual_Core(context, lhs, lhs_instance_type, rhs, rhs_instance_type,
lhs_length, &if_equal, &if_notequal, &if_indirect);
StringEqual_Core(lhs, lhs_instance_type, rhs, rhs_instance_type, lhs_length,
&if_equal, &if_notequal, &if_indirect);
BIND(&if_indirect);
{
......@@ -158,7 +157,7 @@ void StringBuiltinsAssembler::GenerateStringEqual(Node* context, Node* left,
MaybeDerefIndirectStrings(&var_left, lhs_instance_type, &var_right,
rhs_instance_type, &restart);
TailCallRuntime(Runtime::kStringEqual, context, lhs, rhs);
TailCallRuntime(Runtime::kStringEqual, NoContextConstant(), lhs, rhs);
}
BIND(&if_equal);
......@@ -169,9 +168,9 @@ void StringBuiltinsAssembler::GenerateStringEqual(Node* context, Node* left,
}
void StringBuiltinsAssembler::StringEqual_Core(
Node* context, Node* lhs, Node* lhs_instance_type, Node* rhs,
Node* rhs_instance_type, TNode<IntPtrT> length, Label* if_equal,
Label* if_not_equal, Label* if_indirect) {
Node* lhs, Node* lhs_instance_type, Node* rhs, Node* rhs_instance_type,
TNode<IntPtrT> length, Label* if_equal, Label* if_not_equal,
Label* if_indirect) {
CSA_ASSERT(this, IsString(lhs));
CSA_ASSERT(this, IsString(rhs));
CSA_ASSERT(this, WordEqual(LoadStringLengthAsWord(lhs), length));
......@@ -325,8 +324,7 @@ TF_BUILTIN(SubString, StringBuiltinsAssembler) {
Return(SubString(string, SmiUntag(from), SmiUntag(to)));
}
void StringBuiltinsAssembler::GenerateStringRelationalComparison(Node* context,
Node* left,
void StringBuiltinsAssembler::GenerateStringRelationalComparison(Node* left,
Node* right,
Operation op) {
VARIABLE(var_left, MachineRepresentation::kTagged, left);
......@@ -431,16 +429,20 @@ void StringBuiltinsAssembler::GenerateStringRelationalComparison(Node* context,
// TODO(bmeurer): Add support for two byte string relational comparisons.
switch (op) {
case Operation::kLessThan:
TailCallRuntime(Runtime::kStringLessThan, context, lhs, rhs);
TailCallRuntime(Runtime::kStringLessThan, NoContextConstant(), lhs,
rhs);
break;
case Operation::kLessThanOrEqual:
TailCallRuntime(Runtime::kStringLessThanOrEqual, context, lhs, rhs);
TailCallRuntime(Runtime::kStringLessThanOrEqual, NoContextConstant(),
lhs, rhs);
break;
case Operation::kGreaterThan:
TailCallRuntime(Runtime::kStringGreaterThan, context, lhs, rhs);
TailCallRuntime(Runtime::kStringGreaterThan, NoContextConstant(), lhs,
rhs);
break;
case Operation::kGreaterThanOrEqual:
TailCallRuntime(Runtime::kStringGreaterThanOrEqual, context, lhs, rhs);
TailCallRuntime(Runtime::kStringGreaterThanOrEqual, NoContextConstant(),
lhs, rhs);
break;
default:
UNREACHABLE();
......@@ -494,41 +496,33 @@ void StringBuiltinsAssembler::GenerateStringRelationalComparison(Node* context,
}
TF_BUILTIN(StringEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringEqual(context, left, right);
GenerateStringEqual(left, right);
}
TF_BUILTIN(StringLessThan, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
Operation::kLessThan);
GenerateStringRelationalComparison(left, right, Operation::kLessThan);
}
TF_BUILTIN(StringLessThanOrEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
Operation::kLessThanOrEqual);
GenerateStringRelationalComparison(left, right, Operation::kLessThanOrEqual);
}
TF_BUILTIN(StringGreaterThan, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
Operation::kGreaterThan);
GenerateStringRelationalComparison(left, right, Operation::kGreaterThan);
}
TF_BUILTIN(StringGreaterThanOrEqual, StringBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext);
Node* left = Parameter(Descriptor::kLeft);
Node* right = Parameter(Descriptor::kRight);
GenerateStringRelationalComparison(context, left, right,
GenerateStringRelationalComparison(left, right,
Operation::kGreaterThanOrEqual);
}
......@@ -611,7 +605,7 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
{
Label two_byte(this);
// Assume that the resulting string contains only one-byte characters.
Node* one_byte_result = AllocateSeqOneByteString(context, Unsigned(argc));
Node* one_byte_result = AllocateSeqOneByteString(Unsigned(argc));
TVARIABLE(IntPtrT, var_max_index);
var_max_index = IntPtrConstant(0);
......@@ -645,7 +639,7 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
// At least one of the characters in the string requires a 16-bit
// representation. Allocate a SeqTwoByteString to hold the resulting
// string.
Node* two_byte_result = AllocateSeqTwoByteString(context, Unsigned(argc));
Node* two_byte_result = AllocateSeqTwoByteString(Unsigned(argc));
// Copy the characters that have already been put in the 8-bit string into
// their corresponding positions in the new 16-bit string.
......
......@@ -19,10 +19,10 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
Node* GetSubstitution(Node* context, Node* subject_string,
Node* match_start_index, Node* match_end_index,
Node* replace_string);
void StringEqual_Core(Node* context, Node* lhs, Node* lhs_instance_type,
Node* rhs, Node* rhs_instance_type,
TNode<IntPtrT> length, Label* if_equal,
Label* if_not_equal, Label* if_indirect);
void StringEqual_Core(Node* lhs, Node* lhs_instance_type, Node* rhs,
Node* rhs_instance_type, TNode<IntPtrT> length,
Label* if_equal, Label* if_not_equal,
Label* if_indirect);
void BranchIfStringPrimitiveWithNoCustomIteration(TNode<Object> object,
TNode<Context> context,
Label* if_true,
......@@ -58,9 +58,9 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
void ConvertAndBoundsCheckStartArgument(Node* context, Variable* var_start,
Node* start, Node* string_length);
void GenerateStringEqual(Node* context, Node* left, Node* right);
void GenerateStringRelationalComparison(Node* context, Node* left,
Node* right, Operation op);
void GenerateStringEqual(Node* left, Node* right);
void GenerateStringRelationalComparison(Node* left, Node* right,
Operation op);
using StringAtAccessor = std::function<TNode<Object>(
TNode<String> receiver, TNode<IntPtrT> length, TNode<IntPtrT> index)>;
......
......@@ -3307,9 +3307,8 @@ TNode<BoolT> CodeStubAssembler::IsZeroOrContext(SloppyTNode<Object> object) {
}
TNode<String> CodeStubAssembler::AllocateSeqOneByteString(
Node* context, TNode<Uint32T> length, AllocationFlags flags) {
TNode<Uint32T> length, AllocationFlags flags) {
Comment("AllocateSeqOneByteString");
CSA_SLOW_ASSERT(this, IsZeroOrContext(context));
VARIABLE(var_result, MachineRepresentation::kTagged);
// Compute the SeqOneByteString size and check if it fits into new space.
......@@ -3343,8 +3342,9 @@ TNode<String> CodeStubAssembler::AllocateSeqOneByteString(
BIND(&if_notsizeissmall);
{
// We might need to allocate in large object space, go to the runtime.
Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context,
ChangeUint32ToTagged(length));
Node* result =
CallRuntime(Runtime::kAllocateSeqOneByteString, NoContextConstant(),
ChangeUint32ToTagged(length));
var_result.Bind(result);
Goto(&if_join);
}
......@@ -3378,8 +3378,7 @@ TNode<String> CodeStubAssembler::AllocateSeqTwoByteString(
}
TNode<String> CodeStubAssembler::AllocateSeqTwoByteString(
Node* context, TNode<Uint32T> length, AllocationFlags flags) {
CSA_SLOW_ASSERT(this, IsZeroOrContext(context));
TNode<Uint32T> length, AllocationFlags flags) {
Comment("AllocateSeqTwoByteString");
VARIABLE(var_result, MachineRepresentation::kTagged);
......@@ -3414,8 +3413,9 @@ TNode<String> CodeStubAssembler::AllocateSeqTwoByteString(
BIND(&if_notsizeissmall);
{
// We might need to allocate in large object space, go to the runtime.
Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context,
ChangeUint32ToTagged(length));
Node* result =
CallRuntime(Runtime::kAllocateSeqTwoByteString, NoContextConstant(),
ChangeUint32ToTagged(length));
var_result.Bind(result);
Goto(&if_join);
}
......@@ -7011,7 +7011,7 @@ TNode<String> CodeStubAssembler::AllocAndCopyStringCharacters(
BIND(&one_byte_sequential);
{
TNode<String> result = AllocateSeqOneByteString(
NoContextConstant(), Unsigned(TruncateIntPtrToInt32(character_count)));
Unsigned(TruncateIntPtrToInt32(character_count)));
CopyStringCharacters(from, result, from_index, IntPtrConstant(0),
character_count, String::ONE_BYTE_ENCODING,
String::ONE_BYTE_ENCODING);
......@@ -7023,7 +7023,7 @@ TNode<String> CodeStubAssembler::AllocAndCopyStringCharacters(
BIND(&two_byte_sequential);
{
TNode<String> result = AllocateSeqTwoByteString(
NoContextConstant(), Unsigned(TruncateIntPtrToInt32(character_count)));
Unsigned(TruncateIntPtrToInt32(character_count)));
CopyStringCharacters(from, result, from_index, IntPtrConstant(0),
character_count, String::TWO_BYTE_ENCODING,
String::TWO_BYTE_ENCODING);
......@@ -7470,7 +7470,7 @@ TNode<String> CodeStubAssembler::StringAdd(Node* context, TNode<String> left,
Int32Constant(kTwoByteStringTag)),
&two_byte);
// One-byte sequential string case
result = AllocateSeqOneByteString(context, new_length);
result = AllocateSeqOneByteString(new_length);
CopyStringCharacters(var_left.value(), result.value(), IntPtrConstant(0),
IntPtrConstant(0), word_left_length,
String::ONE_BYTE_ENCODING, String::ONE_BYTE_ENCODING);
......@@ -7482,7 +7482,7 @@ TNode<String> CodeStubAssembler::StringAdd(Node* context, TNode<String> left,
BIND(&two_byte);
{
// Two-byte sequential string case
result = AllocateSeqTwoByteString(context, new_length);
result = AllocateSeqTwoByteString(new_length);
CopyStringCharacters(var_left.value(), result.value(), IntPtrConstant(0),
IntPtrConstant(0), word_left_length,
String::TWO_BYTE_ENCODING,
......
......@@ -1550,12 +1550,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Allocate a SeqOneByteString with the given length.
TNode<String> AllocateSeqOneByteString(uint32_t length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqOneByteString(Node* context, TNode<Uint32T> length,
TNode<String> AllocateSeqOneByteString(TNode<Uint32T> length,
AllocationFlags flags = kNone);
// Allocate a SeqTwoByteString with the given length.
TNode<String> AllocateSeqTwoByteString(uint32_t length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqTwoByteString(Node* context, TNode<Uint32T> length,
TNode<String> AllocateSeqTwoByteString(TNode<Uint32T> length,
AllocationFlags flags = kNone);
// Allocate a SlicedOneByteString with the given length, parent and offset.
......
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