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 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 __ bind(&loop); | 1572 __ bind(&loop); |
1573 { | 1573 { |
1574 // Check if all parameters done. | 1574 // Check if all parameters done. |
1575 __ test(ecx, ecx); | 1575 __ test(ecx, ecx); |
1576 __ j(zero, &done_loop); | 1576 __ j(zero, &done_loop); |
1577 | 1577 |
1578 // Load the next parameter tagged value into ebx. | 1578 // Load the next parameter tagged value into ebx. |
1579 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); | 1579 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); |
1580 | 1580 |
1581 // Load the double value of the parameter into stx_1, maybe converting the | 1581 // Load the double value of the parameter into stx_1, maybe converting the |
1582 // parameter to a number first using the ToNumberStub if necessary. | 1582 // parameter to a number first using the ToNumber builtin if necessary. |
1583 Label convert, convert_smi, convert_number, done_convert; | 1583 Label convert, convert_smi, convert_number, done_convert; |
1584 __ bind(&convert); | 1584 __ bind(&convert); |
1585 __ JumpIfSmi(ebx, &convert_smi); | 1585 __ JumpIfSmi(ebx, &convert_smi); |
1586 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), | 1586 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), |
1587 Heap::kHeapNumberMapRootIndex, &convert_number); | 1587 Heap::kHeapNumberMapRootIndex, &convert_number); |
1588 { | 1588 { |
1589 // Parameter is not a Number, use the ToNumberStub to convert it. | 1589 // Parameter is not a Number, use the ToNumber builtin to convert it. |
1590 FrameScope scope(masm, StackFrame::INTERNAL); | 1590 FrameScope scope(masm, StackFrame::INTERNAL); |
1591 __ SmiTag(eax); | 1591 __ SmiTag(eax); |
1592 __ SmiTag(ecx); | 1592 __ SmiTag(ecx); |
1593 __ Push(eax); | 1593 __ Push(eax); |
1594 __ Push(ecx); | 1594 __ Push(ecx); |
1595 __ Push(edx); | 1595 __ Push(edx); |
1596 __ mov(eax, ebx); | 1596 __ mov(eax, ebx); |
1597 ToNumberStub stub(masm->isolate()); | 1597 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1598 __ CallStub(&stub); | |
1599 __ mov(ebx, eax); | 1598 __ mov(ebx, eax); |
1600 __ Pop(edx); | 1599 __ Pop(edx); |
1601 __ Pop(ecx); | 1600 __ Pop(ecx); |
1602 __ Pop(eax); | 1601 __ Pop(eax); |
1603 { | 1602 { |
1604 // Restore the double accumulator value (stX_0). | 1603 // Restore the double accumulator value (stX_0). |
1605 Label restore_smi, done_restore; | 1604 Label restore_smi, done_restore; |
1606 __ JumpIfSmi(edx, &restore_smi, Label::kNear); | 1605 __ JumpIfSmi(edx, &restore_smi, Label::kNear); |
1607 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); | 1606 __ fld_d(FieldOperand(edx, HeapNumber::kValueOffset)); |
1608 __ jmp(&done_restore, Label::kNear); | 1607 __ jmp(&done_restore, Label::kNear); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 __ test(eax, eax); | 1698 __ test(eax, eax); |
1700 __ j(zero, &no_arguments, Label::kNear); | 1699 __ j(zero, &no_arguments, Label::kNear); |
1701 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); | 1700 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); |
1702 __ PopReturnAddressTo(ecx); | 1701 __ PopReturnAddressTo(ecx); |
1703 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); | 1702 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); |
1704 __ PushReturnAddressFrom(ecx); | 1703 __ PushReturnAddressFrom(ecx); |
1705 __ mov(eax, ebx); | 1704 __ mov(eax, ebx); |
1706 } | 1705 } |
1707 | 1706 |
1708 // 2a. Convert the first argument to a number. | 1707 // 2a. Convert the first argument to a number. |
1709 ToNumberStub stub(masm->isolate()); | 1708 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1710 __ TailCallStub(&stub); | |
1711 | 1709 |
1712 // 2b. No arguments, return +0 (already in eax). | 1710 // 2b. No arguments, return +0 (already in eax). |
1713 __ bind(&no_arguments); | 1711 __ bind(&no_arguments); |
1714 __ ret(1 * kPointerSize); | 1712 __ ret(1 * kPointerSize); |
1715 } | 1713 } |
1716 | 1714 |
1717 | 1715 |
1718 // static | 1716 // static |
1719 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 1717 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
1720 // ----------- S t a t e ------------- | 1718 // ----------- S t a t e ------------- |
(...skipping 29 matching lines...) Expand all Loading... |
1750 Label done_convert; | 1748 Label done_convert; |
1751 __ JumpIfSmi(ebx, &done_convert); | 1749 __ JumpIfSmi(ebx, &done_convert); |
1752 __ CompareRoot(FieldOperand(ebx, HeapObject::kMapOffset), | 1750 __ CompareRoot(FieldOperand(ebx, HeapObject::kMapOffset), |
1753 Heap::kHeapNumberMapRootIndex); | 1751 Heap::kHeapNumberMapRootIndex); |
1754 __ j(equal, &done_convert); | 1752 __ j(equal, &done_convert); |
1755 { | 1753 { |
1756 FrameScope scope(masm, StackFrame::INTERNAL); | 1754 FrameScope scope(masm, StackFrame::INTERNAL); |
1757 __ Push(edi); | 1755 __ Push(edi); |
1758 __ Push(edx); | 1756 __ Push(edx); |
1759 __ Move(eax, ebx); | 1757 __ Move(eax, ebx); |
1760 ToNumberStub stub(masm->isolate()); | 1758 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
1761 __ CallStub(&stub); | |
1762 __ Move(ebx, eax); | 1759 __ Move(ebx, eax); |
1763 __ Pop(edx); | 1760 __ Pop(edx); |
1764 __ Pop(edi); | 1761 __ Pop(edi); |
1765 } | 1762 } |
1766 __ bind(&done_convert); | 1763 __ bind(&done_convert); |
1767 } | 1764 } |
1768 | 1765 |
1769 // 4. Check if new target and constructor differ. | 1766 // 4. Check if new target and constructor differ. |
1770 Label new_object; | 1767 Label new_object; |
1771 __ cmp(edx, edi); | 1768 __ cmp(edx, edi); |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2671 __ IndexFromHash(eax, eax); | 2668 __ IndexFromHash(eax, eax); |
2672 __ Ret(); | 2669 __ Ret(); |
2673 | 2670 |
2674 __ bind(&runtime); | 2671 __ bind(&runtime); |
2675 __ PopReturnAddressTo(ecx); // Pop return address. | 2672 __ PopReturnAddressTo(ecx); // Pop return address. |
2676 __ Push(eax); // Push argument. | 2673 __ Push(eax); // Push argument. |
2677 __ PushReturnAddressFrom(ecx); // Push return address. | 2674 __ PushReturnAddressFrom(ecx); // Push return address. |
2678 __ TailCallRuntime(Runtime::kStringToNumber); | 2675 __ TailCallRuntime(Runtime::kStringToNumber); |
2679 } | 2676 } |
2680 | 2677 |
| 2678 // static |
| 2679 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
| 2680 // The ToNumber stub takes one argument in eax. |
| 2681 Label not_smi; |
| 2682 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
| 2683 __ Ret(); |
| 2684 __ bind(¬_smi); |
| 2685 |
| 2686 Label not_heap_number; |
| 2687 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); |
| 2688 __ j(not_equal, ¬_heap_number, Label::kNear); |
| 2689 __ Ret(); |
| 2690 __ bind(¬_heap_number); |
| 2691 |
| 2692 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(), |
| 2693 RelocInfo::CODE_TARGET); |
| 2694 } |
| 2695 |
| 2696 // static |
| 2697 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) { |
| 2698 // The NonNumberToNumber stub takes one argument in eax. |
| 2699 __ AssertNotNumber(eax); |
| 2700 |
| 2701 Label not_string; |
| 2702 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
| 2703 // eax: object |
| 2704 // edi: object map |
| 2705 __ j(above_equal, ¬_string, Label::kNear); |
| 2706 __ Jump(masm->isolate()->builtins()->StringToNumber(), |
| 2707 RelocInfo::CODE_TARGET); |
| 2708 __ bind(¬_string); |
| 2709 |
| 2710 Label not_oddball; |
| 2711 __ CmpInstanceType(edi, ODDBALL_TYPE); |
| 2712 __ j(not_equal, ¬_oddball, Label::kNear); |
| 2713 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
| 2714 __ Ret(); |
| 2715 __ bind(¬_oddball); |
| 2716 |
| 2717 __ pop(ecx); // Pop return address. |
| 2718 __ push(eax); // Push argument. |
| 2719 __ push(ecx); // Push return address. |
| 2720 __ TailCallRuntime(Runtime::kToNumber); |
| 2721 } |
| 2722 |
2681 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2723 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2682 // ----------- S t a t e ------------- | 2724 // ----------- S t a t e ------------- |
2683 // -- eax : actual number of arguments | 2725 // -- eax : actual number of arguments |
2684 // -- ebx : expected number of arguments | 2726 // -- ebx : expected number of arguments |
2685 // -- edx : new target (passed through to callee) | 2727 // -- edx : new target (passed through to callee) |
2686 // -- edi : function (passed through to callee) | 2728 // -- edi : function (passed through to callee) |
2687 // ----------------------------------- | 2729 // ----------------------------------- |
2688 | 2730 |
2689 Label invoke, dont_adapt_arguments, stack_overflow; | 2731 Label invoke, dont_adapt_arguments, stack_overflow; |
2690 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); | 2732 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 // And "return" to the OSR entry point of the function. | 2972 // And "return" to the OSR entry point of the function. |
2931 __ ret(0); | 2973 __ ret(0); |
2932 } | 2974 } |
2933 | 2975 |
2934 | 2976 |
2935 #undef __ | 2977 #undef __ |
2936 } // namespace internal | 2978 } // namespace internal |
2937 } // namespace v8 | 2979 } // namespace v8 |
2938 | 2980 |
2939 #endif // V8_TARGET_ARCH_X87 | 2981 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |