Chromium Code Reviews| Index: src/a64/lithium-codegen-a64.cc |
| diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc |
| index 4742ed0306464aee783efae7a7c38d9e75d9f80f..d8c9e37de5b60cdf1f57f35514b4065b69cc027b 100644 |
| --- a/src/a64/lithium-codegen-a64.cc |
| +++ b/src/a64/lithium-codegen-a64.cc |
| @@ -4448,6 +4448,59 @@ void LCodeGen::DoReturn(LReturn* instr) { |
| } |
| +MemOperand LCodeGen::BuildSeqStringOperand(Register string, |
| + Register temp, |
| + LOperand* index, |
| + String::Encoding encoding) { |
| + if (index->IsConstantOperand()) { |
| + int offset = ToInteger32(LConstantOperand::cast(index)); |
| + if (encoding == String::TWO_BYTE_ENCODING) { |
| + offset *= kUC16Size; |
| + } |
| + STATIC_ASSERT(kCharSize == 1); |
| + return FieldMemOperand(string, SeqString::kHeaderSize + offset); |
| + } |
| + ASSERT(!temp.is(string)); |
|
Rodolph Perfetta (ARM)
2014/02/05 20:07:22
string is declared "AtStart" and temp is declared
|
| + ASSERT(!temp.is(ToRegister(index))); |
|
Rodolph Perfetta (ARM)
2014/02/05 20:07:22
ditto.
|
| + if (encoding == String::ONE_BYTE_ENCODING) { |
| + __ Add(temp, string, Operand(ToRegister(index))); |
| + } else { |
| + STATIC_ASSERT(kUC16Size == 2); |
| + __ Add(temp, string, Operand(ToRegister(index), LSL, 1)); |
| + } |
| + return FieldMemOperand(temp, SeqString::kHeaderSize); |
| +} |
| + |
| + |
| +void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) { |
| + String::Encoding encoding = instr->hydrogen()->encoding(); |
| + Register string = ToRegister(instr->string()); |
| + Register result = ToRegister(instr->result()); |
| + Register temp = ToRegister(instr->temp()); |
| + |
| + if (FLAG_debug_code) { |
|
Rodolph Perfetta (ARM)
2014/02/05 20:07:22
because string and index are at start, this debug
ulan
2014/02/06 08:55:54
Good catch! I removed "AtStart" and added TODO.
|
| + __ Ldr(temp, FieldMemOperand(string, HeapObject::kMapOffset)); |
| + __ Ldrb(temp, FieldMemOperand(temp, Map::kInstanceTypeOffset)); |
| + |
| + __ And(temp, temp, |
| + Operand(kStringRepresentationMask | kStringEncodingMask)); |
| + static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
| + static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
| + __ Cmp(temp, Operand(encoding == String::ONE_BYTE_ENCODING |
| + ? one_byte_seq_type : two_byte_seq_type)); |
| + __ Check(eq, kUnexpectedStringType); |
| + } |
| + |
| + MemOperand operand = |
| + BuildSeqStringOperand(string, temp, instr->index(), encoding); |
| + if (encoding == String::ONE_BYTE_ENCODING) { |
| + __ Ldrb(result, operand); |
| + } else { |
| + __ Ldrh(result, operand); |
| + } |
| +} |
| + |
| + |
| void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) { |
| // TODO(all): Port ARM optimizations from r16707. |