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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 138 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
139 ArrayConstructorStub stub(masm->isolate()); | 139 ArrayConstructorStub stub(masm->isolate()); |
140 __ TailCallStub(&stub); | 140 __ TailCallStub(&stub); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 // static | 144 // static |
145 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 145 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
146 // ----------- S t a t e ------------- | 146 // ----------- S t a t e ------------- |
147 // -- a0 : number of arguments | 147 // -- a0 : number of arguments |
| 148 // -- a1 : function |
| 149 // -- cp : context |
148 // -- ra : return address | 150 // -- ra : return address |
149 // -- sp[(argc - n) * 8] : arg[n] (zero-based) | 151 // -- sp[(argc - n) * 8] : arg[n] (zero-based) |
150 // -- sp[(argc + 1) * 8] : receiver | 152 // -- sp[(argc + 1) * 8] : receiver |
151 // ----------------------------------- | 153 // ----------------------------------- |
152 Heap::RootListIndex const root_index = | 154 Heap::RootListIndex const root_index = |
153 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 155 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
154 : Heap::kMinusInfinityValueRootIndex; | 156 : Heap::kMinusInfinityValueRootIndex; |
155 | 157 |
156 // Load the accumulator with the default return value (either -Infinity or | 158 // Load the accumulator with the default return value (either -Infinity or |
157 // +Infinity), with the tagged value in a1 and the double value in f0. | 159 // +Infinity), with the tagged value in t1 and the double value in f0. |
158 __ LoadRoot(a1, root_index); | 160 __ LoadRoot(t1, root_index); |
159 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 161 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); |
160 __ Addu(a3, a0, Operand(1)); | 162 __ mov(a3, a0); |
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 __ Subu(a0, a0, Operand(1)); | 168 __ Subu(a0, a0, Operand(1)); |
167 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); | 169 __ Branch(&done_loop, lt, a0, Operand(zero_reg)); |
168 | 170 |
169 // Load the next parameter tagged value into a2. | 171 // Load the next parameter tagged value into a2. |
170 __ Lsa(at, sp, a0, kPointerSizeLog2); | 172 __ Lsa(at, sp, a0, kPointerSizeLog2); |
171 __ lw(a2, MemOperand(at)); | 173 __ lw(a2, MemOperand(at)); |
172 | 174 |
173 // Load the double value of the parameter into f2, maybe converting the | 175 // Load the double value of the parameter into f2, maybe converting the |
174 // parameter to a number first using the ToNumberStub if necessary. | 176 // parameter to a number first using the ToNumberStub if necessary. |
175 Label convert, convert_smi, convert_number, done_convert; | 177 Label convert, convert_smi, convert_number, done_convert; |
176 __ bind(&convert); | 178 __ bind(&convert); |
177 __ JumpIfSmi(a2, &convert_smi); | 179 __ JumpIfSmi(a2, &convert_smi); |
178 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); | 180 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); |
179 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); | 181 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); |
180 { | 182 { |
181 // Parameter is not a Number, use the ToNumberStub to convert it. | 183 // Parameter is not a Number, use the ToNumberStub to convert it. |
182 FrameScope scope(masm, StackFrame::INTERNAL); | 184 FrameScope scope(masm, StackFrame::MANUAL); |
| 185 __ Push(ra, fp); |
| 186 __ Move(fp, sp); |
| 187 __ Push(cp, a1); |
183 __ SmiTag(a0); | 188 __ SmiTag(a0); |
184 __ SmiTag(a3); | 189 __ SmiTag(a3); |
185 __ Push(a0, a1, a3); | 190 __ Push(a0, t1, a3); |
186 __ mov(a0, a2); | 191 __ mov(a0, a2); |
187 ToNumberStub stub(masm->isolate()); | 192 ToNumberStub stub(masm->isolate()); |
188 __ CallStub(&stub); | 193 __ CallStub(&stub); |
189 __ mov(a2, v0); | 194 __ mov(a2, v0); |
190 __ Pop(a0, a1, a3); | 195 __ Pop(a0, t1, a3); |
191 { | 196 { |
192 // Restore the double accumulator value (f0). | 197 // Restore the double accumulator value (f0). |
193 Label restore_smi, done_restore; | 198 Label restore_smi, done_restore; |
194 __ JumpIfSmi(a1, &restore_smi); | 199 __ JumpIfSmi(t1, &restore_smi); |
195 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 200 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); |
196 __ jmp(&done_restore); | 201 __ jmp(&done_restore); |
197 __ bind(&restore_smi); | 202 __ bind(&restore_smi); |
198 __ SmiToDoubleFPURegister(a1, f0, t0); | 203 __ SmiToDoubleFPURegister(t1, f0, t0); |
199 __ bind(&done_restore); | 204 __ bind(&done_restore); |
200 } | 205 } |
201 __ SmiUntag(a3); | 206 __ SmiUntag(a3); |
202 __ SmiUntag(a0); | 207 __ SmiUntag(a0); |
| 208 __ Pop(cp, a1); |
| 209 __ Pop(ra, fp); |
203 } | 210 } |
204 __ jmp(&convert); | 211 __ jmp(&convert); |
205 __ bind(&convert_number); | 212 __ bind(&convert_number); |
206 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); | 213 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); |
207 __ jmp(&done_convert); | 214 __ jmp(&done_convert); |
208 __ bind(&convert_smi); | 215 __ bind(&convert_smi); |
209 __ SmiToDoubleFPURegister(a2, f2, t0); | 216 __ SmiToDoubleFPURegister(a2, f2, t0); |
210 __ bind(&done_convert); | 217 __ bind(&done_convert); |
211 | 218 |
212 // Perform the actual comparison with using Min/Max macro instructions the | 219 // Perform the actual comparison with using Min/Max macro instructions the |
213 // accumulator value on the left hand side (f0) and the next parameter value | 220 // accumulator value on the left hand side (f0) and the next parameter value |
214 // on the right hand side (f2). | 221 // on the right hand side (f2). |
215 // We need to work out which HeapNumber (or smi) the result came from. | 222 // We need to work out which HeapNumber (or smi) the result came from. |
216 Label compare_nan, set_value; | 223 Label compare_nan, set_value; |
217 __ BranchF(nullptr, &compare_nan, eq, f0, f2); | 224 __ BranchF(nullptr, &compare_nan, eq, f0, f2); |
218 __ Move(t0, t1, f0); | 225 __ Move(t0, t1, f0); |
219 if (kind == MathMaxMinKind::kMin) { | 226 if (kind == MathMaxMinKind::kMin) { |
220 __ MinNaNCheck_d(f0, f0, f2); | 227 __ MinNaNCheck_d(f0, f0, f2); |
221 } else { | 228 } else { |
222 DCHECK(kind == MathMaxMinKind::kMax); | 229 DCHECK(kind == MathMaxMinKind::kMax); |
223 __ MaxNaNCheck_d(f0, f0, f2); | 230 __ MaxNaNCheck_d(f0, f0, f2); |
224 } | 231 } |
225 __ Move(at, t8, f0); | 232 __ Move(at, t8, f0); |
226 __ Branch(&set_value, ne, t0, Operand(at)); | 233 __ Branch(&set_value, ne, t0, Operand(at)); |
227 __ Branch(&set_value, ne, t1, Operand(t8)); | 234 __ Branch(&set_value, ne, t1, Operand(t8)); |
228 __ jmp(&loop); | 235 __ jmp(&loop); |
229 __ bind(&set_value); | 236 __ bind(&set_value); |
230 __ mov(a1, a2); | 237 __ mov(t1, a2); |
231 __ jmp(&loop); | 238 __ jmp(&loop); |
232 | 239 |
233 // At least one side is NaN, which means that the result will be NaN too. | 240 // At least one side is NaN, which means that the result will be NaN too. |
234 __ bind(&compare_nan); | 241 __ bind(&compare_nan); |
235 __ LoadRoot(a1, Heap::kNanValueRootIndex); | 242 __ LoadRoot(t1, Heap::kNanValueRootIndex); |
236 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset)); | 243 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); |
237 __ jmp(&loop); | 244 __ jmp(&loop); |
238 } | 245 } |
239 | 246 |
240 __ bind(&done_loop); | 247 __ bind(&done_loop); |
241 __ Lsa(sp, sp, a3, kPointerSizeLog2); | 248 __ Lsa(sp, sp, a3, kPointerSizeLog2); |
| 249 __ Addu(sp, sp, kPointerSize); |
242 __ Ret(USE_DELAY_SLOT); | 250 __ Ret(USE_DELAY_SLOT); |
243 __ mov(v0, a1); // In delay slot. | 251 __ mov(v0, t1); // In delay slot. |
244 } | 252 } |
245 | 253 |
246 // static | 254 // static |
247 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 255 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
248 // ----------- S t a t e ------------- | 256 // ----------- S t a t e ------------- |
249 // -- a0 : number of arguments | 257 // -- a0 : number of arguments |
250 // -- a1 : constructor function | 258 // -- a1 : constructor function |
251 // -- ra : return address | 259 // -- ra : return address |
252 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 260 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
253 // -- sp[argc * 4] : receiver | 261 // -- sp[argc * 4] : receiver |
(...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2857 } | 2865 } |
2858 } | 2866 } |
2859 | 2867 |
2860 | 2868 |
2861 #undef __ | 2869 #undef __ |
2862 | 2870 |
2863 } // namespace internal | 2871 } // namespace internal |
2864 } // namespace v8 | 2872 } // namespace v8 |
2865 | 2873 |
2866 #endif // V8_TARGET_ARCH_MIPS | 2874 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |