| 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 6144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6155 // ebx: instance type | 6155 // ebx: instance type |
| 6156 | 6156 |
| 6157 // Calculate length of sub string using the smi values. | 6157 // Calculate length of sub string using the smi values. |
| 6158 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index. | 6158 __ mov(ecx, Operand(esp, 1 * kPointerSize)); // To index. |
| 6159 __ JumpIfNotSmi(ecx, &runtime); | 6159 __ JumpIfNotSmi(ecx, &runtime); |
| 6160 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index. | 6160 __ mov(edx, Operand(esp, 2 * kPointerSize)); // From index. |
| 6161 __ JumpIfNotSmi(edx, &runtime); | 6161 __ JumpIfNotSmi(edx, &runtime); |
| 6162 __ sub(ecx, edx); | 6162 __ sub(ecx, edx); |
| 6163 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset)); | 6163 __ cmp(ecx, FieldOperand(eax, String::kLengthOffset)); |
| 6164 Label not_original_string; | 6164 Label not_original_string; |
| 6165 __ j(not_equal, ¬_original_string, Label::kNear); | 6165 // Shorter than original string's length: an actual substring. |
| 6166 __ j(below, ¬_original_string, Label::kNear); |
| 6167 // Longer than original string's length or negative: unsafe arguments. |
| 6168 __ j(above, &runtime); |
| 6169 // Return original string. |
| 6166 Counters* counters = masm->isolate()->counters(); | 6170 Counters* counters = masm->isolate()->counters(); |
| 6167 __ IncrementCounter(counters->sub_string_native(), 1); | 6171 __ IncrementCounter(counters->sub_string_native(), 1); |
| 6168 __ ret(3 * kPointerSize); | 6172 __ ret(3 * kPointerSize); |
| 6169 __ bind(¬_original_string); | 6173 __ bind(¬_original_string); |
| 6170 | 6174 |
| 6171 // eax: string | 6175 // eax: string |
| 6172 // ebx: instance type | 6176 // ebx: instance type |
| 6173 // ecx: sub string length (smi) | 6177 // ecx: sub string length (smi) |
| 6174 // edx: from index (smi) | 6178 // edx: from index (smi) |
| 6175 // Deal with different string types: update the index if necessary | 6179 // Deal with different string types: update the index if necessary |
| (...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7379 false); | 7383 false); |
| 7380 __ pop(edx); | 7384 __ pop(edx); |
| 7381 __ ret(0); | 7385 __ ret(0); |
| 7382 } | 7386 } |
| 7383 | 7387 |
| 7384 #undef __ | 7388 #undef __ |
| 7385 | 7389 |
| 7386 } } // namespace v8::internal | 7390 } } // namespace v8::internal |
| 7387 | 7391 |
| 7388 #endif // V8_TARGET_ARCH_IA32 | 7392 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |