OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.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 __ Subs(x0, x0, 1); | 166 __ Subs(x0, x0, 1); |
167 __ B(lt, &done_loop); | 167 __ B(lt, &done_loop); |
168 | 168 |
169 // Load the next parameter tagged value into x2. | 169 // Load the next parameter tagged value into x2. |
170 __ Peek(x2, Operand(x0, LSL, kPointerSizeLog2)); | 170 __ Peek(x2, Operand(x0, 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_smi, convert_number, done_convert; | 174 Label convert_smi, convert_number, done_convert; |
175 __ JumpIfSmi(x2, &convert_smi); | 175 __ JumpIfSmi(x2, &convert_smi); |
176 __ JumpIfHeapNumber(x2, &convert_number); | 176 __ JumpIfHeapNumber(x2, &convert_number); |
177 { | 177 { |
178 // Parameter is not a Number, use the ToNumberStub to convert it. | 178 // Parameter is not a Number, use the ToNumber builtin to convert it. |
179 FrameScope scope(masm, StackFrame::INTERNAL); | 179 FrameScope scope(masm, StackFrame::INTERNAL); |
180 __ SmiTag(x0); | 180 __ SmiTag(x0); |
181 __ SmiTag(x4); | 181 __ SmiTag(x4); |
182 __ Push(x0, x1, x4); | 182 __ Push(x0, x1, x4); |
183 __ Mov(x0, x2); | 183 __ Mov(x0, x2); |
184 ToNumberStub stub(masm->isolate()); | 184 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
185 __ CallStub(&stub); | |
186 __ Mov(x2, x0); | 185 __ Mov(x2, x0); |
187 __ Pop(x4, x1, x0); | 186 __ Pop(x4, x1, x0); |
188 { | 187 { |
189 // Restore the double accumulator value (d1). | 188 // Restore the double accumulator value (d1). |
190 Label done_restore; | 189 Label done_restore; |
191 __ SmiUntagToDouble(d1, x1, kSpeculativeUntag); | 190 __ SmiUntagToDouble(d1, x1, kSpeculativeUntag); |
192 __ JumpIfSmi(x1, &done_restore); | 191 __ JumpIfSmi(x1, &done_restore); |
193 __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); | 192 __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); |
194 __ Bind(&done_restore); | 193 __ Bind(&done_restore); |
195 } | 194 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // receiver). | 242 // receiver). |
244 Label no_arguments; | 243 Label no_arguments; |
245 { | 244 { |
246 __ Cbz(x0, &no_arguments); | 245 __ Cbz(x0, &no_arguments); |
247 __ Sub(x0, x0, 1); | 246 __ Sub(x0, x0, 1); |
248 __ Drop(x0); | 247 __ Drop(x0); |
249 __ Ldr(x0, MemOperand(jssp, 2 * kPointerSize, PostIndex)); | 248 __ Ldr(x0, MemOperand(jssp, 2 * kPointerSize, PostIndex)); |
250 } | 249 } |
251 | 250 |
252 // 2a. Convert first argument to number. | 251 // 2a. Convert first argument to number. |
253 ToNumberStub stub(masm->isolate()); | 252 __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
254 __ TailCallStub(&stub); | |
255 | 253 |
256 // 2b. No arguments, return +0 (already in x0). | 254 // 2b. No arguments, return +0 (already in x0). |
257 __ Bind(&no_arguments); | 255 __ Bind(&no_arguments); |
258 __ Drop(1); | 256 __ Drop(1); |
259 __ Ret(); | 257 __ Ret(); |
260 } | 258 } |
261 | 259 |
262 | 260 |
263 // static | 261 // static |
264 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 262 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
(...skipping 27 matching lines...) Expand all Loading... |
292 | 290 |
293 // 3. Make sure x2 is a number. | 291 // 3. Make sure x2 is a number. |
294 { | 292 { |
295 Label done_convert; | 293 Label done_convert; |
296 __ JumpIfSmi(x2, &done_convert); | 294 __ JumpIfSmi(x2, &done_convert); |
297 __ JumpIfObjectType(x2, x4, x4, HEAP_NUMBER_TYPE, &done_convert, eq); | 295 __ JumpIfObjectType(x2, x4, x4, HEAP_NUMBER_TYPE, &done_convert, eq); |
298 { | 296 { |
299 FrameScope scope(masm, StackFrame::INTERNAL); | 297 FrameScope scope(masm, StackFrame::INTERNAL); |
300 __ Push(x1, x3); | 298 __ Push(x1, x3); |
301 __ Move(x0, x2); | 299 __ Move(x0, x2); |
302 ToNumberStub stub(masm->isolate()); | 300 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
303 __ CallStub(&stub); | |
304 __ Move(x2, x0); | 301 __ Move(x2, x0); |
305 __ Pop(x3, x1); | 302 __ Pop(x3, x1); |
306 } | 303 } |
307 __ Bind(&done_convert); | 304 __ Bind(&done_convert); |
308 } | 305 } |
309 | 306 |
310 // 4. Check if new target and constructor differ. | 307 // 4. Check if new target and constructor differ. |
311 Label new_object; | 308 Label new_object; |
312 __ Cmp(x1, x3); | 309 __ Cmp(x1, x3); |
313 __ B(ne, &new_object); | 310 __ B(ne, &new_object); |
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 // -- x1 : requested object size (untagged) | 2772 // -- x1 : requested object size (untagged) |
2776 // -- lr : return address | 2773 // -- lr : return address |
2777 // ----------------------------------- | 2774 // ----------------------------------- |
2778 __ SmiTag(x1); | 2775 __ SmiTag(x1); |
2779 __ Move(x2, Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); | 2776 __ Move(x2, Smi::FromInt(AllocateTargetSpace::encode(OLD_SPACE))); |
2780 __ Push(x1, x2); | 2777 __ Push(x1, x2); |
2781 __ Move(cp, Smi::FromInt(0)); | 2778 __ Move(cp, Smi::FromInt(0)); |
2782 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); | 2779 __ TailCallRuntime(Runtime::kAllocateInTargetSpace); |
2783 } | 2780 } |
2784 | 2781 |
| 2782 // static |
2785 void Builtins::Generate_StringToNumber(MacroAssembler* masm) { | 2783 void Builtins::Generate_StringToNumber(MacroAssembler* masm) { |
2786 // The StringToNumber stub takes one argument in x0. | 2784 // The StringToNumber stub takes one argument in x0. |
2787 __ AssertString(x0); | 2785 __ AssertString(x0); |
2788 | 2786 |
2789 // Check if string has a cached array index. | 2787 // Check if string has a cached array index. |
2790 Label runtime; | 2788 Label runtime; |
2791 __ Ldr(x2, FieldMemOperand(x0, String::kHashFieldOffset)); | 2789 __ Ldr(x2, FieldMemOperand(x0, String::kHashFieldOffset)); |
2792 __ Tst(x2, Operand(String::kContainsCachedArrayIndexMask)); | 2790 __ Tst(x2, Operand(String::kContainsCachedArrayIndexMask)); |
2793 __ B(ne, &runtime); | 2791 __ B(ne, &runtime); |
2794 __ IndexFromHash(x2, x0); | 2792 __ IndexFromHash(x2, x0); |
2795 __ Ret(); | 2793 __ Ret(); |
2796 | 2794 |
2797 __ Bind(&runtime); | 2795 __ Bind(&runtime); |
2798 __ Push(x0); // Push argument. | 2796 __ Push(x0); // Push argument. |
2799 __ TailCallRuntime(Runtime::kStringToNumber); | 2797 __ TailCallRuntime(Runtime::kStringToNumber); |
2800 } | 2798 } |
2801 | 2799 |
| 2800 // static |
| 2801 void Builtins::Generate_ToNumber(MacroAssembler* masm) { |
| 2802 // The ToNumber stub takes one argument in x0. |
| 2803 Label not_smi; |
| 2804 __ JumpIfNotSmi(x0, ¬_smi); |
| 2805 __ Ret(); |
| 2806 __ Bind(¬_smi); |
| 2807 |
| 2808 Label not_heap_number; |
| 2809 __ CompareObjectType(x0, x1, x1, HEAP_NUMBER_TYPE); |
| 2810 // x0: receiver |
| 2811 // x1: receiver instance type |
| 2812 __ B(ne, ¬_heap_number); |
| 2813 __ Ret(); |
| 2814 __ Bind(¬_heap_number); |
| 2815 |
| 2816 __ Jump(masm->isolate()->builtins()->NonNumberToNumber(), |
| 2817 RelocInfo::CODE_TARGET); |
| 2818 } |
| 2819 |
| 2820 // static |
| 2821 void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) { |
| 2822 // The NonNumberToNumber stub takes one argument in x0. |
| 2823 __ AssertNotNumber(x0); |
| 2824 |
| 2825 Label not_string; |
| 2826 __ CompareObjectType(x0, x1, x1, FIRST_NONSTRING_TYPE); |
| 2827 // x0: receiver |
| 2828 // x1: receiver instance type |
| 2829 __ B(hs, ¬_string); |
| 2830 __ Jump(masm->isolate()->builtins()->StringToNumber(), |
| 2831 RelocInfo::CODE_TARGET); |
| 2832 __ Bind(¬_string); |
| 2833 |
| 2834 Label not_oddball; |
| 2835 __ Cmp(x1, ODDBALL_TYPE); |
| 2836 __ B(ne, ¬_oddball); |
| 2837 __ Ldr(x0, FieldMemOperand(x0, Oddball::kToNumberOffset)); |
| 2838 __ Ret(); |
| 2839 __ Bind(¬_oddball); |
| 2840 |
| 2841 __ Push(x0); // Push argument. |
| 2842 __ TailCallRuntime(Runtime::kToNumber); |
| 2843 } |
| 2844 |
2802 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 2845 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
2803 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); | 2846 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); |
2804 // ----------- S t a t e ------------- | 2847 // ----------- S t a t e ------------- |
2805 // -- x0 : actual number of arguments | 2848 // -- x0 : actual number of arguments |
2806 // -- x1 : function (passed through to callee) | 2849 // -- x1 : function (passed through to callee) |
2807 // -- x2 : expected number of arguments | 2850 // -- x2 : expected number of arguments |
2808 // -- x3 : new target (passed through to callee) | 2851 // -- x3 : new target (passed through to callee) |
2809 // ----------------------------------- | 2852 // ----------------------------------- |
2810 | 2853 |
2811 Register argc_actual = x0; // Excluding the receiver. | 2854 Register argc_actual = x0; // Excluding the receiver. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2944 } | 2987 } |
2945 } | 2988 } |
2946 | 2989 |
2947 | 2990 |
2948 #undef __ | 2991 #undef __ |
2949 | 2992 |
2950 } // namespace internal | 2993 } // namespace internal |
2951 } // namespace v8 | 2994 } // namespace v8 |
2952 | 2995 |
2953 #endif // V8_TARGET_ARCH_ARM | 2996 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |