Index: src/arm64/builtins-arm64.cc |
diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc |
index c76cbffbdc67589049861c29942b1e29a5bd9350..4ee3e082c3702a1d8231aa0d175f3db86c76162f 100644 |
--- a/src/arm64/builtins-arm64.cc |
+++ b/src/arm64/builtins-arm64.cc |
@@ -141,6 +141,8 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
// ----------- S t a t e ------------- |
// -- x0 : number of arguments |
+ // -- x1 : function |
+ // -- cp : context |
// -- lr : return address |
// -- sp[(argc - n) * 8] : arg[n] (zero-based) |
// -- sp[(argc + 1) * 8] : receiver |
@@ -152,22 +154,22 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
: Heap::kMinusInfinityValueRootIndex; |
// Load the accumulator with the default return value (either -Infinity or |
- // +Infinity), with the tagged value in x1 and the double value in d1. |
- __ LoadRoot(x1, root_index); |
- __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); |
+ // +Infinity), with the tagged value in x5 and the double value in d5. |
+ __ LoadRoot(x5, root_index); |
+ __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); |
// Remember how many slots to drop (including the receiver). |
- __ Add(x4, x0, 1); |
+ __ Mov(x4, x0); |
Label done_loop, loop; |
__ Bind(&loop); |
{ |
// Check if all parameters done. |
- __ Subs(x0, x0, 1); |
+ __ Subs(x4, x4, 1); |
__ B(lt, &done_loop); |
// Load the next parameter tagged value into x2. |
- __ Peek(x2, Operand(x0, LSL, kPointerSizeLog2)); |
+ __ Peek(x2, Operand(x4, LSL, kPointerSizeLog2)); |
// Load the double value of the parameter into d2, maybe converting the |
// parameter to a number first using the ToNumberStub if necessary. |
@@ -176,25 +178,29 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
__ JumpIfHeapNumber(x2, &convert_number); |
{ |
// Parameter is not a Number, use the ToNumberStub to convert it. |
- FrameScope scope(masm, StackFrame::INTERNAL); |
+ FrameScope scope(masm, StackFrame::MANUAL); |
+ __ Push(lr, fp); |
+ __ Move(fp, jssp); |
+ __ Push(cp, x1); |
__ SmiTag(x0); |
__ SmiTag(x4); |
- __ Push(x0, x1, x4); |
+ __ Push(x0, x5, x4); |
__ Mov(x0, x2); |
ToNumberStub stub(masm->isolate()); |
__ CallStub(&stub); |
__ Mov(x2, x0); |
- __ Pop(x4, x1, x0); |
+ __ Pop(x4, x5, x0); |
{ |
- // Restore the double accumulator value (d1). |
+ // Restore the double accumulator value (d5). |
Label done_restore; |
- __ SmiUntagToDouble(d1, x1, kSpeculativeUntag); |
- __ JumpIfSmi(x1, &done_restore); |
- __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); |
+ __ SmiUntagToDouble(d5, x5, kSpeculativeUntag); |
+ __ JumpIfSmi(x5, &done_restore); |
+ __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); |
__ Bind(&done_restore); |
} |
__ SmiUntag(x4); |
__ SmiUntag(x0); |
+ __ Pop(x1, cp, fp, lr); |
} |
__ AssertNumber(x2); |
__ JumpIfSmi(x2, &convert_smi); |
@@ -209,22 +215,23 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
// We can use a single fmin/fmax for the operation itself, but we then need |
// to work out which HeapNumber (or smi) the result came from. |
- __ Fmov(x11, d1); |
+ __ Fmov(x11, d5); |
if (kind == MathMaxMinKind::kMin) { |
- __ Fmin(d1, d1, d2); |
+ __ Fmin(d5, d5, d2); |
} else { |
DCHECK(kind == MathMaxMinKind::kMax); |
- __ Fmax(d1, d1, d2); |
+ __ Fmax(d5, d5, d2); |
} |
- __ Fmov(x10, d1); |
+ __ Fmov(x10, d5); |
__ Cmp(x10, x11); |
- __ Csel(x1, x1, x2, eq); |
+ __ Csel(x5, x5, x2, eq); |
__ B(&loop); |
} |
__ Bind(&done_loop); |
- __ Mov(x0, x1); |
__ Drop(x4); |
+ __ Drop(1); |
+ __ Mov(x0, x5); |
__ Ret(); |
} |