| 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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
| 7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
| 10 #include "src/mips/macro-assembler-mips.h" | 10 #include "src/mips/macro-assembler-mips.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 __ srl(at, kScratchReg, 31); | 185 __ srl(at, kScratchReg, 31); |
| 186 __ sll(at, at, 31); | 186 __ sll(at, at, 31); |
| 187 __ Mthc1(at, result_); | 187 __ Mthc1(at, result_); |
| 188 } | 188 } |
| 189 | 189 |
| 190 private: | 190 private: |
| 191 DoubleRegister const result_; | 191 DoubleRegister const result_; |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 | 194 |
| 195 class OutOfLineRound32 : public OutOfLineCode { |
| 196 public: |
| 197 OutOfLineRound32(CodeGenerator* gen, DoubleRegister result) |
| 198 : OutOfLineCode(gen), result_(result) {} |
| 199 |
| 200 void Generate() final { |
| 201 // Handle rounding to zero case where sign has to be preserved. |
| 202 // High bits of float input already in kScratchReg. |
| 203 __ srl(at, kScratchReg, 31); |
| 204 __ sll(at, at, 31); |
| 205 __ mtc1(at, result_); |
| 206 } |
| 207 |
| 208 private: |
| 209 DoubleRegister const result_; |
| 210 }; |
| 211 |
| 212 |
| 195 class OutOfLineTruncate final : public OutOfLineRound { | 213 class OutOfLineTruncate final : public OutOfLineRound { |
| 196 public: | 214 public: |
| 197 OutOfLineTruncate(CodeGenerator* gen, DoubleRegister result) | 215 OutOfLineTruncate(CodeGenerator* gen, DoubleRegister result) |
| 198 : OutOfLineRound(gen, result) {} | 216 : OutOfLineRound(gen, result) {} |
| 199 }; | 217 }; |
| 200 | 218 |
| 201 | 219 |
| 202 class OutOfLineFloor final : public OutOfLineRound { | 220 class OutOfLineFloor final : public OutOfLineRound { |
| 203 public: | 221 public: |
| 204 OutOfLineFloor(CodeGenerator* gen, DoubleRegister result) | 222 OutOfLineFloor(CodeGenerator* gen, DoubleRegister result) |
| 205 : OutOfLineRound(gen, result) {} | 223 : OutOfLineRound(gen, result) {} |
| 206 }; | 224 }; |
| 207 | 225 |
| 208 | 226 |
| 209 class OutOfLineCeil final : public OutOfLineRound { | 227 class OutOfLineCeil final : public OutOfLineRound { |
| 210 public: | 228 public: |
| 211 OutOfLineCeil(CodeGenerator* gen, DoubleRegister result) | 229 OutOfLineCeil(CodeGenerator* gen, DoubleRegister result) |
| 212 : OutOfLineRound(gen, result) {} | 230 : OutOfLineRound(gen, result) {} |
| 213 }; | 231 }; |
| 214 | 232 |
| 215 | 233 |
| 216 class OutOfLineTiesEven final : public OutOfLineRound { | 234 class OutOfLineTiesEven final : public OutOfLineRound { |
| 217 public: | 235 public: |
| 218 OutOfLineTiesEven(CodeGenerator* gen, DoubleRegister result) | 236 OutOfLineTiesEven(CodeGenerator* gen, DoubleRegister result) |
| 219 : OutOfLineRound(gen, result) {} | 237 : OutOfLineRound(gen, result) {} |
| 220 }; | 238 }; |
| 221 | 239 |
| 222 | 240 |
| 241 class OutOfLineTruncate32 final : public OutOfLineRound32 { |
| 242 public: |
| 243 OutOfLineTruncate32(CodeGenerator* gen, DoubleRegister result) |
| 244 : OutOfLineRound32(gen, result) {} |
| 245 }; |
| 246 |
| 247 |
| 248 class OutOfLineFloor32 final : public OutOfLineRound32 { |
| 249 public: |
| 250 OutOfLineFloor32(CodeGenerator* gen, DoubleRegister result) |
| 251 : OutOfLineRound32(gen, result) {} |
| 252 }; |
| 253 |
| 254 |
| 255 class OutOfLineCeil32 final : public OutOfLineRound32 { |
| 256 public: |
| 257 OutOfLineCeil32(CodeGenerator* gen, DoubleRegister result) |
| 258 : OutOfLineRound32(gen, result) {} |
| 259 }; |
| 260 |
| 261 |
| 262 class OutOfLineTiesEven32 final : public OutOfLineRound32 { |
| 263 public: |
| 264 OutOfLineTiesEven32(CodeGenerator* gen, DoubleRegister result) |
| 265 : OutOfLineRound32(gen, result) {} |
| 266 }; |
| 267 |
| 268 |
| 223 class OutOfLineRecordWrite final : public OutOfLineCode { | 269 class OutOfLineRecordWrite final : public OutOfLineCode { |
| 224 public: | 270 public: |
| 225 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, | 271 OutOfLineRecordWrite(CodeGenerator* gen, Register object, Register index, |
| 226 Register value, Register scratch0, Register scratch1, | 272 Register value, Register scratch0, Register scratch1, |
| 227 RecordWriteMode mode) | 273 RecordWriteMode mode) |
| 228 : OutOfLineCode(gen), | 274 : OutOfLineCode(gen), |
| 229 object_(object), | 275 object_(object), |
| 230 index_(index), | 276 index_(index), |
| 231 value_(value), | 277 value_(value), |
| 232 scratch0_(scratch0), | 278 scratch0_(scratch0), |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ | 492 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
| 447 __ Move(at, kScratchReg2, i.OutputDoubleRegister()); \ | 493 __ Move(at, kScratchReg2, i.OutputDoubleRegister()); \ |
| 448 __ or_(at, at, kScratchReg2); \ | 494 __ or_(at, at, kScratchReg2); \ |
| 449 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ | 495 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ |
| 450 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ | 496 __ cvt_d_l(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
| 451 __ bind(ool->exit()); \ | 497 __ bind(ool->exit()); \ |
| 452 __ bind(&done); \ | 498 __ bind(&done); \ |
| 453 } while (0) | 499 } while (0) |
| 454 | 500 |
| 455 | 501 |
| 502 #define ASSEMBLE_ROUND_FLOAT_TO_FLOAT(asm_instr, operation) \ |
| 503 do { \ |
| 504 int32_t kFloat32ExponentBias = 127; \ |
| 505 int32_t kFloat32MantissaBits = 23; \ |
| 506 int32_t kFloat32ExponentBits = 8; \ |
| 507 auto ool = \ |
| 508 new (zone()) OutOfLine##operation##32(this, i.OutputDoubleRegister()); \ |
| 509 Label done; \ |
| 510 __ mtc1(kScratchReg, i.InputDoubleRegister(0)); \ |
| 511 __ Ext(at, kScratchReg, kFloat32MantissaBits, kFloat32ExponentBits); \ |
| 512 __ Branch(USE_DELAY_SLOT, &done, hs, at, \ |
| 513 Operand(kFloat32ExponentBias + kFloat32MantissaBits)); \ |
| 514 __ mov_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
| 515 __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
| 516 __ mfc1(at, i.OutputDoubleRegister()); \ |
| 517 __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ |
| 518 __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
| 519 __ bind(ool->exit()); \ |
| 520 __ bind(&done); \ |
| 521 } while (0) |
| 522 |
| 456 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 523 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
| 457 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 524 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
| 458 if (sp_slot_delta > 0) { | 525 if (sp_slot_delta > 0) { |
| 459 __ addiu(sp, sp, sp_slot_delta * kPointerSize); | 526 __ addiu(sp, sp, sp_slot_delta * kPointerSize); |
| 460 } | 527 } |
| 461 if (frame()->needs_frame()) { | 528 if (frame()->needs_frame()) { |
| 462 __ Pop(ra, fp); | 529 __ Pop(ra, fp); |
| 463 } | 530 } |
| 464 frame_access_state()->SetFrameAccessToDefault(); | 531 frame_access_state()->SetFrameAccessToDefault(); |
| 465 } | 532 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 i.InputDoubleRegister(1)); | 873 i.InputDoubleRegister(1)); |
| 807 break; | 874 break; |
| 808 case kMipsMinD: | 875 case kMipsMinD: |
| 809 __ min_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), | 876 __ min_d(i.OutputDoubleRegister(), i.InputDoubleRegister(0), |
| 810 i.InputDoubleRegister(1)); | 877 i.InputDoubleRegister(1)); |
| 811 break; | 878 break; |
| 812 case kMipsFloat64RoundDown: { | 879 case kMipsFloat64RoundDown: { |
| 813 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(floor_l_d, Floor); | 880 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(floor_l_d, Floor); |
| 814 break; | 881 break; |
| 815 } | 882 } |
| 883 case kMipsFloat32RoundDown: { |
| 884 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(floor_w_s, Floor); |
| 885 break; |
| 886 } |
| 816 case kMipsFloat64RoundTruncate: { | 887 case kMipsFloat64RoundTruncate: { |
| 817 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(trunc_l_d, Truncate); | 888 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(trunc_l_d, Truncate); |
| 818 break; | 889 break; |
| 819 } | 890 } |
| 891 case kMipsFloat32RoundTruncate: { |
| 892 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(trunc_w_s, Truncate); |
| 893 break; |
| 894 } |
| 820 case kMipsFloat64RoundUp: { | 895 case kMipsFloat64RoundUp: { |
| 821 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(ceil_l_d, Ceil); | 896 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(ceil_l_d, Ceil); |
| 822 break; | 897 break; |
| 823 } | 898 } |
| 899 case kMipsFloat32RoundUp: { |
| 900 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(ceil_w_s, Ceil); |
| 901 break; |
| 902 } |
| 824 case kMipsFloat64RoundTiesEven: { | 903 case kMipsFloat64RoundTiesEven: { |
| 825 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(round_l_d, TiesEven); | 904 ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(round_l_d, TiesEven); |
| 826 break; | 905 break; |
| 827 } | 906 } |
| 907 case kMipsFloat32RoundTiesEven: { |
| 908 ASSEMBLE_ROUND_FLOAT_TO_FLOAT(round_w_s, TiesEven); |
| 909 break; |
| 910 } |
| 828 case kMipsFloat64Max: { | 911 case kMipsFloat64Max: { |
| 829 // (b < a) ? a : b | 912 // (b < a) ? a : b |
| 830 if (IsMipsArchVariant(kMips32r6)) { | 913 if (IsMipsArchVariant(kMips32r6)) { |
| 831 __ cmp_d(OLT, i.OutputDoubleRegister(), i.InputDoubleRegister(1), | 914 __ cmp_d(OLT, i.OutputDoubleRegister(), i.InputDoubleRegister(1), |
| 832 i.InputDoubleRegister(0)); | 915 i.InputDoubleRegister(0)); |
| 833 __ sel_d(i.OutputDoubleRegister(), i.InputDoubleRegister(1), | 916 __ sel_d(i.OutputDoubleRegister(), i.InputDoubleRegister(1), |
| 834 i.InputDoubleRegister(0)); | 917 i.InputDoubleRegister(0)); |
| 835 } else { | 918 } else { |
| 836 __ c_d(OLT, i.InputDoubleRegister(0), i.InputDoubleRegister(1)); | 919 __ c_d(OLT, i.InputDoubleRegister(0), i.InputDoubleRegister(1)); |
| 837 // Left operand is result, passthrough if false. | 920 // Left operand is result, passthrough if false. |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 padding_size -= v8::internal::Assembler::kInstrSize; | 1695 padding_size -= v8::internal::Assembler::kInstrSize; |
| 1613 } | 1696 } |
| 1614 } | 1697 } |
| 1615 } | 1698 } |
| 1616 | 1699 |
| 1617 #undef __ | 1700 #undef __ |
| 1618 | 1701 |
| 1619 } // namespace compiler | 1702 } // namespace compiler |
| 1620 } // namespace internal | 1703 } // namespace internal |
| 1621 } // namespace v8 | 1704 } // namespace v8 |
| OLD | NEW |