Commit 421eaeef authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] TNodify builtins-string-gen

Bug: v8:9810
Change-Id: I915e0b1f903e8c5aa75280965819b2efb9fdc6dd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1906206Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64887}
parent db49e223
This diff is collapsed.
......@@ -21,8 +21,8 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
TNode<Smi> match_start_index,
TNode<Smi> match_end_index,
TNode<String> replace_string);
void StringEqual_Core(SloppyTNode<String> lhs, Node* lhs_instance_type,
SloppyTNode<String> rhs, Node* rhs_instance_type,
void StringEqual_Core(TNode<String> lhs, TNode<Word32T> lhs_instance_type,
TNode<String> rhs, TNode<Word32T> rhs_instance_type,
TNode<IntPtrT> length, Label* if_equal,
Label* if_not_equal, Label* if_indirect);
void BranchIfStringPrimitiveWithNoCustomIteration(TNode<Object> object,
......@@ -30,9 +30,8 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
Label* if_true,
Label* if_false);
TNode<Int32T> LoadSurrogatePairAt(SloppyTNode<String> string,
SloppyTNode<IntPtrT> length,
SloppyTNode<IntPtrT> index,
TNode<Int32T> LoadSurrogatePairAt(TNode<String> string, TNode<IntPtrT> length,
TNode<IntPtrT> index,
UnicodeEncoding encoding);
TNode<String> StringFromSingleUTF16EncodedCodePoint(TNode<Int32T> codepoint);
......@@ -55,37 +54,38 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
// |from_index|, |to_index| and |character_count| must be intptr_ts s.t. 0 <=
// |from_index| <= |from_index| + |character_count| <= from_string.length and
// 0 <= |to_index| <= |to_index| + |character_count| <= to_string.length.
V8_EXPORT_PRIVATE void CopyStringCharacters(
Node* from_string, Node* to_string, TNode<IntPtrT> from_index,
TNode<IntPtrT> to_index, TNode<IntPtrT> character_count,
String::Encoding from_encoding, String::Encoding to_encoding);
template <typename T>
void CopyStringCharacters(TNode<T> from_string, TNode<String> to_string,
TNode<IntPtrT> from_index, TNode<IntPtrT> to_index,
TNode<IntPtrT> character_count,
String::Encoding from_encoding,
String::Encoding to_encoding);
protected:
void StringEqual_Loop(Node* lhs, Node* lhs_instance_type,
MachineType lhs_type, Node* rhs,
Node* rhs_instance_type, MachineType rhs_type,
void StringEqual_Loop(TNode<String> lhs, TNode<Word32T> lhs_instance_type,
MachineType lhs_type, TNode<String> rhs,
TNode<Word32T> rhs_instance_type, MachineType rhs_type,
TNode<IntPtrT> length, Label* if_equal,
Label* if_not_equal);
Node* DirectStringData(Node* string, Node* string_instance_type);
TNode<IntPtrT> DirectStringData(TNode<String> string,
TNode<Word32T> string_instance_type);
void DispatchOnStringEncodings(Node* const lhs_instance_type,
Node* const rhs_instance_type,
void DispatchOnStringEncodings(const TNode<Word32T> lhs_instance_type,
const TNode<Word32T> rhs_instance_type,
Label* if_one_one, Label* if_one_two,
Label* if_two_one, Label* if_two_two);
template <typename SubjectChar, typename PatternChar>
Node* CallSearchStringRaw(Node* const subject_ptr, Node* const subject_length,
Node* const search_ptr, Node* const search_length,
Node* const start_position);
TNode<IntPtrT> CallSearchStringRaw(const TNode<RawPtrT> subject_ptr,
const TNode<IntPtrT> subject_length,
const TNode<RawPtrT> search_ptr,
const TNode<IntPtrT> search_length,
const TNode<IntPtrT> start_position);
TNode<RawPtrT> PointerToStringDataAtIndex(TNode<RawPtrT> string_data,
TNode<IntPtrT> index,
String::Encoding encoding);
// substr and slice have a common way of handling the {start} argument.
void ConvertAndBoundsCheckStartArgument(Node* context, Variable* var_start,
Node* start, Node* string_length);
void GenerateStringEqual(TNode<String> left, TNode<String> right);
void GenerateStringRelationalComparison(TNode<String> left,
TNode<String> right, Operation op);
......@@ -98,7 +98,8 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
const TNode<Smi> position,
const std::function<void(TNode<Smi>)>& f_return);
TNode<Smi> IndexOfDollarChar(Node* const context, Node* const string);
const TNode<Smi> IndexOfDollarChar(const TNode<Context> context,
const TNode<String> string);
TNode<JSArray> StringToArray(TNode<NativeContext> context,
TNode<String> subject_string,
......@@ -112,7 +113,7 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
TNode<String> AllocateConsString(TNode<Uint32T> length, TNode<String> left,
TNode<String> right);
TNode<String> StringAdd(Node* context, TNode<String> left,
TNode<String> StringAdd(SloppyTNode<Context> context, TNode<String> left,
TNode<String> right);
// Check if |string| is an indirect (thin or flat cons) string type that can
......@@ -154,18 +155,19 @@ class StringBuiltinsAssembler : public CodeStubAssembler {
// Contains fast paths for Smi and RegExp objects.
// Important: {regexp_call} may not contain any code that can call into JS.
using NodeFunction0 = std::function<void()>;
using NodeFunction1 = std::function<void(Node* fn)>;
using NodeFunction1 = std::function<void(TNode<Object> fn)>;
using DescriptorIndexNameValue =
PrototypeCheckAssembler::DescriptorIndexNameValue;
void MaybeCallFunctionAtSymbol(
Node* const context, Node* const object, Node* const maybe_string,
Handle<Symbol> symbol,
const TNode<Context> context, const TNode<Object> object,
const TNode<Object> maybe_string, Handle<Symbol> symbol,
DescriptorIndexNameValue additional_property_to_check,
const NodeFunction0& regexp_call, const NodeFunction1& generic_call);
private:
TNode<String> AllocAndCopyStringCharacters(Node* from,
Node* from_instance_type,
template <typename T>
TNode<String> AllocAndCopyStringCharacters(TNode<T> from,
TNode<Int32T> from_instance_type,
TNode<IntPtrT> from_index,
TNode<IntPtrT> character_count);
};
......@@ -195,13 +197,15 @@ class StringTrimAssembler : public StringBuiltinsAssembler {
TNode<Context> context);
void ScanForNonWhiteSpaceOrLineTerminator(
Node* const string_data, Node* const string_data_offset,
Node* const is_stringonebyte, TVariable<IntPtrT>* const var_index,
const TNode<RawPtrT> string_data, const TNode<IntPtrT> string_data_offset,
const TNode<BoolT> is_stringonebyte, TVariable<IntPtrT>* const var_index,
const TNode<IntPtrT> end, int increment, Label* const if_none_found);
void BuildLoop(TVariable<IntPtrT>* const var_index, const TNode<IntPtrT> end,
template <typename T>
void BuildLoop(
TVariable<IntPtrT>* const var_index, const TNode<IntPtrT> end,
int increment, Label* const if_none_found, Label* const out,
const std::function<Node*(Node*)>& get_character);
const std::function<TNode<T>(const TNode<IntPtrT>)>& get_character);
};
} // namespace internal
......
......@@ -6099,7 +6099,7 @@ TNode<BoolT> CodeStubAssembler::IsStringInstanceType(
}
TNode<BoolT> CodeStubAssembler::IsOneByteStringInstanceType(
SloppyTNode<Int32T> instance_type) {
TNode<Int32T> instance_type) {
CSA_ASSERT(this, IsStringInstanceType(instance_type));
return Word32Equal(
Word32And(instance_type, Int32Constant(kStringEncodingMask)),
......
......@@ -2468,7 +2468,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> IsNullOrJSReceiver(SloppyTNode<HeapObject> object);
TNode<BoolT> IsNullOrUndefined(SloppyTNode<Object> object);
TNode<BoolT> IsNumberDictionary(SloppyTNode<HeapObject> object);
TNode<BoolT> IsOneByteStringInstanceType(SloppyTNode<Int32T> instance_type);
TNode<BoolT> IsOneByteStringInstanceType(TNode<Int32T> instance_type);
TNode<BoolT> IsPrimitiveInstanceType(SloppyTNode<Int32T> instance_type);
TNode<BoolT> IsPrivateSymbol(SloppyTNode<HeapObject> object);
TNode<BoolT> IsPrivateName(SloppyTNode<Symbol> symbol);
......
......@@ -26,8 +26,7 @@ struct IntegralT : UntaggedT {};
struct WordT : IntegralT {
static const MachineRepresentation kMachineRepresentation =
(kSystemPointerSize == 4) ? MachineRepresentation::kWord32
: MachineRepresentation::kWord64;
MachineType::PointerRepresentation();
};
struct RawPtrT : WordT {
......
......@@ -2003,9 +2003,10 @@ TEST(OneToTwoByteStringCopy) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
StringBuiltinsAssembler m(asm_tester.state());
m.CopyStringCharacters(m.Parameter(0), m.Parameter(1), m.IntPtrConstant(0),
m.IntPtrConstant(0), m.IntPtrConstant(5),
String::ONE_BYTE_ENCODING, String::TWO_BYTE_ENCODING);
m.CopyStringCharacters<String>(m.CAST(m.Parameter(0)), m.CAST(m.Parameter(1)),
m.IntPtrConstant(0), m.IntPtrConstant(0),
m.IntPtrConstant(5), String::ONE_BYTE_ENCODING,
String::TWO_BYTE_ENCODING);
m.Return(m.SmiConstant(Smi::FromInt(0)));
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
......@@ -2035,9 +2036,10 @@ TEST(OneToOneByteStringCopy) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
StringBuiltinsAssembler m(asm_tester.state());
m.CopyStringCharacters(m.Parameter(0), m.Parameter(1), m.IntPtrConstant(0),
m.IntPtrConstant(0), m.IntPtrConstant(5),
String::ONE_BYTE_ENCODING, String::ONE_BYTE_ENCODING);
m.CopyStringCharacters<String>(m.CAST(m.Parameter(0)), m.CAST(m.Parameter(1)),
m.IntPtrConstant(0), m.IntPtrConstant(0),
m.IntPtrConstant(5), String::ONE_BYTE_ENCODING,
String::ONE_BYTE_ENCODING);
m.Return(m.SmiConstant(Smi::FromInt(0)));
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
......@@ -2067,9 +2069,10 @@ TEST(OneToOneByteStringCopyNonZeroStart) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
StringBuiltinsAssembler m(asm_tester.state());
m.CopyStringCharacters(m.Parameter(0), m.Parameter(1), m.IntPtrConstant(0),
m.IntPtrConstant(3), m.IntPtrConstant(2),
String::ONE_BYTE_ENCODING, String::ONE_BYTE_ENCODING);
m.CopyStringCharacters<String>(m.CAST(m.Parameter(0)), m.CAST(m.Parameter(1)),
m.IntPtrConstant(0), m.IntPtrConstant(3),
m.IntPtrConstant(2), String::ONE_BYTE_ENCODING,
String::ONE_BYTE_ENCODING);
m.Return(m.SmiConstant(Smi::FromInt(0)));
Handle<String> string1 = isolate->factory()->InternalizeUtf8String("abcde");
......@@ -2096,9 +2099,10 @@ TEST(TwoToTwoByteStringCopy) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
StringBuiltinsAssembler m(asm_tester.state());
m.CopyStringCharacters(m.Parameter(0), m.Parameter(1), m.IntPtrConstant(0),
m.IntPtrConstant(0), m.IntPtrConstant(5),
String::TWO_BYTE_ENCODING, String::TWO_BYTE_ENCODING);
m.CopyStringCharacters<String>(m.CAST(m.Parameter(0)), m.CAST(m.Parameter(1)),
m.IntPtrConstant(0), m.IntPtrConstant(0),
m.IntPtrConstant(5), String::TWO_BYTE_ENCODING,
String::TWO_BYTE_ENCODING);
m.Return(m.SmiConstant(Smi::FromInt(0)));
uc16 array1[] = {2000, 2001, 2002, 2003, 2004};
......
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