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

Side by Side Diff: src/builtins/arm64/builtins-arm64.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 | « src/builtins/arm/builtins-arm.cc ('k') | src/builtins/builtins.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 // Run the native code for the Array function called as a normal function. 113 // Run the native code for the Array function called as a normal function.
114 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); 114 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex);
115 __ Mov(x3, x1); 115 __ Mov(x3, x1);
116 ArrayConstructorStub stub(masm->isolate()); 116 ArrayConstructorStub stub(masm->isolate());
117 __ TailCallStub(&stub); 117 __ TailCallStub(&stub);
118 } 118 }
119 119
120 // static 120 // static
121 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
122 // ----------- S t a t e -------------
123 // -- x0 : number of arguments
124 // -- x1 : function
125 // -- cp : context
126 // -- lr : return address
127 // -- sp[(argc - n - 1) * 8] : arg[n] (zero-based)
128 // -- sp[argc * 8] : receiver
129 // -----------------------------------
130 ASM_LOCATION("Builtins::Generate_MathMaxMin");
131
132 Heap::RootListIndex const root_index =
133 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
134 : Heap::kMinusInfinityValueRootIndex;
135
136 // Load the accumulator with the default return value (either -Infinity or
137 // +Infinity), with the tagged value in x5 and the double value in d5.
138 __ LoadRoot(x5, root_index);
139 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset));
140
141 Label done_loop, loop;
142 __ mov(x4, x0);
143 __ Bind(&loop);
144 {
145 // Check if all parameters done.
146 __ Subs(x4, x4, 1);
147 __ B(lt, &done_loop);
148
149 // Load the next parameter tagged value into x2.
150 __ Peek(x2, Operand(x4, LSL, kPointerSizeLog2));
151
152 // Load the double value of the parameter into d2, maybe converting the
153 // parameter to a number first using the ToNumber builtin if necessary.
154 Label convert_smi, convert_number, done_convert;
155 __ JumpIfSmi(x2, &convert_smi);
156 __ JumpIfHeapNumber(x2, &convert_number);
157 {
158 // Parameter is not a Number, use the ToNumber builtin to convert it.
159 FrameScope scope(masm, StackFrame::MANUAL);
160 __ SmiTag(x0);
161 __ SmiTag(x4);
162 __ EnterBuiltinFrame(cp, x1, x0);
163 __ Push(x5, x4);
164 __ Mov(x0, x2);
165 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
166 __ Mov(x2, x0);
167 __ Pop(x4, x5);
168 __ LeaveBuiltinFrame(cp, x1, x0);
169 __ SmiUntag(x4);
170 __ SmiUntag(x0);
171 {
172 // Restore the double accumulator value (d5).
173 Label done_restore;
174 __ SmiUntagToDouble(d5, x5, kSpeculativeUntag);
175 __ JumpIfSmi(x5, &done_restore);
176 __ Ldr(d5, FieldMemOperand(x5, HeapNumber::kValueOffset));
177 __ Bind(&done_restore);
178 }
179 }
180 __ AssertNumber(x2);
181 __ JumpIfSmi(x2, &convert_smi);
182
183 __ Bind(&convert_number);
184 __ Ldr(d2, FieldMemOperand(x2, HeapNumber::kValueOffset));
185 __ B(&done_convert);
186
187 __ Bind(&convert_smi);
188 __ SmiUntagToDouble(d2, x2);
189 __ Bind(&done_convert);
190
191 // We can use a single fmin/fmax for the operation itself, but we then need
192 // to work out which HeapNumber (or smi) the result came from.
193 __ Fmov(x11, d5);
194 if (kind == MathMaxMinKind::kMin) {
195 __ Fmin(d5, d5, d2);
196 } else {
197 DCHECK(kind == MathMaxMinKind::kMax);
198 __ Fmax(d5, d5, d2);
199 }
200 __ Fmov(x10, d5);
201 __ Cmp(x10, x11);
202 __ Csel(x5, x5, x2, eq);
203 __ B(&loop);
204 }
205
206 __ Bind(&done_loop);
207 // Drop all slots, including the receiver.
208 __ Add(x0, x0, 1);
209 __ Drop(x0);
210 __ Mov(x0, x5);
211 __ Ret();
212 }
213
214 // static
215 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 121 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
216 // ----------- S t a t e ------------- 122 // ----------- S t a t e -------------
217 // -- x0 : number of arguments 123 // -- x0 : number of arguments
218 // -- x1 : constructor function 124 // -- x1 : constructor function
219 // -- cp : context 125 // -- cp : context
220 // -- lr : return address 126 // -- lr : return address
221 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) 127 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based)
222 // -- sp[argc * 8] : receiver 128 // -- sp[argc * 8] : receiver
223 // ----------------------------------- 129 // -----------------------------------
224 ASM_LOCATION("Builtins::Generate_NumberConstructor"); 130 ASM_LOCATION("Builtins::Generate_NumberConstructor");
(...skipping 3032 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 __ Unreachable(); 3163 __ Unreachable();
3258 } 3164 }
3259 } 3165 }
3260 3166
3261 #undef __ 3167 #undef __
3262 3168
3263 } // namespace internal 3169 } // namespace internal
3264 } // namespace v8 3170 } // namespace v8
3265 3171
3266 #endif // V8_TARGET_ARCH_ARM 3172 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/builtins/arm/builtins-arm.cc ('k') | src/builtins/builtins.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698