| Index: src/x64/lithium-codegen-x64.cc
|
| diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
|
| index 27ed3b5df973d9989eaae15101fe1449d4081de7..0668c2efdd294e029ab353e09e264be26872197e 100644
|
| --- a/src/x64/lithium-codegen-x64.cc
|
| +++ b/src/x64/lithium-codegen-x64.cc
|
| @@ -3306,84 +3306,14 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
|
| LStringCharCodeAt* instr_;
|
| };
|
|
|
| - Register string = ToRegister(instr->string());
|
| - Register index = ToRegister(instr->index());
|
| - Register result = ToRegister(instr->result());
|
| -
|
| DeferredStringCharCodeAt* deferred =
|
| new DeferredStringCharCodeAt(this, instr);
|
|
|
| - // Fetch the instance type of the receiver into result register.
|
| - __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
|
| - __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
|
| -
|
| - // We need special handling for indirect strings.
|
| - Label check_sequential;
|
| - __ testb(result, Immediate(kIsIndirectStringMask));
|
| - __ j(zero, &check_sequential, Label::kNear);
|
| -
|
| - // Dispatch on the indirect string shape: slice or cons.
|
| - Label cons_string;
|
| - __ testb(result, Immediate(kSlicedNotConsMask));
|
| - __ j(zero, &cons_string, Label::kNear);
|
| -
|
| - // Handle slices.
|
| - Label indirect_string_loaded;
|
| - __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset));
|
| - __ addq(index, result);
|
| - __ movq(string, FieldOperand(string, SlicedString::kParentOffset));
|
| - __ jmp(&indirect_string_loaded, Label::kNear);
|
| -
|
| - // Handle conses.
|
| - // 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);
|
| - __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
|
| - Heap::kEmptyStringRootIndex);
|
| - __ j(not_equal, deferred->entry());
|
| - __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
|
| -
|
| - __ bind(&indirect_string_loaded);
|
| - __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
|
| - __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
|
| -
|
| - // Check whether the string is sequential. The only non-sequential
|
| - // shapes we support have just been unwrapped above.
|
| - // Note that if the original string is a cons or slice with an external
|
| - // string as underlying string, we pass that unpacked underlying string with
|
| - // the adjusted index to the runtime function.
|
| - __ bind(&check_sequential);
|
| - STATIC_ASSERT(kSeqStringTag == 0);
|
| - __ testb(result, Immediate(kStringRepresentationMask));
|
| - __ j(not_zero, deferred->entry());
|
| -
|
| - // Dispatch on the encoding: ASCII or two-byte.
|
| - Label ascii_string;
|
| - STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
|
| - STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
|
| - __ testb(result, Immediate(kStringEncodingMask));
|
| - __ j(not_zero, &ascii_string, Label::kNear);
|
| -
|
| - // Two-byte string.
|
| - // Load the two-byte character code into the result register.
|
| - Label done;
|
| - STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
|
| - __ movzxwl(result, FieldOperand(string,
|
| - index,
|
| - times_2,
|
| - SeqTwoByteString::kHeaderSize));
|
| - __ jmp(&done, Label::kNear);
|
| -
|
| - // ASCII string.
|
| - // Load the byte into the result register.
|
| - __ bind(&ascii_string);
|
| - __ movzxbl(result, FieldOperand(string,
|
| - index,
|
| - times_1,
|
| - SeqAsciiString::kHeaderSize));
|
| - __ bind(&done);
|
| + StringCharLoadGenerator::Generate(masm(),
|
| + ToRegister(instr->string()),
|
| + ToRegister(instr->index()),
|
| + ToRegister(instr->result()),
|
| + deferred->entry());
|
| __ bind(deferred->exit());
|
| }
|
|
|
|
|