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-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); | 2626 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
2627 __ Ret(); | 2627 __ Ret(); |
2628 __ bind(¬_smi); | 2628 __ bind(¬_smi); |
2629 | 2629 |
2630 Label not_heap_number; | 2630 Label not_heap_number; |
2631 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); | 2631 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); |
2632 __ j(not_equal, ¬_heap_number, Label::kNear); | 2632 __ j(not_equal, ¬_heap_number, Label::kNear); |
2633 __ Ret(); | 2633 __ Ret(); |
2634 __ bind(¬_heap_number); | 2634 __ bind(¬_heap_number); |
2635 | 2635 |
2636 Label not_string, slow_string; | 2636 NonNumberToNumberStub stub(masm->isolate()); |
| 2637 __ TailCallStub(&stub); |
| 2638 } |
| 2639 |
| 2640 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
| 2641 // The NonNumberToNumber stub takes one argument in eax. |
| 2642 __ AssertNotNumber(eax); |
| 2643 |
| 2644 Label not_string; |
2637 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); | 2645 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
2638 // eax: object | 2646 // eax: object |
2639 // edi: object map | 2647 // edi: object map |
2640 __ j(above_equal, ¬_string, Label::kNear); | 2648 __ j(above_equal, ¬_string, Label::kNear); |
2641 // Check if string has a cached array index. | 2649 StringToNumberStub stub(masm->isolate()); |
2642 __ test(FieldOperand(eax, String::kHashFieldOffset), | 2650 __ TailCallStub(&stub); |
2643 Immediate(String::kContainsCachedArrayIndexMask)); | |
2644 __ j(not_zero, &slow_string, Label::kNear); | |
2645 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); | |
2646 __ IndexFromHash(eax, eax); | |
2647 __ Ret(); | |
2648 __ bind(&slow_string); | |
2649 __ pop(ecx); // Pop return address. | |
2650 __ push(eax); // Push argument. | |
2651 __ push(ecx); // Push return address. | |
2652 __ TailCallRuntime(Runtime::kStringToNumber); | |
2653 __ bind(¬_string); | 2651 __ bind(¬_string); |
2654 | 2652 |
2655 Label not_oddball; | 2653 Label not_oddball; |
2656 __ CmpInstanceType(edi, ODDBALL_TYPE); | 2654 __ CmpInstanceType(edi, ODDBALL_TYPE); |
2657 __ j(not_equal, ¬_oddball, Label::kNear); | 2655 __ j(not_equal, ¬_oddball, Label::kNear); |
2658 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); | 2656 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
2659 __ Ret(); | 2657 __ Ret(); |
2660 __ bind(¬_oddball); | 2658 __ bind(¬_oddball); |
2661 | 2659 |
2662 __ pop(ecx); // Pop return address. | 2660 __ pop(ecx); // Pop return address. |
2663 __ push(eax); // Push argument. | 2661 __ push(eax); // Push argument. |
2664 __ push(ecx); // Push return address. | 2662 __ push(ecx); // Push return address. |
2665 __ TailCallRuntime(Runtime::kToNumber); | 2663 __ TailCallRuntime(Runtime::kToNumber); |
2666 } | 2664 } |
2667 | 2665 |
| 2666 void StringToNumberStub::Generate(MacroAssembler* masm) { |
| 2667 // The StringToNumber stub takes one argument in eax. |
| 2668 __ AssertString(eax); |
| 2669 |
| 2670 // Check if string has a cached array index. |
| 2671 Label runtime; |
| 2672 __ test(FieldOperand(eax, String::kHashFieldOffset), |
| 2673 Immediate(String::kContainsCachedArrayIndexMask)); |
| 2674 __ j(not_zero, &runtime, Label::kNear); |
| 2675 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
| 2676 __ IndexFromHash(eax, eax); |
| 2677 __ Ret(); |
| 2678 |
| 2679 __ bind(&runtime); |
| 2680 __ PopReturnAddressTo(ecx); // Pop return address. |
| 2681 __ Push(eax); // Push argument. |
| 2682 __ PushReturnAddressFrom(ecx); // Push return address. |
| 2683 __ TailCallRuntime(Runtime::kStringToNumber); |
| 2684 } |
2668 | 2685 |
2669 void ToLengthStub::Generate(MacroAssembler* masm) { | 2686 void ToLengthStub::Generate(MacroAssembler* masm) { |
2670 // The ToLength stub takes on argument in eax. | 2687 // The ToLength stub takes on argument in eax. |
2671 Label not_smi, positive_smi; | 2688 Label not_smi, positive_smi; |
2672 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); | 2689 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
2673 STATIC_ASSERT(kSmiTag == 0); | 2690 STATIC_ASSERT(kSmiTag == 0); |
2674 __ test(eax, eax); | 2691 __ test(eax, eax); |
2675 __ j(greater_equal, &positive_smi, Label::kNear); | 2692 __ j(greater_equal, &positive_smi, Label::kNear); |
2676 __ xor_(eax, eax); | 2693 __ xor_(eax, eax); |
2677 __ bind(&positive_smi); | 2694 __ bind(&positive_smi); |
(...skipping 3185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5863 return_value_operand, NULL); | 5880 return_value_operand, NULL); |
5864 } | 5881 } |
5865 | 5882 |
5866 | 5883 |
5867 #undef __ | 5884 #undef __ |
5868 | 5885 |
5869 } // namespace internal | 5886 } // namespace internal |
5870 } // namespace v8 | 5887 } // namespace v8 |
5871 | 5888 |
5872 #endif // V8_TARGET_ARCH_IA32 | 5889 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |