OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 __ mov(ebx, masm->isolate()->factory()->undefined_value()); | 1563 __ mov(ebx, masm->isolate()->factory()->undefined_value()); |
1564 ArrayConstructorStub stub(masm->isolate()); | 1564 ArrayConstructorStub stub(masm->isolate()); |
1565 __ TailCallStub(&stub); | 1565 __ TailCallStub(&stub); |
1566 } | 1566 } |
1567 | 1567 |
1568 | 1568 |
1569 // static | 1569 // static |
1570 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 1570 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
1571 // ----------- S t a t e ------------- | 1571 // ----------- S t a t e ------------- |
1572 // -- eax : number of arguments | 1572 // -- eax : number of arguments |
| 1573 // -- edi : function |
| 1574 // -- esi : context |
1573 // -- esp[0] : return address | 1575 // -- esp[0] : return address |
1574 // -- esp[(argc - n) * 8] : arg[n] (zero-based) | 1576 // -- esp[(argc - n) * 8] : arg[n] (zero-based) |
1575 // -- esp[(argc + 1) * 8] : receiver | 1577 // -- esp[(argc + 1) * 8] : receiver |
1576 // ----------------------------------- | 1578 // ----------------------------------- |
1577 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; | 1579 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; |
1578 Heap::RootListIndex const root_index = | 1580 Heap::RootListIndex const root_index = |
1579 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 1581 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
1580 : Heap::kMinusInfinityValueRootIndex; | 1582 : Heap::kMinusInfinityValueRootIndex; |
1581 const int reg_sel = (kind == MathMaxMinKind::kMin) ? 1 : 0; | 1583 const int reg_sel = (kind == MathMaxMinKind::kMin) ? 1 : 0; |
1582 | 1584 |
(...skipping 15 matching lines...) Expand all Loading... |
1598 | 1600 |
1599 // Load the double value of the parameter into stx_1, maybe converting the | 1601 // Load the double value of the parameter into stx_1, maybe converting the |
1600 // parameter to a number first using the ToNumber builtin if necessary. | 1602 // parameter to a number first using the ToNumber builtin if necessary. |
1601 Label convert, convert_smi, convert_number, done_convert; | 1603 Label convert, convert_smi, convert_number, done_convert; |
1602 __ bind(&convert); | 1604 __ bind(&convert); |
1603 __ JumpIfSmi(ebx, &convert_smi); | 1605 __ JumpIfSmi(ebx, &convert_smi); |
1604 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), | 1606 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), |
1605 Heap::kHeapNumberMapRootIndex, &convert_number); | 1607 Heap::kHeapNumberMapRootIndex, &convert_number); |
1606 { | 1608 { |
1607 // Parameter is not a Number, use the ToNumber builtin to convert it. | 1609 // Parameter is not a Number, use the ToNumber builtin to convert it. |
1608 FrameScope scope(masm, StackFrame::INTERNAL); | 1610 FrameScope scope(masm, StackFrame::MANUAL); |
| 1611 __ Push(ebp); |
| 1612 __ Move(ebp, esp); |
| 1613 __ Push(esi); |
| 1614 __ Push(edi); |
1609 __ SmiTag(eax); | 1615 __ SmiTag(eax); |
1610 __ SmiTag(ecx); | 1616 __ SmiTag(ecx); |
1611 __ Push(eax); | 1617 __ Push(eax); |
1612 __ Push(ecx); | 1618 __ Push(ecx); |
1613 __ Push(edx); | 1619 __ Push(edx); |
1614 __ mov(eax, ebx); | 1620 __ mov(eax, ebx); |
1615 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | 1621 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1616 __ mov(ebx, eax); | 1622 __ mov(ebx, eax); |
1617 __ Pop(edx); | 1623 __ Pop(edx); |
1618 __ Pop(ecx); | 1624 __ Pop(ecx); |
1619 __ Pop(eax); | 1625 __ Pop(eax); |
| 1626 __ Pop(edi); |
| 1627 __ Pop(esi); |
1620 { | 1628 { |
1621 // Restore the double accumulator value (stX_0). | 1629 // Restore the double accumulator value (stX_0). |
1622 Label restore_smi, done_restore; | 1630 Label restore_smi, done_restore; |
1623 __ JumpIfSmi(edx, &restore_smi, Label::kNear); | 1631 __ JumpIfSmi(edx, &restore_smi, Label::kNear); |
1624 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); | 1632 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); |
1625 __ jmp(&done_restore, Label::kNear); | 1633 __ jmp(&done_restore, Label::kNear); |
1626 __ bind(&restore_smi); | 1634 __ bind(&restore_smi); |
1627 __ SmiUntag(edx); | 1635 __ SmiUntag(edx); |
1628 __ push(edx); | 1636 __ push(edx); |
1629 __ fild_s(Operand(esp, 0)); | 1637 __ fild_s(Operand(esp, 0)); |
1630 __ pop(edx); | 1638 __ pop(edx); |
1631 __ SmiTag(edx); | 1639 __ SmiTag(edx); |
1632 __ bind(&done_restore); | 1640 __ bind(&done_restore); |
1633 } | 1641 } |
1634 __ SmiUntag(ecx); | 1642 __ SmiUntag(ecx); |
1635 __ SmiUntag(eax); | 1643 __ SmiUntag(eax); |
| 1644 __ leave(); |
1636 } | 1645 } |
1637 __ jmp(&convert); | 1646 __ jmp(&convert); |
1638 __ bind(&convert_number); | 1647 __ bind(&convert_number); |
1639 // Load another value into stx_1 | 1648 // Load another value into stx_1 |
1640 __ fld_d(FieldOperand(ebx, HeapNumber::kValueOffset)); | 1649 __ fld_d(FieldOperand(ebx, HeapNumber::kValueOffset)); |
1641 __ fxch(); | 1650 __ fxch(); |
1642 __ jmp(&done_convert, Label::kNear); | 1651 __ jmp(&done_convert, Label::kNear); |
1643 __ bind(&convert_smi); | 1652 __ bind(&convert_smi); |
1644 __ SmiUntag(ebx); | 1653 __ SmiUntag(ebx); |
1645 __ push(ebx); | 1654 __ push(ebx); |
(...skipping 1344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2990 // And "return" to the OSR entry point of the function. | 2999 // And "return" to the OSR entry point of the function. |
2991 __ ret(0); | 3000 __ ret(0); |
2992 } | 3001 } |
2993 | 3002 |
2994 | 3003 |
2995 #undef __ | 3004 #undef __ |
2996 } // namespace internal | 3005 } // namespace internal |
2997 } // namespace v8 | 3006 } // namespace v8 |
2998 | 3007 |
2999 #endif // V8_TARGET_ARCH_X87 | 3008 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |