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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 61893003: MIPS: Improve implementation of HSeqStringSetChar. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.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 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 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 } 1724 }
1725 __ bind(&runtime); 1725 __ bind(&runtime);
1726 __ PrepareCallCFunction(2, scratch); 1726 __ PrepareCallCFunction(2, scratch);
1727 __ li(a1, Operand(index)); 1727 __ li(a1, Operand(index));
1728 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); 1728 __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
1729 __ bind(&done); 1729 __ bind(&done);
1730 } 1730 }
1731 } 1731 }
1732 1732
1733 1733
1734 MemOperand LCodeGen::BuildSeqStringOperand(Register string,
1735 LOperand* index,
1736 String::Encoding encoding) {
1737 if (index->IsConstantOperand()) {
1738 int offset = ToInteger32(LConstantOperand::cast(index));
1739 if (encoding == String::TWO_BYTE_ENCODING) {
1740 offset *= kUC16Size;
1741 }
1742 STATIC_ASSERT(kCharSize == 1);
1743 return FieldMemOperand(string, SeqString::kHeaderSize + offset);
1744 }
1745 Register scratch = scratch0();
1746 ASSERT(!scratch.is(string));
1747 ASSERT(!scratch.is(ToRegister(index)));
1748 if (encoding == String::ONE_BYTE_ENCODING) {
1749 __ Addu(scratch, string, ToRegister(index));
1750 } else {
1751 STATIC_ASSERT(kUC16Size == 2);
1752 __ sll(scratch, ToRegister(index), 1);
1753 __ Addu(scratch, string, scratch);
1754 }
1755 return FieldMemOperand(scratch, SeqString::kHeaderSize);
1756 }
1757
1758
1734 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { 1759 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
1760 String::Encoding encoding = instr->hydrogen()->encoding();
1735 Register string = ToRegister(instr->string()); 1761 Register string = ToRegister(instr->string());
1736 LOperand* index_op = instr->index();
1737 Register value = ToRegister(instr->value()); 1762 Register value = ToRegister(instr->value());
1738 Register scratch = scratch0();
1739 String::Encoding encoding = instr->encoding();
1740 1763
1741 if (FLAG_debug_code) { 1764 if (FLAG_debug_code) {
1765 Register scratch = scratch0();
1742 __ lw(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); 1766 __ lw(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
1743 __ lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); 1767 __ lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
1744 1768
1745 __ And(scratch, scratch, 1769 __ And(scratch, scratch,
1746 Operand(kStringRepresentationMask | kStringEncodingMask)); 1770 Operand(kStringRepresentationMask | kStringEncodingMask));
1747 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; 1771 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
1748 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; 1772 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
1749 __ Subu(at, scratch, Operand(encoding == String::ONE_BYTE_ENCODING 1773 __ Subu(at, scratch, Operand(encoding == String::ONE_BYTE_ENCODING
1750 ? one_byte_seq_type : two_byte_seq_type)); 1774 ? one_byte_seq_type : two_byte_seq_type));
1751 __ Check(eq, kUnexpectedStringType, at, Operand(zero_reg)); 1775 __ Check(eq, kUnexpectedStringType, at, Operand(zero_reg));
1752 } 1776 }
1753 1777
1754 if (index_op->IsConstantOperand()) { 1778 MemOperand operand = BuildSeqStringOperand(string, instr->index(), encoding);
1755 int constant_index = ToInteger32(LConstantOperand::cast(index_op)); 1779 if (encoding == String::ONE_BYTE_ENCODING) {
1756 if (encoding == String::ONE_BYTE_ENCODING) { 1780 __ sb(value, operand);
1757 __ sb(value,
1758 FieldMemOperand(string, SeqString::kHeaderSize + constant_index));
1759 } else {
1760 __ sh(value,
1761 FieldMemOperand(string, SeqString::kHeaderSize + constant_index * 2));
1762 }
1763 } else { 1781 } else {
1764 Register index = ToRegister(index_op); 1782 __ sh(value, operand);
1765 if (encoding == String::ONE_BYTE_ENCODING) {
1766 __ Addu(scratch, string, Operand(index));
1767 __ sb(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
1768 } else {
1769 __ sll(scratch, index, 1);
1770 __ Addu(scratch, string, scratch);
1771 __ sh(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
1772 }
1773 } 1783 }
1774 } 1784 }
1775 1785
1776 1786
1777 void LCodeGen::DoThrow(LThrow* instr) { 1787 void LCodeGen::DoThrow(LThrow* instr) {
1778 Register input_reg = EmitLoadRegister(instr->value(), at); 1788 Register input_reg = EmitLoadRegister(instr->value(), at);
1779 __ push(input_reg); 1789 __ push(input_reg);
1780 ASSERT(ToRegister(instr->context()).is(cp)); 1790 ASSERT(ToRegister(instr->context()).is(cp));
1781 CallRuntime(Runtime::kThrow, 1, instr); 1791 CallRuntime(Runtime::kThrow, 1, instr);
1782 1792
(...skipping 4030 matching lines...) Expand 10 before | Expand all | Expand 10 after
5813 __ Subu(scratch, result, scratch); 5823 __ Subu(scratch, result, scratch);
5814 __ lw(result, FieldMemOperand(scratch, 5824 __ lw(result, FieldMemOperand(scratch,
5815 FixedArray::kHeaderSize - kPointerSize)); 5825 FixedArray::kHeaderSize - kPointerSize));
5816 __ bind(&done); 5826 __ bind(&done);
5817 } 5827 }
5818 5828
5819 5829
5820 #undef __ 5830 #undef __
5821 5831
5822 } } // namespace v8::internal 5832 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698