From: m.m.capewell@googlemail.com Date: Thu, 20 Feb 2014 10:08:04 +0000 (+0000) Subject: A64: Fix int32 use in Lithium string functions X-Git-Tag: upstream/4.7.83~10600 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a043c1d3340427de0552eb97664dda900e0ee2b;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/a64/code-stubs-a64.cc b/src/a64/code-stubs-a64.cc index da5b4ae..21bb2f8 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_); diff --git a/src/a64/codegen-a64.cc b/src/a64/codegen-a64.cc index 3f0e229..f008494 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); } diff --git a/src/a64/codegen-a64.h b/src/a64/codegen-a64.h index d66bd34..1bb9661 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, diff --git a/src/a64/lithium-codegen-a64.cc b/src/a64/lithium-codegen-a64.cc index 033a439..2052a27 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());