| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 : Heap::kMinusInfinityValueRootIndex; | 149 : Heap::kMinusInfinityValueRootIndex; |
| 150 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; | 150 DoubleRegister const reg = (kind == MathMaxMinKind::kMin) ? d2 : d1; |
| 151 | 151 |
| 152 // Load the accumulator with the default return value (either -Infinity or | 152 // Load the accumulator with the default return value (either -Infinity or |
| 153 // +Infinity), with the tagged value in r4 and the double value in d1. | 153 // +Infinity), with the tagged value in r4 and the double value in d1. |
| 154 __ LoadRoot(r4, root_index); | 154 __ LoadRoot(r4, root_index); |
| 155 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); | 155 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
| 156 | 156 |
| 157 // Setup state for loop | 157 // Setup state for loop |
| 158 // r5: address of arg[0] + kPointerSize | 158 // r5: address of arg[0] + kPointerSize |
| 159 // r6: number of arguments | 159 // r6: number of slots to drop at exit (arguments + receiver) |
| 160 __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2)); | 160 __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2)); |
| 161 __ add(r5, sp, r5); | 161 __ add(r5, sp, r5); |
| 162 __ mr(r6, r3); | 162 __ addi(r6, r3, Operand(1)); |
| 163 | 163 |
| 164 Label done_loop, loop; | 164 Label done_loop, loop; |
| 165 __ bind(&loop); | 165 __ bind(&loop); |
| 166 { | 166 { |
| 167 // Check if all parameters done. | 167 // Check if all parameters done. |
| 168 __ cmpl(r5, sp); | 168 __ cmpl(r5, sp); |
| 169 __ ble(&done_loop); | 169 __ ble(&done_loop); |
| 170 | 170 |
| 171 // Load the next parameter tagged value into r3. | 171 // Load the next parameter tagged value into r3. |
| 172 __ LoadPU(r3, MemOperand(r5, -kPointerSize)); | 172 __ LoadPU(r3, MemOperand(r5, -kPointerSize)); |
| 173 | 173 |
| 174 // 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 |
| 175 // parameter to a number first using the ToNumberStub if necessary. | 175 // parameter to a number first using the ToNumberStub if necessary. |
| 176 Label convert, convert_smi, convert_number, done_convert; | 176 Label convert, convert_smi, convert_number, done_convert; |
| 177 __ bind(&convert); | 177 __ bind(&convert); |
| 178 __ JumpIfSmi(r3, &convert_smi); | 178 __ JumpIfSmi(r3, &convert_smi); |
| 179 __ LoadP(r7, FieldMemOperand(r3, HeapObject::kMapOffset)); | 179 __ LoadP(r7, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 180 __ JumpIfRoot(r7, Heap::kHeapNumberMapRootIndex, &convert_number); | 180 __ JumpIfRoot(r7, Heap::kHeapNumberMapRootIndex, &convert_number); |
| 181 { | 181 { |
| 182 // Parameter is not a Number, use the ToNumberStub to convert it. | 182 // Parameter is not a Number, use the ToNumberStub to convert it. |
| 183 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 183 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 184 __ SmiTag(r6); | 184 __ SmiTag(r6); |
| 185 __ Push(r4, r5, r6); | 185 __ Push(r4, r5, r6); |
| 186 ToNumberStub stub(masm->isolate()); | 186 ToNumberStub stub(masm->isolate()); |
| 187 __ CallStub(&stub); | 187 __ CallStub(&stub); |
| 188 __ Pop(r4, r5, r6); | 188 __ Pop(r4, r5, r6); |
| 189 __ SmiUntag(r6); | 189 __ SmiUntag(r6); |
| 190 { | 190 { |
| 191 // Restore the double accumulator value (d1). | 191 // Restore the double accumulator value (d1). |
| 192 Label restore_smi, done_restore; | 192 Label done_restore; |
| 193 __ JumpIfSmi(r4, &restore_smi); | 193 __ SmiToDouble(d1, r4); |
| 194 __ JumpIfSmi(r4, &done_restore); |
| 194 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); | 195 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
| 195 __ b(&done_restore); | |
| 196 __ bind(&restore_smi); | |
| 197 __ SmiToDouble(d1, r4); | |
| 198 __ bind(&done_restore); | 196 __ bind(&done_restore); |
| 199 } | 197 } |
| 200 } | 198 } |
| 201 __ b(&convert); | 199 __ b(&convert); |
| 202 __ bind(&convert_number); | 200 __ bind(&convert_number); |
| 203 __ lfd(d2, FieldMemOperand(r3, HeapNumber::kValueOffset)); | 201 __ lfd(d2, FieldMemOperand(r3, HeapNumber::kValueOffset)); |
| 204 __ b(&done_convert); | 202 __ b(&done_convert); |
| 205 __ bind(&convert_smi); | 203 __ bind(&convert_smi); |
| 206 __ SmiToDouble(d2, r3); | 204 __ SmiToDouble(d2, r3); |
| 207 __ bind(&done_convert); | 205 __ bind(&done_convert); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 228 // We still need to visit the rest of the arguments. | 226 // We still need to visit the rest of the arguments. |
| 229 __ bind(&compare_nan); | 227 __ bind(&compare_nan); |
| 230 __ LoadRoot(r4, Heap::kNanValueRootIndex); | 228 __ LoadRoot(r4, Heap::kNanValueRootIndex); |
| 231 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); | 229 __ lfd(d1, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
| 232 __ b(&loop); | 230 __ b(&loop); |
| 233 } | 231 } |
| 234 | 232 |
| 235 __ bind(&done_loop); | 233 __ bind(&done_loop); |
| 236 __ mr(r3, r4); | 234 __ mr(r3, r4); |
| 237 __ Drop(r6); | 235 __ Drop(r6); |
| 238 __ Ret(1); | 236 __ Ret(); |
| 239 } | 237 } |
| 240 | 238 |
| 241 // static | 239 // static |
| 242 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { | 240 void Builtins::Generate_NumberConstructor(MacroAssembler* masm) { |
| 243 // ----------- S t a t e ------------- | 241 // ----------- S t a t e ------------- |
| 244 // -- r3 : number of arguments | 242 // -- r3 : number of arguments |
| 245 // -- r4 : constructor function | 243 // -- r4 : constructor function |
| 246 // -- lr : return address | 244 // -- lr : return address |
| 247 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 245 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
| 248 // -- sp[argc * 4] : receiver | 246 // -- sp[argc * 4] : receiver |
| (...skipping 2522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 __ bkpt(0); | 2769 __ bkpt(0); |
| 2772 } | 2770 } |
| 2773 } | 2771 } |
| 2774 | 2772 |
| 2775 | 2773 |
| 2776 #undef __ | 2774 #undef __ |
| 2777 } // namespace internal | 2775 } // namespace internal |
| 2778 } // namespace v8 | 2776 } // namespace v8 |
| 2779 | 2777 |
| 2780 #endif // V8_TARGET_ARCH_PPC | 2778 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |