| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 5094 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5105   __ movq(rax, Operand(rsp, kStringOffset)); | 5105   __ movq(rax, Operand(rsp, kStringOffset)); | 
| 5106   STATIC_ASSERT(kSmiTag == 0); | 5106   STATIC_ASSERT(kSmiTag == 0); | 
| 5107   __ testl(rax, Immediate(kSmiTagMask)); | 5107   __ testl(rax, Immediate(kSmiTagMask)); | 
| 5108   __ j(zero, &runtime); | 5108   __ j(zero, &runtime); | 
| 5109   Condition is_string = masm->IsObjectStringType(rax, rbx, rbx); | 5109   Condition is_string = masm->IsObjectStringType(rax, rbx, rbx); | 
| 5110   __ j(NegateCondition(is_string), &runtime); | 5110   __ j(NegateCondition(is_string), &runtime); | 
| 5111 | 5111 | 
| 5112   // rax: string | 5112   // rax: string | 
| 5113   // rbx: instance type | 5113   // rbx: instance type | 
| 5114   // Calculate length of sub string using the smi values. | 5114   // Calculate length of sub string using the smi values. | 
| 5115   Label result_longer_than_two; |  | 
| 5116   __ movq(rcx, Operand(rsp, kToOffset)); | 5115   __ movq(rcx, Operand(rsp, kToOffset)); | 
| 5117   __ movq(rdx, Operand(rsp, kFromOffset)); | 5116   __ movq(rdx, Operand(rsp, kFromOffset)); | 
| 5118   __ JumpUnlessBothNonNegativeSmi(rcx, rdx, &runtime); | 5117   __ JumpUnlessBothNonNegativeSmi(rcx, rdx, &runtime); | 
| 5119 | 5118 | 
| 5120   __ SmiSub(rcx, rcx, rdx);  // Overflow doesn't happen. | 5119   __ SmiSub(rcx, rcx, rdx);  // Overflow doesn't happen. | 
| 5121   __ cmpq(FieldOperand(rax, String::kLengthOffset), rcx); | 5120   __ cmpq(FieldOperand(rax, String::kLengthOffset), rcx); | 
| 5122   Label not_original_string; | 5121   Label not_original_string; | 
| 5123   __ j(not_equal, ¬_original_string, Label::kNear); | 5122   // Shorter than original string's length: an actual substring. | 
|  | 5123   __ j(below, ¬_original_string, Label::kNear); | 
|  | 5124   // Longer than original string's length or negative: unsafe arguments. | 
|  | 5125   __ j(above, &runtime); | 
|  | 5126   // Return original string. | 
| 5124   Counters* counters = masm->isolate()->counters(); | 5127   Counters* counters = masm->isolate()->counters(); | 
| 5125   __ IncrementCounter(counters->sub_string_native(), 1); | 5128   __ IncrementCounter(counters->sub_string_native(), 1); | 
| 5126   __ ret(kArgumentsSize); | 5129   __ ret(kArgumentsSize); | 
| 5127   __ bind(¬_original_string); | 5130   __ bind(¬_original_string); | 
| 5128   // Special handling of sub-strings of length 1 and 2. One character strings |  | 
| 5129   // are handled in the runtime system (looked up in the single character |  | 
| 5130   // cache). Two character strings are looked for in the symbol cache. |  | 
| 5131   __ SmiToInteger32(rcx, rcx); |  | 
| 5132   __ cmpl(rcx, Immediate(2)); |  | 
| 5133   __ j(greater, &result_longer_than_two); |  | 
| 5134   __ j(less, &runtime); |  | 
| 5135 | 5131 | 
| 5136   // Sub string of length 2 requested. |  | 
| 5137   // rax: string |  | 
| 5138   // rbx: instance type |  | 
| 5139   // rcx: sub string length (value is 2) |  | 
| 5140   // rdx: from index (smi) |  | 
| 5141   __ JumpIfInstanceTypeIsNotSequentialAscii(rbx, rbx, &runtime); |  | 
| 5142 |  | 
| 5143   // Get the two characters forming the sub string. |  | 
| 5144   __ SmiToInteger32(rdx, rdx);  // From index is no longer smi. |  | 
| 5145   __ movzxbq(rbx, FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize)); |  | 
| 5146   __ movzxbq(rdi, |  | 
| 5147              FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize + 1)); |  | 
| 5148 |  | 
| 5149   // Try to lookup two character string in symbol table. |  | 
| 5150   Label make_two_character_string; |  | 
| 5151   StringHelper::GenerateTwoCharacterSymbolTableProbe( |  | 
| 5152       masm, rbx, rdi, r9, r11, r14, r15, &make_two_character_string); |  | 
| 5153   __ IncrementCounter(counters->sub_string_native(), 1); |  | 
| 5154   __ ret(3 * kPointerSize); |  | 
| 5155 |  | 
| 5156   __ bind(&make_two_character_string); |  | 
| 5157   // Set up registers for allocating the two character string. |  | 
| 5158   __ movzxwq(rbx, FieldOperand(rax, rdx, times_1, SeqAsciiString::kHeaderSize)); |  | 
| 5159   __ AllocateAsciiString(rax, rcx, r11, r14, r15, &runtime); |  | 
| 5160   __ movw(FieldOperand(rax, SeqAsciiString::kHeaderSize), rbx); |  | 
| 5161   __ IncrementCounter(counters->sub_string_native(), 1); |  | 
| 5162   __ ret(3 * kPointerSize); |  | 
| 5163 |  | 
| 5164   __ bind(&result_longer_than_two); |  | 
| 5165   // rax: string | 5132   // rax: string | 
| 5166   // rbx: instance type | 5133   // rbx: instance type | 
| 5167   // rcx: sub string length | 5134   // rcx: sub string length | 
| 5168   // rdx: from index (smi) | 5135   // rdx: from index (smi) | 
| 5169   // Deal with different string types: update the index if necessary | 5136   // Deal with different string types: update the index if necessary | 
| 5170   // and put the underlying string into edi. | 5137   // and put the underlying string into edi. | 
| 5171   Label underlying_unpacked, sliced_string, seq_or_external_string; | 5138   Label underlying_unpacked, sliced_string, seq_or_external_string; | 
| 5172   // If the string is not indirect, it can only be sequential or external. | 5139   // If the string is not indirect, it can only be sequential or external. | 
| 5173   STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 5140   STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); | 
| 5174   STATIC_ASSERT(kIsIndirectStringMask != 0); | 5141   STATIC_ASSERT(kIsIndirectStringMask != 0); | 
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6346                                  xmm0, | 6313                                  xmm0, | 
| 6347                                  &slow_elements); | 6314                                  &slow_elements); | 
| 6348   __ ret(0); | 6315   __ ret(0); | 
| 6349 } | 6316 } | 
| 6350 | 6317 | 
| 6351 #undef __ | 6318 #undef __ | 
| 6352 | 6319 | 
| 6353 } }  // namespace v8::internal | 6320 } }  // namespace v8::internal | 
| 6354 | 6321 | 
| 6355 #endif  // V8_TARGET_ARCH_X64 | 6322 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW | 
|---|