Reviewers: Søren Gjesse, Description: ARM: Implement StringCharAtStub.
Please review this at http://codereview.chromium.org/6334007/ SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/arm/code-stubs-arm.cc M src/arm/lithium-codegen-arm.cc Index: src/arm/code-stubs-arm.cc =================================================================== --- src/arm/code-stubs-arm.cc (revision 6378) +++ src/arm/code-stubs-arm.cc (working copy) @@ -3703,7 +3703,6 @@ // StringCharCodeAtGenerator - void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { Label flat_string; Label ascii_string; @@ -4862,6 +4861,56 @@ } +void StringCharAtStub::Generate(MacroAssembler* masm) { + // Expects two arguments (object, index) on the stack: + // lr: return address + // sp[0]: index + // sp[4]: object + Register object = r1; + Register index = r0; + Register scratch1 = r2; + Register scratch2 = r3; + Register result = r0; + + // Get object and index from the stack. + __ pop(index); + __ pop(object); + + Label need_conversion; + Label index_out_of_range; + Label done; + StringCharAtGenerator generator(object, + index, + scratch1, + scratch2, + result, + &need_conversion, + &need_conversion, + &index_out_of_range, + STRING_INDEX_IS_NUMBER); + generator.GenerateFast(masm); + __ b(&done); + + __ bind(&index_out_of_range); + // When the index is out of range, the spec requires us to return + // the empty string. + __ LoadRoot(result, Heap::kEmptyStringRootIndex); + __ jmp(&done); + + __ bind(&need_conversion); + // Move smi zero into the result register, which will trigger + // conversion. + __ mov(result, Operand(Smi::FromInt(0))); + __ jmp(&done); + + StubRuntimeCallHelper call_helper; + generator.GenerateSlow(masm, call_helper); + + __ bind(&done); + __ Ret(); +} + + void ICCompareStub::GenerateSmis(MacroAssembler* masm) { ASSERT(state_ == CompareIC::SMIS); Label miss; Index: src/arm/lithium-codegen-arm.cc =================================================================== --- src/arm/lithium-codegen-arm.cc (revision 6378) +++ src/arm/lithium-codegen-arm.cc (working copy) @@ -964,7 +964,8 @@ break; } case CodeStub::StringCharAt: { - Abort("StringCharAtStub unimplemented."); + StringCharAtStub stub; + CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); break; } case CodeStub::MathPow: { -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
