Commit 6246a1f9 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[csa] Add some types to some string/regexp-related functions.

E.g. SubString and StringAdd.

Bug: v8:7310
Change-Id: I352044f88fe79c5b576c5423d6feae3bcb7d725a
Reviewed-on: https://chromium-review.googlesource.com/934284Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51504}
parent 0b9b48b5
This diff is collapsed.
......@@ -50,7 +50,7 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
Node* ConstructNewResultFromMatchInfo(Node* const context, Node* const regexp,
Node* const match_info,
Node* const string);
TNode<String> const string);
Node* RegExpPrototypeExecBodyWithoutResult(Node* const context,
Node* const regexp,
......@@ -58,7 +58,7 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
Label* if_didnotmatch,
const bool is_fastpath);
Node* RegExpPrototypeExecBody(Node* const context, Node* const regexp,
Node* const string, const bool is_fastpath);
TNode<String> string, const bool is_fastpath);
Node* ThrowIfNotJSReceiver(Node* context, Node* maybe_receiver,
MessageTemplate::Template msg_template,
......@@ -100,7 +100,8 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
Node* const is_unicode, bool is_fastpath);
void RegExpPrototypeMatchBody(Node* const context, Node* const regexp,
Node* const string, const bool is_fastpath);
TNode<String> const string,
const bool is_fastpath);
void RegExpPrototypeSearchBodyFast(Node* const context, Node* const regexp,
Node* const string);
......@@ -108,12 +109,13 @@ class RegExpBuiltinsAssembler : public CodeStubAssembler {
Node* const string);
void RegExpPrototypeSplitBody(Node* const context, Node* const regexp,
Node* const string, Node* const limit);
TNode<String> const string, Node* const limit);
Node* ReplaceGlobalCallableFastPath(Node* context, Node* regexp, Node* string,
Node* replace_callable);
Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp, Node* string,
Node* replace_string);
Node* ReplaceSimpleStringFastPath(Node* context, Node* regexp,
TNode<String> string,
TNode<String> replace_string);
};
} // namespace internal
......
......@@ -1666,8 +1666,8 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) {
RequireObjectCoercible(context, receiver, "String.prototype.slice");
// 2. Let S be ? ToString(O).
Node* const subject_string =
CallBuiltin(Builtins::kToString, context, receiver);
TNode<String> const subject_string =
CAST(CallBuiltin(Builtins::kToString, context, receiver));
// 3. Let len be the number of elements in S.
TNode<Smi> const length = LoadStringLengthAsSmi(subject_string);
......@@ -1688,7 +1688,7 @@ TF_BUILTIN(StringPrototypeSlice, StringBuiltinsAssembler) {
{
GotoIf(SmiLessThanOrEqual(var_end.value(), var_start.value()),
&return_emptystring);
Node* const result =
TNode<String> const result =
SubString(subject_string, var_start.value(), var_end.value());
args.PopAndReturn(result);
}
......@@ -1819,7 +1819,7 @@ TF_BUILTIN(StringPrototypeSubstr, StringBuiltinsAssembler) {
TNode<Smi> const zero = SmiConstant(0);
// Check that {receiver} is coercible to Object and convert it to a String.
Node* const string =
TNode<String> const string =
ToThisString(context, receiver, "String.prototype.substr");
TNode<Smi> const string_length = LoadStringLengthAsSmi(string);
......@@ -1888,8 +1888,7 @@ TF_BUILTIN(StringPrototypeSubstr, StringBuiltinsAssembler) {
BIND(&out);
{
TNode<Smi> const end = SmiAdd(var_start.value(), var_result_length.value());
Node* const result = SubString(string, var_start.value(), end);
args.PopAndReturn(result);
args.PopAndReturn(SubString(string, var_start.value(), end));
}
}
......@@ -1943,7 +1942,7 @@ TNode<Smi> StringBuiltinsAssembler::ToSmiBetweenZeroAnd(
}
TF_BUILTIN(SubString, CodeStubAssembler) {
Node* string = Parameter(Descriptor::kString);
TNode<String> string = CAST(Parameter(Descriptor::kString));
Node* from = Parameter(Descriptor::kFrom);
Node* to = Parameter(Descriptor::kTo);
......@@ -1970,7 +1969,7 @@ TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
VARIABLE(var_end, MachineRepresentation::kTagged);
// Check that {receiver} is coercible to Object and convert it to a String.
Node* const string =
TNode<String> const string =
ToThisString(context, receiver, "String.prototype.substring");
Node* const length = LoadStringLengthAsSmi(string);
......@@ -1999,10 +1998,7 @@ TF_BUILTIN(StringPrototypeSubstring, StringBuiltinsAssembler) {
}
BIND(&out);
{
Node* result = SubString(string, var_start.value(), var_end.value());
args.PopAndReturn(result);
}
{ args.PopAndReturn(SubString(string, var_start.value(), var_end.value())); }
}
// ES6 #sec-string.prototype.trim
......@@ -2030,7 +2026,7 @@ void StringTrimAssembler::Generate(String::TrimMode mode,
Node* const receiver = arguments.GetReceiver();
// Check that {receiver} is coercible to Object and convert it to a String.
Node* const string = ToThisString(context, receiver, method_name);
TNode<String> const string = ToThisString(context, receiver, method_name);
TNode<IntPtrT> const string_length = LoadStringLengthAsWord(string);
ToDirectStringAssembler to_direct(state(), string);
......
This diff is collapsed.
......@@ -765,38 +765,45 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<WordT> LoadBigIntBitfield(TNode<BigInt> bigint);
TNode<UintPtrT> LoadBigIntDigit(TNode<BigInt> bigint, int digit_index);
// Allocate a SeqOneByteString with the given length.
Node* AllocateSeqOneByteString(int length, AllocationFlags flags = kNone);
Node* AllocateSeqOneByteString(Node* context, TNode<Smi> length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqOneByteString(int length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqOneByteString(Node* context, TNode<Smi> length,
AllocationFlags flags = kNone);
// Allocate a SeqTwoByteString with the given length.
Node* AllocateSeqTwoByteString(int length, AllocationFlags flags = kNone);
Node* AllocateSeqTwoByteString(Node* context, TNode<Smi> length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqTwoByteString(int length,
AllocationFlags flags = kNone);
TNode<String> AllocateSeqTwoByteString(Node* context, TNode<Smi> length,
AllocationFlags flags = kNone);
// Allocate a SlicedOneByteString with the given length, parent and offset.
// |length| and |offset| are expected to be tagged.
Node* AllocateSlicedOneByteString(TNode<Smi> length, Node* parent,
Node* offset);
TNode<String> AllocateSlicedOneByteString(TNode<Smi> length, Node* parent,
Node* offset);
// Allocate a SlicedTwoByteString with the given length, parent and offset.
// |length| and |offset| are expected to be tagged.
Node* AllocateSlicedTwoByteString(TNode<Smi> length, Node* parent,
Node* offset);
TNode<String> AllocateSlicedTwoByteString(TNode<Smi> length, Node* parent,
Node* offset);
// Allocate a one-byte ConsString with the given length, first and second
// parts. |length| is expected to be tagged, and |first| and |second| are
// expected to be one-byte strings.
Node* AllocateOneByteConsString(TNode<Smi> length, Node* first, Node* second,
AllocationFlags flags = kNone);
TNode<String> AllocateOneByteConsString(TNode<Smi> length,
TNode<String> first,
TNode<String> second,
AllocationFlags flags = kNone);
// Allocate a two-byte ConsString with the given length, first and second
// parts. |length| is expected to be tagged, and |first| and |second| are
// expected to be two-byte strings.
Node* AllocateTwoByteConsString(TNode<Smi> length, Node* first, Node* second,
AllocationFlags flags = kNone);
TNode<String> AllocateTwoByteConsString(TNode<Smi> length,
TNode<String> first,
TNode<String> second,
AllocationFlags flags = kNone);
// Allocate an appropriate one- or two-byte ConsString with the first and
// second parts specified by |left| and |right|.
Node* NewConsString(Node* context, TNode<Smi> length, Node* left, Node* right,
AllocationFlags flags = kNone);
TNode<String> NewConsString(Node* context, TNode<Smi> length,
TNode<String> left, TNode<String> right,
AllocationFlags flags = kNone);
Node* AllocateNameDictionary(int at_least_space_for);
Node* AllocateNameDictionary(Node* at_least_space_for);
......@@ -1216,11 +1223,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
// Return a new string object which holds a substring containing the range
// [from,to[ of string. |from| and |to| are expected to be tagged.
Node* SubString(Node* string, Node* from, Node* to);
TNode<String> SubString(TNode<String> string, SloppyTNode<Smi> from,
SloppyTNode<Smi> to);
// Return a new string object produced by concatenating |first| with |second|.
Node* StringAdd(Node* context, Node* first, Node* second,
AllocationFlags flags = kNone);
TNode<String> StringAdd(Node* context, TNode<String> first,
TNode<String> second, AllocationFlags flags = kNone);
// Check if |string| is an indirect (thin or flat cons) string type that can
// be dereferenced by DerefIndirectString.
......@@ -2096,12 +2104,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* EmitKeyedSloppyArguments(Node* receiver, Node* key, Node* value,
Label* bailout);
Node* AllocateSlicedString(Heap::RootListIndex map_root_index,
TNode<Smi> length, Node* parent, Node* offset);
TNode<String> AllocateSlicedString(Heap::RootListIndex map_root_index,
TNode<Smi> length, Node* parent,
Node* offset);
Node* AllocateConsString(Heap::RootListIndex map_root_index,
TNode<Smi> length, Node* first, Node* second,
AllocationFlags flags);
TNode<String> AllocateConsString(Heap::RootListIndex map_root_index,
TNode<Smi> length, TNode<String> first,
TNode<String> second, AllocationFlags flags);
// Implements DescriptorArray::number_of_entries.
// Returns an untagged int32.
......@@ -2114,9 +2123,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Node* CollectFeedbackForString(Node* instance_type);
void GenerateEqual_Same(Node* value, Label* if_equal, Label* if_notequal,
Variable* var_type_feedback = nullptr);
Node* AllocAndCopyStringCharacters(Node* from, Node* from_instance_type,
TNode<IntPtrT> from_index,
TNode<Smi> character_count);
TNode<String> AllocAndCopyStringCharacters(Node* from,
Node* from_instance_type,
TNode<IntPtrT> from_index,
TNode<Smi> character_count);
static const int kElementLoopUnrollThreshold = 8;
......
......@@ -289,7 +289,7 @@ TF_STUB(StringAddStub, CodeStubAssembler) {
CodeStubAssembler::AllocationFlag allocation_flags =
(pretenure_flag == TENURED) ? CodeStubAssembler::kPretenured
: CodeStubAssembler::kNone;
Return(StringAdd(context, left, right, allocation_flags));
Return(StringAdd(context, CAST(left), CAST(right), allocation_flags));
} else {
Callable callable = CodeFactory::StringAdd(isolate(), STRING_ADD_CHECK_NONE,
pretenure_flag);
......
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