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

Side by Side Diff: src/builtins/s390/builtins-s390.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/ppc/builtins-ppc.cc ('k') | src/builtins/x64/builtins-x64.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_S390 5 #if V8_TARGET_ARCH_S390
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 __ LoadRR(r5, r3); 111 __ LoadRR(r5, r3);
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(r4, Heap::kUndefinedValueRootIndex); 114 __ LoadRoot(r4, 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 // -- r2 : number of arguments
123 // -- r3 : 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 r7 and the double value in d1.
137 __ LoadRoot(r7, root_index);
138 __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
139
140 // Setup state for loop
141 // r4: address of arg[0] + kPointerSize
142 // r5: number of slots to drop at exit (arguments + receiver)
143 __ AddP(r6, r2, Operand(1));
144
145 Label done_loop, loop;
146 __ LoadRR(r6, r2);
147 __ bind(&loop);
148 {
149 // Check if all parameters done.
150 __ SubP(r6, Operand(1));
151 __ blt(&done_loop);
152
153 // Load the next parameter tagged value into r2.
154 __ ShiftLeftP(r1, r6, Operand(kPointerSizeLog2));
155 __ LoadP(r4, MemOperand(sp, r1));
156
157 // Load the double value of the parameter into d2, maybe converting the
158 // parameter to a number first using the ToNumber builtin if necessary.
159 Label convert, convert_smi, convert_number, done_convert;
160 __ bind(&convert);
161 __ JumpIfSmi(r4, &convert_smi);
162 __ LoadP(r5, FieldMemOperand(r4, HeapObject::kMapOffset));
163 __ JumpIfRoot(r5, Heap::kHeapNumberMapRootIndex, &convert_number);
164 {
165 // Parameter is not a Number, use the ToNumber builtin to convert it.
166 DCHECK(!FLAG_enable_embedded_constant_pool);
167 FrameScope scope(masm, StackFrame::MANUAL);
168 __ SmiTag(r2);
169 __ SmiTag(r6);
170 __ EnterBuiltinFrame(cp, r3, r2);
171 __ Push(r6, r7);
172 __ LoadRR(r2, r4);
173 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
174 __ LoadRR(r4, r2);
175 __ Pop(r6, r7);
176 __ LeaveBuiltinFrame(cp, r3, r2);
177 __ SmiUntag(r6);
178 __ SmiUntag(r2);
179 {
180 // Restore the double accumulator value (d1).
181 Label done_restore;
182 __ SmiToDouble(d1, r7);
183 __ JumpIfSmi(r7, &done_restore);
184 __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
185 __ bind(&done_restore);
186 }
187 }
188 __ b(&convert);
189 __ bind(&convert_number);
190 __ LoadDouble(d2, FieldMemOperand(r4, HeapNumber::kValueOffset));
191 __ b(&done_convert);
192 __ bind(&convert_smi);
193 __ SmiToDouble(d2, r4);
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 __ cdbr(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, r1, r0);
206 __ bne(&loop);
207
208 // Update accumulator. Result is on the right hand side.
209 __ bind(&compare_swap);
210 __ ldr(d1, d2);
211 __ LoadRR(r7, r4);
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(r7, Heap::kNanValueRootIndex);
218 __ LoadDouble(d1, FieldMemOperand(r7, HeapNumber::kValueOffset));
219 __ b(&loop);
220 }
221
222 __ bind(&done_loop);
223 // Drop all slots, including the receiver.
224 __ AddP(r2, Operand(1));
225 __ Drop(r2);
226 __ LoadRR(r2, r7);
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 // -- r2 : number of arguments 122 // -- r2 : number of arguments
234 // -- r3 : constructor function 123 // -- r3 : 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 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3249 __ bkpt(0); 3138 __ bkpt(0);
3250 } 3139 }
3251 } 3140 }
3252 3141
3253 #undef __ 3142 #undef __
3254 3143
3255 } // namespace internal 3144 } // namespace internal
3256 } // namespace v8 3145 } // namespace v8
3257 3146
3258 #endif // V8_TARGET_ARCH_S390 3147 #endif // V8_TARGET_ARCH_S390
OLDNEW
« no previous file with comments | « src/builtins/ppc/builtins-ppc.cc ('k') | src/builtins/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698