| Index: src/arm/lithium-codegen-arm.cc
|
| diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
|
| index 54ad4581c5ce632e7c74d7f193e5a627fcdff88f..60845e059ad0e8a86f100b10e983aab5b2b37fc9 100644
|
| --- a/src/arm/lithium-codegen-arm.cc
|
| +++ b/src/arm/lithium-codegen-arm.cc
|
| @@ -3424,7 +3424,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
| Register scratch = scratch0();
|
| Register string = ToRegister(instr->string());
|
| Register index = no_reg;
|
| - int const_index = -1;
|
| + int const_index = 0;
|
| if (instr->index()->IsConstantOperand()) {
|
| const_index = ToInteger32(LConstantOperand::cast(instr->index()));
|
| STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
|
| @@ -3446,7 +3446,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
| DeferredStringCharCodeAt* deferred =
|
| new DeferredStringCharCodeAt(this, instr);
|
|
|
| - Label flat_string, ascii_string, done;
|
| + Label flat_string, ascii_string, cons_string, two_byte_string, done;
|
|
|
| // Fetch the instance type of the receiver into result register.
|
| __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
|
| @@ -3458,14 +3458,33 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
| __ b(eq, &flat_string);
|
|
|
| // Handle non-flat strings.
|
| - __ tst(result, Operand(kIsConsStringMask));
|
| + __ and_(result, result, Operand(kStringRepresentationMask));
|
| + __ cmp(result, Operand(kConsStringTag));
|
| + __ b(eq, &cons_string);
|
| + __ cmp(result, Operand(kExternalStringTag));
|
| __ b(eq, deferred->entry());
|
|
|
| + // SlicedString.
|
| + // Unpack slice, add offset and retrieve the result char.
|
| + __ ldr(scratch, FieldMemOperand(string, SlicedString::kOffsetOffset));
|
| + __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
|
| + __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
|
| + __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
|
| + // Check for 1-byte or 2-byte string.
|
| + STATIC_ASSERT(kAsciiStringTag != 0);
|
| + STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
|
| + __ tst(result, Operand(kStringEncodingMask));
|
| + __ add(string, string, scratch, LeaveCC, eq);
|
| + __ b(eq, &two_byte_string);
|
| + __ add(string, string, Operand(scratch, ASR, 1));
|
| + __ jmp(&ascii_string);
|
| +
|
| // ConsString.
|
| // Check whether the right hand side is the empty string (i.e. if
|
| // this is really a flat string in a cons string). If that is not
|
| // the case we would rather go to the runtime system now to flatten
|
| // the string.
|
| + __ bind(&cons_string);
|
| __ ldr(scratch, FieldMemOperand(string, ConsString::kSecondOffset));
|
| __ LoadRoot(ip, Heap::kEmptyStringRootIndex);
|
| __ cmp(scratch, ip);
|
| @@ -3487,6 +3506,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
|
|
| // 2-byte string.
|
| // Load the 2-byte character code into the result register.
|
| + __ bind(&two_byte_string);
|
| STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
|
| if (instr->index()->IsConstantOperand()) {
|
| __ ldrh(result,
|
|
|