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