Reviewers: ulan, jochen,
Description:
A64: Fix int32 use in Lithium string functions
Assert register sizes in StringCharLoadGenerator, and fix char_code
comparison
in DoStringCharFromCode.
BUG=
Please review this at https://codereview.chromium.org/172483002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+13, -11 lines):
M src/a64/code-stubs-a64.cc
M src/a64/codegen-a64.h
M src/a64/codegen-a64.cc
M src/a64/lithium-codegen-a64.cc
Index: src/a64/code-stubs-a64.cc
diff --git a/src/a64/code-stubs-a64.cc b/src/a64/code-stubs-a64.cc
index
da5b4aeda39bce3921168c6bf63ca43b458397fa..21bb2f85bb722d0a9f964b01481384d1c5d07434
100644
--- a/src/a64/code-stubs-a64.cc
+++ b/src/a64/code-stubs-a64.cc
@@ -3540,7 +3540,7 @@ void
StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
StringCharLoadGenerator::Generate(masm,
object_,
- index_,
+ index_.W(),
result_,
&call_runtime_);
__ SmiTag(result_);
Index: src/a64/codegen-a64.cc
diff --git a/src/a64/codegen-a64.cc b/src/a64/codegen-a64.cc
index
3f0e2295df5c014d0f60df57883b9fc84d3568ee..365c8a2bea18a618c4b618e3051b2b7eccc2ddfa
100644
--- a/src/a64/codegen-a64.cc
+++ b/src/a64/codegen-a64.cc
@@ -410,6 +410,7 @@ void StringCharLoadGenerator::Generate(MacroAssembler*
masm,
Register index,
Register result,
Label* call_runtime) {
+ ASSERT(string.Is64Bits() && index.Is32Bits() && result.is64Bits());
// Fetch the instance type of the receiver into result register.
__ Ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
__ Ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
@@ -424,10 +425,10 @@ void
StringCharLoadGenerator::Generate(MacroAssembler* masm,
// Handle slices.
Label indirect_string_loaded;
- __ Ldrsw(result,
- UntagSmiFieldMemOperand(string, SlicedString::kOffsetOffset));
+ __ Ldr(result.W(),
+ UntagSmiFieldMemOperand(string, SlicedString::kOffsetOffset));
__ Ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
- __ Add(index, index, result);
+ __ Add(index, index, result.W());
__ B(&indirect_string_loaded);
// Handle cons strings.
@@ -479,11 +480,11 @@ void
StringCharLoadGenerator::Generate(MacroAssembler* masm,
STATIC_ASSERT(kTwoByteStringTag == 0);
__ TestAndBranchIfAnySet(result, kStringEncodingMask, &ascii);
// Two-byte string.
- __ Ldrh(result, MemOperand(string, index, LSL, 1));
+ __ Ldrh(result, MemOperand(string, index, SXTW, 1));
__ B(&done);
__ Bind(&ascii);
// Ascii string.
- __ Ldrb(result, MemOperand(string, index));
+ __ Ldrb(result, MemOperand(string, index, SXTW));
__ Bind(&done);
}
Index: src/a64/codegen-a64.h
diff --git a/src/a64/codegen-a64.h b/src/a64/codegen-a64.h
index
d66bd34a93665de8e5196047c929efa3d1576626..1bb9661f0b4b70d9e35d3a7f73186898063ac0c3
100644
--- a/src/a64/codegen-a64.h
+++ b/src/a64/codegen-a64.h
@@ -38,7 +38,8 @@ class StringCharLoadGenerator : public AllStatic {
public:
// Generates the code for handling different string types and loading the
// indexed character into |result|. We expect |index| as untagged input
and
- // |result| as untagged output.
+ // |result| as untagged output. Register index is asserted to be a
32-bit W
+ // register.
static void Generate(MacroAssembler* masm,
Register string,
Register index,
Index: src/a64/lithium-codegen-a64.cc
diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc
index
033a439513672589c0727811ac25f47fd4d984a6..2052a27c9743e5a5b238d688bae06b619a0c9d28
100644
--- a/src/a64/lithium-codegen-a64.cc
+++ b/src/a64/lithium-codegen-a64.cc
@@ -5161,7 +5161,7 @@ void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt*
instr) {
StringCharLoadGenerator::Generate(masm(),
ToRegister(instr->string()),
- ToRegister(instr->index()),
+ ToRegister32(instr->index()),
ToRegister(instr->result()),
deferred->entry());
__ Bind(deferred->exit());
@@ -5208,13 +5208,13 @@ void
LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
new(zone()) DeferredStringCharFromCode(this, instr);
ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
- Register char_code = ToRegister(instr->char_code());
+ Register char_code = ToRegister32(instr->char_code());
Register result = ToRegister(instr->result());
- __ Cmp(char_code, Operand(String::kMaxOneByteCharCode));
+ __ Cmp(char_code, String::kMaxOneByteCharCode);
__ B(hi, deferred->entry());
__ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex);
- __ Add(result, result, Operand(char_code, LSL, kPointerSizeLog2));
+ __ Add(result, result, Operand(char_code, SXTW, kPointerSizeLog2));
__ Ldr(result, FieldMemOperand(result, FixedArray::kHeaderSize));
__ CompareRoot(result, Heap::kUndefinedValueRootIndex);
__ B(eq, deferred->entry());
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.