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 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/debug/debug.h" | 12 #include "src/debug/debug.h" |
13 #include "src/mips64/macro-assembler-mips64.h" | 13 #include "src/mips64/macro-assembler-mips64.h" |
14 #include "src/register-configuration.h" | 14 #include "src/register-configuration.h" |
15 #include "src/runtime/runtime.h" | 15 #include "src/runtime/runtime.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
| 20 // Floating point constants. |
| 21 const uint64_t kDoubleSignMask = Double::kSignMask; |
| 22 const uint32_t kDoubleExponentShift = HeapNumber::kMantissaBits; |
| 23 const uint32_t kDoubleNaNShift = kDoubleExponentShift - 1; |
| 24 const uint64_t kDoubleNaNMask = |
| 25 kDoubleSignMask | Double::kExponentMask | (1L << kDoubleNaNShift); |
| 26 |
| 27 const uint32_t kSingleSignMask = kBinary32SignMask; |
| 28 const uint32_t kSingleExponentMask = kBinary32ExponentMask; |
| 29 const uint32_t kSingleExponentShift = kBinary32ExponentShift; |
| 30 const uint32_t kSingleNaNShift = kSingleExponentShift - 1; |
| 31 const uint32_t kSingleNaNMask = |
| 32 kSingleSignMask | kSingleExponentMask | (1 << kSingleNaNShift); |
| 33 |
20 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size, | 34 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size, |
21 CodeObjectRequired create_code_object) | 35 CodeObjectRequired create_code_object) |
22 : Assembler(arg_isolate, buffer, size), | 36 : Assembler(arg_isolate, buffer, size), |
23 generating_stub_(false), | 37 generating_stub_(false), |
24 has_frame_(false), | 38 has_frame_(false), |
25 has_double_zero_reg_set_(false) { | 39 has_double_zero_reg_set_(false) { |
26 if (create_code_object == CodeObjectRequired::kYes) { | 40 if (create_code_object == CodeObjectRequired::kYes) { |
27 code_object_ = | 41 code_object_ = |
28 Handle<Object>::New(isolate()->heap()->undefined_value(), isolate()); | 42 Handle<Object>::New(isolate()->heap()->undefined_value(), isolate()); |
29 } | 43 } |
(...skipping 4817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4847 bind(&done); | 4861 bind(&done); |
4848 Daddu(scratch1, elements_reg, | 4862 Daddu(scratch1, elements_reg, |
4849 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag - | 4863 Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag - |
4850 elements_offset)); | 4864 elements_offset)); |
4851 dsra(scratch2, key_reg, 32 - kDoubleSizeLog2); | 4865 dsra(scratch2, key_reg, 32 - kDoubleSizeLog2); |
4852 Daddu(scratch1, scratch1, scratch2); | 4866 Daddu(scratch1, scratch1, scratch2); |
4853 // scratch1 is now effective address of the double element. | 4867 // scratch1 is now effective address of the double element. |
4854 sdc1(double_result, MemOperand(scratch1, 0)); | 4868 sdc1(double_result, MemOperand(scratch1, 0)); |
4855 } | 4869 } |
4856 | 4870 |
| 4871 void MacroAssembler::SubNanPreservePayloadAndSign_s(FPURegister fd, |
| 4872 FPURegister fs, |
| 4873 FPURegister ft) { |
| 4874 FloatRegister dest = fd.is(fs) || fd.is(ft) ? kLithiumScratchDouble : fd; |
| 4875 Label check_nan, save_payload, done; |
| 4876 Register scratch1 = t8; |
| 4877 Register scratch2 = t9; |
| 4878 |
| 4879 sub_s(dest, fs, ft); |
| 4880 // Check if the result of subtraction is NaN. |
| 4881 BranchF32(nullptr, &check_nan, eq, fs, ft); |
| 4882 Branch(USE_DELAY_SLOT, &done); |
| 4883 dest.is(fd) ? nop() : mov_s(fd, dest); |
| 4884 |
| 4885 bind(&check_nan); |
| 4886 // Check if first operand is a NaN. |
| 4887 mfc1(scratch1, fs); |
| 4888 BranchF32(nullptr, &save_payload, eq, fs, fs); |
| 4889 // Second operand must be a NaN. |
| 4890 mfc1(scratch1, ft); |
| 4891 |
| 4892 bind(&save_payload); |
| 4893 // Reserve payload. |
| 4894 And(scratch1, scratch1, |
| 4895 Operand(kSingleSignMask | ((1 << kSingleNaNShift) - 1))); |
| 4896 mfc1(scratch2, dest); |
| 4897 And(scratch2, scratch2, Operand(kSingleNaNMask)); |
| 4898 Or(scratch2, scratch2, scratch1); |
| 4899 mtc1(scratch2, fd); |
| 4900 |
| 4901 bind(&done); |
| 4902 } |
| 4903 |
| 4904 void MacroAssembler::SubNanPreservePayloadAndSign_d(FPURegister fd, |
| 4905 FPURegister fs, |
| 4906 FPURegister ft) { |
| 4907 FloatRegister dest = fd.is(fs) || fd.is(ft) ? kLithiumScratchDouble : fd; |
| 4908 Label check_nan, save_payload, done; |
| 4909 Register scratch1 = t8; |
| 4910 Register scratch2 = t9; |
| 4911 |
| 4912 sub_d(dest, fs, ft); |
| 4913 // Check if the result of subtraction is NaN. |
| 4914 BranchF64(nullptr, &check_nan, eq, fs, ft); |
| 4915 Branch(USE_DELAY_SLOT, &done); |
| 4916 dest.is(fd) ? nop() : mov_d(fd, dest); |
| 4917 |
| 4918 bind(&check_nan); |
| 4919 // Check if first operand is a NaN. |
| 4920 dmfc1(scratch1, fs); |
| 4921 BranchF64(nullptr, &save_payload, eq, fs, fs); |
| 4922 // Second operand must be a NaN. |
| 4923 dmfc1(scratch1, ft); |
| 4924 |
| 4925 bind(&save_payload); |
| 4926 // Reserve payload. |
| 4927 li(at, Operand(kDoubleSignMask | (1L << kDoubleNaNShift))); |
| 4928 Dsubu(at, at, Operand(1)); |
| 4929 And(scratch1, scratch1, at); |
| 4930 dmfc1(scratch2, dest); |
| 4931 And(scratch2, scratch2, Operand(kDoubleNaNMask)); |
| 4932 Or(scratch2, scratch2, scratch1); |
| 4933 dmtc1(scratch2, fd); |
| 4934 |
| 4935 bind(&done); |
| 4936 } |
4857 | 4937 |
4858 void MacroAssembler::CompareMapAndBranch(Register obj, | 4938 void MacroAssembler::CompareMapAndBranch(Register obj, |
4859 Register scratch, | 4939 Register scratch, |
4860 Handle<Map> map, | 4940 Handle<Map> map, |
4861 Label* early_success, | 4941 Label* early_success, |
4862 Condition cond, | 4942 Condition cond, |
4863 Label* branch_to) { | 4943 Label* branch_to) { |
4864 ld(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 4944 ld(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
4865 CompareMapAndBranch(scratch, map, early_success, cond, branch_to); | 4945 CompareMapAndBranch(scratch, map, early_success, cond, branch_to); |
4866 } | 4946 } |
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7143 if (mag.shift > 0) sra(result, result, mag.shift); | 7223 if (mag.shift > 0) sra(result, result, mag.shift); |
7144 srl(at, dividend, 31); | 7224 srl(at, dividend, 31); |
7145 Addu(result, result, Operand(at)); | 7225 Addu(result, result, Operand(at)); |
7146 } | 7226 } |
7147 | 7227 |
7148 | 7228 |
7149 } // namespace internal | 7229 } // namespace internal |
7150 } // namespace v8 | 7230 } // namespace v8 |
7151 | 7231 |
7152 #endif // V8_TARGET_ARCH_MIPS64 | 7232 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |