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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Run the native code for the Array function called as a normal function. | 134 // Run the native code for the Array function called as a normal function. |
135 // Tail call a stub. | 135 // Tail call a stub. |
136 __ mov(a3, a1); | 136 __ mov(a3, a1); |
137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
138 ArrayConstructorStub stub(masm->isolate()); | 138 ArrayConstructorStub stub(masm->isolate()); |
139 __ TailCallStub(&stub); | 139 __ TailCallStub(&stub); |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 // static | 143 // static |
| 144 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
| 145 // ----------- S t a t e ------------- |
| 146 // -- a0 : number of arguments |
| 147 // -- ra : return address |
| 148 // -- sp[(argc - n) * 8] : arg[n] (zero-based) |
| 149 // -- sp[(argc + 1) * 8] : receiver |
| 150 // ----------------------------------- |
| 151 Condition const cc = (kind == MathMaxMinKind::kMin) ? ge : le; |
| 152 Heap::RootListIndex const root_index = |
| 153 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
| 154 : Heap::kMinusInfinityValueRootIndex; |
| 155 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? f2 : f0; |
| 156 |
| 157 // 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. |
| 159 __ LoadRoot(a1, root_index); |
| 160 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
| 161 __ mov(a3, a0); |
| 162 |
| 163 Label done_loop, loop; |
| 164 __ bind(&loop); |
| 165 { |
| 166 // Check if all parameters done. |
| 167 __ Dsubu(a0, a0, Operand(1)); |
| 168 __ Branch(USE_DELAY_SLOT, &done_loop, lt, a0, Operand(zero_reg)); |
| 169 |
| 170 // Load the next parameter tagged value into a2. |
| 171 __ dsll(at, a0, kPointerSizeLog2); // In delay slot |
| 172 __ Daddu(at, at, sp); |
| 173 __ ld(a2, MemOperand(at)); |
| 174 |
| 175 // Load the double value of the parameter into f2, maybe converting the |
| 176 // parameter to a number first using the ToNumberStub if necessary. |
| 177 Label convert, convert_smi, convert_number, done_convert; |
| 178 __ bind(&convert); |
| 179 __ JumpIfSmi(a2, &convert_smi); |
| 180 __ ld(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); |
| 181 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); |
| 182 { |
| 183 // Parameter is not a Number, use the ToNumberStub to convert it. |
| 184 FrameScope scope(masm, StackFrame::INTERNAL); |
| 185 __ SmiTag(a0); |
| 186 __ SmiTag(a3); |
| 187 __ Push(a0, a1, a3); |
| 188 __ mov(a0, a2); |
| 189 ToNumberStub stub(masm->isolate()); |
| 190 __ CallStub(&stub); |
| 191 __ mov(a2, v0); |
| 192 __ Pop(a0, a1, a3); |
| 193 { |
| 194 // Restore the double accumulator value (f0). |
| 195 Label restore_smi, done_restore; |
| 196 __ JumpIfSmi(a1, &restore_smi); |
| 197 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
| 198 __ jmp(&done_restore); |
| 199 __ bind(&restore_smi); |
| 200 __ SmiToDoubleFPURegister(a1, f0, t0); |
| 201 __ bind(&done_restore); |
| 202 } |
| 203 __ SmiUntag(a3); |
| 204 __ SmiUntag(a0); |
| 205 } |
| 206 __ jmp(&convert); |
| 207 __ bind(&convert_number); |
| 208 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); |
| 209 __ jmp(&done_convert); |
| 210 __ bind(&convert_smi); |
| 211 __ SmiToDoubleFPURegister(a2, f2, t0); |
| 212 __ bind(&done_convert); |
| 213 |
| 214 // Perform the actual comparison with the accumulator value on the left hand |
| 215 // side (d1) and the next parameter value on the right hand side (d2). |
| 216 Label compare_equal, compare_nan, compare_swap; |
| 217 __ BranchF(&compare_equal, &compare_nan, eq, f0, f2); |
| 218 __ BranchF(&compare_swap, nullptr, cc, f0, f2); |
| 219 __ Branch(&loop); |
| 220 |
| 221 // Left and right hand side are equal, check for -0 vs. +0. |
| 222 __ bind(&compare_equal); |
| 223 __ FmoveHigh(t0, reg); |
| 224 __ Branch(&loop, ne, t0, Operand(0x80000000)); |
| 225 |
| 226 // Result is on the right hand side. |
| 227 __ bind(&compare_swap); |
| 228 __ mov_d(f0, f2); |
| 229 __ mov(a1, a2); |
| 230 __ jmp(&loop); |
| 231 |
| 232 // At least one side is NaN, which means that the result will be NaN too. |
| 233 __ bind(&compare_nan); |
| 234 __ LoadRoot(a1, Heap::kNanValueRootIndex); |
| 235 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); |
| 236 __ jmp(&loop); |
| 237 } |
| 238 |
| 239 __ bind(&done_loop); |
| 240 __ dsll(a3, a3, kPointerSizeLog2); |
| 241 __ Daddu(sp, sp, a3); |
| 242 __ mov(v0, a1); |
| 243 __ DropAndRet(1); |
| 244 } |
| 245 |
| 246 // static |
144 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 247 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
145 // ----------- S t a t e ------------- | 248 // ----------- S t a t e ------------- |
146 // -- a0 : number of arguments | 249 // -- a0 : number of arguments |
147 // -- a1 : constructor function | 250 // -- a1 : constructor function |
148 // -- ra : return address | 251 // -- ra : return address |
149 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 252 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
150 // -- sp[argc * 8] : receiver | 253 // -- sp[argc * 8] : receiver |
151 // ----------------------------------- | 254 // ----------------------------------- |
152 | 255 |
153 // 1. Load the first argument into a0 and get rid of the rest (including the | 256 // 1. Load the first argument into a0 and get rid of the rest (including the |
(...skipping 2513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 } | 2770 } |
2668 } | 2771 } |
2669 | 2772 |
2670 | 2773 |
2671 #undef __ | 2774 #undef __ |
2672 | 2775 |
2673 } // namespace internal | 2776 } // namespace internal |
2674 } // namespace v8 | 2777 } // namespace v8 |
2675 | 2778 |
2676 #endif // V8_TARGET_ARCH_MIPS64 | 2779 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |