Commit 23fc6218 authored by plind44@gmail.com's avatar plind44@gmail.com

MIPS: Improve SeqStringSetChar implementation.

Port r16707 (a25d669)

TEST=/test/mjsunit/lithium/SeqStringSetChar.js
BUG=
R=plind44@gmail.com

Review URL: https://codereview.chromium.org/23484043

Patch from Balazs Kilvady <kilvadyb@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16720 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 516339cb
...@@ -1789,33 +1789,43 @@ void LCodeGen::DoDateField(LDateField* instr) { ...@@ -1789,33 +1789,43 @@ void LCodeGen::DoDateField(LDateField* instr) {
void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
Register string = ToRegister(instr->string()); Register string = ToRegister(instr->string());
Register index = ToRegister(instr->index()); LOperand* index_op = instr->index();
Register value = ToRegister(instr->value()); Register value = ToRegister(instr->value());
Register scratch = scratch0(); Register scratch = scratch0();
String::Encoding encoding = instr->encoding(); String::Encoding encoding = instr->encoding();
if (FLAG_debug_code) { if (FLAG_debug_code) {
__ lw(at, FieldMemOperand(string, HeapObject::kMapOffset)); __ lw(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
__ lbu(at, FieldMemOperand(at, Map::kInstanceTypeOffset)); __ lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
__ And(at, at, Operand(kStringRepresentationMask | kStringEncodingMask)); __ And(scratch, scratch,
Operand(kStringRepresentationMask | kStringEncodingMask));
static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
__ Subu(at, at, Operand(encoding == String::ONE_BYTE_ENCODING __ Subu(at, scratch, Operand(encoding == String::ONE_BYTE_ENCODING
? one_byte_seq_type : two_byte_seq_type)); ? one_byte_seq_type : two_byte_seq_type));
__ Check(eq, kUnexpectedStringType, at, Operand(zero_reg)); __ Check(eq, kUnexpectedStringType, at, Operand(zero_reg));
} }
__ Addu(scratch, if (index_op->IsConstantOperand()) {
string, int constant_index = ToInteger32(LConstantOperand::cast(index_op));
Operand(SeqString::kHeaderSize - kHeapObjectTag)); if (encoding == String::ONE_BYTE_ENCODING) {
__ sb(value,
FieldMemOperand(string, SeqString::kHeaderSize + constant_index));
} else {
__ sh(value,
FieldMemOperand(string, SeqString::kHeaderSize + constant_index * 2));
}
} else {
Register index = ToRegister(index_op);
if (encoding == String::ONE_BYTE_ENCODING) { if (encoding == String::ONE_BYTE_ENCODING) {
__ Addu(at, scratch, index); __ Addu(scratch, string, Operand(index));
__ sb(value, MemOperand(at)); __ sb(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
} else { } else {
__ sll(at, index, 1); __ sll(scratch, index, 1);
__ Addu(at, scratch, at); __ Addu(scratch, string, scratch);
__ sh(value, MemOperand(at)); __ sh(value, FieldMemOperand(scratch, SeqString::kHeaderSize));
}
} }
} }
......
...@@ -1783,11 +1783,9 @@ LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { ...@@ -1783,11 +1783,9 @@ LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
LOperand* string = UseRegister(instr->string()); LOperand* string = UseRegister(instr->string());
LOperand* index = UseRegister(instr->index()); LOperand* index = UseRegisterOrConstant(instr->index());
LOperand* value = UseTempRegister(instr->value()); LOperand* value = UseRegister(instr->value());
LSeqStringSetChar* result = return new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
return DefineAsRegister(result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment