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 __ Add(x4, x0, 1); |
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(x0, x0, 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(x0, 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 ToNumber builtin if necessary. | 175 // parameter to a number first using the ToNumber builtin 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 ToNumber builtin to convert it. | 180 // Parameter is not a Number, use the ToNumber builtin 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 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | 189 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
185 __ Mov(x2, x0); | 190 __ Mov(x2, x0); |
186 __ Pop(x4, x1, x0); | 191 __ Pop(x4, x5, x0); |
187 { | 192 { |
188 // Restore the double accumulator value (d1). | 193 // Restore the double accumulator value (d5). |
189 Label done_restore; | 194 Label done_restore; |
190 __ SmiUntagToDouble(d1, x1, kSpeculativeUntag); | 195 __ SmiUntagToDouble(d5, x5, kSpeculativeUntag); |
191 __ JumpIfSmi(x1, &done_restore); | 196 __ JumpIfSmi(x5, &done_restore); |
192 __ Ldr(d1, FieldMemOperand(x1, HeapNumber::kValueOffset)); | 197 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset)); |
193 __ Bind(&done_restore); | 198 __ Bind(&done_restore); |
194 } | 199 } |
195 __ SmiUntag(x4); | 200 __ SmiUntag(x4); |
196 __ SmiUntag(x0); | 201 __ SmiUntag(x0); |
| 202 __ Pop(x1, cp, fp, lr); |
197 } | 203 } |
198 __ AssertNumber(x2); | 204 __ AssertNumber(x2); |
199 __ JumpIfSmi(x2, &convert_smi); | 205 __ JumpIfSmi(x2, &convert_smi); |
200 | 206 |
201 __ Bind(&convert_number); | 207 __ Bind(&convert_number); |
202 __ Ldr(d2, FieldMemOperand(x2, HeapNumber::kValueOffset)); | 208 __ Ldr(d2, FieldMemOperand(x2, HeapNumber::kValueOffset)); |
203 __ B(&done_convert); | 209 __ B(&done_convert); |
204 | 210 |
205 __ Bind(&convert_smi); | 211 __ Bind(&convert_smi); |
206 __ SmiUntagToDouble(d2, x2); | 212 __ SmiUntagToDouble(d2, x2); |
207 __ Bind(&done_convert); | 213 __ Bind(&done_convert); |
208 | 214 |
209 // We can use a single fmin/fmax for the operation itself, but we then need | 215 // We can use a single fmin/fmax for the operation itself, but we then need |
210 // to work out which HeapNumber (or smi) the result came from. | 216 // to work out which HeapNumber (or smi) the result came from. |
211 __ Fmov(x11, d1); | 217 __ Fmov(x11, d5); |
212 if (kind == MathMaxMinKind::kMin) { | 218 if (kind == MathMaxMinKind::kMin) { |
213 __ Fmin(d1, d1, d2); | 219 __ Fmin(d5, d5, d2); |
214 } else { | 220 } else { |
215 DCHECK(kind == MathMaxMinKind::kMax); | 221 DCHECK(kind == MathMaxMinKind::kMax); |
216 __ Fmax(d1, d1, d2); | 222 __ Fmax(d5, d5, d2); |
217 } | 223 } |
218 __ Fmov(x10, d1); | 224 __ Fmov(x10, d5); |
219 __ Cmp(x10, x11); | 225 __ Cmp(x10, x11); |
220 __ Csel(x1, x1, x2, eq); | 226 __ Csel(x5, x5, x2, eq); |
221 __ B(&loop); | 227 __ B(&loop); |
222 } | 228 } |
223 | 229 |
224 __ Bind(&done_loop); | 230 __ Bind(&done_loop); |
225 __ Mov(x0, x1); | |
226 __ Drop(x4); | 231 __ Drop(x4); |
| 232 __ Mov(x0, x5); |
227 __ Ret(); | 233 __ Ret(); |
228 } | 234 } |
229 | 235 |
230 // static | 236 // static |
231 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 237 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
232 // ----------- S t a t e ------------- | 238 // ----------- S t a t e ------------- |
233 // -- x0 : number of arguments | 239 // -- x0 : number of arguments |
234 // -- x1 : constructor function | 240 // -- x1 : constructor function |
235 // -- lr : return address | 241 // -- lr : return address |
236 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 242 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
(...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 } | 2994 } |
2989 } | 2995 } |
2990 | 2996 |
2991 | 2997 |
2992 #undef __ | 2998 #undef __ |
2993 | 2999 |
2994 } // namespace internal | 3000 } // namespace internal |
2995 } // namespace v8 | 3001 } // namespace v8 |
2996 | 3002 |
2997 #endif // V8_TARGET_ARCH_ARM | 3003 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |