Commit 56ca0091 authored by palfia@homejinni.com's avatar palfia@homejinni.com

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
parent eec6ed57
......@@ -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());
......
......@@ -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());
......
......@@ -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,
......
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