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

Unified Diff: src/builtins/x87/builtins-x87.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/x64/builtins-x64.cc ('k') | src/compiler/code-assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/x87/builtins-x87.cc
diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc
index 0678d87f8f0317e52a37fec7924e5685e376df74..a0fe445ba5ef21f84d52101f1d2950edfce4596d 100644
--- a/src/builtins/x87/builtins-x87.cc
+++ b/src/builtins/x87/builtins-x87.cc
@@ -1686,141 +1686,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;
- const int reg_sel = (kind == MathMaxMinKind::kMin) ? 1 : 0;
-
- // Load the accumulator with the default return value (either -Infinity or
- // +Infinity), with the tagged value in edx and the double value in stx_0.
- __ LoadRoot(edx, root_index);
- __ fld_d(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 stx_1, 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 (stX_0).
- Label restore_smi, done_restore;
- __ JumpIfSmi(edx, &restore_smi, Label::kNear);
- __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset));
- __ jmp(&done_restore, Label::kNear);
- __ bind(&restore_smi);
- __ SmiUntag(edx);
- __ push(edx);
- __ fild_s(Operand(esp, 0));
- __ pop(edx);
- __ SmiTag(edx);
- __ bind(&done_restore);
- }
- }
- __ jmp(&convert);
- __ bind(&convert_number);
- // Load another value into stx_1
- __ fld_d(FieldOperand(ebx, HeapNumber::kValueOffset));
- __ fxch();
- __ jmp(&done_convert, Label::kNear);
- __ bind(&convert_smi);
- __ SmiUntag(ebx);
- __ push(ebx);
- __ fild_s(Operand(esp, 0));
- __ pop(ebx);
- __ fxch();
- __ SmiTag(ebx);
- __ bind(&done_convert);
-
- // Perform the actual comparison with the accumulator value on the left hand
- // side (stx_0) and the next parameter value on the right hand side (stx_1).
- Label compare_equal, compare_nan, compare_swap, done_compare;
-
- // Duplicates the 2 float data for FCmp
- __ fld(1);
- __ fld(1);
- __ FCmp();
- __ 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(stx_0).
- __ bind(&compare_swap);
- __ fxch();
- __ 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);
- // Set the result on the right hand side (stx_0) to nan
- __ fstp(0);
- __ LoadRoot(edx, Heap::kNanValueRootIndex);
- __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset));
- __ jmp(&done_compare, Label::kNear);
-
- // Left and right hand side are equal, check for -0 vs. +0.
- __ bind(&compare_equal);
- // Check the sign of the value in reg_sel
- __ fld(reg_sel);
- __ FXamSign();
- __ j(not_zero, &compare_swap);
-
- __ bind(&done_compare);
- // The right result is on the right hand side(stx_0)
- // and can remove the useless stx_1 now.
- __ fxch();
- __ fstp(0);
- __ 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/x64/builtins-x64.cc ('k') | src/compiler/code-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698