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