OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // tail call a stub | 119 // tail call a stub |
120 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | 120 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
121 ArrayConstructorStub stub(masm->isolate()); | 121 ArrayConstructorStub stub(masm->isolate()); |
122 __ TailCallStub(&stub); | 122 __ TailCallStub(&stub); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 // static | 126 // static |
127 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 127 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
128 // ----------- S t a t e ------------- | 128 // ----------- S t a t e ------------- |
129 // -- r3 : number of arguments | 129 // -- r3 : number of arguments |
130 // -- r4 : function | 130 // -- r4 : function |
131 // -- cp : context | 131 // -- cp : context |
132 // -- lr : return address | 132 // -- lr : return address |
133 // -- sp[(argc - n) * 8] : arg[n] (zero-based) | 133 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
134 // -- sp[(argc + 1) * 8] : receiver | 134 // -- sp[argc * 4] : receiver |
135 // ----------------------------------- | 135 // ----------------------------------- |
136 Condition const cond_done = (kind == MathMaxMinKind::kMin) ? lt : gt; | 136 Condition const cond_done = (kind == MathMaxMinKind::kMin) ? lt : gt; |
137 Heap::RootListIndex const root_index = | 137 Heap::RootListIndex const root_index = |
138 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex | 138 (kind == MathMaxMinKind::kMin) ? Heap::kInfinityValueRootIndex |
139 : Heap::kMinusInfinityValueRootIndex; | 139 : Heap::kMinusInfinityValueRootIndex; |
140 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; | 140 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; |
141 | 141 |
142 // Load the accumulator with the default return value (either -Infinity or | 142 // Load the accumulator with the default return value (either -Infinity or |
143 // +Infinity), with the tagged value in r8 and the double value in d1. | 143 // +Infinity), with the tagged value in r8 and the double value in d1. |
144 __ LoadRoot(r8, root_index); | 144 __ LoadRoot(r8, root_index); |
145 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset)); | 145 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset)); |
146 | 146 |
147 // Setup state for loop | 147 // Setup state for loop |
148 // r5: address of arg[0] + kPointerSize | 148 // r5: address of arg[0] + kPointerSize |
149 // r6: number of slots to drop at exit (arguments + receiver) | 149 // r6: number of slots to drop at exit (arguments + receiver) |
150 __ addi(r7, r3, Operand(1)); | 150 __ addi(r7, r3, Operand(1)); |
151 | 151 |
152 Label done_loop, loop; | 152 Label done_loop, loop; |
| 153 __ mr(r7, r3); |
153 __ bind(&loop); | 154 __ bind(&loop); |
154 { | 155 { |
155 // Check if all parameters done. | 156 // Check if all parameters done. |
156 __ subi(r3, r3, Operand(1)); | 157 __ subi(r7, r7, Operand(1)); |
157 __ cmpi(r3, Operand::Zero()); | 158 __ cmpi(r7, Operand::Zero()); |
158 __ blt(&done_loop); | 159 __ blt(&done_loop); |
159 | 160 |
160 // Load the next parameter tagged value into r5. | 161 // Load the next parameter tagged value into r5. |
161 __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2)); | 162 __ ShiftLeftImm(r5, r7, Operand(kPointerSizeLog2)); |
162 __ LoadPX(r5, MemOperand(sp, r5)); | 163 __ LoadPX(r5, MemOperand(sp, r5)); |
163 | 164 |
164 // Load the double value of the parameter into d2, maybe converting the | 165 // Load the double value of the parameter into d2, maybe converting the |
165 // parameter to a number first using the ToNumber builtin if necessary. | 166 // parameter to a number first using the ToNumber builtin if necessary. |
166 Label convert, convert_smi, convert_number, done_convert; | 167 Label convert, convert_smi, convert_number, done_convert; |
167 __ bind(&convert); | 168 __ bind(&convert); |
168 __ JumpIfSmi(r5, &convert_smi); | 169 __ JumpIfSmi(r5, &convert_smi); |
169 __ LoadP(r6, FieldMemOperand(r5, HeapObject::kMapOffset)); | 170 __ LoadP(r6, FieldMemOperand(r5, HeapObject::kMapOffset)); |
170 __ JumpIfRoot(r6, Heap::kHeapNumberMapRootIndex, &convert_number); | 171 __ JumpIfRoot(r6, Heap::kHeapNumberMapRootIndex, &convert_number); |
171 { | 172 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 226 |
226 // At least one side is NaN, which means that the result will be NaN too. | 227 // At least one side is NaN, which means that the result will be NaN too. |
227 // We still need to visit the rest of the arguments. | 228 // We still need to visit the rest of the arguments. |
228 __ bind(&compare_nan); | 229 __ bind(&compare_nan); |
229 __ LoadRoot(r8, Heap::kNanValueRootIndex); | 230 __ LoadRoot(r8, Heap::kNanValueRootIndex); |
230 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset)); | 231 __ lfd(d1, FieldMemOperand(r8, HeapNumber::kValueOffset)); |
231 __ b(&loop); | 232 __ b(&loop); |
232 } | 233 } |
233 | 234 |
234 __ bind(&done_loop); | 235 __ bind(&done_loop); |
| 236 // Drop all slots, including the receiver. |
| 237 __ addi(r3, r3, Operand(1)); |
| 238 __ Drop(r3); |
235 __ mr(r3, r8); | 239 __ mr(r3, r8); |
236 __ Drop(r7); | |
237 __ Ret(); | 240 __ Ret(); |
238 } | 241 } |
239 | 242 |
240 // static | 243 // static |
241 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 244 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
242 // ----------- S t a t e ------------- | 245 // ----------- S t a t e ------------- |
243 // -- r3 : number of arguments | 246 // -- r3 : number of arguments |
244 // -- r4 : constructor function | 247 // -- r4 : constructor function |
245 // -- lr : return address | 248 // -- lr : return address |
246 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 249 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3000 __ bkpt(0); | 3003 __ bkpt(0); |
3001 } | 3004 } |
3002 } | 3005 } |
3003 | 3006 |
3004 | 3007 |
3005 #undef __ | 3008 #undef __ |
3006 } // namespace internal | 3009 } // namespace internal |
3007 } // namespace v8 | 3010 } // namespace v8 |
3008 | 3011 |
3009 #endif // V8_TARGET_ARCH_PPC | 3012 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |