Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: src/mips/builtins-mips.cc

Issue 1641083003: [builtins] Make Math.max and Math.min fast by default. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: SKIP unrelated ignition failures. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // Run the native code for the Array function called as a normal function. 135 // Run the native code for the Array function called as a normal function.
136 // Tail call a stub. 136 // Tail call a stub.
137 __ mov(a3, a1); 137 __ mov(a3, a1);
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) {
146 // ----------- S t a t e -------------
147 // -- a0 : number of arguments
148 // -- ra : return address
149 // -- sp[(argc - n) * 8] : arg[n] (zero-based)
150 // -- sp[(argc + 1) * 8] : receiver
151 // -----------------------------------
152 Condition const cc = (kind == MathMaxMinKind::kMin) ? ge : le;
153 Heap::RootListIndex const root_index =
154 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
155 : Heap::kMinusInfinityValueRootIndex;
156 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? f2 : f0;
157
158 // 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.
160 __ LoadRoot(a1, root_index);
161 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset));
162 __ mov(a3, a0);
163
164 Label done_loop, loop;
165 __ bind(&loop);
166 {
167 // Check if all parameters done.
168 __ Subu(a0, a0, Operand(1));
169 __ Branch(USE_DELAY_SLOT, &done_loop, lt, a0, Operand(zero_reg));
170
171 // Load the next parameter tagged value into a2.
172 __ sll(at, a0, kPointerSizeLog2); // In delay slot
173 __ Addu(at, at, sp);
174 __ lw(a2, MemOperand(at));
175
176 // Load the double value of the parameter into f2, maybe converting the
177 // parameter to a number first using the ToNumberStub if necessary.
178 Label convert, convert_smi, convert_number, done_convert;
179 __ bind(&convert);
180 __ JumpIfSmi(a2, &convert_smi);
181 __ lw(t0, FieldMemOperand(a2, HeapObject::kMapOffset));
182 __ JumpIfRoot(t0, Heap::kHeapNumberMapRootIndex, &convert_number);
183 {
184 // Parameter is not a Number, use the ToNumberStub to convert it.
185 FrameScope scope(masm, StackFrame::INTERNAL);
186 __ SmiTag(a0);
187 __ SmiTag(a3);
188 __ Push(a0, a1, a3);
189 __ mov(a0, a2);
190 ToNumberStub stub(masm->isolate());
191 __ CallStub(&stub);
192 __ mov(a2, v0);
193 __ Pop(a0, a1, a3);
194 {
195 // Restore the double accumulator value (f0).
196 Label restore_smi, done_restore;
197 __ JumpIfSmi(a1, &restore_smi);
198 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset));
199 __ jmp(&done_restore);
200 __ bind(&restore_smi);
201 __ SmiToDoubleFPURegister(a1, f0, t0);
202 __ bind(&done_restore);
203 }
204 __ SmiUntag(a3);
205 __ SmiUntag(a0);
206 }
207 __ jmp(&convert);
208 __ bind(&convert_number);
209 __ ldc1(f2, FieldMemOperand(a2, HeapNumber::kValueOffset));
210 __ jmp(&done_convert);
211 __ bind(&convert_smi);
212 __ SmiToDoubleFPURegister(a2, f2, t0);
213 __ bind(&done_convert);
214
215 // Perform the actual comparison with the accumulator value on the left hand
216 // side (d1) and the next parameter value on the right hand side (d2).
217 Label compare_equal, compare_nan, compare_swap;
218 __ BranchF(&compare_equal, &compare_nan, eq, f0, f2);
219 __ BranchF(&compare_swap, nullptr, cc, f0, f2);
220 __ Branch(&loop);
221
222 // Left and right hand side are equal, check for -0 vs. +0.
223 __ bind(&compare_equal);
224 __ FmoveHigh(t0, reg);
225 __ Branch(&loop, ne, t0, Operand(0x80000000));
226
227 // Result is on the right hand side.
228 __ bind(&compare_swap);
229 __ mov_d(f0, f2);
230 __ mov(a1, a2);
231 __ jmp(&loop);
232
233 // At least one side is NaN, which means that the result will be NaN too.
234 __ bind(&compare_nan);
235 __ LoadRoot(a1, Heap::kNanValueRootIndex);
236 __ ldc1(f0, FieldMemOperand(a1, HeapNumber::kValueOffset));
237 __ jmp(&loop);
238 }
239
240 __ bind(&done_loop);
241 __ sll(a3, a3, kPointerSizeLog2);
242 __ addu(sp, sp, a3);
243 __ mov(v0, a1);
244 __ DropAndRet(1);
245 }
246
247 // static
145 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 248 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
146 // ----------- S t a t e ------------- 249 // ----------- S t a t e -------------
147 // -- a0 : number of arguments 250 // -- a0 : number of arguments
148 // -- a1 : constructor function 251 // -- a1 : constructor function
149 // -- ra : return address 252 // -- ra : return address
150 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 253 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
151 // -- sp[argc * 4] : receiver 254 // -- sp[argc * 4] : receiver
152 // ----------------------------------- 255 // -----------------------------------
153 256
154 // 1. Load the first argument into a0 and get rid of the rest (including the 257 // 1. Load the first argument into a0 and get rid of the rest (including the
(...skipping 2520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 } 2778 }
2676 } 2779 }
2677 2780
2678 2781
2679 #undef __ 2782 #undef __
2680 2783
2681 } // namespace internal 2784 } // namespace internal
2682 } // namespace v8 2785 } // namespace v8
2683 2786
2684 #endif // V8_TARGET_ARCH_MIPS 2787 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698