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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 11348349: Improve array to string conversion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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
OLDNEW
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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // Load the byte into the result register. 786 // Load the byte into the result register.
787 __ bind(&ascii); 787 __ bind(&ascii);
788 __ movzx_b(result, FieldOperand(string, 788 __ movzx_b(result, FieldOperand(string,
789 index, 789 index,
790 times_1, 790 times_1,
791 SeqOneByteString::kHeaderSize)); 791 SeqOneByteString::kHeaderSize));
792 __ bind(&done); 792 __ bind(&done);
793 } 793 }
794 794
795 795
796 void SeqStringSetCharGenerator::Generate(MacroAssembler* masm,
797 bool one_byte_string,
798 Register string,
799 Register index,
800 Register value) {
801 if (FLAG_debug_code) {
802 __ test(index, Immediate(kSmiTagMask));
803 __ Check(zero, "Non-smi index");
804 __ test(value, Immediate(kSmiTagMask));
805 __ Check(zero, "Non-smi value");
806
807 __ cmp(index, FieldOperand(string, String::kLengthOffset));
808 __ Check(less, "Index is too large");
809
810 __ cmp(index, Immediate(Smi::FromInt(0)));
811 __ Check(greater_equal, "Index is negative");
812
813 __ push(value);
814 __ mov(value, FieldOperand(string, HeapObject::kMapOffset));
815 __ movzx_b(value, FieldOperand(value, Map::kInstanceTypeOffset));
816
817 __ and_(value, Immediate(kStringRepresentationMask | kStringEncodingMask));
818 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
819 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
820 __ cmp(value, Immediate(one_byte_string ? one_byte_seq_type
821 : two_byte_seq_type));
822 __ Check(equal, "Unexpected string type");
823 __ pop(value);
824 }
825
826 STATIC_ASSERT(kSmiTagSize == 1);
827 __ SmiUntag(value);
828 if (one_byte_string) {
829 __ SmiUntag(index);
830 __ mov_b(FieldOperand(string, index, times_1, SeqString::kHeaderSize),
831 value);
832 } else {
833 __ mov_w(FieldOperand(string, index, times_1, SeqString::kHeaderSize),
Toon Verwaest 2012/12/05 14:29:12 Can we add a comment that this works because of th
834 value);
835 }
836 }
837
838
796 static Operand ExpConstant(int index) { 839 static Operand ExpConstant(int index) {
797 return Operand::StaticVariable(ExternalReference::math_exp_constants(index)); 840 return Operand::StaticVariable(ExternalReference::math_exp_constants(index));
798 } 841 }
799 842
800 843
801 void MathExpGenerator::EmitMathExp(MacroAssembler* masm, 844 void MathExpGenerator::EmitMathExp(MacroAssembler* masm,
802 XMMRegister input, 845 XMMRegister input,
803 XMMRegister result, 846 XMMRegister result,
804 XMMRegister double_scratch, 847 XMMRegister double_scratch,
805 Register temp1, 848 Register temp1,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 Code* stub = GetCodeAgeStub(age, parity); 951 Code* stub = GetCodeAgeStub(age, parity);
909 CodePatcher patcher(sequence, young_length); 952 CodePatcher patcher(sequence, young_length);
910 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE); 953 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE);
911 } 954 }
912 } 955 }
913 956
914 957
915 } } // namespace v8::internal 958 } } // namespace v8::internal
916 959
917 #endif // V8_TARGET_ARCH_IA32 960 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698