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 | 160 |
159 // Remember how many slots to drop (including the receiver). | 161 // Remember how many slots to drop (including the receiver). |
160 __ add(r4, r0, Operand(1)); | 162 __ add(r4, r0, Operand(1)); |
161 | 163 |
162 Label done_loop, loop; | 164 Label done_loop, loop; |
163 __ bind(&loop); | 165 __ bind(&loop); |
164 { | 166 { |
165 // Check if all parameters done. | 167 // Check if all parameters done. |
166 __ sub(r0, r0, Operand(1), SetCC); | 168 __ sub(r0, r0, Operand(1), SetCC); |
167 __ b(lt, &done_loop); | 169 __ b(lt, &done_loop); |
168 | 170 |
169 // Load the next parameter tagged value into r2. | 171 // Load the next parameter tagged value into r2. |
170 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 172 __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
171 | 173 |
172 // Load the double value of the parameter into d2, maybe converting the | 174 // Load the double value of the parameter into d2, maybe converting the |
173 // parameter to a number first using the ToNumber builtin if necessary. | 175 // parameter to a number first using the ToNumber builtin if necessary. |
174 Label convert, convert_smi, convert_number, done_convert; | 176 Label convert, convert_smi, convert_number, done_convert; |
175 __ bind(&convert); | 177 __ bind(&convert); |
176 __ JumpIfSmi(r2, &convert_smi); | 178 __ JumpIfSmi(r2, &convert_smi); |
177 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); | 179 __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset)); |
178 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); | 180 __ JumpIfRoot(r3, Heap::kHeapNumberMapRootIndex, &convert_number); |
179 { | 181 { |
180 // Parameter is not a Number, use the ToNumber builtin to convert it. | 182 // Parameter is not a Number, use the ToNumber builtin to convert it. |
181 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 183 DCHECK(!FLAG_enable_embedded_constant_pool); |
| 184 FrameScope scope(masm, StackFrame::MANUAL); |
| 185 __ Push(lr, fp, cp, r1); |
| 186 __ add(fp, sp, Operand(2 * kPointerSize)); |
182 __ SmiTag(r0); | 187 __ SmiTag(r0); |
183 __ SmiTag(r4); | 188 __ SmiTag(r4); |
184 __ Push(r0, r1, r4); | 189 __ Push(r0, r4, r5); |
185 __ mov(r0, r2); | 190 __ mov(r0, r2); |
186 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); | 191 __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET); |
187 __ mov(r2, r0); | 192 __ mov(r2, r0); |
188 __ Pop(r0, r1, r4); | 193 __ Pop(r0, r4, r5); |
189 { | 194 { |
190 // Restore the double accumulator value (d1). | 195 // Restore the double accumulator value (d1). |
191 Label done_restore; | 196 Label done_restore; |
192 __ SmiToDouble(d1, r1); | 197 __ SmiToDouble(d1, r5); |
193 __ JumpIfSmi(r1, &done_restore); | 198 __ JumpIfSmi(r5, &done_restore); |
194 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 199 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); |
195 __ bind(&done_restore); | 200 __ bind(&done_restore); |
196 } | 201 } |
197 __ SmiUntag(r4); | 202 __ SmiUntag(r4); |
198 __ SmiUntag(r0); | 203 __ SmiUntag(r0); |
| 204 __ Pop(lr, fp, cp, r1); |
199 } | 205 } |
200 __ b(&convert); | 206 __ b(&convert); |
201 __ bind(&convert_number); | 207 __ bind(&convert_number); |
202 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset)); | 208 __ vldr(d2, FieldMemOperand(r2, HeapNumber::kValueOffset)); |
203 __ b(&done_convert); | 209 __ b(&done_convert); |
204 __ bind(&convert_smi); | 210 __ bind(&convert_smi); |
205 __ SmiToDouble(d2, r2); | 211 __ SmiToDouble(d2, r2); |
206 __ bind(&done_convert); | 212 __ bind(&done_convert); |
207 | 213 |
208 // Perform the actual comparison with the accumulator value on the left hand | 214 // Perform the actual comparison with the accumulator value on the left hand |
209 // side (d1) and the next parameter value on the right hand side (d2). | 215 // side (d1) and the next parameter value on the right hand side (d2). |
210 Label compare_nan, compare_swap; | 216 Label compare_nan, compare_swap; |
211 __ VFPCompareAndSetFlags(d1, d2); | 217 __ VFPCompareAndSetFlags(d1, d2); |
212 __ b(cc_done, &loop); | 218 __ b(cc_done, &loop); |
213 __ b(cc_swap, &compare_swap); | 219 __ b(cc_swap, &compare_swap); |
214 __ b(vs, &compare_nan); | 220 __ b(vs, &compare_nan); |
215 | 221 |
216 // Left and right hand side are equal, check for -0 vs. +0. | 222 // Left and right hand side are equal, check for -0 vs. +0. |
217 __ VmovHigh(ip, reg); | 223 __ VmovHigh(ip, reg); |
218 __ cmp(ip, Operand(0x80000000)); | 224 __ cmp(ip, Operand(0x80000000)); |
219 __ b(ne, &loop); | 225 __ b(ne, &loop); |
220 | 226 |
221 // Result is on the right hand side. | 227 // Result is on the right hand side. |
222 __ bind(&compare_swap); | 228 __ bind(&compare_swap); |
223 __ vmov(d1, d2); | 229 __ vmov(d1, d2); |
224 __ mov(r1, r2); | 230 __ mov(r5, r2); |
225 __ b(&loop); | 231 __ b(&loop); |
226 | 232 |
227 // At least one side is NaN, which means that the result will be NaN too. | 233 // At least one side is NaN, which means that the result will be NaN too. |
228 __ bind(&compare_nan); | 234 __ bind(&compare_nan); |
229 __ LoadRoot(r1, Heap::kNanValueRootIndex); | 235 __ LoadRoot(r5, Heap::kNanValueRootIndex); |
230 __ vldr(d1, FieldMemOperand(r1, HeapNumber::kValueOffset)); | 236 __ vldr(d1, FieldMemOperand(r5, HeapNumber::kValueOffset)); |
231 __ b(&loop); | 237 __ b(&loop); |
232 } | 238 } |
233 | 239 |
234 __ bind(&done_loop); | 240 __ bind(&done_loop); |
235 __ mov(r0, r1); | 241 __ mov(r0, r5); |
236 __ Drop(r4); | 242 __ Drop(r4); |
237 __ Ret(); | 243 __ Ret(); |
238 } | 244 } |
239 | 245 |
240 // static | 246 // static |
241 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 247 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
242 // ----------- S t a t e ------------- | 248 // ----------- S t a t e ------------- |
243 // -- r0 : number of arguments | 249 // -- r0 : number of arguments |
244 // -- r1 : constructor function | 250 // -- r1 : constructor function |
245 // -- lr : return address | 251 // -- lr : return address |
(...skipping 2619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 } | 2871 } |
2866 } | 2872 } |
2867 | 2873 |
2868 | 2874 |
2869 #undef __ | 2875 #undef __ |
2870 | 2876 |
2871 } // namespace internal | 2877 } // namespace internal |
2872 } // namespace v8 | 2878 } // namespace v8 |
2873 | 2879 |
2874 #endif // V8_TARGET_ARCH_ARM | 2880 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |