Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: src/builtins/ia32/builtins-ia32.cc

Issue 2728463006: Migrate Math.Min/Max to CodeStubAssembler (Closed)
Patch Set: ChangeFloat64ToTagged Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/builtins-math.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/ia32/builtins-ia32.cc
diff --git a/src/builtins/ia32/builtins-ia32.cc b/src/builtins/ia32/builtins-ia32.cc
index c074dd88eadbbf675bc740e3a71591dffc9df728..ed736ca904430d1fef52a73e7d9f59102f68c97d 100644
--- a/src/builtins/ia32/builtins-ia32.cc
+++ b/src/builtins/ia32/builtins-ia32.cc
@@ -1719,125 +1719,6 @@ void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
}
// static
-void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
- // ----------- S t a t e -------------
- // -- eax : number of arguments
- // -- edi : function
- // -- esi : context
- // -- esp[0] : return address
- // -- esp[(argc - n) * 8] : arg[n] (zero-based)
- // -- esp[(argc + 1) * 8] : receiver
- // -----------------------------------
- Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above;
- Heap::RootListIndex const root_index =
- (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
- : Heap::kMinusInfinityValueRootIndex;
- XMMRegister const reg = (kind == MathMaxMinKind::kMin) ? xmm1 : xmm0;
-
- // Load the accumulator with the default return value (either -Infinity or
- // +Infinity), with the tagged value in edx and the double value in xmm0.
- __ LoadRoot(edx, root_index);
- __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
- __ Move(ecx, eax);
-
- Label done_loop, loop;
- __ bind(&loop);
- {
- // Check if all parameters done.
- __ test(ecx, ecx);
- __ j(zero, &done_loop);
-
- // Load the next parameter tagged value into ebx.
- __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0));
-
- // Load the double value of the parameter into xmm1, maybe converting the
- // parameter to a number first using the ToNumber builtin if necessary.
- Label convert, convert_smi, convert_number, done_convert;
- __ bind(&convert);
- __ JumpIfSmi(ebx, &convert_smi);
- __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset),
- Heap::kHeapNumberMapRootIndex, &convert_number);
- {
- // Parameter is not a Number, use the ToNumber builtin to convert it.
- FrameScope scope(masm, StackFrame::MANUAL);
- __ SmiTag(eax);
- __ SmiTag(ecx);
- __ EnterBuiltinFrame(esi, edi, eax);
- __ Push(ecx);
- __ Push(edx);
- __ mov(eax, ebx);
- __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
- __ mov(ebx, eax);
- __ Pop(edx);
- __ Pop(ecx);
- __ LeaveBuiltinFrame(esi, edi, eax);
- __ SmiUntag(ecx);
- __ SmiUntag(eax);
- {
- // Restore the double accumulator value (xmm0).
- Label restore_smi, done_restore;
- __ JumpIfSmi(edx, &restore_smi, Label::kNear);
- __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
- __ jmp(&done_restore, Label::kNear);
- __ bind(&restore_smi);
- __ SmiUntag(edx);
- __ Cvtsi2sd(xmm0, edx);
- __ SmiTag(edx);
- __ bind(&done_restore);
- }
- }
- __ jmp(&convert);
- __ bind(&convert_number);
- __ movsd(xmm1, FieldOperand(ebx, HeapNumber::kValueOffset));
- __ jmp(&done_convert, Label::kNear);
- __ bind(&convert_smi);
- __ SmiUntag(ebx);
- __ Cvtsi2sd(xmm1, ebx);
- __ SmiTag(ebx);
- __ bind(&done_convert);
-
- // Perform the actual comparison with the accumulator value on the left hand
- // side (xmm0) and the next parameter value on the right hand side (xmm1).
- Label compare_equal, compare_nan, compare_swap, done_compare;
- __ ucomisd(xmm0, xmm1);
- __ j(parity_even, &compare_nan, Label::kNear);
- __ j(cc, &done_compare, Label::kNear);
- __ j(equal, &compare_equal, Label::kNear);
-
- // Result is on the right hand side.
- __ bind(&compare_swap);
- __ movaps(xmm0, xmm1);
- __ mov(edx, ebx);
- __ jmp(&done_compare, Label::kNear);
-
- // At least one side is NaN, which means that the result will be NaN too.
- __ bind(&compare_nan);
- __ LoadRoot(edx, Heap::kNanValueRootIndex);
- __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
- __ jmp(&done_compare, Label::kNear);
-
- // Left and right hand side are equal, check for -0 vs. +0.
- __ bind(&compare_equal);
- __ Push(edi); // Preserve function in edi.
- __ movmskpd(edi, reg);
- __ test(edi, Immediate(1));
- __ Pop(edi);
- __ j(not_zero, &compare_swap);
-
- __ bind(&done_compare);
- __ dec(ecx);
- __ jmp(&loop);
- }
-
- __ bind(&done_loop);
- __ PopReturnAddressTo(ecx);
- __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
- __ PushReturnAddressFrom(ecx);
- __ mov(eax, edx);
- __ Ret();
-}
-
-// static
void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- eax : number of arguments
« no previous file with comments | « src/builtins/builtins-math.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698