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/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 { | 164 { |
165 // Check if all parameters done. | 165 // Check if all parameters done. |
166 __ Subu(a0, a0, Operand(1)); | 166 __ Subu(a0, a0, Operand(1)); |
167 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); | 167 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); |
168 | 168 |
169 // Load the next parameter tagged value into a2. | 169 // Load the next parameter tagged value into a2. |
170 __ Lsa(at, sp, a0, kPointerSizeLog2); | 170 __ Lsa(at, sp, a0, kPointerSizeLog2); |
171 __ lw(a2, MemOperand(at)); | 171 __ lw(a2, MemOperand(at)); |
172 | 172 |
173 // Load the double value of the parameter into f2, maybe converting the | 173 // Load the double value of the parameter into f2, maybe converting the |
174 // parameter to a number first using the ToNumberStub if necessary. | 174 // parameter to a number first using the ToNumber builtin if necessary. |
175 Label convert, convert_smi, convert_number, done_convert; | 175 Label convert, convert_smi, convert_number, done_convert; |
176 __ bind(&convert); | 176 __ bind(&convert); |
177 __ JumpIfSmi(a2, &convert_smi); | 177 __ JumpIfSmi(a2, &convert_smi); |
178 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); | 178 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); |
179 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); | 179 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); |
180 { | 180 { |
181 // Parameter is not a Number, use the ToNumberStub to convert it. | 181 // Parameter is not a Number, use the ToNumber builtin to convert it. |
182 FrameScope scope(masm, StackFrame::INTERNAL); | 182 FrameScope scope(masm, StackFrame::INTERNAL); |
183 __ SmiTag(a0); | 183 __ SmiTag(a0); |
184 __ SmiTag(a3); | 184 __ SmiTag(a3); |
185 __ Push(a0, a1, a3); | 185 __ Push(a0, a1, a3); |
186 __ mov(a0, a2); | 186 __ mov(a0, a2); |
187 ToNumberStub stub(masm->isolate()); | 187 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
188 __ CallStub(&stub); | |
189 __ mov(a2, v0); | 188 __ mov(a2, v0); |
190 __ Pop(a0, a1, a3); | 189 __ Pop(a0, a1, a3); |
191 { | 190 { |
192 // Restore the double accumulator value (f0). | 191 // Restore the double accumulator value (f0). |
193 Label restore_smi, done_restore; | 192 Label restore_smi, done_restore; |
194 __ JumpIfSmi(a1, &restore_smi); | 193 __ JumpIfSmi(a1, &restore_smi); |
195 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 194 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
196 __ jmp(&done_restore); | 195 __ jmp(&done_restore); |
197 __ bind(&restore_smi); | 196 __ bind(&restore_smi); |
198 __ SmiToDoubleFPURegister(a1, f0, t0); | 197 __ SmiToDoubleFPURegister(a1, f0, t0); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 Label no_arguments; | 257 Label no_arguments; |
259 { | 258 { |
260 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); | 259 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
261 __ Subu(a0, a0, Operand(1)); | 260 __ Subu(a0, a0, Operand(1)); |
262 __ Lsa(sp, sp, a0, kPointerSizeLog2); | 261 __ Lsa(sp, sp, a0, kPointerSizeLog2); |
263 __ lw(a0, MemOperand(sp)); | 262 __ lw(a0, MemOperand(sp)); |
264 __ Drop(2); | 263 __ Drop(2); |
265 } | 264 } |
266 | 265 |
267 // 2a. Convert first argument to number. | 266 // 2a. Convert first argument to number. |
268 ToNumberStub stub(masm->isolate()); | 267 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
269 __ TailCallStub(&stub); | |
270 | 268 |
271 // 2b. No arguments, return +0. | 269 // 2b. No arguments, return +0. |
272 __ bind(&no_arguments); | 270 __ bind(&no_arguments); |
273 __ Move(v0, Smi::FromInt(0)); | 271 __ Move(v0, Smi::FromInt(0)); |
274 __ DropAndRet(1); | 272 __ DropAndRet(1); |
275 } | 273 } |
276 | 274 |
277 | 275 |
278 // static | 276 // static |
279 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 277 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
(...skipping 27 matching lines...) Expand all Loading... |
307 | 305 |
308 // 3. Make sure a0 is a number. | 306 // 3. Make sure a0 is a number. |
309 { | 307 { |
310 Label done_convert; | 308 Label done_convert; |
311 __ JumpIfSmi(a0, &done_convert); | 309 __ JumpIfSmi(a0, &done_convert); |
312 __ GetObjectType(a0, a2, a2); | 310 __ GetObjectType(a0, a2, a2); |
313 __ Branch(&done_convert, eq, a2, Operand(HEAP_NUMBER_TYPE)); | 311 __ Branch(&done_convert, eq, a2, Operand(HEAP_NUMBER_TYPE)); |
314 { | 312 { |
315 FrameScope scope(masm, StackFrame::INTERNAL); | 313 FrameScope scope(masm, StackFrame::INTERNAL); |
316 __ Push(a1, a3); | 314 __ Push(a1, a3); |
317 ToNumberStub stub(masm->isolate()); | 315 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
318 __ CallStub(&stub); | |
319 __ Move(a0, v0); | 316 __ Move(a0, v0); |
320 __ Pop(a1, a3); | 317 __ Pop(a1, a3); |
321 } | 318 } |
322 __ bind(&done_convert); | 319 __ bind(&done_convert); |
323 } | 320 } |
324 | 321 |
325 // 4. Check if new target and constructor differ. | 322 // 4. Check if new target and constructor differ. |
326 Label new_object; | 323 Label new_object; |
327 __ Branch(&new_object, ne, a1, Operand(a3)); | 324 __ Branch(&new_object, ne, a1, Operand(a3)); |
328 | 325 |
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask)); | 2773 __ And(at, a2, Operand(String::kContainsCachedArrayIndexMask)); |
2777 __ Branch(&runtime, ne, at, Operand(zero_reg)); | 2774 __ Branch(&runtime, ne, at, Operand(zero_reg)); |
2778 __ IndexFromHash(a2, v0); | 2775 __ IndexFromHash(a2, v0); |
2779 __ Ret(); | 2776 __ Ret(); |
2780 | 2777 |
2781 __ bind(&runtime); | 2778 __ bind(&runtime); |
2782 __ Push(a0); // Push argument. | 2779 __ Push(a0); // Push argument. |
2783 __ TailCallRuntime(Runtime::kStringToNumber); | 2780 __ TailCallRuntime(Runtime::kStringToNumber); |
2784 } | 2781 } |
2785 | 2782 |
| 2783 // static |
| 2784 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
| 2785 // The ToNumber stub takes one argument in a0. |
| 2786 Label not_smi; |
| 2787 __ JumpIfNotSmi(a0, ¬_smi); |
| 2788 __ Ret(USE_DELAY_SLOT); |
| 2789 __ mov(v0, a0); |
| 2790 __ bind(¬_smi); |
| 2791 |
| 2792 Label not_heap_number; |
| 2793 __ GetObjectType(a0, a1, a1); |
| 2794 // a0: receiver |
| 2795 // a1: receiver instance type |
| 2796 __ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); |
| 2797 __ Ret(USE_DELAY_SLOT); |
| 2798 __ mov(v0, a0); |
| 2799 __ bind(¬_heap_number); |
| 2800 |
| 2801 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(), |
| 2802 RelocInfo::CODE_TARGET); |
| 2803 } |
| 2804 |
| 2805 // static |
| 2806 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) { |
| 2807 // The NonNumberToNumber stub takes on argument in a0. |
| 2808 __ AssertNotNumber(a0); |
| 2809 |
| 2810 Label not_string; |
| 2811 __ GetObjectType(a0, a1, a1); |
| 2812 // a0: receiver |
| 2813 // a1: receiver instance type |
| 2814 __ Branch(¬_string, hs, a1, Operand(FIRST_NONSTRING_TYPE)); |
| 2815 __ Jump(masm->isolate()->builtins()->StringToNumber(), |
| 2816 RelocInfo::CODE_TARGET); |
| 2817 __ bind(¬_string); |
| 2818 |
| 2819 Label not_oddball; |
| 2820 __ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE)); |
| 2821 __ Ret(USE_DELAY_SLOT); |
| 2822 __ lw(v0, FieldMemOperand(a0, Oddball::kToNumberOffset)); // In delay slot. |
| 2823 __ bind(¬_oddball); |
| 2824 |
| 2825 __ Push(a0); // Push argument. |
| 2826 __ TailCallRuntime(Runtime::kToNumber); |
| 2827 } |
| 2828 |
2786 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2829 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2787 // State setup as expected by MacroAssembler::InvokePrologue. | 2830 // State setup as expected by MacroAssembler::InvokePrologue. |
2788 // ----------- S t a t e ------------- | 2831 // ----------- S t a t e ------------- |
2789 // -- a0: actual arguments count | 2832 // -- a0: actual arguments count |
2790 // -- a1: function (passed through to callee) | 2833 // -- a1: function (passed through to callee) |
2791 // -- a2: expected arguments count | 2834 // -- a2: expected arguments count |
2792 // -- a3: new target (passed through to callee) | 2835 // -- a3: new target (passed through to callee) |
2793 // ----------------------------------- | 2836 // ----------------------------------- |
2794 | 2837 |
2795 Label invoke, dont_adapt_arguments, stack_overflow; | 2838 Label invoke, dont_adapt_arguments, stack_overflow; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2914 } | 2957 } |
2915 } | 2958 } |
2916 | 2959 |
2917 | 2960 |
2918 #undef __ | 2961 #undef __ |
2919 | 2962 |
2920 } // namespace internal | 2963 } // namespace internal |
2921 } // namespace v8 | 2964 } // namespace v8 |
2922 | 2965 |
2923 #endif // V8_TARGET_ARCH_MIPS | 2966 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |