| Index: src/ia32/lithium-codegen-ia32.cc
|
| diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
|
| index e2a18eb2fc96d8d0ec43548a0f3b6547cd4e4777..cb99f170c958f5128d77b8fc7cc7890d085ccb86 100644
|
| --- a/src/ia32/lithium-codegen-ia32.cc
|
| +++ b/src/ia32/lithium-codegen-ia32.cc
|
| @@ -3139,6 +3139,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
|
|
| Register string = ToRegister(instr->string());
|
| Register index = no_reg;
|
| + Register offset = ToRegister(instr->TempAt(0));
|
| int const_index = -1;
|
| if (instr->index()->IsConstantOperand()) {
|
| const_index = ToInteger32(LConstantOperand::cast(instr->index()));
|
| @@ -3161,7 +3162,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, sliced_ascii_string, done;
|
|
|
| // Fetch the instance type of the receiver into result register.
|
| __ mov(result, FieldOperand(string, HeapObject::kMapOffset));
|
| @@ -3173,14 +3174,46 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
| __ j(zero, &flat_string, Label::kNear);
|
|
|
| // Handle non-flat strings.
|
| - __ test(result, Immediate(kIsConsStringMask));
|
| - __ j(zero, deferred->entry());
|
| + __ and_(result, kStringRepresentationMask);
|
| + __ cmp(result, kConsStringTag);
|
| + __ j(equal, &cons_string, Label::kNear);
|
| + __ cmp(result, kExternalStringTag);
|
| + __ j(equal, deferred->entry());
|
| +
|
| + // SlicedString.
|
| + // Unpack slice, add offset and retrieve the result char.
|
| + __ mov(offset, FieldOperand(string, SlicedString::kOffsetOffset));
|
| + __ SmiUntag(offset);
|
| + if (instr->index()->IsConstantOperand()) {
|
| + __ add(Operand(offset), Immediate(const_index));
|
| + } else {
|
| + __ add(offset, Operand(index));
|
| + }
|
| + __ mov(string, FieldOperand(string, SlicedString::kParentOffset));
|
| + __ mov(result, FieldOperand(string, HeapObject::kMapOffset));
|
| + __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset));
|
| + // Check for ASCII or two-byte string.
|
| + STATIC_ASSERT(kAsciiStringTag != 0);
|
| + __ test(result, Immediate(kStringEncodingMask));
|
| + __ j(not_zero, &sliced_ascii_string, Label::kNear);
|
| + __ movzx_w(result, FieldOperand(string,
|
| + offset,
|
| + times_2,
|
| + SeqTwoByteString::kHeaderSize));
|
| + __ jmp(&done, Label::kNear);
|
| + __ bind(&sliced_ascii_string);
|
| + __ movzx_b(result, FieldOperand(string,
|
| + offset,
|
| + times_1,
|
| + SeqAsciiString::kHeaderSize));
|
| + __ jmp(&done, Label::kNear);
|
|
|
| // 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);
|
| __ cmp(FieldOperand(string, ConsString::kSecondOffset),
|
| Immediate(factory()->empty_string()));
|
| __ j(not_equal, deferred->entry());
|
|
|