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 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) * 8] : arg[n] (zero-based) | |
131 // -- sp[argc * 8] : 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 t1 and the double value in f0. | |
139 __ LoadRoot(t1, root_index); | |
140 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); | |
141 | |
142 Label done_loop, loop, done; | |
143 __ mov(a3, a0); | |
144 __ bind(&loop); | |
145 { | |
146 // Check if all parameters done. | |
147 __ Dsubu(a3, a3, Operand(1)); | |
148 __ Branch(&done_loop, lt, a3, Operand(zero_reg)); | |
149 | |
150 // Load the next parameter tagged value into a2. | |
151 __ Dlsa(at, sp, a3, kPointerSizeLog2); | |
152 __ ld(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 __ ld(a4, FieldMemOperand(a2, HeapObject::kMapOffset)); | |
160 __ JumpIfRoot(a4, 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(t1, a3); | |
168 __ mov(a0, a2); | |
169 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | |
170 __ mov(a2, v0); | |
171 __ Pop(t1, 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(t1, &restore_smi); | |
179 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); | |
180 __ jmp(&done_restore); | |
181 __ bind(&restore_smi); | |
182 __ SmiToDoubleFPURegister(t1, f0, a4); | |
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, a4); | |
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, ool_min, ool_max; | |
199 __ BranchF(nullptr, &compare_nan, eq, f0, f2); | |
200 __ Move(a4, 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, f0); | |
218 __ Branch(&loop, eq, a4, Operand(at)); | |
219 __ mov(t1, a2); | |
220 __ jmp(&loop); | |
221 | |
222 // At least one side is NaN, which means that the result will be NaN too. | |
223 __ bind(&compare_nan); | |
224 __ LoadRoot(t1, Heap::kNanValueRootIndex); | |
225 __ ldc1(f0, FieldMemOperand(t1, HeapNumber::kValueOffset)); | |
226 __ jmp(&loop); | |
227 } | |
228 | |
229 __ bind(&done_loop); | |
230 // Drop all slots, including the receiver. | |
231 __ Daddu(a0, a0, Operand(1)); | |
232 __ Dlsa(sp, sp, a0, kPointerSizeLog2); | |
233 __ Ret(USE_DELAY_SLOT); | |
234 __ mov(v0, t1); // In delay slot. | |
235 } | |
236 | |
237 // static | |
238 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 124 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
239 // ----------- S t a t e ------------- | 125 // ----------- S t a t e ------------- |
240 // -- a0 : number of arguments | 126 // -- a0 : number of arguments |
241 // -- a1 : constructor function | 127 // -- a1 : constructor function |
242 // -- cp : context | 128 // -- cp : context |
243 // -- ra : return address | 129 // -- ra : return address |
244 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 130 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
245 // -- sp[argc * 8] : receiver | 131 // -- sp[argc * 8] : receiver |
246 // ----------------------------------- | 132 // ----------------------------------- |
247 | 133 |
(...skipping 2999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3247 __ break_(0xCC); | 3133 __ break_(0xCC); |
3248 } | 3134 } |
3249 } | 3135 } |
3250 | 3136 |
3251 #undef __ | 3137 #undef __ |
3252 | 3138 |
3253 } // namespace internal | 3139 } // namespace internal |
3254 } // namespace v8 | 3140 } // namespace v8 |
3255 | 3141 |
3256 #endif // V8_TARGET_ARCH_MIPS64 | 3142 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |