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

Side by Side Diff: src/builtins/ppc/builtins-ppc.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/mips64/builtins-mips64.cc ('k') | src/builtins/s390/builtins-s390.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 __ mr(r6, r4); 111 __ mr(r6, r4);
112 // Run the native code for the Array function called as a normal function. 112 // Run the native code for the Array function called as a normal function.
113 // tail call a stub 113 // tail call a stub
114 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); 114 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
115 ArrayConstructorStub stub(masm->isolate()); 115 ArrayConstructorStub stub(masm->isolate());
116 __ TailCallStub(&stub); 116 __ TailCallStub(&stub);
117 } 117 }
118 118
119 // static 119 // static
120 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
121 // ----------- S t a t e -------------
122 // -- r3 : number of arguments
123 // -- r4 : function
124 // -- cp : context
125 // -- lr : return address
126 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
127 // -- sp[argc * 4] : receiver
128 // -----------------------------------
129 Condition const cond_done = (kind == MathMaxMinKind::kMin) ? lt : gt;
130 Heap::RootListIndex const root_index =
131 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex
132 : Heap::kMinusInfinityValueRootIndex;
133 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1;
134
135 // Load the accumulator with the default return value (either -Infinity or
136 // +Infinity), with the tagged value in r8 and the double value in d1.
137 __ LoadRoot(r8, root_index);
138 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset));
139
140 // Setup state for loop
141 // r5: address of arg[0] + kPointerSize
142 // r6: number of slots to drop at exit (arguments + receiver)
143 __ addi(r7, r3, Operand(1));
144
145 Label done_loop, loop;
146 __ mr(r7, r3);
147 __ bind(&loop);
148 {
149 // Check if all parameters done.
150 __ subi(r7, r7, Operand(1));
151 __ cmpi(r7, Operand::Zero());
152 __ blt(&done_loop);
153
154 // Load the next parameter tagged value into r5.
155 __ ShiftLeftImm(r5, r7, Operand(kPointerSizeLog2));
156 __ LoadPX(r5, MemOperand(sp, r5));
157
158 // Load the double value of the parameter into d2, maybe converting the
159 // parameter to a number first using the ToNumber builtin if necessary.
160 Label convert, convert_smi, convert_number, done_convert;
161 __ bind(&convert);
162 __ JumpIfSmi(r5, &convert_smi);
163 __ LoadP(r6, FieldMemOperand(r5, HeapObject::kMapOffset));
164 __ JumpIfRoot(r6, Heap::kHeapNumberMapRootIndex, &convert_number);
165 {
166 // Parameter is not a Number, use the ToNumber builtin to convert it.
167 FrameScope scope(masm, StackFrame::MANUAL);
168 __ SmiTag(r3);
169 __ SmiTag(r7);
170 __ EnterBuiltinFrame(cp, r4, r3);
171 __ Push(r7, r8);
172 __ mr(r3, r5);
173 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
174 __ mr(r5, r3);
175 __ Pop(r7, r8);
176 __ LeaveBuiltinFrame(cp, r4, r3);
177 __ SmiUntag(r7);
178 __ SmiUntag(r3);
179 {
180 // Restore the double accumulator value (d1).
181 Label done_restore;
182 __ SmiToDouble(d1, r8);
183 __ JumpIfSmi(r8, &done_restore);
184 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset));
185 __ bind(&done_restore);
186 }
187 }
188 __ b(&convert);
189 __ bind(&convert_number);
190 __ lfd(d2, FieldMemOperand(r5, HeapNumber::kValueOffset));
191 __ b(&done_convert);
192 __ bind(&convert_smi);
193 __ SmiToDouble(d2, r5);
194 __ bind(&done_convert);
195
196 // Perform the actual comparison with the accumulator value on the left hand
197 // side (d1) and the next parameter value on the right hand side (d2).
198 Label compare_nan, compare_swap;
199 __ fcmpu(d1, d2);
200 __ bunordered(&compare_nan);
201 __ b(cond_done, &loop);
202 __ b(CommuteCondition(cond_done), &compare_swap);
203
204 // Left and right hand side are equal, check for -0 vs. +0.
205 __ TestDoubleIsMinusZero(reg, r9, r0);
206 __ bne(&loop);
207
208 // Update accumulator. Result is on the right hand side.
209 __ bind(&compare_swap);
210 __ fmr(d1, d2);
211 __ mr(r8, r5);
212 __ b(&loop);
213
214 // At least one side is NaN, which means that the result will be NaN too.
215 // We still need to visit the rest of the arguments.
216 __ bind(&compare_nan);
217 __ LoadRoot(r8, Heap::kNanValueRootIndex);
218 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset));
219 __ b(&loop);
220 }
221
222 __ bind(&done_loop);
223 // Drop all slots, including the receiver.
224 __ addi(r3, r3, Operand(1));
225 __ Drop(r3);
226 __ mr(r3, r8);
227 __ Ret();
228 }
229
230 // static
231 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { 120 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
232 // ----------- S t a t e ------------- 121 // ----------- S t a t e -------------
233 // -- r3 : number of arguments 122 // -- r3 : number of arguments
234 // -- r4 : constructor function 123 // -- r4 : constructor function
235 // -- cp : context 124 // -- cp : context
236 // -- lr : return address 125 // -- lr : return address
237 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 126 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
238 // -- sp[argc * 4] : receiver 127 // -- sp[argc * 4] : receiver
239 // ----------------------------------- 128 // -----------------------------------
240 129
(...skipping 2996 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 __ CallRuntime(Runtime::kThrowStackOverflow); 3126 __ CallRuntime(Runtime::kThrowStackOverflow);
3238 __ bkpt(0); 3127 __ bkpt(0);
3239 } 3128 }
3240 } 3129 }
3241 3130
3242 #undef __ 3131 #undef __
3243 } // namespace internal 3132 } // namespace internal
3244 } // namespace v8 3133 } // namespace v8
3245 3134
3246 #endif // V8_TARGET_ARCH_PPC 3135 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/builtins/mips64/builtins-mips64.cc ('k') | src/builtins/s390/builtins-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698