Revision: 9947
Author: [email protected]
Date: Thu Nov 10 00:07:39 2011
Log: MIPS: Simplify StringCharCodeAt in non-crankshaft codegen.
Port r9936 (61034d).
BUG=
TEST=
Review URL: http://codereview.chromium.org/8506024
Patch from Gergely Kis <[email protected]>.
http://code.google.com/p/v8/source/detail?r=9947
Modified:
/branches/bleeding_edge/src/arm/code-stubs-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/mips/code-stubs-mips.cc
/branches/bleeding_edge/src/mips/full-codegen-mips.cc
/branches/bleeding_edge/src/mips/ic-mips.cc
/branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
/branches/bleeding_edge/src/mips/stub-cache-mips.cc
/branches/bleeding_edge/src/x64/code-stubs-x64.cc
/branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Nov 9 06:32:51
2011
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Nov 10 00:07:39
2011
@@ -5103,7 +5103,7 @@
// Check that parent is not an external string. Go to runtime otherwise.
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
STATIC_ASSERT(kSeqStringTag == 0);
__ tst(result_, Operand(kStringRepresentationMask));
__ b(ne, &call_runtime_);
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed Nov 9
06:32:51 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Nov 10
00:07:39 2011
@@ -3649,7 +3649,7 @@
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
__ bind(&check_sequential);
STATIC_ASSERT(kSeqStringTag == 0);
__ tst(result, Operand(kStringRepresentationMask));
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Nov 9 06:32:51
2011
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Nov 10 00:07:39
2011
@@ -5146,7 +5146,7 @@
// Assure that we are dealing with a sequential string. Go to runtime if
not.
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
__ bind(&assure_seq_string);
__ mov(result_, FieldOperand(object_, HeapObject::kMapOffset));
__ movzx_b(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed Nov 9
06:32:51 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Nov 10
00:07:39 2011
@@ -3453,7 +3453,7 @@
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
__ bind(&check_sequential);
STATIC_ASSERT(kSeqStringTag == 0);
__ test(result, Immediate(kStringRepresentationMask));
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Wed Nov 9 04:19:26
2011
+++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Nov 10 00:07:39
2011
@@ -5243,7 +5243,6 @@
Label got_char_code;
Label sliced_string;
- ASSERT(!t0.is(scratch_));
ASSERT(!t0.is(index_));
ASSERT(!t0.is(result_));
ASSERT(!t0.is(object_));
@@ -5261,13 +5260,11 @@
// If the index is non-smi trigger the non-smi case.
__ JumpIfNotSmi(index_, &index_not_smi_);
- // Put smi-tagged index into scratch register.
- __ mov(scratch_, index_);
__ bind(&got_smi_index_);
// Check for index out of range.
__ lw(t0, FieldMemOperand(object_, String::kLengthOffset));
- __ Branch(index_out_of_range_, ls, t0, Operand(scratch_));
+ __ Branch(index_out_of_range_, ls, t0, Operand(index_));
// We need special handling for non-flat strings.
STATIC_ASSERT(kSeqStringTag == 0);
@@ -5291,28 +5288,28 @@
__ LoadRoot(t0, Heap::kEmptyStringRootIndex);
__ Branch(&call_runtime_, ne, result_, Operand(t0));
- // Get the first of the two strings and load its instance type.
- __ lw(result_, FieldMemOperand(object_, ConsString::kFirstOffset));
+ // Get the first of the two parts.
+ __ lw(object_, FieldMemOperand(object_, ConsString::kFirstOffset));
__ jmp(&assure_seq_string);
// SlicedString, unpack and add offset.
__ bind(&sliced_string);
__ lw(result_, FieldMemOperand(object_, SlicedString::kOffsetOffset));
- __ addu(scratch_, scratch_, result_);
- __ lw(result_, FieldMemOperand(object_, SlicedString::kParentOffset));
+ __ Addu(index_, index_, result_);
+ __ lw(object_, FieldMemOperand(object_, SlicedString::kParentOffset));
// Assure that we are dealing with a sequential string. Go to runtime if
not.
__ bind(&assure_seq_string);
- __ lw(result_, FieldMemOperand(result_, HeapObject::kMapOffset));
+ __ lw(result_, FieldMemOperand(object_, HeapObject::kMapOffset));
__ lbu(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset));
// Check that parent is not an external string. Go to runtime otherwise.
+ // 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.
STATIC_ASSERT(kSeqStringTag == 0);
__ And(t0, result_, Operand(kStringRepresentationMask));
__ Branch(&call_runtime_, ne, t0, Operand(zero_reg));
- // Actually fetch the parent string if it is confirmed to be sequential.
- STATIC_ASSERT(SlicedString::kParentOffset == ConsString::kFirstOffset);
- __ lw(object_, FieldMemOperand(object_, SlicedString::kParentOffset));
// Check for 1-byte or 2-byte string.
__ bind(&flat_string);
@@ -5326,18 +5323,18 @@
// add without shifting since the smi tag size is the log2 of the
// number of bytes in a two-byte character.
STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1 && kSmiShiftSize == 0);
- __ Addu(scratch_, object_, Operand(scratch_));
- __ lhu(result_, FieldMemOperand(scratch_,
SeqTwoByteString::kHeaderSize));
+ __ Addu(index_, object_, Operand(index_));
+ __ lhu(result_, FieldMemOperand(index_, SeqTwoByteString::kHeaderSize));
__ Branch(&got_char_code);
// ASCII string.
// Load the byte into the result register.
__ bind(&ascii_string);
- __ srl(t0, scratch_, kSmiTagSize);
- __ Addu(scratch_, object_, t0);
-
- __ lbu(result_, FieldMemOperand(scratch_, SeqAsciiString::kHeaderSize));
+ __ srl(t0, index_, kSmiTagSize);
+ __ Addu(index_, object_, t0);
+
+ __ lbu(result_, FieldMemOperand(index_, SeqAsciiString::kHeaderSize));
__ bind(&got_char_code);
__ sll(result_, result_, kSmiTagSize);
@@ -5354,13 +5351,13 @@
__ bind(&index_not_smi_);
// If index is a heap number, try converting it to an integer.
__ CheckMap(index_,
- scratch_,
+ result_,
Heap::kHeapNumberMapRootIndex,
index_not_number_,
DONT_DO_SMI_CHECK);
call_helper.BeforeCall(masm);
// Consumed by runtime conversion function:
- __ Push(object_, index_, index_);
+ __ Push(object_, index_);
if (index_flags_ == STRING_INDEX_IS_NUMBER) {
__ CallRuntime(Runtime::kNumberToIntegerMapMinusZero, 1);
} else {
@@ -5372,16 +5369,14 @@
// Save the conversion result before the pop instructions below
// have a chance to overwrite it.
- __ Move(scratch_, v0);
-
- __ pop(index_);
+ __ Move(index_, v0);
__ pop(object_);
// Reload the instance type.
__ lw(result_, FieldMemOperand(object_, HeapObject::kMapOffset));
__ lbu(result_, FieldMemOperand(result_, Map::kInstanceTypeOffset));
call_helper.AfterCall(masm);
// If index is still not a smi, it must be out of range.
- __ JumpIfNotSmi(scratch_, index_out_of_range_);
+ __ JumpIfNotSmi(index_, index_out_of_range_);
// Otherwise, return to the fast path.
__ Branch(&got_smi_index_);
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Wed Nov 9
04:19:26 2011
+++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu Nov 10
00:07:39 2011
@@ -3058,7 +3058,6 @@
Register object = a1;
Register index = a0;
- Register scratch = a2;
Register result = v0;
__ pop(object);
@@ -3068,7 +3067,6 @@
Label done;
StringCharCodeAtGenerator generator(object,
index,
- scratch,
result,
&need_conversion,
&need_conversion,
@@ -3107,8 +3105,7 @@
Register object = a1;
Register index = a0;
- Register scratch1 = a2;
- Register scratch2 = a3;
+ Register scratch = a3;
Register result = v0;
__ pop(object);
@@ -3118,8 +3115,7 @@
Label done;
StringCharAtGenerator generator(object,
index,
- scratch1,
- scratch2,
+ scratch,
result,
&need_conversion,
&need_conversion,
=======================================
--- /branches/bleeding_edge/src/mips/ic-mips.cc Mon Nov 7 00:41:47 2011
+++ /branches/bleeding_edge/src/mips/ic-mips.cc Thu Nov 10 00:07:39 2011
@@ -1120,14 +1120,12 @@
Register receiver = a1;
Register index = a0;
- Register scratch1 = a2;
- Register scratch2 = a3;
+ Register scratch = a3;
Register result = v0;
StringCharAtGenerator char_at_generator(receiver,
index,
- scratch1,
- scratch2,
+ scratch,
result,
&miss, // When not a string.
&miss, // When not a number.
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Wed Nov 9
04:19:26 2011
+++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Nov 10
00:07:39 2011
@@ -3569,6 +3569,9 @@
// 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);
__ And(temp, result, Operand(kStringRepresentationMask));
=======================================
--- /branches/bleeding_edge/src/mips/stub-cache-mips.cc Mon Nov 7 00:41:47
2011
+++ /branches/bleeding_edge/src/mips/stub-cache-mips.cc Thu Nov 10 00:07:39
2011
@@ -1751,7 +1751,6 @@
Register receiver = a1;
Register index = t1;
- Register scratch = a3;
Register result = v0;
__ lw(receiver, MemOperand(sp, argc * kPointerSize));
if (argc > 0) {
@@ -1762,7 +1761,6 @@
StringCharCodeAtGenerator generator(receiver,
index,
- scratch,
result,
&miss, // When not a string.
&miss, // When not a number.
@@ -1833,8 +1831,7 @@
Register receiver = v0;
Register index = t1;
- Register scratch1 = a1;
- Register scratch2 = a3;
+ Register scratch = a3;
Register result = v0;
__ lw(receiver, MemOperand(sp, argc * kPointerSize));
if (argc > 0) {
@@ -1845,8 +1842,7 @@
StringCharAtGenerator generator(receiver,
index,
- scratch1,
- scratch2,
+ scratch,
result,
&miss, // When not a string.
&miss, // When not a number.
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Nov 9 06:47:12
2011
+++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Thu Nov 10 00:07:39
2011
@@ -4108,7 +4108,7 @@
// Assure that we are dealing with a sequential string. Go to runtime if
not.
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
__ bind(&assure_seq_string);
__ movq(result_, FieldOperand(object_, HeapObject::kMapOffset));
__ movzxbl(result_, FieldOperand(result_, Map::kInstanceTypeOffset));
=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed Nov 9
06:32:51 2011
+++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Nov 10
00:07:39 2011
@@ -3382,7 +3382,7 @@
// 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 updated index to the runtime function.
+ // the adjusted index to the runtime function.
__ bind(&check_sequential);
STATIC_ASSERT(kSeqStringTag == 0);
__ testb(result, Immediate(kStringRepresentationMask));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev