Revision: 4951
Author: [email protected]
Date: Fri Jun 25 04:24:41 2010
Log: Add special case of taking a substring that is the entire string to stub.

Review URL: http://codereview.chromium.org/2800027
http://code.google.com/p/v8/source/detail?r=4951

Modified:
 /branches/bleeding_edge/src/ia32/codegen-ia32.cc
 /branches/bleeding_edge/src/x64/codegen-x64.cc

=======================================
--- /branches/bleeding_edge/src/ia32/codegen-ia32.cc Thu Jun 24 06:56:35 2010 +++ /branches/bleeding_edge/src/ia32/codegen-ia32.cc Fri Jun 25 04:24:41 2010
@@ -13295,6 +13295,9 @@
   __ test(edx, Immediate(kSmiTagMask));
   __ j(not_zero, &runtime);
   __ sub(ecx, Operand(edx));
+  __ cmp(ecx, FieldOperand(eax, String::kLengthOffset));
+  Label return_eax;
+  __ j(equal, &return_eax);
// 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.
@@ -13399,12 +13402,15 @@
   // esi: character of sub string start
   StringHelper::GenerateCopyCharactersREP(masm, edi, esi, ecx, ebx, false);
   __ mov(esi, edx);  // Restore esi.
+
+  __ bind(&return_eax);
   __ IncrementCounter(&Counters::sub_string_native, 1);
   __ ret(3 * kPointerSize);

   // Just jump to runtime to create the sub string.
   __ bind(&runtime);
   __ TailCallRuntime(Runtime::kSubString, 3, 1);
+
 }


=======================================
--- /branches/bleeding_edge/src/x64/codegen-x64.cc      Thu Jun 24 07:22:25 2010
+++ /branches/bleeding_edge/src/x64/codegen-x64.cc      Fri Jun 25 04:24:41 2010
@@ -11574,7 +11574,9 @@
   __ JumpIfNotBothPositiveSmi(rcx, rdx, &runtime);

   __ SmiSub(rcx, rcx, rdx, NULL);  // Overflow doesn't happen.
-  __ j(negative, &runtime);
+  __ cmpq(FieldOperand(rax, String::kLengthOffset), rcx);
+  Label return_rax;
+  __ j(equal, &return_rax);
// 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.
@@ -11677,6 +11679,8 @@
   // rsi: character of sub string start
   StringHelper::GenerateCopyCharactersREP(masm, rdi, rsi, rcx, false);
   __ movq(rsi, rdx);  // Restore esi.
+
+  __ bind(&return_rax);
   __ IncrementCounter(&Counters::sub_string_native, 1);
   __ ret(kArgumentsSize);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to