Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: src/code-stub-assembler.cc

Issue 2667963002: [stubs] Remove StringIndexOfChar (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index ad0dd093eafa0fd8c629bdbd854504c596dff425..018d882c75f58e06b1410314deb823e59895cfad 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -3732,73 +3732,6 @@ Node* CodeStubAssembler::StringAdd(Node* context, Node* left, Node* right,
return result.value();
}
-Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string,
- Node* needle_char, Node* from) {
- CSA_ASSERT(this, IsString(string));
- Variable var_result(this, MachineRepresentation::kTagged);
-
- Label out(this), runtime(this, Label::kDeferred);
-
- // Let runtime handle non-one-byte {needle_char}.
-
- Node* const one_byte_char_mask = Int32Constant(0xFF);
- GotoUnless(
- Word32Equal(Word32And(needle_char, one_byte_char_mask), needle_char),
- &runtime);
-
- // TODO(jgruber): Handle external and two-byte strings.
-
- Node* const one_byte_seq_mask = Int32Constant(
- kIsIndirectStringMask | kExternalStringTag | kStringEncodingMask);
- Node* const expected_masked = Int32Constant(kOneByteStringTag);
-
- Node* const string_instance_type = LoadInstanceType(string);
- GotoUnless(Word32Equal(Word32And(string_instance_type, one_byte_seq_mask),
- expected_masked),
- &runtime);
-
- // If we reach this, {string} is a non-indirect, non-external one-byte string.
-
- Node* const length = LoadStringLength(string);
- Node* const search_range_length = SmiUntag(SmiSub(length, from));
-
- const int offset = SeqOneByteString::kHeaderSize - kHeapObjectTag;
- Node* const begin = IntPtrConstant(offset);
- Node* const cursor = IntPtrAdd(begin, SmiUntag(from));
- Node* const end = IntPtrAdd(cursor, search_range_length);
-
- var_result.Bind(SmiConstant(Smi::FromInt(-1)));
-
- BuildFastLoop(
- cursor, end,
- [this, string, needle_char, begin, &var_result, &out](Node* cursor) {
- Label next(this);
- Node* value = Load(MachineType::Uint8(), string, cursor);
- GotoUnless(Word32Equal(value, needle_char), &next);
-
- // Found a match.
- Node* index = SmiTag(IntPtrSub(cursor, begin));
- var_result.Bind(index);
- Goto(&out);
-
- Bind(&next);
- },
- 1, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
- Goto(&out);
-
- Bind(&runtime);
- {
- Node* const pattern = StringFromCharCode(needle_char);
- Node* const result =
- CallRuntime(Runtime::kStringIndexOf, context, string, pattern, from);
- var_result.Bind(result);
- Goto(&out);
- }
-
- Bind(&out);
- return var_result.value();
-}
-
Node* CodeStubAssembler::StringFromCodePoint(Node* codepoint,
UnicodeEncoding encoding) {
Variable var_result(this, MachineRepresentation::kTagged,
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698