OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4636 LOperand* index, | 4636 LOperand* index, |
4637 String::Encoding encoding) { | 4637 String::Encoding encoding) { |
4638 if (index->IsConstantOperand()) { | 4638 if (index->IsConstantOperand()) { |
4639 int offset = ToInteger32(LConstantOperand::cast(index)); | 4639 int offset = ToInteger32(LConstantOperand::cast(index)); |
4640 if (encoding == String::TWO_BYTE_ENCODING) { | 4640 if (encoding == String::TWO_BYTE_ENCODING) { |
4641 offset *= kUC16Size; | 4641 offset *= kUC16Size; |
4642 } | 4642 } |
4643 STATIC_ASSERT(kCharSize == 1); | 4643 STATIC_ASSERT(kCharSize == 1); |
4644 return FieldMemOperand(string, SeqString::kHeaderSize + offset); | 4644 return FieldMemOperand(string, SeqString::kHeaderSize + offset); |
4645 } | 4645 } |
4646 ASSERT(!temp.is(string)); | 4646 |
4647 ASSERT(!temp.is(ToRegister(index))); | |
4648 if (encoding == String::ONE_BYTE_ENCODING) { | 4647 if (encoding == String::ONE_BYTE_ENCODING) { |
4649 __ Add(temp, string, Operand(ToRegister32(index), SXTW)); | 4648 __ Add(temp, string, Operand(ToRegister32(index), SXTW)); |
4650 } else { | 4649 } else { |
4651 STATIC_ASSERT(kUC16Size == 2); | 4650 STATIC_ASSERT(kUC16Size == 2); |
4652 __ Add(temp, string, Operand(ToRegister32(index), SXTW, 1)); | 4651 __ Add(temp, string, Operand(ToRegister32(index), SXTW, 1)); |
4653 } | 4652 } |
4654 return FieldMemOperand(temp, SeqString::kHeaderSize); | 4653 return FieldMemOperand(temp, SeqString::kHeaderSize); |
4655 } | 4654 } |
4656 | 4655 |
4657 | 4656 |
4658 void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) { | 4657 void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) { |
4659 String::Encoding encoding = instr->hydrogen()->encoding(); | 4658 String::Encoding encoding = instr->hydrogen()->encoding(); |
4660 Register string = ToRegister(instr->string()); | 4659 Register string = ToRegister(instr->string()); |
4661 Register result = ToRegister(instr->result()); | 4660 Register result = ToRegister(instr->result()); |
4662 Register temp = ToRegister(instr->temp()); | 4661 Register temp = ToRegister(instr->temp()); |
4663 | 4662 |
4664 if (FLAG_debug_code) { | 4663 if (FLAG_debug_code) { |
4665 __ Ldr(temp, FieldMemOperand(string, HeapObject::kMapOffset)); | 4664 // Even though this lithium instruction comes with a temp register, we |
4666 __ Ldrb(temp, FieldMemOperand(temp, Map::kInstanceTypeOffset)); | 4665 // can't use it here because we want to use "AtStart" constraints on the |
| 4666 // inputs and the debug code here needs a scratch register. |
| 4667 UseScratchRegisterScope temps(masm()); |
| 4668 Register dbg_temp = temps.AcquireX(); |
4667 | 4669 |
4668 __ And(temp, temp, | 4670 __ Ldr(dbg_temp, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 4671 __ Ldrb(dbg_temp, FieldMemOperand(dbg_temp, Map::kInstanceTypeOffset)); |
| 4672 |
| 4673 __ And(dbg_temp, dbg_temp, |
4669 Operand(kStringRepresentationMask | kStringEncodingMask)); | 4674 Operand(kStringRepresentationMask | kStringEncodingMask)); |
4670 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; | 4675 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
4671 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; | 4676 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
4672 __ Cmp(temp, Operand(encoding == String::ONE_BYTE_ENCODING | 4677 __ Cmp(dbg_temp, Operand(encoding == String::ONE_BYTE_ENCODING |
4673 ? one_byte_seq_type : two_byte_seq_type)); | 4678 ? one_byte_seq_type : two_byte_seq_type)); |
4674 __ Check(eq, kUnexpectedStringType); | 4679 __ Check(eq, kUnexpectedStringType); |
4675 } | 4680 } |
4676 | 4681 |
4677 MemOperand operand = | 4682 MemOperand operand = |
4678 BuildSeqStringOperand(string, temp, instr->index(), encoding); | 4683 BuildSeqStringOperand(string, temp, instr->index(), encoding); |
4679 if (encoding == String::ONE_BYTE_ENCODING) { | 4684 if (encoding == String::ONE_BYTE_ENCODING) { |
4680 __ Ldrb(result, operand); | 4685 __ Ldrb(result, operand); |
4681 } else { | 4686 } else { |
4682 __ Ldrh(result, operand); | 4687 __ Ldrh(result, operand); |
4683 } | 4688 } |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5832 __ Bind(&out_of_object); | 5837 __ Bind(&out_of_object); |
5833 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5838 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
5834 // Index is equal to negated out of object property index plus 1. | 5839 // Index is equal to negated out of object property index plus 1. |
5835 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5840 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
5836 __ Ldr(result, FieldMemOperand(result, | 5841 __ Ldr(result, FieldMemOperand(result, |
5837 FixedArray::kHeaderSize - kPointerSize)); | 5842 FixedArray::kHeaderSize - kPointerSize)); |
5838 __ Bind(&done); | 5843 __ Bind(&done); |
5839 } | 5844 } |
5840 | 5845 |
5841 } } // namespace v8::internal | 5846 } } // namespace v8::internal |
OLD | NEW |