MIPS: Add new HSeqStringGetChar instruction.

Port r17565 (dce7927c)

Original commit message:
This instruction is required for copying characters from sequential
strings in the hydrogenized StringAddStub.

BUG=
R=plind44@gmail.com

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17574 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
palfia@homejinni.com 2013-11-07 21:59:45 +00:00
parent eec6ed57fb
commit 56ca009108
3 changed files with 51 additions and 0 deletions

View File

@ -1756,6 +1756,34 @@ MemOperand LCodeGen::BuildSeqStringOperand(Register string,
}
void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) {
String::Encoding encoding = instr->hydrogen()->encoding();
Register string = ToRegister(instr->string());
Register result = ToRegister(instr->result());
if (FLAG_debug_code) {
Register scratch = scratch0();
__ lw(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
__ lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
__ And(scratch, scratch,
Operand(kStringRepresentationMask | kStringEncodingMask));
static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag;
static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
__ Subu(at, scratch, Operand(encoding == String::ONE_BYTE_ENCODING
? one_byte_seq_type : two_byte_seq_type));
__ Check(eq, kUnexpectedStringType, at, Operand(zero_reg));
}
MemOperand operand = BuildSeqStringOperand(string, instr->index(), encoding);
if (encoding == String::ONE_BYTE_ENCODING) {
__ lbu(result, operand);
} else {
__ lhu(result, operand);
}
}
void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
String::Encoding encoding = instr->hydrogen()->encoding();
Register string = ToRegister(instr->string());

View File

@ -1804,6 +1804,13 @@ LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
}
LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
LOperand* string = UseRegisterAtStart(instr->string());
LOperand* index = UseRegisterOrConstantAtStart(instr->index());
return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index));
}
LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
LOperand* string = UseRegister(instr->string());
LOperand* index = UseRegisterOrConstant(instr->index());

View File

@ -155,6 +155,7 @@ class LCodeGen;
V(Random) \
V(RegExpLiteral) \
V(Return) \
V(SeqStringGetChar) \
V(SeqStringSetChar) \
V(ShiftI) \
V(SmiTag) \
@ -1340,6 +1341,21 @@ class LDateField V8_FINAL : public LTemplateInstruction<1, 1, 1> {
};
class LSeqStringGetChar V8_FINAL : public LTemplateInstruction<1, 2, 0> {
public:
LSeqStringGetChar(LOperand* string, LOperand* index) {
inputs_[0] = string;
inputs_[1] = index;
}
LOperand* string() const { return inputs_[0]; }
LOperand* index() const { return inputs_[1]; }
DECLARE_CONCRETE_INSTRUCTION(SeqStringGetChar, "seq-string-get-char")
DECLARE_HYDROGEN_ACCESSOR(SeqStringGetChar)
};
class LSeqStringSetChar V8_FINAL : public LTemplateInstruction<1, 3, 0> {
public:
LSeqStringSetChar(LOperand* string,