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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2790 | 2790 |
2791 void ToNumberStub::Generate(MacroAssembler* masm) { | 2791 void ToNumberStub::Generate(MacroAssembler* masm) { |
2792 // The ToNumber stub takes one argument in a0. | 2792 // The ToNumber stub takes one argument in a0. |
2793 Label not_smi; | 2793 Label not_smi; |
2794 __ JumpIfNotSmi(a0, ¬_smi); | 2794 __ JumpIfNotSmi(a0, ¬_smi); |
2795 __ Ret(USE_DELAY_SLOT); | 2795 __ Ret(USE_DELAY_SLOT); |
2796 __ mov(v0, a0); | 2796 __ mov(v0, a0); |
2797 __ bind(¬_smi); | 2797 __ bind(¬_smi); |
2798 | 2798 |
2799 Label not_heap_number; | 2799 Label not_heap_number; |
2800 __ lw(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); | 2800 __ GetObjectType(a0, a1, a1); |
2801 __ lbu(a1, FieldMemOperand(a1, Map::kInstanceTypeOffset)); | 2801 // a0: receiver |
2802 // a0: object | 2802 // a1: receiver instance type |
2803 // a1: instance type. | |
2804 __ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); | 2803 __ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); |
2805 __ Ret(USE_DELAY_SLOT); | 2804 __ Ret(USE_DELAY_SLOT); |
2806 __ mov(v0, a0); | 2805 __ mov(v0, a0); |
2807 __ bind(¬_heap_number); | 2806 __ bind(¬_heap_number); |
2808 | 2807 |
2809 Label not_string, slow_string; | 2808 NonNumberToNumberStub stub(masm->isolate()); |
| 2809 __ TailCallStub(&stub); |
| 2810 } |
| 2811 |
| 2812 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
| 2813 // The NonNumberToNumber stub takes on argument in a0. |
| 2814 __ AssertNotNumber(a0); |
| 2815 |
| 2816 Label not_string; |
| 2817 __ GetObjectType(a0, a1, a1); |
| 2818 // a0: receiver |
| 2819 // a1: receiver instance type |
2810 __ Branch(¬_string, hs, a1, Operand(FIRST_NONSTRING_TYPE)); | 2820 __ Branch(¬_string, hs, a1, Operand(FIRST_NONSTRING_TYPE)); |
2811 // Check if string has a cached array index. | 2821 StringToNumberStub stub(masm->isolate()); |
2812 __ lw(a2, FieldMemOperand(a0, String::kHashFieldOffset)); | 2822 __ TailCallStub(&stub); |
2813 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask)); | |
2814 __ Branch(&slow_string, ne, at, Operand(zero_reg)); | |
2815 __ IndexFromHash(a2, a0); | |
2816 __ Ret(USE_DELAY_SLOT); | |
2817 __ mov(v0, a0); | |
2818 __ bind(&slow_string); | |
2819 __ push(a0); // Push argument. | |
2820 __ TailCallRuntime(Runtime::kStringToNumber); | |
2821 __ bind(¬_string); | 2823 __ bind(¬_string); |
2822 | 2824 |
2823 Label not_oddball; | 2825 Label not_oddball; |
2824 __ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE)); | 2826 __ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE)); |
2825 __ Ret(USE_DELAY_SLOT); | 2827 __ Ret(USE_DELAY_SLOT); |
2826 __ lw(v0, FieldMemOperand(a0, Oddball::kToNumberOffset)); | 2828 __ lw(v0, FieldMemOperand(a0, Oddball::kToNumberOffset)); // In delay slot. |
2827 __ bind(¬_oddball); | 2829 __ bind(¬_oddball); |
2828 | 2830 |
2829 __ push(a0); // Push argument. | 2831 __ Push(a0); // Push argument. |
2830 __ TailCallRuntime(Runtime::kToNumber); | 2832 __ TailCallRuntime(Runtime::kToNumber); |
2831 } | 2833 } |
2832 | 2834 |
| 2835 void StringToNumberStub::Generate(MacroAssembler* masm) { |
| 2836 // The StringToNumber stub takes on argument in a0. |
| 2837 __ AssertString(a0); |
| 2838 |
| 2839 // Check if string has a cached array index. |
| 2840 Label runtime; |
| 2841 __ lw(a2, FieldMemOperand(a0, String::kHashFieldOffset)); |
| 2842 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask)); |
| 2843 __ Branch(&runtime, ne, at, Operand(zero_reg)); |
| 2844 __ IndexFromHash(a2, v0); |
| 2845 __ Ret(USE_DELAY_SLOT); |
| 2846 __ mov(v0, a0); // In delay slot. |
| 2847 |
| 2848 __ bind(&runtime); |
| 2849 __ Push(a0); // Push argument. |
| 2850 __ TailCallRuntime(Runtime::kStringToNumber); |
| 2851 } |
2833 | 2852 |
2834 void ToLengthStub::Generate(MacroAssembler* masm) { | 2853 void ToLengthStub::Generate(MacroAssembler* masm) { |
2835 // The ToLength stub takes on argument in a0. | 2854 // The ToLength stub takes on argument in a0. |
2836 Label not_smi, positive_smi; | 2855 Label not_smi, positive_smi; |
2837 __ JumpIfNotSmi(a0, ¬_smi); | 2856 __ JumpIfNotSmi(a0, ¬_smi); |
2838 STATIC_ASSERT(kSmiTag == 0); | 2857 STATIC_ASSERT(kSmiTag == 0); |
2839 __ Branch(&positive_smi, ge, a0, Operand(zero_reg)); | 2858 __ Branch(&positive_smi, ge, a0, Operand(zero_reg)); |
2840 __ mov(a0, zero_reg); | 2859 __ mov(a0, zero_reg); |
2841 __ bind(&positive_smi); | 2860 __ bind(&positive_smi); |
2842 __ Ret(USE_DELAY_SLOT); | 2861 __ Ret(USE_DELAY_SLOT); |
(...skipping 2901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5744 return_value_operand, NULL); | 5763 return_value_operand, NULL); |
5745 } | 5764 } |
5746 | 5765 |
5747 | 5766 |
5748 #undef __ | 5767 #undef __ |
5749 | 5768 |
5750 } // namespace internal | 5769 } // namespace internal |
5751 } // namespace v8 | 5770 } // namespace v8 |
5752 | 5771 |
5753 #endif // V8_TARGET_ARCH_MIPS | 5772 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |