OLD | NEW |
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { | 140 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
141 // ----------- S t a t e ------------- | 141 // ----------- S t a t e ------------- |
142 // -- r0 : number of arguments | 142 // -- r0 : number of arguments |
| 143 // -- r1 : function |
| 144 // -- cp : context |
143 // -- lr : return address | 145 // -- lr : return address |
144 // -- sp[(argc - n) * 8] : arg[n] (zero-based) | 146 // -- sp[(argc - n) * 8] : arg[n] (zero-based) |
145 // -- sp[(argc + 1) * 8] : receiver | 147 // -- sp[(argc + 1) * 8] : receiver |
146 // ----------------------------------- | 148 // ----------------------------------- |
147 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt; | 149 Condition const cc_done = (kind == MathMaxMinKind::kMin) ? mi : gt; |
148 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi; | 150 Condition const cc_swap = (kind == MathMaxMinKind::kMin) ? gt : mi; |
149 Heap::RootListIndex const root_index = | 151 Heap::RootListIndex const root_index = |
150 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 152 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
151 : Heap::kMinusInfinityValueRootIndex; | 153 : Heap::kMinusInfinityValueRootIndex; |
152 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; | 154 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; |
153 | 155 |
154 // Load the accumulator with the default return value (either -Infinity or | 156 // 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. | 157 // +Infinity), with the tagged value in r5 and the double value in d1. |
156 __ LoadRoot(r1, root_index); | 158 __ LoadRoot(r5, root_index); |
157 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 159 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); |
158 | |
159 // Remember how many slots to drop (including the receiver). | |
160 __ add(r4, r0, Operand(1)); | |
161 | 160 |
162 Label done_loop, loop; | 161 Label done_loop, loop; |
| 162 __ mov(r4, r0); |
163 __ bind(&loop); | 163 __ bind(&loop); |
164 { | 164 { |
165 // Check if all parameters done. | 165 // Check if all parameters done. |
166 __ sub(r0, r0, Operand(1), SetCC); | 166 __ sub(r4, r4, Operand(1), SetCC); |
167 __ b(lt, &done_loop); | 167 __ b(lt, &done_loop); |
168 | 168 |
169 // Load the next parameter tagged value into r2. | 169 // Load the next parameter tagged value into r2. |
170 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 170 __ ldr(r2, MemOperand(sp, r4, LSL, kPointerSizeLog2)); |
171 | 171 |
172 // Load the double value of the parameter into d2, maybe converting the | 172 // Load the double value of the parameter into d2, maybe converting the |
173 // parameter to a number first using the ToNumberStub if necessary. | 173 // parameter to a number first using the ToNumberStub if necessary. |
174 Label convert, convert_smi, convert_number, done_convert; | 174 Label convert, convert_smi, convert_number, done_convert; |
175 __ bind(&convert); | 175 __ bind(&convert); |
176 __ JumpIfSmi(r2, &convert_smi); | 176 __ JumpIfSmi(r2, &convert_smi); |
177 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); | 177 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); |
178 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); | 178 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); |
179 { | 179 { |
180 // Parameter is not a Number, use the ToNumberStub to convert it. | 180 // Parameter is not a Number, use the ToNumberStub to convert it. |
181 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 181 DCHECK(!FLAG_enable_embedded_constant_pool); |
| 182 FrameScope scope(masm, StackFrame::MANUAL); |
| 183 __ Push(lr, fp, cp, r1); |
| 184 __ add(fp, sp, Operand(2 * kPointerSize)); |
182 __ SmiTag(r0); | 185 __ SmiTag(r0); |
183 __ SmiTag(r4); | 186 __ SmiTag(r4); |
184 __ Push(r0, r1, r4); | 187 __ Push(r0, r4, r5); |
185 __ mov(r0, r2); | 188 __ mov(r0, r2); |
186 ToNumberStub stub(masm->isolate()); | 189 ToNumberStub stub(masm->isolate()); |
187 __ CallStub(&stub); | 190 __ CallStub(&stub); |
188 __ mov(r2, r0); | 191 __ mov(r2, r0); |
189 __ Pop(r0, r1, r4); | 192 __ Pop(r0, r4, r5); |
190 { | 193 { |
191 // Restore the double accumulator value (d1). | 194 // Restore the double accumulator value (d1). |
192 Label done_restore; | 195 Label done_restore; |
193 __ SmiToDouble(d1, r1); | 196 __ SmiToDouble(d1, r5); |
194 __ JumpIfSmi(r1, &done_restore); | 197 __ JumpIfSmi(r5, &done_restore); |
195 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 198 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); |
196 __ bind(&done_restore); | 199 __ bind(&done_restore); |
197 } | 200 } |
198 __ SmiUntag(r4); | 201 __ SmiUntag(r4); |
199 __ SmiUntag(r0); | 202 __ SmiUntag(r0); |
| 203 __ Pop(lr, fp, cp, r1); |
200 } | 204 } |
201 __ b(&convert); | 205 __ b(&convert); |
202 __ bind(&convert_number); | 206 __ bind(&convert_number); |
203 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset)); | 207 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset)); |
204 __ b(&done_convert); | 208 __ b(&done_convert); |
205 __ bind(&convert_smi); | 209 __ bind(&convert_smi); |
206 __ SmiToDouble(d2, r2); | 210 __ SmiToDouble(d2, r2); |
207 __ bind(&done_convert); | 211 __ bind(&done_convert); |
208 | 212 |
209 // Perform the actual comparison with the accumulator value on the left hand | 213 // 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). | 214 // side (d1) and the next parameter value on the right hand side (d2). |
211 Label compare_nan, compare_swap; | 215 Label compare_nan, compare_swap; |
212 __ VFPCompareAndSetFlags(d1, d2); | 216 __ VFPCompareAndSetFlags(d1, d2); |
213 __ b(cc_done, &loop); | 217 __ b(cc_done, &loop); |
214 __ b(cc_swap, &compare_swap); | 218 __ b(cc_swap, &compare_swap); |
215 __ b(vs, &compare_nan); | 219 __ b(vs, &compare_nan); |
216 | 220 |
217 // Left and right hand side are equal, check for -0 vs. +0. | 221 // Left and right hand side are equal, check for -0 vs. +0. |
218 __ VmovHigh(ip, reg); | 222 __ VmovHigh(ip, reg); |
219 __ cmp(ip, Operand(0x80000000)); | 223 __ cmp(ip, Operand(0x80000000)); |
220 __ b(ne, &loop); | 224 __ b(ne, &loop); |
221 | 225 |
222 // Result is on the right hand side. | 226 // Result is on the right hand side. |
223 __ bind(&compare_swap); | 227 __ bind(&compare_swap); |
224 __ vmov(d1, d2); | 228 __ vmov(d1, d2); |
225 __ mov(r1, r2); | 229 __ mov(r5, r2); |
226 __ b(&loop); | 230 __ b(&loop); |
227 | 231 |
228 // At least one side is NaN, which means that the result will be NaN too. | 232 // At least one side is NaN, which means that the result will be NaN too. |
229 __ bind(&compare_nan); | 233 __ bind(&compare_nan); |
230 __ LoadRoot(r1, Heap::kNanValueRootIndex); | 234 __ LoadRoot(r5, Heap::kNanValueRootIndex); |
231 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 235 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); |
232 __ b(&loop); | 236 __ b(&loop); |
233 } | 237 } |
234 | 238 |
235 __ bind(&done_loop); | 239 __ bind(&done_loop); |
236 __ mov(r0, r1); | 240 __ Drop(r0); |
237 __ Drop(r4); | 241 __ Drop(1); |
| 242 __ mov(r0, r5); |
238 __ Ret(); | 243 __ Ret(); |
239 } | 244 } |
240 | 245 |
241 // static | 246 // static |
242 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 247 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
243 // ----------- S t a t e ------------- | 248 // ----------- S t a t e ------------- |
244 // -- r0 : number of arguments | 249 // -- r0 : number of arguments |
245 // -- r1 : constructor function | 250 // -- r1 : constructor function |
246 // -- lr : return address | 251 // -- lr : return address |
247 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 252 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
(...skipping 2526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2774 } | 2779 } |
2775 } | 2780 } |
2776 | 2781 |
2777 | 2782 |
2778 #undef __ | 2783 #undef __ |
2779 | 2784 |
2780 } // namespace internal | 2785 } // namespace internal |
2781 } // namespace v8 | 2786 } // namespace v8 |
2782 | 2787 |
2783 #endif // V8_TARGET_ARCH_ARM | 2788 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |