Commit b06c0414 authored by yangguo@chromium.org's avatar yangguo@chromium.org

MIPS: Fixed several bugs in SubStringStub::Generate.

A combination of bugs caused this function to almost always jump to runtime
which is why most tests passed.

BUG=
TEST=sputnik/S15.5.4.13_A2_T6

Review URL: https://chromiumcodereview.appspot.com/9382005
Patch from Daniel Kalmar <kalmard@homejinni.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10678 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7c695dcf
......@@ -6061,25 +6061,23 @@ void SubStringStub::Generate(MacroAssembler* masm) {
// Utilize delay slots. SmiUntag doesn't emit a jump, everything else is
// safe in this case.
__ UntagAndJumpIfSmi(a2, a2, &runtime);
__ UntagAndJumpIfSmi(a3, a3, &runtime);
__ UntagAndJumpIfNotSmi(a2, a2, &runtime);
__ UntagAndJumpIfNotSmi(a3, a3, &runtime);
// Both a2 and a3 are untagged integers.
__ Branch(&runtime, lt, a3, Operand(zero_reg)); // From < 0.
__ subu(a2, t5, a3);
__ Branch(&runtime, gt, a3, Operand(t5)); // Fail if from > to.
__ Branch(&runtime, gt, a3, Operand(a2)); // Fail if from > to.
__ Subu(a2, a2, a3);
// Make sure first argument is a string.
__ lw(v0, MemOperand(sp, kStringOffset));
__ Branch(&runtime, eq, v0, Operand(kSmiTagMask));
__ JumpIfSmi(v0, &runtime);
__ lw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ lbu(a1, FieldMemOperand(a1, Map::kInstanceTypeOffset));
__ And(t4, v0, Operand(kIsNotStringMask));
__ And(t0, a1, Operand(kIsNotStringMask));
__ Branch(&runtime, ne, t4, Operand(zero_reg));
__ Branch(&runtime, ne, t0, Operand(zero_reg));
// Short-cut for the case of trivial substring.
Label return_v0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment