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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 __ bind(&loop); | 163 __ bind(&loop); |
164 { | 164 { |
165 // Check if all parameters done. | 165 // Check if all parameters done. |
166 __ sub(r0, r0, Operand(1), SetCC); | 166 __ sub(r0, r0, Operand(1), SetCC); |
167 __ b(lt, &done_loop); | 167 __ b(lt, &done_loop); |
168 | 168 |
169 // Load the next parameter tagged value into r2. | 169 // Load the next parameter tagged value into r2. |
170 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 170 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
171 | 171 |
172 // Load the double value of the parameter into d2, maybe converting the | 172 // Load the double value of the parameter into d2, maybe converting the |
173 // parameter to a number first using the ToNumberStub if necessary. | 173 // parameter to a number first using the ToNumber builtin if necessary. |
174 Label convert, convert_smi, convert_number, done_convert; | 174 Label convert, convert_smi, convert_number, done_convert; |
175 __ bind(&convert); | 175 __ bind(&convert); |
176 __ JumpIfSmi(r2, &convert_smi); | 176 __ JumpIfSmi(r2, &convert_smi); |
177 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); | 177 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); |
178 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); | 178 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); |
179 { | 179 { |
180 // Parameter is not a Number, use the ToNumberStub to convert it. | 180 // Parameter is not a Number, use the ToNumber builtin to convert it. |
181 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 181 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
182 __ SmiTag(r0); | 182 __ SmiTag(r0); |
183 __ SmiTag(r4); | 183 __ SmiTag(r4); |
184 __ Push(r0, r1, r4); | 184 __ Push(r0, r1, r4); |
185 __ mov(r0, r2); | 185 __ mov(r0, r2); |
186 ToNumberStub stub(masm->isolate()); | 186 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
187 __ CallStub(&stub); | |
188 __ mov(r2, r0); | 187 __ mov(r2, r0); |
189 __ Pop(r0, r1, r4); | 188 __ Pop(r0, r1, r4); |
190 { | 189 { |
191 // Restore the double accumulator value (d1). | 190 // Restore the double accumulator value (d1). |
192 Label done_restore; | 191 Label done_restore; |
193 __ SmiToDouble(d1, r1); | 192 __ SmiToDouble(d1, r1); |
194 __ JumpIfSmi(r1, &done_restore); | 193 __ JumpIfSmi(r1, &done_restore); |
195 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 194 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); |
196 __ bind(&done_restore); | 195 __ bind(&done_restore); |
197 } | 196 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // receiver). | 251 // receiver). |
253 Label no_arguments; | 252 Label no_arguments; |
254 { | 253 { |
255 __ sub(r0, r0, Operand(1), SetCC); | 254 __ sub(r0, r0, Operand(1), SetCC); |
256 __ b(lo, &no_arguments); | 255 __ b(lo, &no_arguments); |
257 __ ldr(r0, MemOperand(sp, r0, LSL, kPointerSizeLog2, PreIndex)); | 256 __ ldr(r0, MemOperand(sp, r0, LSL, kPointerSizeLog2, PreIndex)); |
258 __ Drop(2); | 257 __ Drop(2); |
259 } | 258 } |
260 | 259 |
261 // 2a. Convert the first argument to a number. | 260 // 2a. Convert the first argument to a number. |
262 ToNumberStub stub(masm->isolate()); | 261 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
263 __ TailCallStub(&stub); | |
264 | 262 |
265 // 2b. No arguments, return +0. | 263 // 2b. No arguments, return +0. |
266 __ bind(&no_arguments); | 264 __ bind(&no_arguments); |
267 __ Move(r0, Smi::FromInt(0)); | 265 __ Move(r0, Smi::FromInt(0)); |
268 __ Ret(1); | 266 __ Ret(1); |
269 } | 267 } |
270 | 268 |
271 | 269 |
272 // static | 270 // static |
273 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 271 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
(...skipping 27 matching lines...) Expand all Loading... |
301 // 3. Make sure r2 is a number. | 299 // 3. Make sure r2 is a number. |
302 { | 300 { |
303 Label done_convert; | 301 Label done_convert; |
304 __ JumpIfSmi(r2, &done_convert); | 302 __ JumpIfSmi(r2, &done_convert); |
305 __ CompareObjectType(r2, r4, r4, HEAP_NUMBER_TYPE); | 303 __ CompareObjectType(r2, r4, r4, HEAP_NUMBER_TYPE); |
306 __ b(eq, &done_convert); | 304 __ b(eq, &done_convert); |
307 { | 305 { |
308 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 306 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
309 __ Push(r1, r3); | 307 __ Push(r1, r3); |
310 __ Move(r0, r2); | 308 __ Move(r0, r2); |
311 ToNumberStub stub(masm->isolate()); | 309 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
312 __ CallStub(&stub); | |
313 __ Move(r2, r0); | 310 __ Move(r2, r0); |
314 __ Pop(r1, r3); | 311 __ Pop(r1, r3); |
315 } | 312 } |
316 __ bind(&done_convert); | 313 __ bind(&done_convert); |
317 } | 314 } |
318 | 315 |
319 // 4. Check if new target and constructor differ. | 316 // 4. Check if new target and constructor differ. |
320 Label new_object; | 317 Label new_object; |
321 __ cmp(r1, r3); | 318 __ cmp(r1, r3); |
322 __ b(ne, &new_object); | 319 __ b(ne, &new_object); |
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2700 __ tst(r2, Operand(String::kContainsCachedArrayIndexMask)); | 2697 __ tst(r2, Operand(String::kContainsCachedArrayIndexMask)); |
2701 __ b(ne, &runtime); | 2698 __ b(ne, &runtime); |
2702 __ IndexFromHash(r2, r0); | 2699 __ IndexFromHash(r2, r0); |
2703 __ Ret(); | 2700 __ Ret(); |
2704 | 2701 |
2705 __ bind(&runtime); | 2702 __ bind(&runtime); |
2706 __ Push(r0); // Push argument. | 2703 __ Push(r0); // Push argument. |
2707 __ TailCallRuntime(Runtime::kStringToNumber); | 2704 __ TailCallRuntime(Runtime::kStringToNumber); |
2708 } | 2705 } |
2709 | 2706 |
| 2707 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
| 2708 // The ToNumber stub takes one argument in r0. |
| 2709 STATIC_ASSERT(kSmiTag == 0); |
| 2710 __ tst(r0, Operand(kSmiTagMask)); |
| 2711 __ Ret(eq); |
| 2712 |
| 2713 __ CompareObjectType(r0, r1, r1, HEAP_NUMBER_TYPE); |
| 2714 // r0: receiver |
| 2715 // r1: receiver instance type |
| 2716 __ Ret(eq); |
| 2717 |
| 2718 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(), |
| 2719 RelocInfo::CODE_TARGET); |
| 2720 } |
| 2721 |
| 2722 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) { |
| 2723 // The NonNumberToNumber stub takes one argument in r0. |
| 2724 __ AssertNotNumber(r0); |
| 2725 |
| 2726 __ CompareObjectType(r0, r1, r1, FIRST_NONSTRING_TYPE); |
| 2727 // r0: receiver |
| 2728 // r1: receiver instance type |
| 2729 __ Jump(masm->isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET, |
| 2730 lo); |
| 2731 |
| 2732 Label not_oddball; |
| 2733 __ cmp(r1, Operand(ODDBALL_TYPE)); |
| 2734 __ b(ne, ¬_oddball); |
| 2735 __ ldr(r0, FieldMemOperand(r0, Oddball::kToNumberOffset)); |
| 2736 __ Ret(); |
| 2737 __ bind(¬_oddball); |
| 2738 |
| 2739 __ Push(r0); // Push argument. |
| 2740 __ TailCallRuntime(Runtime::kToNumber); |
| 2741 } |
| 2742 |
2710 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2743 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2711 // ----------- S t a t e ------------- | 2744 // ----------- S t a t e ------------- |
2712 // -- r0 : actual number of arguments | 2745 // -- r0 : actual number of arguments |
2713 // -- r1 : function (passed through to callee) | 2746 // -- r1 : function (passed through to callee) |
2714 // -- r2 : expected number of arguments | 2747 // -- r2 : expected number of arguments |
2715 // -- r3 : new target (passed through to callee) | 2748 // -- r3 : new target (passed through to callee) |
2716 // ----------------------------------- | 2749 // ----------------------------------- |
2717 | 2750 |
2718 Label invoke, dont_adapt_arguments, stack_overflow; | 2751 Label invoke, dont_adapt_arguments, stack_overflow; |
2719 | 2752 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2831 } | 2864 } |
2832 } | 2865 } |
2833 | 2866 |
2834 | 2867 |
2835 #undef __ | 2868 #undef __ |
2836 | 2869 |
2837 } // namespace internal | 2870 } // namespace internal |
2838 } // namespace v8 | 2871 } // namespace v8 |
2839 | 2872 |
2840 #endif // V8_TARGET_ARCH_ARM | 2873 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |