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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 __ mov(ebx, masm->isolate()->factory()->undefined_value()); | 1562 __ mov(ebx, masm->isolate()->factory()->undefined_value()); |
1563 ArrayConstructorStub stub(masm->isolate()); | 1563 ArrayConstructorStub stub(masm->isolate()); |
1564 __ TailCallStub(&stub); | 1564 __ TailCallStub(&stub); |
1565 } | 1565 } |
1566 | 1566 |
1567 | 1567 |
1568 // static | 1568 // static |
1569 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 1569 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
1570 // ----------- S t a t e ------------- | 1570 // ----------- S t a t e ------------- |
1571 // -- eax : number of arguments | 1571 // -- eax : number of arguments |
| 1572 // -- edi : function |
| 1573 // -- esi : context |
1572 // -- esp[0] : return address | 1574 // -- esp[0] : return address |
1573 // -- esp[(argc - n) * 8] : arg[n] (zero-based) | 1575 // -- esp[(argc - n) * 8] : arg[n] (zero-based) |
1574 // -- esp[(argc + 1) * 8] : receiver | 1576 // -- esp[(argc + 1) * 8] : receiver |
1575 // ----------------------------------- | 1577 // ----------------------------------- |
1576 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; | 1578 Condition const cc = (kind == MathMaxMinKind::kMin) ? below : above; |
1577 Heap::RootListIndex const root_index = | 1579 Heap::RootListIndex const root_index = |
1578 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 1580 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
1579 : Heap::kMinusInfinityValueRootIndex; | 1581 : Heap::kMinusInfinityValueRootIndex; |
1580 XMMRegister const reg = (kind == MathMaxMinKind::kMin) ? xmm1 : xmm0; | 1582 XMMRegister const reg = (kind == MathMaxMinKind::kMin) ? xmm1 : xmm0; |
1581 | 1583 |
(...skipping 15 matching lines...) Expand all Loading... |
1597 | 1599 |
1598 // Load the double value of the parameter into xmm1, maybe converting the | 1600 // Load the double value of the parameter into xmm1, maybe converting the |
1599 // parameter to a number first using the ToNumber builtin if necessary. | 1601 // parameter to a number first using the ToNumber builtin if necessary. |
1600 Label convert, convert_smi, convert_number, done_convert; | 1602 Label convert, convert_smi, convert_number, done_convert; |
1601 __ bind(&convert); | 1603 __ bind(&convert); |
1602 __ JumpIfSmi(ebx, &convert_smi); | 1604 __ JumpIfSmi(ebx, &convert_smi); |
1603 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), | 1605 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), |
1604 Heap::kHeapNumberMapRootIndex, &convert_number); | 1606 Heap::kHeapNumberMapRootIndex, &convert_number); |
1605 { | 1607 { |
1606 // Parameter is not a Number, use the ToNumber builtin to convert it. | 1608 // Parameter is not a Number, use the ToNumber builtin to convert it. |
1607 FrameScope scope(masm, StackFrame::INTERNAL); | 1609 FrameScope scope(masm, StackFrame::MANUAL); |
| 1610 __ Push(ebp); |
| 1611 __ Move(ebp, esp); |
| 1612 __ Push(esi); |
| 1613 __ Push(edi); |
1608 __ SmiTag(eax); | 1614 __ SmiTag(eax); |
1609 __ SmiTag(ecx); | 1615 __ SmiTag(ecx); |
1610 __ Push(eax); | 1616 __ Push(eax); |
1611 __ Push(ecx); | 1617 __ Push(ecx); |
1612 __ Push(edx); | 1618 __ Push(edx); |
1613 __ mov(eax, ebx); | 1619 __ mov(eax, ebx); |
1614 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | 1620 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1615 __ mov(ebx, eax); | 1621 __ mov(ebx, eax); |
1616 __ Pop(edx); | 1622 __ Pop(edx); |
1617 __ Pop(ecx); | 1623 __ Pop(ecx); |
1618 __ Pop(eax); | 1624 __ Pop(eax); |
| 1625 __ Pop(edi); |
| 1626 __ Pop(esi); |
1619 { | 1627 { |
1620 // Restore the double accumulator value (xmm0). | 1628 // Restore the double accumulator value (xmm0). |
1621 Label restore_smi, done_restore; | 1629 Label restore_smi, done_restore; |
1622 __ JumpIfSmi(edx, &restore_smi, Label::kNear); | 1630 __ JumpIfSmi(edx, &restore_smi, Label::kNear); |
1623 __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); | 1631 __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); |
1624 __ jmp(&done_restore, Label::kNear); | 1632 __ jmp(&done_restore, Label::kNear); |
1625 __ bind(&restore_smi); | 1633 __ bind(&restore_smi); |
1626 __ SmiUntag(edx); | 1634 __ SmiUntag(edx); |
1627 __ Cvtsi2sd(xmm0, edx); | 1635 __ Cvtsi2sd(xmm0, edx); |
1628 __ SmiTag(edx); | 1636 __ SmiTag(edx); |
1629 __ bind(&done_restore); | 1637 __ bind(&done_restore); |
1630 } | 1638 } |
1631 __ SmiUntag(ecx); | 1639 __ SmiUntag(ecx); |
1632 __ SmiUntag(eax); | 1640 __ SmiUntag(eax); |
| 1641 __ leave(); |
1633 } | 1642 } |
1634 __ jmp(&convert); | 1643 __ jmp(&convert); |
1635 __ bind(&convert_number); | 1644 __ bind(&convert_number); |
1636 __ movsd(xmm1, FieldOperand(ebx, HeapNumber::kValueOffset)); | 1645 __ movsd(xmm1, FieldOperand(ebx, HeapNumber::kValueOffset)); |
1637 __ jmp(&done_convert, Label::kNear); | 1646 __ jmp(&done_convert, Label::kNear); |
1638 __ bind(&convert_smi); | 1647 __ bind(&convert_smi); |
1639 __ SmiUntag(ebx); | 1648 __ SmiUntag(ebx); |
1640 __ Cvtsi2sd(xmm1, ebx); | 1649 __ Cvtsi2sd(xmm1, ebx); |
1641 __ SmiTag(ebx); | 1650 __ SmiTag(ebx); |
1642 __ bind(&done_convert); | 1651 __ bind(&done_convert); |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 // And "return" to the OSR entry point of the function. | 2972 // And "return" to the OSR entry point of the function. |
2964 __ ret(0); | 2973 __ ret(0); |
2965 } | 2974 } |
2966 | 2975 |
2967 | 2976 |
2968 #undef __ | 2977 #undef __ |
2969 } // namespace internal | 2978 } // namespace internal |
2970 } // namespace v8 | 2979 } // namespace v8 |
2971 | 2980 |
2972 #endif // V8_TARGET_ARCH_IA32 | 2981 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |