A64: Fix int32 use in Lithium string functions

Assert register sizes in StringCharLoadGenerator, and fix char_code comparison
in DoStringCharFromCode.

BUG=
R=jochen@chromium.org

Review URL: https://codereview.chromium.org/172483002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19503 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
m.m.capewell@googlemail.com 2014-02-20 10:08:04 +00:00
parent 672bc20af8
commit 6a043c1d33
4 changed files with 13 additions and 11 deletions

View File

@ -3540,7 +3540,7 @@ void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
StringCharLoadGenerator::Generate(masm,
object_,
index_,
index_.W(),
result_,
&call_runtime_);
__ SmiTag(result_);

View File

@ -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);
}

View File

@ -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,

View File

@ -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());