| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Run the native code for the Array function called as a normal function. | 115 // Run the native code for the Array function called as a normal function. |
| 116 // Tail call a stub. | 116 // Tail call a stub. |
| 117 __ mov(a3, a1); | 117 __ mov(a3, a1); |
| 118 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 118 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 119 ArrayConstructorStub stub(masm->isolate()); | 119 ArrayConstructorStub stub(masm->isolate()); |
| 120 __ TailCallStub(&stub); | 120 __ TailCallStub(&stub); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // static | 123 // static |
| 124 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | |
| 125 // ----------- S t a t e ------------- | |
| 126 // -- a0 : number of arguments | |
| 127 // -- a1 : function | |
| 128 // -- cp : context | |
| 129 // -- ra : return address | |
| 130 // -- sp[(argc - n - 1) * 4] : arg[n] (zero-based) | |
| 131 // -- sp[argc * 4] : receiver | |
| 132 // ----------------------------------- | |
| 133 Heap::RootListIndex const root_index = | |
| 134 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | |
| 135 : Heap::kMinusInfinityValueRootIndex; | |
| 136 | |
| 137 // Load the accumulator with the default return value (either -Infinity or | |
| 138 // +Infinity), with the tagged value in t2 and the double value in f0. | |
| 139 __ LoadRoot(t2, root_index); | |
| 140 __ ldc1(f0, FieldMemOperand(t2, HeapNumber::kValueOffset)); | |
| 141 | |
| 142 Label done_loop, loop, done; | |
| 143 __ mov(a3, a0); | |
| 144 __ bind(&loop); | |
| 145 { | |
| 146 // Check if all parameters done. | |
| 147 __ Subu(a3, a3, Operand(1)); | |
| 148 __ Branch(&done_loop, lt, a3, Operand(zero_reg)); | |
| 149 | |
| 150 // Load the next parameter tagged value into a2. | |
| 151 __ Lsa(at, sp, a3, kPointerSizeLog2); | |
| 152 __ lw(a2, MemOperand(at)); | |
| 153 | |
| 154 // Load the double value of the parameter into f2, maybe converting the | |
| 155 // parameter to a number first using the ToNumber builtin if necessary. | |
| 156 Label convert, convert_smi, convert_number, done_convert; | |
| 157 __ bind(&convert); | |
| 158 __ JumpIfSmi(a2, &convert_smi); | |
| 159 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset)); | |
| 160 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number); | |
| 161 { | |
| 162 // Parameter is not a Number, use the ToNumber builtin to convert it. | |
| 163 FrameScope scope(masm, StackFrame::MANUAL); | |
| 164 __ SmiTag(a0); | |
| 165 __ SmiTag(a3); | |
| 166 __ EnterBuiltinFrame(cp, a1, a0); | |
| 167 __ Push(t2, a3); | |
| 168 __ mov(a0, a2); | |
| 169 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | |
| 170 __ mov(a2, v0); | |
| 171 __ Pop(t2, a3); | |
| 172 __ LeaveBuiltinFrame(cp, a1, a0); | |
| 173 __ SmiUntag(a3); | |
| 174 __ SmiUntag(a0); | |
| 175 { | |
| 176 // Restore the double accumulator value (f0). | |
| 177 Label restore_smi, done_restore; | |
| 178 __ JumpIfSmi(t2, &restore_smi); | |
| 179 __ ldc1(f0, FieldMemOperand(t2, HeapNumber::kValueOffset)); | |
| 180 __ jmp(&done_restore); | |
| 181 __ bind(&restore_smi); | |
| 182 __ SmiToDoubleFPURegister(t2, f0, t0); | |
| 183 __ bind(&done_restore); | |
| 184 } | |
| 185 } | |
| 186 __ jmp(&convert); | |
| 187 __ bind(&convert_number); | |
| 188 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset)); | |
| 189 __ jmp(&done_convert); | |
| 190 __ bind(&convert_smi); | |
| 191 __ SmiToDoubleFPURegister(a2, f2, t0); | |
| 192 __ bind(&done_convert); | |
| 193 | |
| 194 // Perform the actual comparison with using Min/Max macro instructions the | |
| 195 // accumulator value on the left hand side (f0) and the next parameter value | |
| 196 // on the right hand side (f2). | |
| 197 // We need to work out which HeapNumber (or smi) the result came from. | |
| 198 Label compare_nan, set_value, ool_min, ool_max; | |
| 199 __ BranchF(nullptr, &compare_nan, eq, f0, f2); | |
| 200 __ Move(t0, t1, f0); | |
| 201 if (kind == MathMaxMinKind::kMin) { | |
| 202 __ Float64Min(f0, f0, f2, &ool_min); | |
| 203 } else { | |
| 204 DCHECK(kind == MathMaxMinKind::kMax); | |
| 205 __ Float64Max(f0, f0, f2, &ool_max); | |
| 206 } | |
| 207 __ jmp(&done); | |
| 208 | |
| 209 __ bind(&ool_min); | |
| 210 __ Float64MinOutOfLine(f0, f0, f2); | |
| 211 __ jmp(&done); | |
| 212 | |
| 213 __ bind(&ool_max); | |
| 214 __ Float64MaxOutOfLine(f0, f0, f2); | |
| 215 | |
| 216 __ bind(&done); | |
| 217 __ Move(at, t8, f0); | |
| 218 __ Branch(&set_value, ne, t0, Operand(at)); | |
| 219 __ Branch(&set_value, ne, t1, Operand(t8)); | |
| 220 __ jmp(&loop); | |
| 221 __ bind(&set_value); | |
| 222 __ mov(t2, a2); | |
| 223 __ jmp(&loop); | |
| 224 | |
| 225 // At least one side is NaN, which means that the result will be NaN too. | |
| 226 __ bind(&compare_nan); | |
| 227 __ LoadRoot(t2, Heap::kNanValueRootIndex); | |
| 228 __ ldc1(f0, FieldMemOperand(t2, HeapNumber::kValueOffset)); | |
| 229 __ jmp(&loop); | |
| 230 } | |
| 231 | |
| 232 __ bind(&done_loop); | |
| 233 // Drop all slots, including the receiver. | |
| 234 __ Addu(a0, a0, Operand(1)); | |
| 235 __ Lsa(sp, sp, a0, kPointerSizeLog2); | |
| 236 __ Ret(USE_DELAY_SLOT); | |
| 237 __ mov(v0, t2); // In delay slot. | |
| 238 } | |
| 239 | |
| 240 // static | |
| 241 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 124 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
| 242 // ----------- S t a t e ------------- | 125 // ----------- S t a t e ------------- |
| 243 // -- a0 : number of arguments | 126 // -- a0 : number of arguments |
| 244 // -- a1 : constructor function | 127 // -- a1 : constructor function |
| 245 // -- cp : context | 128 // -- cp : context |
| 246 // -- ra : return address | 129 // -- ra : return address |
| 247 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 130 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
| 248 // -- sp[argc * 4] : receiver | 131 // -- sp[argc * 4] : receiver |
| 249 // ----------------------------------- | 132 // ----------------------------------- |
| 250 | 133 |
| (...skipping 2972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3223 __ break_(0xCC); | 3106 __ break_(0xCC); |
| 3224 } | 3107 } |
| 3225 } | 3108 } |
| 3226 | 3109 |
| 3227 #undef __ | 3110 #undef __ |
| 3228 | 3111 |
| 3229 } // namespace internal | 3112 } // namespace internal |
| 3230 } // namespace v8 | 3113 } // namespace v8 |
| 3231 | 3114 |
| 3232 #endif // V8_TARGET_ARCH_MIPS | 3115 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |