[v8] r19166 committed - A64: Port LSeqStringSetChar optimizations from r16707 and r17521....

1 view
Skip to first unread message

codesite...@google.com

unread,
Feb 6, 2014, 11:16:46 AM2/6/14
to v8-...@googlegroups.com
Revision: 19166
Author: ul...@chromium.org
Date: Thu Feb 6 16:16:30 2014 UTC
Log: A64: Port LSeqStringSetChar optimizations from r16707 and r17521.

BUG=
TEST=mjsunit/lithium/SeqStringSetChar
R=baptis...@arm.com

Review URL: https://codereview.chromium.org/141713009
http://code.google.com/p/v8/source/detail?r=19166

Modified:
/branches/experimental/a64/src/a64/full-codegen-a64.cc
/branches/experimental/a64/src/a64/lithium-codegen-a64.cc
/branches/experimental/a64/src/a64/macro-assembler-a64.cc
/branches/experimental/a64/src/a64/macro-assembler-a64.h

=======================================
--- /branches/experimental/a64/src/a64/full-codegen-a64.cc Thu Feb 6
14:30:18 2014 UTC
+++ /branches/experimental/a64/src/a64/full-codegen-a64.cc Thu Feb 6
16:16:30 2014 UTC
@@ -3224,9 +3224,9 @@
__ Throw(kNonSmiValue);
__ Throw(kNonSmiIndex);
__ Bind(&both_smis);
-
static const uint32_t one_byte_seq_type = kSeqStringTag |
kOneByteStringTag;
- __ EmitSeqStringSetCharCheck(string, index, one_byte_seq_type);
+ __ EmitSeqStringSetCharCheck(string, index, kIndexIsSmi, scratch,
+ one_byte_seq_type);
}

__ Add(scratch, string, SeqOneByteString::kHeaderSize - kHeapObjectTag);
@@ -3257,9 +3257,9 @@
__ Throw(kNonSmiValue);
__ Throw(kNonSmiIndex);
__ Bind(&both_smis);
-
static const uint32_t two_byte_seq_type = kSeqStringTag |
kTwoByteStringTag;
- __ EmitSeqStringSetCharCheck(string, index, two_byte_seq_type);
+ __ EmitSeqStringSetCharCheck(string, index, kIndexIsSmi, scratch,
+ two_byte_seq_type);
}

__ Add(scratch, string, SeqTwoByteString::kHeaderSize - kHeapObjectTag);
=======================================
--- /branches/experimental/a64/src/a64/lithium-codegen-a64.cc Thu Feb 6
14:40:59 2014 UTC
+++ /branches/experimental/a64/src/a64/lithium-codegen-a64.cc Thu Feb 6
16:16:30 2014 UTC
@@ -4522,30 +4522,27 @@


void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
- // TODO(all): Port ARM optimizations from r16707.
-
String::Encoding encoding = instr->encoding();
Register string = ToRegister(instr->string());
- Register index = ToRegister(instr->index());
Register value = ToRegister(instr->value());
Register temp = ToRegister(instr->temp());

if (FLAG_debug_code) {
- if (encoding == String::ONE_BYTE_ENCODING) {
- __ EmitSeqStringSetCharCheck(
- string, index, kSeqStringTag | kOneByteStringTag);
- } else {
- ASSERT(encoding == String::TWO_BYTE_ENCODING);
- __ EmitSeqStringSetCharCheck(
- string, index, kSeqStringTag | kTwoByteStringTag);
- }
+ Register index = ToRegister(instr->index());
+ static const uint32_t one_byte_seq_type = kSeqStringTag |
kOneByteStringTag;
+ static const uint32_t two_byte_seq_type = kSeqStringTag |
kTwoByteStringTag;
+ int encoding_mask =
+ instr->hydrogen()->encoding() == String::ONE_BYTE_ENCODING
+ ? one_byte_seq_type : two_byte_seq_type;
+ __ EmitSeqStringSetCharCheck(string, index, kIndexIsInteger32, temp,
+ encoding_mask);
}
-
- __ Add(temp, string, SeqString::kHeaderSize - kHeapObjectTag);
+ MemOperand operand =
+ BuildSeqStringOperand(string, temp, instr->index(), encoding);
if (encoding == String::ONE_BYTE_ENCODING) {
- __ Strb(value, MemOperand(temp, index));
+ __ Strb(value, operand);
} else {
- __ Strh(value, MemOperand(temp, index, LSL, 1));
+ __ Strh(value, operand);
}
}

=======================================
--- /branches/experimental/a64/src/a64/macro-assembler-a64.cc Thu Feb 6
15:38:09 2014 UTC
+++ /branches/experimental/a64/src/a64/macro-assembler-a64.cc Thu Feb 6
16:16:30 2014 UTC
@@ -3628,13 +3628,17 @@
}


-void MacroAssembler::EmitSeqStringSetCharCheck(Register string,
- Register index,
- uint32_t encoding_mask) {
- Register scratch = __ Tmp1();
+void MacroAssembler::EmitSeqStringSetCharCheck(
+ Register string,
+ Register index,
+ SeqStringSetCharCheckIndexType index_type,
+ Register scratch,
+ uint32_t encoding_mask) {
ASSERT(!AreAliased(string, index, scratch));

- AssertSmi(index);
+ if (index_type == kIndexIsSmi) {
+ AssertSmi(index);
+ }

// Check that string is an object.
ThrowIfSmi(string, kNonObject);
@@ -3642,16 +3646,17 @@
// Check that string has an appropriate map.
Ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
Ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
+
And(scratch, scratch, kStringRepresentationMask | kStringEncodingMask);
Cmp(scratch, encoding_mask);
ThrowIf(ne, kUnexpectedStringType);

- // Check that the index points inside the string.
Ldr(scratch, FieldMemOperand(string, String::kLengthOffset));
- Cmp(index, scratch);
+ Cmp(index, index_type == kIndexIsSmi ? scratch :
Operand::UntagSmi(scratch));
ThrowIf(ge, kIndexIsTooLarge);

- Cmp(index, Operand(Smi::FromInt(0)));
+ ASSERT_EQ(0, Smi::FromInt(0));
+ Cmp(index, 0);
ThrowIf(lt, kIndexIsNegative);
}

=======================================
--- /branches/experimental/a64/src/a64/macro-assembler-a64.h Thu Feb 6
14:30:18 2014 UTC
+++ /branches/experimental/a64/src/a64/macro-assembler-a64.h Thu Feb 6
16:16:30 2014 UTC
@@ -74,6 +74,7 @@
enum ArrayHasHoles { kArrayCantHaveHoles, kArrayCanHaveHoles };
enum CopyHint { kCopyUnknown, kCopyShort, kCopyLong };
enum DiscardMoveMode { kDontDiscardForSameWReg, kDiscardForSameWReg };
+enum SeqStringSetCharCheckIndexType { kIndexIsSmi, kIndexIsInteger32 };

class MacroAssembler : public Assembler {
public:
@@ -1475,7 +1476,9 @@
// Inline caching support.

void EmitSeqStringSetCharCheck(Register string,
- Register index, // Smi
+ Register index,
+ SeqStringSetCharCheckIndexType index_type,
+ Register scratch,
uint32_t encoding_mask);

// Generate code for checking access rights - used for security checks
Reply all
Reply to author
Forward
0 new messages