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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 2051113002: [stubs] ToNumberStub --> ToNumber builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix full-code on non-x64 platforms Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 __ bind(&loop); 1588 __ bind(&loop);
1589 { 1589 {
1590 // Check if all parameters done. 1590 // Check if all parameters done.
1591 __ test(ecx, ecx); 1591 __ test(ecx, ecx);
1592 __ j(zero, &done_loop); 1592 __ j(zero, &done_loop);
1593 1593
1594 // Load the next parameter tagged value into ebx. 1594 // Load the next parameter tagged value into ebx.
1595 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0)); 1595 __ mov(ebx, Operand(esp, ecx, times_pointer_size, 0));
1596 1596
1597 // Load the double value of the parameter into xmm1, maybe converting the 1597 // Load the double value of the parameter into xmm1, maybe converting the
1598 // parameter to a number first using the ToNumberStub if necessary. 1598 // parameter to a number first using the ToNumber builtin if necessary.
1599 Label convert, convert_smi, convert_number, done_convert; 1599 Label convert, convert_smi, convert_number, done_convert;
1600 __ bind(&convert); 1600 __ bind(&convert);
1601 __ JumpIfSmi(ebx, &convert_smi); 1601 __ JumpIfSmi(ebx, &convert_smi);
1602 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset), 1602 __ JumpIfRoot(FieldOperand(ebx, HeapObject::kMapOffset),
1603 Heap::kHeapNumberMapRootIndex, &convert_number); 1603 Heap::kHeapNumberMapRootIndex, &convert_number);
1604 { 1604 {
1605 // Parameter is not a Number, use the ToNumberStub to convert it. 1605 // Parameter is not a Number, use the ToNumber builtin to convert it.
1606 FrameScope scope(masm, StackFrame::INTERNAL); 1606 FrameScope scope(masm, StackFrame::INTERNAL);
1607 __ SmiTag(eax); 1607 __ SmiTag(eax);
1608 __ SmiTag(ecx); 1608 __ SmiTag(ecx);
1609 __ Push(eax); 1609 __ Push(eax);
1610 __ Push(ecx); 1610 __ Push(ecx);
1611 __ Push(edx); 1611 __ Push(edx);
1612 __ mov(eax, ebx); 1612 __ mov(eax, ebx);
1613 ToNumberStub stub(masm->isolate()); 1613 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
1614 __ CallStub(&stub);
1615 __ mov(ebx, eax); 1614 __ mov(ebx, eax);
1616 __ Pop(edx); 1615 __ Pop(edx);
1617 __ Pop(ecx); 1616 __ Pop(ecx);
1618 __ Pop(eax); 1617 __ Pop(eax);
1619 { 1618 {
1620 // Restore the double accumulator value (xmm0). 1619 // Restore the double accumulator value (xmm0).
1621 Label restore_smi, done_restore; 1620 Label restore_smi, done_restore;
1622 __ JumpIfSmi(edx, &restore_smi, Label::kNear); 1621 __ JumpIfSmi(edx, &restore_smi, Label::kNear);
1623 __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset)); 1622 __ movsd(xmm0, FieldOperand(edx, HeapNumber::kValueOffset));
1624 __ jmp(&done_restore, Label::kNear); 1623 __ jmp(&done_restore, Label::kNear);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 __ test(eax, eax); 1696 __ test(eax, eax);
1698 __ j(zero, &no_arguments, Label::kNear); 1697 __ j(zero, &no_arguments, Label::kNear);
1699 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); 1698 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0));
1700 __ PopReturnAddressTo(ecx); 1699 __ PopReturnAddressTo(ecx);
1701 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); 1700 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
1702 __ PushReturnAddressFrom(ecx); 1701 __ PushReturnAddressFrom(ecx);
1703 __ mov(eax, ebx); 1702 __ mov(eax, ebx);
1704 } 1703 }
1705 1704
1706 // 2a. Convert the first argument to a number. 1705 // 2a. Convert the first argument to a number.
1707 ToNumberStub stub(masm->isolate()); 1706 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
1708 __ TailCallStub(&stub);
1709 1707
1710 // 2b. No arguments, return +0 (already in eax). 1708 // 2b. No arguments, return +0 (already in eax).
1711 __ bind(&no_arguments); 1709 __ bind(&no_arguments);
1712 __ ret(1 * kPointerSize); 1710 __ ret(1 * kPointerSize);
1713 } 1711 }
1714 1712
1715 1713
1716 // static 1714 // static
1717 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { 1715 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) {
1718 // ----------- S t a t e ------------- 1716 // ----------- S t a t e -------------
(...skipping 29 matching lines...) Expand all
1748 Label done_convert; 1746 Label done_convert;
1749 __ JumpIfSmi(ebx, &done_convert); 1747 __ JumpIfSmi(ebx, &done_convert);
1750 __ CompareRoot(FieldOperand(ebx, HeapObject::kMapOffset), 1748 __ CompareRoot(FieldOperand(ebx, HeapObject::kMapOffset),
1751 Heap::kHeapNumberMapRootIndex); 1749 Heap::kHeapNumberMapRootIndex);
1752 __ j(equal, &done_convert); 1750 __ j(equal, &done_convert);
1753 { 1751 {
1754 FrameScope scope(masm, StackFrame::INTERNAL); 1752 FrameScope scope(masm, StackFrame::INTERNAL);
1755 __ Push(edi); 1753 __ Push(edi);
1756 __ Push(edx); 1754 __ Push(edx);
1757 __ Move(eax, ebx); 1755 __ Move(eax, ebx);
1758 ToNumberStub stub(masm->isolate()); 1756 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
1759 __ CallStub(&stub);
1760 __ Move(ebx, eax); 1757 __ Move(ebx, eax);
1761 __ Pop(edx); 1758 __ Pop(edx);
1762 __ Pop(edi); 1759 __ Pop(edi);
1763 } 1760 }
1764 __ bind(&done_convert); 1761 __ bind(&done_convert);
1765 } 1762 }
1766 1763
1767 // 4. Check if new target and constructor differ. 1764 // 4. Check if new target and constructor differ.
1768 Label new_object; 1765 Label new_object;
1769 __ cmp(edx, edi); 1766 __ cmp(edx, edi);
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 __ IndexFromHash(eax, eax); 2659 __ IndexFromHash(eax, eax);
2663 __ Ret(); 2660 __ Ret();
2664 2661
2665 __ bind(&runtime); 2662 __ bind(&runtime);
2666 __ PopReturnAddressTo(ecx); // Pop return address. 2663 __ PopReturnAddressTo(ecx); // Pop return address.
2667 __ Push(eax); // Push argument. 2664 __ Push(eax); // Push argument.
2668 __ PushReturnAddressFrom(ecx); // Push return address. 2665 __ PushReturnAddressFrom(ecx); // Push return address.
2669 __ TailCallRuntime(Runtime::kStringToNumber); 2666 __ TailCallRuntime(Runtime::kStringToNumber);
2670 } 2667 }
2671 2668
2669 // static
2670 void Builtins::Generate_ToNumber(MacroAssembler* masm) {
2671 // The ToNumber stub takes one argument in eax.
2672 Label not_smi;
2673 __ JumpIfNotSmi(eax, &not_smi, Label::kNear);
2674 __ Ret();
2675 __ bind(&not_smi);
2676
2677 Label not_heap_number;
2678 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map());
2679 __ j(not_equal, &not_heap_number, Label::kNear);
2680 __ Ret();
2681 __ bind(&not_heap_number);
2682
2683 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(),
2684 RelocInfo::CODE_TARGET);
2685 }
2686
2687 // static
2688 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) {
2689 // The NonNumberToNumber stub takes one argument in eax.
2690 __ AssertNotNumber(eax);
2691
2692 Label not_string;
2693 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2694 // eax: object
2695 // edi: object map
2696 __ j(above_equal, &not_string, Label::kNear);
2697 __ Jump(masm->isolate()->builtins()->StringToNumber(),
2698 RelocInfo::CODE_TARGET);
2699 __ bind(&not_string);
2700
2701 Label not_oddball;
2702 __ CmpInstanceType(edi, ODDBALL_TYPE);
2703 __ j(not_equal, &not_oddball, Label::kNear);
2704 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset));
2705 __ Ret();
2706 __ bind(&not_oddball);
2707
2708 __ pop(ecx); // Pop return address.
2709 __ push(eax); // Push argument.
2710 __ push(ecx); // Push return address.
2711 __ TailCallRuntime(Runtime::kToNumber);
2712 }
2713
2672 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { 2714 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
2673 // ----------- S t a t e ------------- 2715 // ----------- S t a t e -------------
2674 // -- eax : actual number of arguments 2716 // -- eax : actual number of arguments
2675 // -- ebx : expected number of arguments 2717 // -- ebx : expected number of arguments
2676 // -- edx : new target (passed through to callee) 2718 // -- edx : new target (passed through to callee)
2677 // -- edi : function (passed through to callee) 2719 // -- edi : function (passed through to callee)
2678 // ----------------------------------- 2720 // -----------------------------------
2679 2721
2680 Label invoke, dont_adapt_arguments, stack_overflow; 2722 Label invoke, dont_adapt_arguments, stack_overflow;
2681 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); 2723 __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
2920 // And "return" to the OSR entry point of the function. 2962 // And "return" to the OSR entry point of the function.
2921 __ ret(0); 2963 __ ret(0);
2922 } 2964 }
2923 2965
2924 2966
2925 #undef __ 2967 #undef __
2926 } // namespace internal 2968 } // namespace internal
2927 } // namespace v8 2969 } // namespace v8
2928 2970
2929 #endif // V8_TARGET_ARCH_IA32 2971 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698