@@ -549,8 +549,9 @@ TF_BUILTIN(StringGreaterThanOrEqual, StringBuiltinsAssembler) {
549549}
550550
551551TF_BUILTIN (StringCharAt, StringBuiltinsAssembler) {
552- Node* receiver = Parameter (Descriptor::kReceiver );
553- Node* position = Parameter (Descriptor::kPosition );
552+ TNode<String> receiver = CAST (Parameter (Descriptor::kReceiver ));
553+ TNode<IntPtrT> position =
554+ UncheckedCast<IntPtrT>(Parameter (Descriptor::kPosition ));
554555
555556 // Load the character code at the {position} from the {receiver}.
556557 TNode<Int32T> code = StringCharCodeAt (receiver, position);
@@ -601,7 +602,6 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
601602 Node* context = Parameter (Descriptor::kContext );
602603
603604 CodeStubArguments arguments (this , ChangeInt32ToIntPtr (argc));
604- TNode<Smi> smi_argc = SmiTag (arguments.GetLength (INTPTR_PARAMETERS));
605605 // Check if we have exactly one argument (plus the implicit receiver), i.e.
606606 // if the parent frame is not an arguments adaptor frame.
607607 Label if_oneargument (this ), if_notoneargument (this );
@@ -626,7 +626,7 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
626626 {
627627 Label two_byte (this );
628628 // Assume that the resulting string contains only one-byte characters.
629- Node* one_byte_result = AllocateSeqOneByteString (context, smi_argc );
629+ Node* one_byte_result = AllocateSeqOneByteString (context, Unsigned (argc) );
630630
631631 TVARIABLE (IntPtrT, var_max_index);
632632 var_max_index = IntPtrConstant (0 );
@@ -660,7 +660,7 @@ TF_BUILTIN(StringFromCharCode, CodeStubAssembler) {
660660 // At least one of the characters in the string requires a 16-bit
661661 // representation. Allocate a SeqTwoByteString to hold the resulting
662662 // string.
663- Node* two_byte_result = AllocateSeqTwoByteString (context, smi_argc );
663+ Node* two_byte_result = AllocateSeqTwoByteString (context, Unsigned (argc) );
664664
665665 // Copy the characters that have already been put in the 8-bit string into
666666 // their corresponding positions in the new 16-bit string.
@@ -1191,8 +1191,6 @@ TF_BUILTIN(StringPrototypeRepeat, StringBuiltinsAssembler) {
11911191 TNode<Object> count = CAST (Parameter (Descriptor::kCount ));
11921192 Node* const string =
11931193 ToThisString (context, receiver, " String.prototype.repeat" );
1194- Node* const is_stringempty =
1195- SmiEqual (LoadStringLengthAsSmi (string), SmiConstant (0 ));
11961194
11971195 VARIABLE (
11981196 var_count, MachineRepresentation::kTagged ,
@@ -1210,7 +1208,8 @@ TF_BUILTIN(StringPrototypeRepeat, StringBuiltinsAssembler) {
12101208 TNode<Smi> smi_count = CAST (var_count.value ());
12111209 GotoIf (SmiLessThan (smi_count, SmiConstant (0 )), &invalid_count);
12121210 GotoIf (SmiEqual (smi_count, SmiConstant (0 )), &return_emptystring);
1213- GotoIf (is_stringempty, &return_emptystring);
1211+ GotoIf (Word32Equal (LoadStringLengthAsWord32 (string), Int32Constant (0 )),
1212+ &return_emptystring);
12141213 GotoIf (SmiGreaterThan (smi_count, SmiConstant (String::kMaxLength )),
12151214 &invalid_string_length);
12161215 Return (CallBuiltin (Builtins::kStringRepeat , context, string, smi_count));
@@ -1228,7 +1227,8 @@ TF_BUILTIN(StringPrototypeRepeat, StringBuiltinsAssembler) {
12281227 &invalid_count);
12291228 GotoIf (Float64LessThan (number_value, Float64Constant (0.0 )),
12301229 &invalid_count);
1231- Branch (is_stringempty, &return_emptystring, &invalid_string_length);
1230+ Branch (Word32Equal (LoadStringLengthAsWord32 (string), Int32Constant (0 )),
1231+ &return_emptystring, &invalid_string_length);
12321232 }
12331233 }
12341234
@@ -1328,16 +1328,16 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
13281328 TNode<String> const subject_string = ToString_Inline (context, receiver);
13291329 TNode<String> const search_string = ToString_Inline (context, search);
13301330
1331- TNode<Smi > const subject_length = LoadStringLengthAsSmi (subject_string);
1332- TNode<Smi > const search_length = LoadStringLengthAsSmi (search_string);
1331+ TNode<IntPtrT > const subject_length = LoadStringLengthAsWord (subject_string);
1332+ TNode<IntPtrT > const search_length = LoadStringLengthAsWord (search_string);
13331333
13341334 // Fast-path single-char {search}, long cons {receiver}, and simple string
13351335 // {replace}.
13361336 {
13371337 Label next (this );
13381338
1339- GotoIfNot (SmiEqual (search_length, SmiConstant (1 )), &next);
1340- GotoIfNot (SmiGreaterThan (subject_length, SmiConstant (0xFF )), &next);
1339+ GotoIfNot (WordEqual (search_length, IntPtrConstant (1 )), &next);
1340+ GotoIfNot (IntPtrGreaterThan (subject_length, IntPtrConstant (0xFF )), &next);
13411341 GotoIf (TaggedIsSmi (replace), &next);
13421342 GotoIfNot (IsString (replace), &next);
13431343
@@ -1389,7 +1389,8 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
13891389 BIND (&next);
13901390 }
13911391
1392- TNode<Smi> const match_end_index = SmiAdd (match_start_index, search_length);
1392+ TNode<Smi> const match_end_index =
1393+ SmiAdd (match_start_index, SmiFromIntPtr (search_length));
13931394
13941395 VARIABLE (var_result, MachineRepresentation::kTagged , EmptyStringConstant ());
13951396
@@ -1441,7 +1442,7 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
14411442 {
14421443 Node* const suffix =
14431444 CallBuiltin (Builtins::kStringSubstring , context, subject_string,
1444- SmiUntag (match_end_index), SmiUntag ( subject_length) );
1445+ SmiUntag (match_end_index), subject_length);
14451446 Node* const result = CallBuiltin (Builtins::kStringAdd_CheckNone , context,
14461447 var_result.value (), suffix);
14471448 Return (result);
0 commit comments