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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 8513016: Change generated code for substring not to bail out to runtime system. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 5955 matching lines...) Expand 10 before | Expand all | Expand 10 after
5966 // If coming from the make_two_character_string path, the string 5966 // If coming from the make_two_character_string path, the string
5967 // is too short to be sliced anyways. 5967 // is too short to be sliced anyways.
5968 STATIC_ASSERT(2 < SlicedString::kMinLength); 5968 STATIC_ASSERT(2 < SlicedString::kMinLength);
5969 __ jmp(&copy_routine); 5969 __ jmp(&copy_routine);
5970 __ bind(&result_longer_than_two); 5970 __ bind(&result_longer_than_two);
5971 5971
5972 // eax: string 5972 // eax: string
5973 // ebx: instance type 5973 // ebx: instance type
5974 // ecx: sub string length 5974 // ecx: sub string length
5975 // edx: from index (smi) 5975 // edx: from index (smi)
5976 Label allocate_slice, sliced_string, seq_string; 5976 Label allocate_slice, sliced_string, seq_or_external_string;
5977 __ cmp(ecx, SlicedString::kMinLength); 5977 __ cmp(ecx, SlicedString::kMinLength);
5978 // Short slice. Copy instead of slicing. 5978 // Short slice. Copy instead of slicing.
5979 __ j(less, &copy_routine); 5979 __ j(less, &copy_routine);
5980 STATIC_ASSERT(kSeqStringTag == 0);
5981 __ test(ebx, Immediate(kStringRepresentationMask));
5982 __ j(zero, &seq_string, Label::kNear);
5983 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag)); 5980 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
Rico 2011/11/17 07:27:20 These two asserts and the following test is a bit
5984 STATIC_ASSERT(kIsIndirectStringMask != 0); 5981 STATIC_ASSERT(kIsIndirectStringMask != 0);
5985 __ test(ebx, Immediate(kIsIndirectStringMask)); 5982 __ test(ebx, Immediate(kIsIndirectStringMask));
5986 // External string. Jump to runtime. 5983 __ j(zero, &seq_or_external_string, Label::kNear);
5987 __ j(zero, &runtime);
5988 5984
5989 Factory* factory = masm->isolate()->factory(); 5985 Factory* factory = masm->isolate()->factory();
5990 __ test(ebx, Immediate(kSlicedNotConsMask)); 5986 __ test(ebx, Immediate(kSlicedNotConsMask));
5991 __ j(not_zero, &sliced_string, Label::kNear); 5987 __ j(not_zero, &sliced_string, Label::kNear);
5992 // Cons string. Check whether it is flat, then fetch first part. 5988 // Cons string. Check whether it is flat, then fetch first part.
5993 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), 5989 __ cmp(FieldOperand(eax, ConsString::kSecondOffset),
5994 factory->empty_string()); 5990 factory->empty_string());
5995 __ j(not_equal, &runtime); 5991 __ j(not_equal, &runtime);
5996 __ mov(edi, FieldOperand(eax, ConsString::kFirstOffset)); 5992 __ mov(edi, FieldOperand(eax, ConsString::kFirstOffset));
5997 __ jmp(&allocate_slice, Label::kNear); 5993 __ jmp(&allocate_slice, Label::kNear);
5998 5994
5999 __ bind(&sliced_string); 5995 __ bind(&sliced_string);
6000 // Sliced string. Fetch parent and correct start index by offset. 5996 // Sliced string. Fetch parent and correct start index by offset.
6001 __ add(edx, FieldOperand(eax, SlicedString::kOffsetOffset)); 5997 __ add(edx, FieldOperand(eax, SlicedString::kOffsetOffset));
6002 __ mov(edi, FieldOperand(eax, SlicedString::kParentOffset)); 5998 __ mov(edi, FieldOperand(eax, SlicedString::kParentOffset));
6003 __ jmp(&allocate_slice, Label::kNear); 5999 __ jmp(&allocate_slice, Label::kNear);
6004 6000
6005 __ bind(&seq_string); 6001 __ bind(&seq_or_external_string);
6006 // Sequential string. Just move string to the right register. 6002 // Sequential or external string. Just move string to the correct register.
6007 __ mov(edi, eax); 6003 __ mov(edi, eax);
6008 6004
6009 __ bind(&allocate_slice); 6005 __ bind(&allocate_slice);
6010 // edi: underlying subject string 6006 // edi: underlying subject string
6011 // ebx: instance type of original subject string 6007 // ebx: instance type of original subject string
6012 // edx: offset 6008 // edx: offset
6013 // ecx: length 6009 // ecx: length
6014 // Allocate new sliced string. At this point we do not reload the instance 6010 // Allocate new sliced string. At this point we do not reload the instance
6015 // type including the string encoding because we simply rely on the info 6011 // type including the string encoding because we simply rely on the info
6016 // provided by the original string. It does not matter if the original 6012 // provided by the original string. It does not matter if the original
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
7107 false); 7103 false);
7108 __ pop(edx); 7104 __ pop(edx);
7109 __ ret(0); 7105 __ ret(0);
7110 } 7106 }
7111 7107
7112 #undef __ 7108 #undef __
7113 7109
7114 } } // namespace v8::internal 7110 } } // namespace v8::internal
7115 7111
7116 #endif // V8_TARGET_ARCH_IA32 7112 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698