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

Side by Side Diff: src/arm/builtins-arm.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
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.h » ('j') | src/arm64/builtins-arm64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ARM 5 #if V8_TARGET_ARCH_ARM
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 __ mov(r3, r1); 130 __ mov(r3, r1);
131 // Run the native code for the Array function called as a normal function. 131 // Run the native code for the Array function called as a normal function.
132 // tail call a stub 132 // tail call a stub
133 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); 133 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
134 ArrayConstructorStub stub(masm->isolate()); 134 ArrayConstructorStub stub(masm->isolate());
135 __ TailCallStub(&stub); 135 __ TailCallStub(&stub);
136 } 136 }
137 137
138 138
139 // static 139 // static
140 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
141 // ----------- S t a t e -------------
142 // -- r0 : number of arguments
143 // -- lr : return address
144 // -- sp[(argc - n) * 8] : arg[n] (zero-based)
145 // -- sp[(argc + 1) * 8] : receiver
146 // -----------------------------------
147 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt;
148 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi;
149 Heap::RootListIndex const root_index =
150 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
151 : Heap::kMinusInfinityValueRootIndex;
152 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1;
153
154 // Load the accumulator with the default return value (either -Infinity or
155 // +Infinity), with the tagged value in r1 and the double value in d1.
156 __ LoadRoot(r1, root_index);
157 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset));
158 __ mov(r4, r0);
159
160 Label done_loop, loop;
161 __ bind(&loop);
162 {
163 // Check if all parameters done.
164 __ sub(r0, r0, Operand(1), SetCC);
165 __ b(lt, &done_loop);
166
167 // Load the next parameter tagged value into r2.
168 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2));
169
170 // Load the double value of the parameter into d2, maybe converting the
171 // parameter to a number first using the ToNumberStub if necessary.
172 Label convert, convert_smi, convert_number, done_convert;
173 __ bind(&convert);
174 __ JumpIfSmi(r2, &convert_smi);
175 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
176 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number);
177 {
178 // Parameter is not a Number, use the ToNumberStub to convert it.
179 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
180 __ SmiTag(r0, r0);
181 __ SmiTag(r4, r4);
182 __ Push(r0, r1, r4);
183 __ mov(r0, r2);
184 ToNumberStub stub(masm->isolate());
185 __ CallStub(&stub);
186 __ mov(r2, r0);
187 __ Pop(r0, r1, r4);
188 {
189 // Restore the double accumulator value (d1).
190 Label restore_smi, done_restore;
191 __ JumpIfSmi(r1, &restore_smi);
192 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset));
193 __ b(&done_restore);
194 __ bind(&restore_smi);
195 __ SmiToDouble(d1, r1);
196 __ bind(&done_restore);
197 }
198 __ SmiUntag(r4);
199 __ SmiUntag(r0);
200 }
201 __ b(&convert);
202 __ bind(&convert_number);
203 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset));
204 __ b(&done_convert);
205 __ bind(&convert_smi);
206 __ SmiToDouble(d2, r2);
207 __ bind(&done_convert);
208
209 // Perform the actual comparison with the accumulator value on the left hand
210 // side (d1) and the next parameter value on the right hand side (d2).
211 Label compare_nan, compare_swap;
212 __ VFPCompareAndSetFlags(d1, d2);
213 __ b(cc_done, &loop);
214 __ b(cc_swap, &compare_swap);
215 __ b(vs, &compare_nan);
216
217 // Left and right hand side are equal, check for -0 vs. +0.
218 __ VmovHigh(ip, reg);
219 __ cmp(ip, Operand(0x80000000));
220 __ b(ne, &loop);
221
222 // Result is on the right hand side.
223 __ bind(&compare_swap);
224 __ vmov(d1, d2);
225 __ mov(r1, r2);
226 __ b(&loop);
227
228 // At least one side is NaN, which means that the result will be NaN too.
229 __ bind(&compare_nan);
230 __ LoadRoot(r1, Heap::kNanValueRootIndex);
231 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset));
232 __ b(&loop);
233 }
234
235 __ bind(&done_loop);
236 __ mov(r0, r1);
237 __ Drop(r4);
238 __ Ret(1);
239 }
240
241 // static
140 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 242 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
141 // ----------- S t a t e ------------- 243 // ----------- S t a t e -------------
142 // -- r0 : number of arguments 244 // -- r0 : number of arguments
143 // -- r1 : constructor function 245 // -- r1 : constructor function
144 // -- lr : return address 246 // -- lr : return address
145 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 247 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
146 // -- sp[argc * 4] : receiver 248 // -- sp[argc * 4] : receiver
147 // ----------------------------------- 249 // -----------------------------------
148 250
149 // 1. Load the first argument into r0 and get rid of the rest (including the 251 // 1. Load the first argument into r0 and get rid of the rest (including the
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 } 2699 }
2598 } 2700 }
2599 2701
2600 2702
2601 #undef __ 2703 #undef __
2602 2704
2603 } // namespace internal 2705 } // namespace internal
2604 } // namespace v8 2706 } // namespace v8
2605 2707
2606 #endif // V8_TARGET_ARCH_ARM 2708 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/macro-assembler-arm.h » ('j') | src/arm64/builtins-arm64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698