From 56ca0091082aeda16567196e788f344d5a4694e8 Mon Sep 17 00:00:00 2001 From: "palfia@homejinni.com" Date: Thu, 7 Nov 2013 21:59:45 +0000 Subject: [PATCH] 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 --- src/mips/lithium-codegen-mips.cc | 28 ++++++++++++++++++++++++++++ src/mips/lithium-mips.cc | 7 +++++++ src/mips/lithium-mips.h | 16 ++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 5d09a30..2d8939f 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -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()); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 6f8d95e..7686096 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -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()); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 9b4d111..14bd29b 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -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, -- 2.7.4