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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 | 142 |
143 // static | 143 // static |
144 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 144 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
145 // ----------- S t a t e ------------- | 145 // ----------- S t a t e ------------- |
146 // -- a0 : number of arguments | 146 // -- a0 : number of arguments |
147 // -- ra : return address | 147 // -- ra : return address |
148 // -- sp[(argc - n) * 8] : arg[n] (zero-based) | 148 // -- sp[(argc - n) * 8] : arg[n] (zero-based) |
149 // -- sp[(argc + 1) * 8] : receiver | 149 // -- sp[(argc + 1) * 8] : receiver |
150 // ----------------------------------- | 150 // ----------------------------------- |
151 Condition const cc = (kind == MathMaxMinKind::kMin) ? ge : le; | |
152 Heap::RootListIndex const root_index = | 151 Heap::RootListIndex const root_index = |
153 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 152 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
154 : Heap::kMinusInfinityValueRootIndex; | 153 : Heap::kMinusInfinityValueRootIndex; |
155 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? f2 : f0; | |
156 | 154 |
157 // Load the accumulator with the default return value (either -Infinity or | 155 // Load the accumulator with the default return value (either -Infinity or |
158 // +Infinity), with the tagged value in a1 and the double value in f0. | 156 // +Infinity), with the tagged value in a1 and the double value in f0. |
159 __ LoadRoot(a1, root_index); | 157 __ LoadRoot(a1, root_index); |
160 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 158 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
161 __ mov(a3, a0); | 159 __ Addu(a3, a0, 1); |
162 | 160 |
163 Label done_loop, loop; | 161 Label done_loop, loop; |
164 __ bind(&loop); | 162 __ bind(&loop); |
165 { | 163 { |
166 // Check if all parameters done. | 164 // Check if all parameters done. |
167 __ Dsubu(a0, a0, Operand(1)); | 165 __ Dsubu(a0, a0, Operand(1)); |
168 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); | 166 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); |
169 | 167 |
170 // Load the next parameter tagged value into a2. | 168 // Load the next parameter tagged value into a2. |
171 __ Dlsa(at, sp, a0, kPointerSizeLog2); | 169 __ Dlsa(at, sp, a0, kPointerSizeLog2); |
172 __ ld(a2, MemOperand(at)); | 170 __ ld(a2, MemOperand(at)); |
173 | 171 |
174 // Load the double value of the parameter into f2, maybe converting the | 172 // Load the double value of the parameter into f2, maybe converting the |
175 // parameter to a number first using the ToNumberStub if necessary. | 173 // parameter to a number first using the ToNumberStub if necessary. |
176 Label convert, convert_smi, convert_number, done_convert; | 174 Label convert, convert_smi, convert_number, done_convert; |
177 __ bind(&convert); | 175 __ bind(&convert); |
178 __ JumpIfSmi(a2, &convert_smi); | 176 __ JumpIfSmi(a2, &convert_smi); |
179 __ ld(a4, FieldMemOperand(a2, HeapObject::kMapOffset)); | 177 __ ld(a4, FieldMemOperand(a2, HeapObject::kMapOffset)); |
180 __ JumpIfRoot(a4, Heap::kHeapNumberMapRootIndex, &convert_number); | 178 __ JumpIfRoot(a4, Heap::kHeapNumberMapRootIndex, &convert_number); |
181 { | 179 { |
182 // Parameter is not a Number, use the ToNumberStub to convert it. | 180 // Parameter is not a Number, use the ToNumberStub to convert it. |
183 FrameScope scope(masm, StackFrame::INTERNAL); | 181 FrameScope scope(masm, StackFrame::INTERNAL); |
184 __ SmiTag(a0); | |
185 __ SmiTag(a3); | |
186 __ Push(a0, a1, a3); | 182 __ Push(a0, a1, a3); |
187 __ mov(a0, a2); | 183 __ mov(a0, a2); |
188 ToNumberStub stub(masm->isolate()); | 184 ToNumberStub stub(masm->isolate()); |
189 __ CallStub(&stub); | 185 __ CallStub(&stub); |
190 __ mov(a2, v0); | 186 __ mov(a2, v0); |
191 __ Pop(a0, a1, a3); | 187 __ Pop(a0, a1, a3); |
192 { | 188 { |
193 // Restore the double accumulator value (f0). | 189 // Restore the double accumulator value (f0). |
194 Label restore_smi, done_restore; | 190 Label restore_smi, done_restore; |
195 __ JumpIfSmi(a1, &restore_smi); | 191 __ JumpIfSmi(a1, &restore_smi); |
196 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 192 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
197 __ jmp(&done_restore); | 193 __ jmp(&done_restore); |
198 __ bind(&restore_smi); | 194 __ bind(&restore_smi); |
199 __ SmiToDoubleFPURegister(a1, f0, a4); | 195 __ SmiToDoubleFPURegister(a1, f0, a4); |
200 __ bind(&done_restore); | 196 __ bind(&done_restore); |
201 } | 197 } |
202 __ SmiUntag(a3); | |
203 __ SmiUntag(a0); | |
204 } | 198 } |
205 __ jmp(&convert); | 199 __ jmp(&convert); |
206 __ bind(&convert_number); | 200 __ bind(&convert_number); |
207 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); | 201 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); |
208 __ jmp(&done_convert); | 202 __ jmp(&done_convert); |
209 __ bind(&convert_smi); | 203 __ bind(&convert_smi); |
210 __ SmiToDoubleFPURegister(a2, f2, a4); | 204 __ SmiToDoubleFPURegister(a2, f2, a4); |
211 __ bind(&done_convert); | 205 __ bind(&done_convert); |
212 | 206 |
213 // Perform the actual comparison with the accumulator value on the left hand | 207 // Perform the actual comparison with using Min/Max macro instructions the |
214 // side (f0) and the next parameter value on the right hand side (f2). | 208 // accumulator value on the left hand side (f0) and the next parameter value |
215 Label compare_equal, compare_nan, compare_swap; | 209 // on the right hand side (f2). |
216 __ BranchF(&compare_equal, &compare_nan, eq, f0, f2); | 210 // We need to work out which HeapNumber (or smi) the result came from. |
217 __ BranchF(&compare_swap, nullptr, cc, f0, f2); | 211 Label compare_nan; |
218 __ Branch(&loop); | 212 __ BranchF(nullptr, &compare_nan, eq, f0, f2); |
219 | 213 __ Move(a4, f0); |
220 // Left and right hand side are equal, check for -0 vs. +0. | 214 if (kind == MathMaxMinKind::kMin) { |
221 __ bind(&compare_equal); | 215 __ MinNaNCheck_d(f0, f0, f2); |
222 __ FmoveHigh(a4, reg); | 216 } else { |
223 // Make a4 unsigned. | 217 DCHECK(kind == MathMaxMinKind::kMax); |
224 __ dsll32(a4, a4, 0); | 218 __ MaxNaNCheck_d(f0, f0, f2); |
225 __ Branch(&loop, ne, a4, Operand(0x8000000000000000)); | 219 } |
226 | 220 __ Move(at, f0); |
227 // Result is on the right hand side. | 221 __ Branch(&loop, eq, a4, Operand(at)); |
228 __ bind(&compare_swap); | |
229 __ mov_d(f0, f2); | |
230 __ mov(a1, a2); | 222 __ mov(a1, a2); |
231 __ jmp(&loop); | 223 __ jmp(&loop); |
232 | 224 |
233 // At least one side is NaN, which means that the result will be NaN too. | 225 // At least one side is NaN, which means that the result will be NaN too. |
234 __ bind(&compare_nan); | 226 __ bind(&compare_nan); |
235 __ LoadRoot(a1, Heap::kNanValueRootIndex); | 227 __ LoadRoot(a1, Heap::kNanValueRootIndex); |
236 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 228 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
237 __ jmp(&loop); | 229 __ jmp(&loop); |
238 } | 230 } |
239 | 231 |
240 __ bind(&done_loop); | 232 __ bind(&done_loop); |
241 __ Dlsa(sp, sp, a3, kPointerSizeLog2); | 233 __ Dlsa(sp, sp, a3, kPointerSizeLog2); |
242 __ mov(v0, a1); | 234 __ Ret(USE_DELAY_SLOT); |
243 __ DropAndRet(1); | 235 __ mov(v0, a1); // In delay slot. |
244 } | 236 } |
245 | 237 |
246 // static | 238 // static |
247 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 239 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
248 // ----------- S t a t e ------------- | 240 // ----------- S t a t e ------------- |
249 // -- a0 : number of arguments | 241 // -- a0 : number of arguments |
250 // -- a1 : constructor function | 242 // -- a1 : constructor function |
251 // -- ra : return address | 243 // -- ra : return address |
252 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 244 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
253 // -- sp[argc * 8] : receiver | 245 // -- sp[argc * 8] : receiver |
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2585 } | 2577 } |
2586 } | 2578 } |
2587 | 2579 |
2588 | 2580 |
2589 #undef __ | 2581 #undef __ |
2590 | 2582 |
2591 } // namespace internal | 2583 } // namespace internal |
2592 } // namespace v8 | 2584 } // namespace v8 |
2593 | 2585 |
2594 #endif // V8_TARGET_ARCH_MIPS64 | 2586 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |