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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 __ Mov(x3, x1); | 134 __ Mov(x3, x1); |
135 ArrayConstructorStub stub(masm->isolate()); | 135 ArrayConstructorStub stub(masm->isolate()); |
136 __ TailCallStub(&stub); | 136 __ TailCallStub(&stub); |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 // static | 140 // static |
141 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 141 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
142 // ----------- S t a t e ------------- | 142 // ----------- S t a t e ------------- |
143 // -- x0 : number of arguments | 143 // -- x0 : number of arguments |
| 144 // -- x1 : function |
| 145 // -- cp : context |
144 // -- lr : return address | 146 // -- lr : return address |
145 // -- sp[(argc - n) * 8] : arg[n] (zero-based) | 147 // -- sp[(argc - n) * 8] : arg[n] (zero-based) |
146 // -- sp[(argc + 1) * 8] : receiver | 148 // -- sp[(argc + 1) * 8] : receiver |
147 // ----------------------------------- | 149 // ----------------------------------- |
148 ASM_LOCATION("Builtins::Generate_MathMaxMin"); | 150 ASM_LOCATION("Builtins::Generate_MathMaxMin"); |
149 | 151 |
150 Heap::RootListIndex const root_index = | 152 Heap::RootListIndex const root_index = |
151 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 153 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
152 : Heap::kMinusInfinityValueRootIndex; | 154 : Heap::kMinusInfinityValueRootIndex; |
153 | 155 |
154 // Load the accumulator with the default return value (either -Infinity or | 156 // Load the accumulator with the default return value (either -Infinity or |
155 // +Infinity), with the tagged value in x1 and the double value in d1. | 157 // +Infinity), with the tagged value in x5 and the double value in d5. |
156 __ LoadRoot(x1, root_index); | 158 __ LoadRoot(x5, root_index); |
157 __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); | 159 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); |
158 | 160 |
159 // Remember how many slots to drop (including the receiver). | 161 // Remember how many slots to drop (including the receiver). |
160 __ Add(x4, x0, 1); | 162 __ Mov(x4, x0); |
161 | 163 |
162 Label done_loop, loop; | 164 Label done_loop, loop; |
163 __ Bind(&loop); | 165 __ Bind(&loop); |
164 { | 166 { |
165 // Check if all parameters done. | 167 // Check if all parameters done. |
166 __ Subs(x0, x0, 1); | 168 __ Subs(x4, x4, 1); |
167 __ B(lt, &done_loop); | 169 __ B(lt, &done_loop); |
168 | 170 |
169 // Load the next parameter tagged value into x2. | 171 // Load the next parameter tagged value into x2. |
170 __ Peek(x2, Operand(x0, LSL, kPointerSizeLog2)); | 172 __ Peek(x2, Operand(x4, LSL, kPointerSizeLog2)); |
171 | 173 |
172 // Load the double value of the parameter into d2, maybe converting the | 174 // Load the double value of the parameter into d2, maybe converting the |
173 // parameter to a number first using the ToNumberStub if necessary. | 175 // parameter to a number first using the ToNumberStub if necessary. |
174 Label convert_smi, convert_number, done_convert; | 176 Label convert_smi, convert_number, done_convert; |
175 __ JumpIfSmi(x2, &convert_smi); | 177 __ JumpIfSmi(x2, &convert_smi); |
176 __ JumpIfHeapNumber(x2, &convert_number); | 178 __ JumpIfHeapNumber(x2, &convert_number); |
177 { | 179 { |
178 // Parameter is not a Number, use the ToNumberStub to convert it. | 180 // Parameter is not a Number, use the ToNumberStub to convert it. |
179 FrameScope scope(masm, StackFrame::INTERNAL); | 181 FrameScope scope(masm, StackFrame::MANUAL); |
| 182 __ Push(lr, fp); |
| 183 __ Move(fp, jssp); |
| 184 __ Push(cp, x1); |
180 __ SmiTag(x0); | 185 __ SmiTag(x0); |
181 __ SmiTag(x4); | 186 __ SmiTag(x4); |
182 __ Push(x0, x1, x4); | 187 __ Push(x0, x5, x4); |
183 __ Mov(x0, x2); | 188 __ Mov(x0, x2); |
184 ToNumberStub stub(masm->isolate()); | 189 ToNumberStub stub(masm->isolate()); |
185 __ CallStub(&stub); | 190 __ CallStub(&stub); |
186 __ Mov(x2, x0); | 191 __ Mov(x2, x0); |
187 __ Pop(x4, x1, x0); | 192 __ Pop(x4, x5, x0); |
188 { | 193 { |
189 // Restore the double accumulator value (d1). | 194 // Restore the double accumulator value (d5). |
190 Label done_restore; | 195 Label done_restore; |
191 __ SmiUntagToDouble(d1, x1, kSpeculativeUntag); | 196 __ SmiUntagToDouble(d5, x5, kSpeculativeUntag); |
192 __ JumpIfSmi(x1, &done_restore); | 197 __ JumpIfSmi(x5, &done_restore); |
193 __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); | 198 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); |
194 __ Bind(&done_restore); | 199 __ Bind(&done_restore); |
195 } | 200 } |
196 __ SmiUntag(x4); | 201 __ SmiUntag(x4); |
197 __ SmiUntag(x0); | 202 __ SmiUntag(x0); |
| 203 __ Pop(x1, cp, fp, lr); |
198 } | 204 } |
199 __ AssertNumber(x2); | 205 __ AssertNumber(x2); |
200 __ JumpIfSmi(x2, &convert_smi); | 206 __ JumpIfSmi(x2, &convert_smi); |
201 | 207 |
202 __ Bind(&convert_number); | 208 __ Bind(&convert_number); |
203 __ Ldr(d2, FieldMemOperand(x2, HeapNumber::kValueOffset)); | 209 __ Ldr(d2, FieldMemOperand(x2, HeapNumber::kValueOffset)); |
204 __ B(&done_convert); | 210 __ B(&done_convert); |
205 | 211 |
206 __ Bind(&convert_smi); | 212 __ Bind(&convert_smi); |
207 __ SmiUntagToDouble(d2, x2); | 213 __ SmiUntagToDouble(d2, x2); |
208 __ Bind(&done_convert); | 214 __ Bind(&done_convert); |
209 | 215 |
210 // We can use a single fmin/fmax for the operation itself, but we then need | 216 // We can use a single fmin/fmax for the operation itself, but we then need |
211 // to work out which HeapNumber (or smi) the result came from. | 217 // to work out which HeapNumber (or smi) the result came from. |
212 __ Fmov(x11, d1); | 218 __ Fmov(x11, d5); |
213 if (kind == MathMaxMinKind::kMin) { | 219 if (kind == MathMaxMinKind::kMin) { |
214 __ Fmin(d1, d1, d2); | 220 __ Fmin(d5, d5, d2); |
215 } else { | 221 } else { |
216 DCHECK(kind == MathMaxMinKind::kMax); | 222 DCHECK(kind == MathMaxMinKind::kMax); |
217 __ Fmax(d1, d1, d2); | 223 __ Fmax(d5, d5, d2); |
218 } | 224 } |
219 __ Fmov(x10, d1); | 225 __ Fmov(x10, d5); |
220 __ Cmp(x10, x11); | 226 __ Cmp(x10, x11); |
221 __ Csel(x1, x1, x2, eq); | 227 __ Csel(x5, x5, x2, eq); |
222 __ B(&loop); | 228 __ B(&loop); |
223 } | 229 } |
224 | 230 |
225 __ Bind(&done_loop); | 231 __ Bind(&done_loop); |
226 __ Mov(x0, x1); | |
227 __ Drop(x4); | 232 __ Drop(x4); |
| 233 __ Drop(1); |
| 234 __ Mov(x0, x5); |
228 __ Ret(); | 235 __ Ret(); |
229 } | 236 } |
230 | 237 |
231 // static | 238 // static |
232 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 239 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
233 // ----------- S t a t e ------------- | 240 // ----------- S t a t e ------------- |
234 // -- x0 : number of arguments | 241 // -- x0 : number of arguments |
235 // -- x1 : constructor function | 242 // -- x1 : constructor function |
236 // -- lr : return address | 243 // -- lr : return address |
237 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 244 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
(...skipping 2648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2886 } | 2893 } |
2887 } | 2894 } |
2888 | 2895 |
2889 | 2896 |
2890 #undef __ | 2897 #undef __ |
2891 | 2898 |
2892 } // namespace internal | 2899 } // namespace internal |
2893 } // namespace v8 | 2900 } // namespace v8 |
2894 | 2901 |
2895 #endif // V8_TARGET_ARCH_ARM | 2902 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |