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

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

Issue 2728463006: Migrate Math.Min/Max to CodeStubAssembler (Closed)
Patch Set: ChangeFloat64ToTagged Created 3 years, 9 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/builtins/arm64/builtins-arm64.cc » ('j') | no next file with comments »
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/assembler-inl.h" 7 #include "src/assembler-inl.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/counters.h" 9 #include "src/counters.h"
10 #include "src/debug/debug.h" 10 #include "src/debug/debug.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 __ mov(r3, r1); 114 __ mov(r3, r1);
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 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); 117 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
118 ArrayConstructorStub stub(masm->isolate()); 118 ArrayConstructorStub stub(masm->isolate());
119 __ TailCallStub(&stub); 119 __ TailCallStub(&stub);
120 } 120 }
121 121
122 // static 122 // static
123 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
124 // ----------- S t a t e -------------
125 // -- r0 : number of arguments
126 // -- r1 : function
127 // -- cp : context
128 // -- lr : return address
129 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
130 // -- sp[argc * 4] : receiver
131 // -----------------------------------
132 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt;
133 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi;
134 Heap::RootListIndex const root_index =
135 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
136 : Heap::kMinusInfinityValueRootIndex;
137 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1;
138
139 // Load the accumulator with the default return value (either -Infinity or
140 // +Infinity), with the tagged value in r5 and the double value in d1.
141 __ LoadRoot(r5, root_index);
142 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset));
143
144 Label done_loop, loop;
145 __ mov(r4, r0);
146 __ bind(&loop);
147 {
148 // Check if all parameters done.
149 __ sub(r4, r4, Operand(1), SetCC);
150 __ b(lt, &done_loop);
151
152 // Load the next parameter tagged value into r2.
153 __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2));
154
155 // Load the double value of the parameter into d2, maybe converting the
156 // parameter to a number first using the ToNumber builtin if necessary.
157 Label convert, convert_smi, convert_number, done_convert;
158 __ bind(&convert);
159 __ JumpIfSmi(r2, &convert_smi);
160 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
161 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number);
162 {
163 // Parameter is not a Number, use the ToNumber builtin to convert it.
164 DCHECK(!FLAG_enable_embedded_constant_pool);
165 FrameScope scope(masm, StackFrame::MANUAL);
166 __ SmiTag(r0);
167 __ SmiTag(r4);
168 __ EnterBuiltinFrame(cp, r1, r0);
169 __ Push(r4, r5);
170 __ mov(r0, r2);
171 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
172 __ mov(r2, r0);
173 __ Pop(r4, r5);
174 __ LeaveBuiltinFrame(cp, r1, r0);
175 __ SmiUntag(r4);
176 __ SmiUntag(r0);
177 {
178 // Restore the double accumulator value (d1).
179 Label done_restore;
180 __ SmiToDouble(d1, r5);
181 __ JumpIfSmi(r5, &done_restore);
182 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset));
183 __ bind(&done_restore);
184 }
185 }
186 __ b(&convert);
187 __ bind(&convert_number);
188 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset));
189 __ b(&done_convert);
190 __ bind(&convert_smi);
191 __ SmiToDouble(d2, r2);
192 __ bind(&done_convert);
193
194 // Perform the actual comparison with the accumulator value on the left hand
195 // side (d1) and the next parameter value on the right hand side (d2).
196 Label compare_nan, compare_swap;
197 __ VFPCompareAndSetFlags(d1, d2);
198 __ b(cc_done, &loop);
199 __ b(cc_swap, &compare_swap);
200 __ b(vs, &compare_nan);
201
202 // Left and right hand side are equal, check for -0 vs. +0.
203 __ VmovHigh(ip, reg);
204 __ cmp(ip, Operand(0x80000000));
205 __ b(ne, &loop);
206
207 // Result is on the right hand side.
208 __ bind(&compare_swap);
209 __ vmov(d1, d2);
210 __ mov(r5, r2);
211 __ b(&loop);
212
213 // At least one side is NaN, which means that the result will be NaN too.
214 __ bind(&compare_nan);
215 __ LoadRoot(r5, Heap::kNanValueRootIndex);
216 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset));
217 __ b(&loop);
218 }
219
220 __ bind(&done_loop);
221 // Drop all slots, including the receiver.
222 __ add(r0, r0, Operand(1));
223 __ Drop(r0);
224 __ mov(r0, r5);
225 __ Ret();
226 }
227
228 // static
229 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 123 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
230 // ----------- S t a t e ------------- 124 // ----------- S t a t e -------------
231 // -- r0 : number of arguments 125 // -- r0 : number of arguments
232 // -- r1 : constructor function 126 // -- r1 : constructor function
233 // -- cp : context 127 // -- cp : context
234 // -- lr : return address 128 // -- lr : return address
235 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 129 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
236 // -- sp[argc * 4] : receiver 130 // -- sp[argc * 4] : receiver
237 // ----------------------------------- 131 // -----------------------------------
238 132
(...skipping 2915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3154 __ bkpt(0); 3048 __ bkpt(0);
3155 } 3049 }
3156 } 3050 }
3157 3051
3158 #undef __ 3052 #undef __
3159 3053
3160 } // namespace internal 3054 } // namespace internal
3161 } // namespace v8 3055 } // namespace v8
3162 3056
3163 #endif // V8_TARGET_ARCH_ARM 3057 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/builtins/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698