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

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

Issue 7744052: Generated code for substring slices in ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months 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 | « no previous file | src/ia32/macro-assembler-ia32.h » ('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 5624 matching lines...) Expand 10 before | Expand all | Expand 10 after
5635 __ test(hash, Operand(hash)); 5635 __ test(hash, Operand(hash));
5636 __ j(not_zero, &hash_not_zero, Label::kNear); 5636 __ j(not_zero, &hash_not_zero, Label::kNear);
5637 __ mov(hash, Immediate(27)); 5637 __ mov(hash, Immediate(27));
5638 __ bind(&hash_not_zero); 5638 __ bind(&hash_not_zero);
5639 } 5639 }
5640 5640
5641 5641
5642 void SubStringStub::Generate(MacroAssembler* masm) { 5642 void SubStringStub::Generate(MacroAssembler* masm) {
5643 Label runtime; 5643 Label runtime;
5644 5644
5645 if (FLAG_string_slices) {
5646 __ jmp(&runtime);
5647 }
5648 // Stack frame on entry. 5645 // Stack frame on entry.
5649 // esp[0]: return address 5646 // esp[0]: return address
5650 // esp[4]: to 5647 // esp[4]: to
5651 // esp[8]: from 5648 // esp[8]: from
5652 // esp[12]: string 5649 // esp[12]: string
5653 5650
5654 // Make sure first argument is a string. 5651 // Make sure first argument is a string.
5655 __ mov(eax, Operand(esp, 3 * kPointerSize)); 5652 __ mov(eax, Operand(esp, 3 * kPointerSize));
5656 STATIC_ASSERT(kSmiTag == 0); 5653 STATIC_ASSERT(kSmiTag == 0);
5657 __ JumpIfSmi(eax, &runtime); 5654 __ JumpIfSmi(eax, &runtime);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5699 &make_two_character_string, &make_two_character_string); 5696 &make_two_character_string, &make_two_character_string);
5700 __ ret(3 * kPointerSize); 5697 __ ret(3 * kPointerSize);
5701 5698
5702 __ bind(&make_two_character_string); 5699 __ bind(&make_two_character_string);
5703 // Setup registers for allocating the two character string. 5700 // Setup registers for allocating the two character string.
5704 __ mov(eax, Operand(esp, 3 * kPointerSize)); 5701 __ mov(eax, Operand(esp, 3 * kPointerSize));
5705 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 5702 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
5706 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); 5703 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset));
5707 __ Set(ecx, Immediate(2)); 5704 __ Set(ecx, Immediate(2));
5708 5705
5709 __ bind(&result_longer_than_two); 5706 if (FLAG_string_slices) {
5707 __ SmiTag(edx); // Make edx a smi again.
antonm 2011/08/26 16:10:55 do you want to fallback here from make_two_charact
Yang 2011/08/29 12:55:56 Yes.
antonm 2011/08/29 14:51:27 Brevity is .... :) I meant you know for sure you
Yang 2011/08/29 15:17:07 Oups. I actually managed to overlook this simple f
5708 __ bind(&result_longer_than_two);
5709
5710 // eax: string
5711 // ebx: instance type
5712 // ecx: sub string length
5713 // edx: from index (smi)
5714 Label copy_routine, allocate_slice, sliced_string, seq_string;
5715 __ cmp(ecx, SlicedString::kMinLength);
5716 // Short slice. Copy instead of slicing.
5717 __ j(less, &copy_routine);
5718 STATIC_ASSERT(kSeqStringTag == 0);
5719 __ test(ebx, Immediate(kStringRepresentationMask));
5720 __ j(zero, &seq_string, Label::kNear);
5721 STATIC_ASSERT(kIsIndirectStringMask == (kSlicedStringTag & kConsStringTag));
5722 STATIC_ASSERT(kIsIndirectStringMask != 0);
5723 __ test(ebx, Immediate(kIsIndirectStringMask));
5724 // External string. Jump to runtime.
5725 __ j(zero, &runtime);
5726
5727 Factory* factory = masm->isolate()->factory();
5728 const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag;
antonm 2011/08/26 16:10:55 lift those constants into objects.h?
antonm 2011/08/29 14:51:27 any response?
Yang 2011/08/29 15:17:07 I did move these two lines into objects.h Maybe yo
antonm 2011/08/29 17:19:26 Sorry, didn't notice that. Usually people respond
5729 ASSERT(IsPowerOf2(kSlicedNotConsMask) && kSlicedNotConsMask != 0);
5730 __ test(ebx, Immediate(kSlicedNotConsMask));
5731 __ j(not_zero, &sliced_string, Label::kNear);
5732 // Cons string. Check whether it is flat, then fetch first part.
5733 __ cmp(FieldOperand(eax, ConsString::kSecondOffset),
5734 factory->empty_string());
5735 __ j(not_equal, &runtime);
5736 __ mov(edi, FieldOperand(eax, ConsString::kFirstOffset));
5737 __ jmp(&allocate_slice, Label::kNear);
5738
5739 __ bind(&sliced_string);
5740 // Sliced string. Fetch parent and correct start index by offset.
5741 __ add(edx, FieldOperand(eax, SlicedString::kOffsetOffset));
5742 __ mov(edi, FieldOperand(eax, SlicedString::kParentOffset));
5743 __ jmp(&allocate_slice, Label::kNear);
5744
5745 __ bind(&seq_string);
5746 // Sequential string. Just move string to the right register.
5747 __ mov(edi, eax);
antonm 2011/08/26 16:10:55 maybe keep the parent string in eax and save this
Yang 2011/08/29 12:55:56 eax has to be used as destination when allocation
antonm 2011/08/29 14:51:27 I am not sure, apparently you can allocate into an
Yang 2011/08/29 15:17:07 Yes but the issue is that the return value of this
antonm 2011/08/29 17:19:26 ok
5748
5749 __ bind(&allocate_slice);
5750 // edi: parent string
5751 // ebx: instance type of parent string
5752 // edx: offset
5753 // ecx: length
5754 // Allocate new sliced string. At this point we do not reload the instance
5755 // type including the string encoding because we simply rely on the info
5756 // provided by the parent string. It does not matter if the parent's
5757 // encoding is wrong because we have to recheck encoding of the slice's
5758 // parent anyways due to externalized strings
5759 Label two_byte_slice, set_slice_header;
5760 STATIC_ASSERT(kAsciiStringTag != 0);
5761 __ test(ebx, Immediate(kAsciiStringTag));
5762 __ j(zero, &two_byte_slice, Label::kNear);
5763 __ AllocateAsciiSlicedString(eax, ebx, no_reg, &runtime);
5764 __ jmp(&set_slice_header, Label::kNear);
5765 __ bind(&two_byte_slice);
5766 __ AllocateSlicedString(eax, ebx, no_reg, &runtime);
5767 __ bind(&set_slice_header);
5768 __ mov(FieldOperand(eax, SlicedString::kOffsetOffset), edx);
5769 __ SmiTag(ecx);
antonm 2011/08/26 16:10:55 apparently there is too much of tagging/untagging,
Yang 2011/08/29 12:55:56 The alternative saves this one tagging, but would
antonm 2011/08/29 14:51:27 Up to you.
5770 __ mov(FieldOperand(eax, SlicedString::kLengthOffset), ecx);
5771 __ mov(FieldOperand(eax, SlicedString::kParentOffset), edi);
5772 __ mov(FieldOperand(eax, SlicedString::kHashFieldOffset),
5773 Immediate(String::kEmptyHashField));
5774 __ jmp(&return_eax);
5775
5776 __ bind(&copy_routine);
5777 } else {
5778 __ bind(&result_longer_than_two);
5779 }
5780
5710 // eax: string 5781 // eax: string
5711 // ebx: instance type 5782 // ebx: instance type
5712 // ecx: result string length 5783 // ecx: result string length
5713 // Check for flat ascii string 5784 // Check for flat ascii string
5714 Label non_ascii_flat; 5785 Label non_ascii_flat;
5715 __ JumpIfInstanceTypeIsNotSequentialAscii(ebx, ebx, &non_ascii_flat); 5786 __ JumpIfInstanceTypeIsNotSequentialAscii(ebx, ebx, &non_ascii_flat);
5716 5787
5717 // Allocate the result. 5788 // Allocate the result.
5718 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime); 5789 __ AllocateAsciiString(eax, ecx, ebx, edx, edi, &runtime);
5719 5790
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 __ Drop(1); 6485 __ Drop(1);
6415 __ ret(2 * kPointerSize); 6486 __ ret(2 * kPointerSize);
6416 } 6487 }
6417 6488
6418 6489
6419 #undef __ 6490 #undef __
6420 6491
6421 } } // namespace v8::internal 6492 } } // namespace v8::internal
6422 6493
6423 #endif // V8_TARGET_ARCH_IA32 6494 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698