Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 284503977128c86ff92776424c47f3267be931c7..fb2e79d233c5214d5a6a605a1b507afbdb4ca712 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -5112,7 +5112,6 @@ void SubStringStub::Generate(MacroAssembler* masm) { |
// rax: string |
// rbx: instance type |
// Calculate length of sub string using the smi values. |
- Label result_longer_than_two; |
__ movq(rcx, Operand(rsp, kToOffset)); |
__ movq(rdx, Operand(rsp, kFromOffset)); |
__ JumpUnlessBothNonNegativeSmi(rcx, rdx, &runtime); |
@@ -5120,48 +5119,16 @@ void SubStringStub::Generate(MacroAssembler* masm) { |
__ SmiSub(rcx, rcx, rdx); // Overflow doesn't happen. |
__ cmpq(FieldOperand(rax, String::kLengthOffset), rcx); |
Label not_original_string; |
- __ j(not_equal, ¬_original_string, Label::kNear); |
+ // Shorter than original string's length: an actual substring. |
+ __ j(below, ¬_original_string, Label::kNear); |
+ // Longer than original string's length or negative: unsafe arguments. |
+ __ j(above, &runtime); |
+ // Return original string. |
Counters* counters = masm->isolate()->counters(); |
__ IncrementCounter(counters->sub_string_native(), 1); |
__ ret(kArgumentsSize); |
__ bind(¬_original_string); |
- // Special handling of sub-strings of length 1 and 2. One character strings |
- // are handled in the runtime system (looked up in the single character |
- // cache). Two character strings are looked for in the symbol cache. |
- __ SmiToInteger32(rcx, rcx); |
- __ cmpl(rcx, Immediate(2)); |
- __ j(greater, &result_longer_than_two); |
- __ j(less, &runtime); |
- |
- // Sub string of length 2 requested. |
- // rax: string |
- // rbx: instance type |
- // rcx: sub string length (value is 2) |
- // rdx: from index (smi) |
- __ JumpIfInstanceTypeIsNotSequentialAscii(rbx, rbx, &runtime); |
- |
- // Get the two characters forming the sub string. |
- __ SmiToInteger32(rdx, rdx); // From index is no longer smi. |
- __ movzxbq(rbx, FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize)); |
- __ movzxbq(rdi, |
- FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize + 1)); |
- |
- // Try to lookup two character string in symbol table. |
- Label make_two_character_string; |
- StringHelper::GenerateTwoCharacterSymbolTableProbe( |
- masm, rbx, rdi, r9, r11, r14, r15, &make_two_character_string); |
- __ IncrementCounter(counters->sub_string_native(), 1); |
- __ ret(3 * kPointerSize); |
- |
- __ bind(&make_two_character_string); |
- // Set up registers for allocating the two character string. |
- __ movzxwq(rbx, FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize)); |
- __ AllocateAsciiString(rax, rcx, r11, r14, r15, &runtime); |
- __ movw(FieldOperand(rax, SeqAsciiString::kHeaderSize), rbx); |
- __ IncrementCounter(counters->sub_string_native(), 1); |
- __ ret(3 * kPointerSize); |
- __ bind(&result_longer_than_two); |
// rax: string |
// rbx: instance type |
// rcx: sub string length |