| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include <cmath> | 5 #include <cmath> |
| 6 #include <functional> | 6 #include <functional> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 | 961 |
| 962 FOR_INT32_INPUTS(i) { | 962 FOR_INT32_INPUTS(i) { |
| 963 int32_t magic = 0x2342aabb + *i * 3; | 963 int32_t magic = 0x2342aabb + *i * 3; |
| 964 RawMachineAssemblerTester<int32_t> m; | 964 RawMachineAssemblerTester<int32_t> m; |
| 965 int32_t offset = *i; | 965 int32_t offset = *i; |
| 966 byte* from = reinterpret_cast<byte*>(&p1) - offset; | 966 byte* from = reinterpret_cast<byte*>(&p1) - offset; |
| 967 byte* to = reinterpret_cast<byte*>(&p2) - offset; | 967 byte* to = reinterpret_cast<byte*>(&p2) - offset; |
| 968 // generate load [#base + #index] | 968 // generate load [#base + #index] |
| 969 Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from), | 969 Node* load = m.Load(MachineType::Float32(), m.PointerConstant(from), |
| 970 m.IntPtrConstant(offset)); | 970 m.IntPtrConstant(offset)); |
| 971 m.Store(MachineType::Float32(), m.PointerConstant(to), | 971 m.Store(MachineRepresentation::kFloat32, m.PointerConstant(to), |
| 972 m.IntPtrConstant(offset), load, kNoWriteBarrier); | 972 m.IntPtrConstant(offset), load, kNoWriteBarrier); |
| 973 m.Return(m.Int32Constant(magic)); | 973 m.Return(m.Int32Constant(magic)); |
| 974 | 974 |
| 975 FOR_FLOAT32_INPUTS(j) { | 975 FOR_FLOAT32_INPUTS(j) { |
| 976 p1 = *j; | 976 p1 = *j; |
| 977 p2 = *j - 5; | 977 p2 = *j - 5; |
| 978 CHECK_EQ(magic, m.Call()); | 978 CHECK_EQ(magic, m.Call()); |
| 979 CheckDoubleEq(p1, p2); | 979 CheckDoubleEq(p1, p2); |
| 980 } | 980 } |
| 981 } | 981 } |
| 982 } | 982 } |
| 983 | 983 |
| 984 | 984 |
| 985 TEST(RunLoadStoreFloat64Offset) { | 985 TEST(RunLoadStoreFloat64Offset) { |
| 986 double p1 = 0; // loads directly from this location. | 986 double p1 = 0; // loads directly from this location. |
| 987 double p2 = 0; // and stores directly into this location. | 987 double p2 = 0; // and stores directly into this location. |
| 988 | 988 |
| 989 FOR_INT32_INPUTS(i) { | 989 FOR_INT32_INPUTS(i) { |
| 990 int32_t magic = 0x2342aabb + *i * 3; | 990 int32_t magic = 0x2342aabb + *i * 3; |
| 991 RawMachineAssemblerTester<int32_t> m; | 991 RawMachineAssemblerTester<int32_t> m; |
| 992 int32_t offset = *i; | 992 int32_t offset = *i; |
| 993 byte* from = reinterpret_cast<byte*>(&p1) - offset; | 993 byte* from = reinterpret_cast<byte*>(&p1) - offset; |
| 994 byte* to = reinterpret_cast<byte*>(&p2) - offset; | 994 byte* to = reinterpret_cast<byte*>(&p2) - offset; |
| 995 // generate load [#base + #index] | 995 // generate load [#base + #index] |
| 996 Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from), | 996 Node* load = m.Load(MachineType::Float64(), m.PointerConstant(from), |
| 997 m.IntPtrConstant(offset)); | 997 m.IntPtrConstant(offset)); |
| 998 m.Store(MachineType::Float64(), m.PointerConstant(to), | 998 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(to), |
| 999 m.IntPtrConstant(offset), load, kNoWriteBarrier); | 999 m.IntPtrConstant(offset), load, kNoWriteBarrier); |
| 1000 m.Return(m.Int32Constant(magic)); | 1000 m.Return(m.Int32Constant(magic)); |
| 1001 | 1001 |
| 1002 FOR_FLOAT64_INPUTS(j) { | 1002 FOR_FLOAT64_INPUTS(j) { |
| 1003 p1 = *j; | 1003 p1 = *j; |
| 1004 p2 = *j - 5; | 1004 p2 = *j - 5; |
| 1005 CHECK_EQ(magic, m.Call()); | 1005 CHECK_EQ(magic, m.Call()); |
| 1006 CheckDoubleEq(p1, p2); | 1006 CheckDoubleEq(p1, p2); |
| 1007 } | 1007 } |
| 1008 } | 1008 } |
| (...skipping 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3399 for (size_t i = 0; i < sizeof(buffer); i++) { | 3399 for (size_t i = 0; i < sizeof(buffer); i++) { |
| 3400 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); | 3400 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); |
| 3401 } | 3401 } |
| 3402 | 3402 |
| 3403 RawMachineAssemblerTester<int32_t> m; | 3403 RawMachineAssemblerTester<int32_t> m; |
| 3404 int32_t OK = 0x29000 + x; | 3404 int32_t OK = 0x29000 + x; |
| 3405 Node* base = m.PointerConstant(buffer); | 3405 Node* base = m.PointerConstant(buffer); |
| 3406 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); | 3406 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); |
| 3407 Node* load = m.Load(rep, base, index0); | 3407 Node* load = m.Load(rep, base, index0); |
| 3408 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); | 3408 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); |
| 3409 m.Store(rep, base, index1, load, kNoWriteBarrier); | 3409 m.Store(rep.representation(), base, index1, load, kNoWriteBarrier); |
| 3410 m.Return(m.Int32Constant(OK)); | 3410 m.Return(m.Int32Constant(OK)); |
| 3411 | 3411 |
| 3412 CHECK(buffer[x] != buffer[y]); | 3412 CHECK(buffer[x] != buffer[y]); |
| 3413 CHECK_EQ(OK, m.Call()); | 3413 CHECK_EQ(OK, m.Call()); |
| 3414 CHECK(buffer[x] == buffer[y]); | 3414 CHECK(buffer[x] == buffer[y]); |
| 3415 } | 3415 } |
| 3416 } | 3416 } |
| 3417 | 3417 |
| 3418 | 3418 |
| 3419 TEST(RunLoadStore) { | 3419 TEST(RunLoadStore) { |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4039 RawMachineLabel blocka, blockb, end; | 4039 RawMachineLabel blocka, blockb, end; |
| 4040 Node* k1 = m.Float32Constant(constant); | 4040 Node* k1 = m.Float32Constant(constant); |
| 4041 Node* k2 = m.Float32Constant(0 - constant); | 4041 Node* k2 = m.Float32Constant(0 - constant); |
| 4042 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4042 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4043 m.Bind(&blocka); | 4043 m.Bind(&blocka); |
| 4044 m.Goto(&end); | 4044 m.Goto(&end); |
| 4045 m.Bind(&blockb); | 4045 m.Bind(&blockb); |
| 4046 m.Goto(&end); | 4046 m.Goto(&end); |
| 4047 m.Bind(&end); | 4047 m.Bind(&end); |
| 4048 Node* phi = m.Phi(MachineRepresentation::kFloat32, k2, k1); | 4048 Node* phi = m.Phi(MachineRepresentation::kFloat32, k2, k1); |
| 4049 m.Store(MachineType::Float32(), m.PointerConstant(&buffer), | 4049 m.Store(MachineRepresentation::kFloat32, m.PointerConstant(&buffer), |
| 4050 m.IntPtrConstant(0), phi, kNoWriteBarrier); | 4050 m.IntPtrConstant(0), phi, kNoWriteBarrier); |
| 4051 m.Return(m.Int32Constant(magic)); | 4051 m.Return(m.Int32Constant(magic)); |
| 4052 | 4052 |
| 4053 CHECK_EQ(magic, m.Call()); | 4053 CHECK_EQ(magic, m.Call()); |
| 4054 CHECK(constant == buffer); | 4054 CHECK(constant == buffer); |
| 4055 } | 4055 } |
| 4056 | 4056 |
| 4057 | 4057 |
| 4058 TEST(RunDoubleDiamond) { | 4058 TEST(RunDoubleDiamond) { |
| 4059 RawMachineAssemblerTester<int32_t> m; | 4059 RawMachineAssemblerTester<int32_t> m; |
| 4060 | 4060 |
| 4061 const int magic = 99645; | 4061 const int magic = 99645; |
| 4062 double buffer = 0.1; | 4062 double buffer = 0.1; |
| 4063 double constant = 99.99; | 4063 double constant = 99.99; |
| 4064 | 4064 |
| 4065 RawMachineLabel blocka, blockb, end; | 4065 RawMachineLabel blocka, blockb, end; |
| 4066 Node* k1 = m.Float64Constant(constant); | 4066 Node* k1 = m.Float64Constant(constant); |
| 4067 Node* k2 = m.Float64Constant(0 - constant); | 4067 Node* k2 = m.Float64Constant(0 - constant); |
| 4068 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4068 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4069 m.Bind(&blocka); | 4069 m.Bind(&blocka); |
| 4070 m.Goto(&end); | 4070 m.Goto(&end); |
| 4071 m.Bind(&blockb); | 4071 m.Bind(&blockb); |
| 4072 m.Goto(&end); | 4072 m.Goto(&end); |
| 4073 m.Bind(&end); | 4073 m.Bind(&end); |
| 4074 Node* phi = m.Phi(MachineRepresentation::kFloat64, k2, k1); | 4074 Node* phi = m.Phi(MachineRepresentation::kFloat64, k2, k1); |
| 4075 m.Store(MachineType::Float64(), m.PointerConstant(&buffer), | 4075 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&buffer), |
| 4076 m.Int32Constant(0), phi, kNoWriteBarrier); | 4076 m.Int32Constant(0), phi, kNoWriteBarrier); |
| 4077 m.Return(m.Int32Constant(magic)); | 4077 m.Return(m.Int32Constant(magic)); |
| 4078 | 4078 |
| 4079 CHECK_EQ(magic, m.Call()); | 4079 CHECK_EQ(magic, m.Call()); |
| 4080 CHECK_EQ(constant, buffer); | 4080 CHECK_EQ(constant, buffer); |
| 4081 } | 4081 } |
| 4082 | 4082 |
| 4083 | 4083 |
| 4084 TEST(RunRefDiamond) { | 4084 TEST(RunRefDiamond) { |
| 4085 RawMachineAssemblerTester<int32_t> m; | 4085 RawMachineAssemblerTester<int32_t> m; |
| 4086 | 4086 |
| 4087 const int magic = 99644; | 4087 const int magic = 99644; |
| 4088 Handle<String> rexpected = | 4088 Handle<String> rexpected = |
| 4089 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); | 4089 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); |
| 4090 String* buffer; | 4090 String* buffer; |
| 4091 | 4091 |
| 4092 RawMachineLabel blocka, blockb, end; | 4092 RawMachineLabel blocka, blockb, end; |
| 4093 Node* k1 = m.StringConstant("A"); | 4093 Node* k1 = m.StringConstant("A"); |
| 4094 Node* k2 = m.StringConstant("B"); | 4094 Node* k2 = m.StringConstant("B"); |
| 4095 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4095 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4096 m.Bind(&blocka); | 4096 m.Bind(&blocka); |
| 4097 m.Goto(&end); | 4097 m.Goto(&end); |
| 4098 m.Bind(&blockb); | 4098 m.Bind(&blockb); |
| 4099 m.Goto(&end); | 4099 m.Goto(&end); |
| 4100 m.Bind(&end); | 4100 m.Bind(&end); |
| 4101 Node* phi = m.Phi(MachineRepresentation::kTagged, k2, k1); | 4101 Node* phi = m.Phi(MachineRepresentation::kTagged, k2, k1); |
| 4102 m.Store(MachineType::AnyTagged(), m.PointerConstant(&buffer), | 4102 m.Store(MachineRepresentation::kTagged, m.PointerConstant(&buffer), |
| 4103 m.Int32Constant(0), phi, kNoWriteBarrier); | 4103 m.Int32Constant(0), phi, kNoWriteBarrier); |
| 4104 m.Return(m.Int32Constant(magic)); | 4104 m.Return(m.Int32Constant(magic)); |
| 4105 | 4105 |
| 4106 CHECK_EQ(magic, m.Call()); | 4106 CHECK_EQ(magic, m.Call()); |
| 4107 CHECK(rexpected->SameValue(buffer)); | 4107 CHECK(rexpected->SameValue(buffer)); |
| 4108 } | 4108 } |
| 4109 | 4109 |
| 4110 | 4110 |
| 4111 TEST(RunDoubleRefDiamond) { | 4111 TEST(RunDoubleRefDiamond) { |
| 4112 RawMachineAssemblerTester<int32_t> m; | 4112 RawMachineAssemblerTester<int32_t> m; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4124 Node* r1 = m.StringConstant("AX"); | 4124 Node* r1 = m.StringConstant("AX"); |
| 4125 Node* r2 = m.StringConstant("BX"); | 4125 Node* r2 = m.StringConstant("BX"); |
| 4126 m.Branch(m.Int32Constant(0), &blocka, &blockb); | 4126 m.Branch(m.Int32Constant(0), &blocka, &blockb); |
| 4127 m.Bind(&blocka); | 4127 m.Bind(&blocka); |
| 4128 m.Goto(&end); | 4128 m.Goto(&end); |
| 4129 m.Bind(&blockb); | 4129 m.Bind(&blockb); |
| 4130 m.Goto(&end); | 4130 m.Goto(&end); |
| 4131 m.Bind(&end); | 4131 m.Bind(&end); |
| 4132 Node* dphi = m.Phi(MachineRepresentation::kFloat64, d2, d1); | 4132 Node* dphi = m.Phi(MachineRepresentation::kFloat64, d2, d1); |
| 4133 Node* rphi = m.Phi(MachineRepresentation::kTagged, r2, r1); | 4133 Node* rphi = m.Phi(MachineRepresentation::kTagged, r2, r1); |
| 4134 m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer), | 4134 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&dbuffer), |
| 4135 m.Int32Constant(0), dphi, kNoWriteBarrier); | 4135 m.Int32Constant(0), dphi, kNoWriteBarrier); |
| 4136 m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer), | 4136 m.Store(MachineRepresentation::kTagged, m.PointerConstant(&rbuffer), |
| 4137 m.Int32Constant(0), rphi, kNoWriteBarrier); | 4137 m.Int32Constant(0), rphi, kNoWriteBarrier); |
| 4138 m.Return(m.Int32Constant(magic)); | 4138 m.Return(m.Int32Constant(magic)); |
| 4139 | 4139 |
| 4140 CHECK_EQ(magic, m.Call()); | 4140 CHECK_EQ(magic, m.Call()); |
| 4141 CHECK_EQ(dconstant, dbuffer); | 4141 CHECK_EQ(dconstant, dbuffer); |
| 4142 CHECK(rexpected->SameValue(rbuffer)); | 4142 CHECK(rexpected->SameValue(rbuffer)); |
| 4143 } | 4143 } |
| 4144 | 4144 |
| 4145 | 4145 |
| 4146 TEST(RunDoubleRefDoubleDiamond) { | 4146 TEST(RunDoubleRefDoubleDiamond) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4169 m.Branch(m.Int32Constant(0), &blockd, &blocke); | 4169 m.Branch(m.Int32Constant(0), &blockd, &blocke); |
| 4170 | 4170 |
| 4171 m.Bind(&blockd); | 4171 m.Bind(&blockd); |
| 4172 m.Goto(&end); | 4172 m.Goto(&end); |
| 4173 m.Bind(&blocke); | 4173 m.Bind(&blocke); |
| 4174 m.Goto(&end); | 4174 m.Goto(&end); |
| 4175 m.Bind(&end); | 4175 m.Bind(&end); |
| 4176 Node* dphi2 = m.Phi(MachineRepresentation::kFloat64, d1, dphi1); | 4176 Node* dphi2 = m.Phi(MachineRepresentation::kFloat64, d1, dphi1); |
| 4177 Node* rphi2 = m.Phi(MachineRepresentation::kTagged, r1, rphi1); | 4177 Node* rphi2 = m.Phi(MachineRepresentation::kTagged, r1, rphi1); |
| 4178 | 4178 |
| 4179 m.Store(MachineType::Float64(), m.PointerConstant(&dbuffer), | 4179 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&dbuffer), |
| 4180 m.Int32Constant(0), dphi2, kNoWriteBarrier); | 4180 m.Int32Constant(0), dphi2, kNoWriteBarrier); |
| 4181 m.Store(MachineType::AnyTagged(), m.PointerConstant(&rbuffer), | 4181 m.Store(MachineRepresentation::kTagged, m.PointerConstant(&rbuffer), |
| 4182 m.Int32Constant(0), rphi2, kNoWriteBarrier); | 4182 m.Int32Constant(0), rphi2, kNoWriteBarrier); |
| 4183 m.Return(m.Int32Constant(magic)); | 4183 m.Return(m.Int32Constant(magic)); |
| 4184 | 4184 |
| 4185 CHECK_EQ(magic, m.Call()); | 4185 CHECK_EQ(magic, m.Call()); |
| 4186 CHECK_EQ(dconstant, dbuffer); | 4186 CHECK_EQ(dconstant, dbuffer); |
| 4187 CHECK(rexpected->SameValue(rbuffer)); | 4187 CHECK(rexpected->SameValue(rbuffer)); |
| 4188 } | 4188 } |
| 4189 | 4189 |
| 4190 | 4190 |
| 4191 TEST(RunDoubleLoopPhi) { | 4191 TEST(RunDoubleLoopPhi) { |
| 4192 RawMachineAssemblerTester<int32_t> m; | 4192 RawMachineAssemblerTester<int32_t> m; |
| 4193 RawMachineLabel header, body, end; | 4193 RawMachineLabel header, body, end; |
| 4194 | 4194 |
| 4195 int magic = 99773; | 4195 int magic = 99773; |
| 4196 double buffer = 0.99; | 4196 double buffer = 0.99; |
| 4197 double dconstant = 777.1; | 4197 double dconstant = 777.1; |
| 4198 | 4198 |
| 4199 Node* zero = m.Int32Constant(0); | 4199 Node* zero = m.Int32Constant(0); |
| 4200 Node* dk = m.Float64Constant(dconstant); | 4200 Node* dk = m.Float64Constant(dconstant); |
| 4201 | 4201 |
| 4202 m.Goto(&header); | 4202 m.Goto(&header); |
| 4203 m.Bind(&header); | 4203 m.Bind(&header); |
| 4204 Node* phi = m.Phi(MachineRepresentation::kFloat64, dk, dk); | 4204 Node* phi = m.Phi(MachineRepresentation::kFloat64, dk, dk); |
| 4205 phi->ReplaceInput(1, phi); | 4205 phi->ReplaceInput(1, phi); |
| 4206 m.Branch(zero, &body, &end); | 4206 m.Branch(zero, &body, &end); |
| 4207 m.Bind(&body); | 4207 m.Bind(&body); |
| 4208 m.Goto(&header); | 4208 m.Goto(&header); |
| 4209 m.Bind(&end); | 4209 m.Bind(&end); |
| 4210 m.Store(MachineType::Float64(), m.PointerConstant(&buffer), | 4210 m.Store(MachineRepresentation::kFloat64, m.PointerConstant(&buffer), |
| 4211 m.Int32Constant(0), phi, kNoWriteBarrier); | 4211 m.Int32Constant(0), phi, kNoWriteBarrier); |
| 4212 m.Return(m.Int32Constant(magic)); | 4212 m.Return(m.Int32Constant(magic)); |
| 4213 | 4213 |
| 4214 CHECK_EQ(magic, m.Call()); | 4214 CHECK_EQ(magic, m.Call()); |
| 4215 } | 4215 } |
| 4216 | 4216 |
| 4217 | 4217 |
| 4218 TEST(RunCountToTenAccRaw) { | 4218 TEST(RunCountToTenAccRaw) { |
| 4219 RawMachineAssemblerTester<int32_t> m; | 4219 RawMachineAssemblerTester<int32_t> m; |
| 4220 | 4220 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4505 } | 4505 } |
| 4506 | 4506 |
| 4507 | 4507 |
| 4508 template <typename IntType> | 4508 template <typename IntType> |
| 4509 static void LoadStoreTruncation(MachineType kRepresentation) { | 4509 static void LoadStoreTruncation(MachineType kRepresentation) { |
| 4510 IntType input; | 4510 IntType input; |
| 4511 | 4511 |
| 4512 RawMachineAssemblerTester<int32_t> m; | 4512 RawMachineAssemblerTester<int32_t> m; |
| 4513 Node* a = m.LoadFromPointer(&input, kRepresentation); | 4513 Node* a = m.LoadFromPointer(&input, kRepresentation); |
| 4514 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); | 4514 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); |
| 4515 m.StoreToPointer(&input, kRepresentation, ap1); | 4515 m.StoreToPointer(&input, kRepresentation.representation(), ap1); |
| 4516 m.Return(ap1); | 4516 m.Return(ap1); |
| 4517 | 4517 |
| 4518 const IntType max = std::numeric_limits<IntType>::max(); | 4518 const IntType max = std::numeric_limits<IntType>::max(); |
| 4519 const IntType min = std::numeric_limits<IntType>::min(); | 4519 const IntType min = std::numeric_limits<IntType>::min(); |
| 4520 | 4520 |
| 4521 // Test upper bound. | 4521 // Test upper bound. |
| 4522 input = max; | 4522 input = max; |
| 4523 CHECK_EQ(max + 1, m.Call()); | 4523 CHECK_EQ(max + 1, m.Call()); |
| 4524 CHECK_EQ(min, input); | 4524 CHECK_EQ(min, input); |
| 4525 | 4525 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4609 int32_t outputs[kInputSize]; | 4609 int32_t outputs[kInputSize]; |
| 4610 for (int i = 0; i < kInputSize; i++) { | 4610 for (int i = 0; i < kInputSize; i++) { |
| 4611 inputs[i] = i; | 4611 inputs[i] = i; |
| 4612 outputs[i] = -1; | 4612 outputs[i] = -1; |
| 4613 } | 4613 } |
| 4614 RawMachineAssemblerTester<int32_t*> m; | 4614 RawMachineAssemblerTester<int32_t*> m; |
| 4615 Node* input = m.PointerConstant(&inputs[0]); | 4615 Node* input = m.PointerConstant(&inputs[0]); |
| 4616 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); | 4616 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); |
| 4617 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); | 4617 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); |
| 4618 for (int i = 0; i < kInputSize; i++) { | 4618 for (int i = 0; i < kInputSize; i++) { |
| 4619 m.Store(MachineType::Int32(), output, m.Load(MachineType::Int32(), input), | 4619 m.Store(MachineRepresentation::kWord32, output, |
| 4620 kNoWriteBarrier); | 4620 m.Load(MachineType::Int32(), input), kNoWriteBarrier); |
| 4621 input = m.IntPtrAdd(input, elem_size); | 4621 input = m.IntPtrAdd(input, elem_size); |
| 4622 output = m.IntPtrSub(output, elem_size); | 4622 output = m.IntPtrSub(output, elem_size); |
| 4623 } | 4623 } |
| 4624 m.Return(input); | 4624 m.Return(input); |
| 4625 CHECK_EQ(&inputs[kInputSize], m.Call()); | 4625 CHECK_EQ(&inputs[kInputSize], m.Call()); |
| 4626 for (int i = 0; i < kInputSize; i++) { | 4626 for (int i = 0; i < kInputSize; i++) { |
| 4627 CHECK_EQ(i, inputs[i]); | 4627 CHECK_EQ(i, inputs[i]); |
| 4628 CHECK_EQ(kInputSize - i - 1, outputs[i]); | 4628 CHECK_EQ(kInputSize - i - 1, outputs[i]); |
| 4629 } | 4629 } |
| 4630 } | 4630 } |
| 4631 | 4631 |
| 4632 | 4632 |
| 4633 TEST(RunSpillLotsOfThings) { | 4633 TEST(RunSpillLotsOfThings) { |
| 4634 static const int kInputSize = 1000; | 4634 static const int kInputSize = 1000; |
| 4635 RawMachineAssemblerTester<int32_t> m; | 4635 RawMachineAssemblerTester<int32_t> m; |
| 4636 Node* accs[kInputSize]; | 4636 Node* accs[kInputSize]; |
| 4637 int32_t outputs[kInputSize]; | 4637 int32_t outputs[kInputSize]; |
| 4638 Node* one = m.Int32Constant(1); | 4638 Node* one = m.Int32Constant(1); |
| 4639 Node* acc = one; | 4639 Node* acc = one; |
| 4640 for (int i = 0; i < kInputSize; i++) { | 4640 for (int i = 0; i < kInputSize; i++) { |
| 4641 acc = m.Int32Add(acc, one); | 4641 acc = m.Int32Add(acc, one); |
| 4642 accs[i] = acc; | 4642 accs[i] = acc; |
| 4643 } | 4643 } |
| 4644 for (int i = 0; i < kInputSize; i++) { | 4644 for (int i = 0; i < kInputSize; i++) { |
| 4645 m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]); | 4645 m.StoreToPointer(&outputs[i], MachineRepresentation::kWord32, accs[i]); |
| 4646 } | 4646 } |
| 4647 m.Return(one); | 4647 m.Return(one); |
| 4648 m.Call(); | 4648 m.Call(); |
| 4649 for (int i = 0; i < kInputSize; i++) { | 4649 for (int i = 0; i < kInputSize; i++) { |
| 4650 CHECK_EQ(outputs[i], i + 2); | 4650 CHECK_EQ(outputs[i], i + 2); |
| 4651 } | 4651 } |
| 4652 } | 4652 } |
| 4653 | 4653 |
| 4654 | 4654 |
| 4655 TEST(RunSpillConstantsAndParameters) { | 4655 TEST(RunSpillConstantsAndParameters) { |
| 4656 static const int kInputSize = 1000; | 4656 static const int kInputSize = 1000; |
| 4657 static const int32_t kBase = 987; | 4657 static const int32_t kBase = 987; |
| 4658 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), | 4658 RawMachineAssemblerTester<int32_t> m(MachineType::Int32(), |
| 4659 MachineType::Int32()); | 4659 MachineType::Int32()); |
| 4660 int32_t outputs[kInputSize]; | 4660 int32_t outputs[kInputSize]; |
| 4661 Node* csts[kInputSize]; | 4661 Node* csts[kInputSize]; |
| 4662 Node* accs[kInputSize]; | 4662 Node* accs[kInputSize]; |
| 4663 Node* acc = m.Int32Constant(0); | 4663 Node* acc = m.Int32Constant(0); |
| 4664 for (int i = 0; i < kInputSize; i++) { | 4664 for (int i = 0; i < kInputSize; i++) { |
| 4665 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); | 4665 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); |
| 4666 } | 4666 } |
| 4667 for (int i = 0; i < kInputSize; i++) { | 4667 for (int i = 0; i < kInputSize; i++) { |
| 4668 acc = m.Int32Add(acc, csts[i]); | 4668 acc = m.Int32Add(acc, csts[i]); |
| 4669 accs[i] = acc; | 4669 accs[i] = acc; |
| 4670 } | 4670 } |
| 4671 for (int i = 0; i < kInputSize; i++) { | 4671 for (int i = 0; i < kInputSize; i++) { |
| 4672 m.StoreToPointer(&outputs[i], MachineType::Int32(), accs[i]); | 4672 m.StoreToPointer(&outputs[i], MachineRepresentation::kWord32, accs[i]); |
| 4673 } | 4673 } |
| 4674 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); | 4674 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); |
| 4675 FOR_INT32_INPUTS(i) { | 4675 FOR_INT32_INPUTS(i) { |
| 4676 FOR_INT32_INPUTS(j) { | 4676 FOR_INT32_INPUTS(j) { |
| 4677 int32_t expected = *i + *j; | 4677 int32_t expected = *i + *j; |
| 4678 for (int k = 0; k < kInputSize; k++) { | 4678 for (int k = 0; k < kInputSize; k++) { |
| 4679 expected += kBase + k; | 4679 expected += kBase + k; |
| 4680 } | 4680 } |
| 4681 CHECK_EQ(expected, m.Call(*i, *j)); | 4681 CHECK_EQ(expected, m.Call(*i, *j)); |
| 4682 expected = 0; | 4682 expected = 0; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4714 } | 4714 } |
| 4715 | 4715 |
| 4716 | 4716 |
| 4717 TEST(RunInt32AddWithOverflowP) { | 4717 TEST(RunInt32AddWithOverflowP) { |
| 4718 int32_t actual_val = -1; | 4718 int32_t actual_val = -1; |
| 4719 RawMachineAssemblerTester<int32_t> m; | 4719 RawMachineAssemblerTester<int32_t> m; |
| 4720 Int32BinopTester bt(&m); | 4720 Int32BinopTester bt(&m); |
| 4721 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); | 4721 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); |
| 4722 Node* val = m.Projection(0, add); | 4722 Node* val = m.Projection(0, add); |
| 4723 Node* ovf = m.Projection(1, add); | 4723 Node* ovf = m.Projection(1, add); |
| 4724 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4724 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4725 bt.AddReturn(ovf); | 4725 bt.AddReturn(ovf); |
| 4726 FOR_INT32_INPUTS(i) { | 4726 FOR_INT32_INPUTS(i) { |
| 4727 FOR_INT32_INPUTS(j) { | 4727 FOR_INT32_INPUTS(j) { |
| 4728 int32_t expected_val; | 4728 int32_t expected_val; |
| 4729 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); | 4729 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); |
| 4730 CHECK_EQ(expected_ovf, bt.call(*i, *j)); | 4730 CHECK_EQ(expected_ovf, bt.call(*i, *j)); |
| 4731 CHECK_EQ(expected_val, actual_val); | 4731 CHECK_EQ(expected_val, actual_val); |
| 4732 } | 4732 } |
| 4733 } | 4733 } |
| 4734 } | 4734 } |
| 4735 | 4735 |
| 4736 | 4736 |
| 4737 TEST(RunInt32AddWithOverflowImm) { | 4737 TEST(RunInt32AddWithOverflowImm) { |
| 4738 int32_t actual_val = -1, expected_val = 0; | 4738 int32_t actual_val = -1, expected_val = 0; |
| 4739 FOR_INT32_INPUTS(i) { | 4739 FOR_INT32_INPUTS(i) { |
| 4740 { | 4740 { |
| 4741 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 4741 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 4742 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); | 4742 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); |
| 4743 Node* val = m.Projection(0, add); | 4743 Node* val = m.Projection(0, add); |
| 4744 Node* ovf = m.Projection(1, add); | 4744 Node* ovf = m.Projection(1, add); |
| 4745 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4745 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4746 m.Return(ovf); | 4746 m.Return(ovf); |
| 4747 FOR_INT32_INPUTS(j) { | 4747 FOR_INT32_INPUTS(j) { |
| 4748 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); | 4748 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); |
| 4749 CHECK_EQ(expected_ovf, m.Call(*j)); | 4749 CHECK_EQ(expected_ovf, m.Call(*j)); |
| 4750 CHECK_EQ(expected_val, actual_val); | 4750 CHECK_EQ(expected_val, actual_val); |
| 4751 } | 4751 } |
| 4752 } | 4752 } |
| 4753 { | 4753 { |
| 4754 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 4754 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 4755 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); | 4755 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); |
| 4756 Node* val = m.Projection(0, add); | 4756 Node* val = m.Projection(0, add); |
| 4757 Node* ovf = m.Projection(1, add); | 4757 Node* ovf = m.Projection(1, add); |
| 4758 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4758 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4759 m.Return(ovf); | 4759 m.Return(ovf); |
| 4760 FOR_INT32_INPUTS(j) { | 4760 FOR_INT32_INPUTS(j) { |
| 4761 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); | 4761 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); |
| 4762 CHECK_EQ(expected_ovf, m.Call(*j)); | 4762 CHECK_EQ(expected_ovf, m.Call(*j)); |
| 4763 CHECK_EQ(expected_val, actual_val); | 4763 CHECK_EQ(expected_val, actual_val); |
| 4764 } | 4764 } |
| 4765 } | 4765 } |
| 4766 FOR_INT32_INPUTS(j) { | 4766 FOR_INT32_INPUTS(j) { |
| 4767 RawMachineAssemblerTester<int32_t> m; | 4767 RawMachineAssemblerTester<int32_t> m; |
| 4768 Node* add = | 4768 Node* add = |
| 4769 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); | 4769 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); |
| 4770 Node* val = m.Projection(0, add); | 4770 Node* val = m.Projection(0, add); |
| 4771 Node* ovf = m.Projection(1, add); | 4771 Node* ovf = m.Projection(1, add); |
| 4772 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4772 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4773 m.Return(ovf); | 4773 m.Return(ovf); |
| 4774 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); | 4774 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); |
| 4775 CHECK_EQ(expected_ovf, m.Call()); | 4775 CHECK_EQ(expected_ovf, m.Call()); |
| 4776 CHECK_EQ(expected_val, actual_val); | 4776 CHECK_EQ(expected_val, actual_val); |
| 4777 } | 4777 } |
| 4778 } | 4778 } |
| 4779 } | 4779 } |
| 4780 | 4780 |
| 4781 | 4781 |
| 4782 TEST(RunInt32AddWithOverflowInBranchP) { | 4782 TEST(RunInt32AddWithOverflowInBranchP) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4802 } | 4802 } |
| 4803 | 4803 |
| 4804 | 4804 |
| 4805 TEST(RunInt32SubWithOverflowP) { | 4805 TEST(RunInt32SubWithOverflowP) { |
| 4806 int32_t actual_val = -1; | 4806 int32_t actual_val = -1; |
| 4807 RawMachineAssemblerTester<int32_t> m; | 4807 RawMachineAssemblerTester<int32_t> m; |
| 4808 Int32BinopTester bt(&m); | 4808 Int32BinopTester bt(&m); |
| 4809 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); | 4809 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); |
| 4810 Node* val = m.Projection(0, add); | 4810 Node* val = m.Projection(0, add); |
| 4811 Node* ovf = m.Projection(1, add); | 4811 Node* ovf = m.Projection(1, add); |
| 4812 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4812 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4813 bt.AddReturn(ovf); | 4813 bt.AddReturn(ovf); |
| 4814 FOR_INT32_INPUTS(i) { | 4814 FOR_INT32_INPUTS(i) { |
| 4815 FOR_INT32_INPUTS(j) { | 4815 FOR_INT32_INPUTS(j) { |
| 4816 int32_t expected_val; | 4816 int32_t expected_val; |
| 4817 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); | 4817 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); |
| 4818 CHECK_EQ(expected_ovf, bt.call(*i, *j)); | 4818 CHECK_EQ(expected_ovf, bt.call(*i, *j)); |
| 4819 CHECK_EQ(expected_val, actual_val); | 4819 CHECK_EQ(expected_val, actual_val); |
| 4820 } | 4820 } |
| 4821 } | 4821 } |
| 4822 } | 4822 } |
| 4823 | 4823 |
| 4824 | 4824 |
| 4825 TEST(RunInt32SubWithOverflowImm) { | 4825 TEST(RunInt32SubWithOverflowImm) { |
| 4826 int32_t actual_val = -1, expected_val = 0; | 4826 int32_t actual_val = -1, expected_val = 0; |
| 4827 FOR_INT32_INPUTS(i) { | 4827 FOR_INT32_INPUTS(i) { |
| 4828 { | 4828 { |
| 4829 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 4829 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 4830 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); | 4830 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); |
| 4831 Node* val = m.Projection(0, add); | 4831 Node* val = m.Projection(0, add); |
| 4832 Node* ovf = m.Projection(1, add); | 4832 Node* ovf = m.Projection(1, add); |
| 4833 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4833 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4834 m.Return(ovf); | 4834 m.Return(ovf); |
| 4835 FOR_INT32_INPUTS(j) { | 4835 FOR_INT32_INPUTS(j) { |
| 4836 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); | 4836 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); |
| 4837 CHECK_EQ(expected_ovf, m.Call(*j)); | 4837 CHECK_EQ(expected_ovf, m.Call(*j)); |
| 4838 CHECK_EQ(expected_val, actual_val); | 4838 CHECK_EQ(expected_val, actual_val); |
| 4839 } | 4839 } |
| 4840 } | 4840 } |
| 4841 { | 4841 { |
| 4842 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 4842 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 4843 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); | 4843 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); |
| 4844 Node* val = m.Projection(0, add); | 4844 Node* val = m.Projection(0, add); |
| 4845 Node* ovf = m.Projection(1, add); | 4845 Node* ovf = m.Projection(1, add); |
| 4846 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4846 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4847 m.Return(ovf); | 4847 m.Return(ovf); |
| 4848 FOR_INT32_INPUTS(j) { | 4848 FOR_INT32_INPUTS(j) { |
| 4849 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); | 4849 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); |
| 4850 CHECK_EQ(expected_ovf, m.Call(*j)); | 4850 CHECK_EQ(expected_ovf, m.Call(*j)); |
| 4851 CHECK_EQ(expected_val, actual_val); | 4851 CHECK_EQ(expected_val, actual_val); |
| 4852 } | 4852 } |
| 4853 } | 4853 } |
| 4854 FOR_INT32_INPUTS(j) { | 4854 FOR_INT32_INPUTS(j) { |
| 4855 RawMachineAssemblerTester<int32_t> m; | 4855 RawMachineAssemblerTester<int32_t> m; |
| 4856 Node* add = | 4856 Node* add = |
| 4857 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); | 4857 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); |
| 4858 Node* val = m.Projection(0, add); | 4858 Node* val = m.Projection(0, add); |
| 4859 Node* ovf = m.Projection(1, add); | 4859 Node* ovf = m.Projection(1, add); |
| 4860 m.StoreToPointer(&actual_val, MachineType::Int32(), val); | 4860 m.StoreToPointer(&actual_val, MachineRepresentation::kWord32, val); |
| 4861 m.Return(ovf); | 4861 m.Return(ovf); |
| 4862 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); | 4862 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); |
| 4863 CHECK_EQ(expected_ovf, m.Call()); | 4863 CHECK_EQ(expected_ovf, m.Call()); |
| 4864 CHECK_EQ(expected_val, actual_val); | 4864 CHECK_EQ(expected_val, actual_val); |
| 4865 } | 4865 } |
| 4866 } | 4866 } |
| 4867 } | 4867 } |
| 4868 | 4868 |
| 4869 | 4869 |
| 4870 TEST(RunInt32SubWithOverflowInBranchP) { | 4870 TEST(RunInt32SubWithOverflowInBranchP) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4907 CHECK_EQ(2, m.Call()); | 4907 CHECK_EQ(2, m.Call()); |
| 4908 input = V8_INT64_C(0x100000000); | 4908 input = V8_INT64_C(0x100000000); |
| 4909 CHECK_EQ(2, m.Call()); | 4909 CHECK_EQ(2, m.Call()); |
| 4910 } | 4910 } |
| 4911 | 4911 |
| 4912 | 4912 |
| 4913 TEST(RunChangeInt32ToInt64P) { | 4913 TEST(RunChangeInt32ToInt64P) { |
| 4914 if (kPointerSize < 8) return; | 4914 if (kPointerSize < 8) return; |
| 4915 int64_t actual = -1; | 4915 int64_t actual = -1; |
| 4916 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 4916 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 4917 m.StoreToPointer(&actual, MachineType::Int64(), | 4917 m.StoreToPointer(&actual, MachineRepresentation::kWord64, |
| 4918 m.ChangeInt32ToInt64(m.Parameter(0))); | 4918 m.ChangeInt32ToInt64(m.Parameter(0))); |
| 4919 m.Return(m.Int32Constant(0)); | 4919 m.Return(m.Int32Constant(0)); |
| 4920 FOR_INT32_INPUTS(i) { | 4920 FOR_INT32_INPUTS(i) { |
| 4921 int64_t expected = *i; | 4921 int64_t expected = *i; |
| 4922 CHECK_EQ(0, m.Call(*i)); | 4922 CHECK_EQ(0, m.Call(*i)); |
| 4923 CHECK_EQ(expected, actual); | 4923 CHECK_EQ(expected, actual); |
| 4924 } | 4924 } |
| 4925 } | 4925 } |
| 4926 | 4926 |
| 4927 | 4927 |
| 4928 TEST(RunChangeUint32ToUint64P) { | 4928 TEST(RunChangeUint32ToUint64P) { |
| 4929 if (kPointerSize < 8) return; | 4929 if (kPointerSize < 8) return; |
| 4930 int64_t actual = -1; | 4930 int64_t actual = -1; |
| 4931 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); | 4931 RawMachineAssemblerTester<int32_t> m(MachineType::Uint32()); |
| 4932 m.StoreToPointer(&actual, MachineType::Uint64(), | 4932 m.StoreToPointer(&actual, MachineRepresentation::kWord64, |
| 4933 m.ChangeUint32ToUint64(m.Parameter(0))); | 4933 m.ChangeUint32ToUint64(m.Parameter(0))); |
| 4934 m.Return(m.Int32Constant(0)); | 4934 m.Return(m.Int32Constant(0)); |
| 4935 FOR_UINT32_INPUTS(i) { | 4935 FOR_UINT32_INPUTS(i) { |
| 4936 int64_t expected = static_cast<uint64_t>(*i); | 4936 int64_t expected = static_cast<uint64_t>(*i); |
| 4937 CHECK_EQ(0, m.Call(*i)); | 4937 CHECK_EQ(0, m.Call(*i)); |
| 4938 CHECK_EQ(expected, actual); | 4938 CHECK_EQ(expected, actual); |
| 4939 } | 4939 } |
| 4940 } | 4940 } |
| 4941 | 4941 |
| 4942 | 4942 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5407 | 5407 |
| 5408 TEST(RunCheckedStoreInt64) { | 5408 TEST(RunCheckedStoreInt64) { |
| 5409 const int64_t write = 0x5566778899aabbLL; | 5409 const int64_t write = 0x5566778899aabbLL; |
| 5410 const int64_t before = 0x33bbccddeeff0011LL; | 5410 const int64_t before = 0x33bbccddeeff0011LL; |
| 5411 int64_t buffer[] = {before, before}; | 5411 int64_t buffer[] = {before, before}; |
| 5412 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); | 5412 RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); |
| 5413 Node* base = m.PointerConstant(buffer); | 5413 Node* base = m.PointerConstant(buffer); |
| 5414 Node* index = m.Parameter(0); | 5414 Node* index = m.Parameter(0); |
| 5415 Node* length = m.Int32Constant(16); | 5415 Node* length = m.Int32Constant(16); |
| 5416 Node* value = m.Int64Constant(write); | 5416 Node* value = m.Int64Constant(write); |
| 5417 Node* store = m.AddNode(m.machine()->CheckedStore(MachineType::Int64()), base, | 5417 Node* store = |
| 5418 index, length, value); | 5418 m.AddNode(m.machine()->CheckedStore(MachineRepresentation::kWord64), base, |
| 5419 index, length, value); |
| 5419 USE(store); | 5420 USE(store); |
| 5420 m.Return(m.Int32Constant(11)); | 5421 m.Return(m.Int32Constant(11)); |
| 5421 | 5422 |
| 5422 CHECK_EQ(11, m.Call(16)); | 5423 CHECK_EQ(11, m.Call(16)); |
| 5423 CHECK_EQ(before, buffer[0]); | 5424 CHECK_EQ(before, buffer[0]); |
| 5424 CHECK_EQ(before, buffer[1]); | 5425 CHECK_EQ(before, buffer[1]); |
| 5425 | 5426 |
| 5426 CHECK_EQ(11, m.Call(0)); | 5427 CHECK_EQ(11, m.Call(0)); |
| 5427 CHECK_EQ(write, buffer[0]); | 5428 CHECK_EQ(write, buffer[0]); |
| 5428 CHECK_EQ(before, buffer[1]); | 5429 CHECK_EQ(before, buffer[1]); |
| 5429 | 5430 |
| 5430 CHECK_EQ(11, m.Call(8)); | 5431 CHECK_EQ(11, m.Call(8)); |
| 5431 CHECK_EQ(write, buffer[0]); | 5432 CHECK_EQ(write, buffer[0]); |
| 5432 CHECK_EQ(write, buffer[1]); | 5433 CHECK_EQ(write, buffer[1]); |
| 5433 } | 5434 } |
| 5434 | 5435 |
| 5435 | 5436 |
| 5436 TEST(RunBitcastInt64ToFloat64) { | 5437 TEST(RunBitcastInt64ToFloat64) { |
| 5437 int64_t input = 1; | 5438 int64_t input = 1; |
| 5438 double output = 0.0; | 5439 double output = 0.0; |
| 5439 RawMachineAssemblerTester<int32_t> m; | 5440 RawMachineAssemblerTester<int32_t> m; |
| 5440 m.StoreToPointer( | 5441 m.StoreToPointer( |
| 5441 &output, MachineType::Float64(), | 5442 &output, MachineRepresentation::kFloat64, |
| 5442 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64()))); | 5443 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, MachineType::Int64()))); |
| 5443 m.Return(m.Int32Constant(11)); | 5444 m.Return(m.Int32Constant(11)); |
| 5444 FOR_INT64_INPUTS(i) { | 5445 FOR_INT64_INPUTS(i) { |
| 5445 input = *i; | 5446 input = *i; |
| 5446 CHECK_EQ(11, m.Call()); | 5447 CHECK_EQ(11, m.Call()); |
| 5447 double expected = bit_cast<double>(input); | 5448 double expected = bit_cast<double>(input); |
| 5448 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); | 5449 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); |
| 5449 } | 5450 } |
| 5450 } | 5451 } |
| 5451 | 5452 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 5470 } | 5471 } |
| 5471 } | 5472 } |
| 5472 | 5473 |
| 5473 | 5474 |
| 5474 TEST(RunTryTruncateFloat32ToInt64WithCheck) { | 5475 TEST(RunTryTruncateFloat32ToInt64WithCheck) { |
| 5475 int64_t success = 0; | 5476 int64_t success = 0; |
| 5476 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32()); | 5477 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float32()); |
| 5477 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); | 5478 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); |
| 5478 Node* val = m.Projection(0, trunc); | 5479 Node* val = m.Projection(0, trunc); |
| 5479 Node* check = m.Projection(1, trunc); | 5480 Node* check = m.Projection(1, trunc); |
| 5480 m.StoreToPointer(&success, MachineType::Int64(), check); | 5481 m.StoreToPointer(&success, MachineRepresentation::kWord64, check); |
| 5481 m.Return(val); | 5482 m.Return(val); |
| 5482 | 5483 |
| 5483 FOR_FLOAT32_INPUTS(i) { | 5484 FOR_FLOAT32_INPUTS(i) { |
| 5484 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { | 5485 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { |
| 5485 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); | 5486 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); |
| 5486 CHECK_NE(0, success); | 5487 CHECK_NE(0, success); |
| 5487 } else { | 5488 } else { |
| 5488 m.Call(*i); | 5489 m.Call(*i); |
| 5489 CHECK_EQ(0, success); | 5490 CHECK_EQ(0, success); |
| 5490 } | 5491 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5502 } | 5503 } |
| 5503 } | 5504 } |
| 5504 | 5505 |
| 5505 | 5506 |
| 5506 TEST(RunTryTruncateFloat64ToInt64WithCheck) { | 5507 TEST(RunTryTruncateFloat64ToInt64WithCheck) { |
| 5507 int64_t success = 0; | 5508 int64_t success = 0; |
| 5508 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); | 5509 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); |
| 5509 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); | 5510 Node* trunc = m.TryTruncateFloat64ToInt64(m.Parameter(0)); |
| 5510 Node* val = m.Projection(0, trunc); | 5511 Node* val = m.Projection(0, trunc); |
| 5511 Node* check = m.Projection(1, trunc); | 5512 Node* check = m.Projection(1, trunc); |
| 5512 m.StoreToPointer(&success, MachineType::Int64(), check); | 5513 m.StoreToPointer(&success, MachineRepresentation::kWord64, check); |
| 5513 m.Return(val); | 5514 m.Return(val); |
| 5514 | 5515 |
| 5515 FOR_FLOAT64_INPUTS(i) { | 5516 FOR_FLOAT64_INPUTS(i) { |
| 5516 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { | 5517 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { |
| 5517 // Conversions within this range should succeed. | 5518 // Conversions within this range should succeed. |
| 5518 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); | 5519 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); |
| 5519 CHECK_NE(0, success); | 5520 CHECK_NE(0, success); |
| 5520 } else { | 5521 } else { |
| 5521 m.Call(*i); | 5522 m.Call(*i); |
| 5522 CHECK_EQ(0, success); | 5523 CHECK_EQ(0, success); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5542 } | 5543 } |
| 5543 } | 5544 } |
| 5544 | 5545 |
| 5545 | 5546 |
| 5546 TEST(RunTryTruncateFloat32ToUint64WithCheck) { | 5547 TEST(RunTryTruncateFloat32ToUint64WithCheck) { |
| 5547 int64_t success = 0; | 5548 int64_t success = 0; |
| 5548 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32()); | 5549 BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Float32()); |
| 5549 Node* trunc = m.TryTruncateFloat32ToUint64(m.Parameter(0)); | 5550 Node* trunc = m.TryTruncateFloat32ToUint64(m.Parameter(0)); |
| 5550 Node* val = m.Projection(0, trunc); | 5551 Node* val = m.Projection(0, trunc); |
| 5551 Node* check = m.Projection(1, trunc); | 5552 Node* check = m.Projection(1, trunc); |
| 5552 m.StoreToPointer(&success, MachineType::Int64(), check); | 5553 m.StoreToPointer(&success, MachineRepresentation::kWord64, check); |
| 5553 m.Return(val); | 5554 m.Return(val); |
| 5554 | 5555 |
| 5555 FOR_FLOAT32_INPUTS(i) { | 5556 FOR_FLOAT32_INPUTS(i) { |
| 5556 if (*i < 18446744073709551616.0 && *i >= 0.0) { | 5557 if (*i < 18446744073709551616.0 && *i >= 0.0) { |
| 5557 // Conversions within this range should succeed. | 5558 // Conversions within this range should succeed. |
| 5558 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); | 5559 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); |
| 5559 CHECK_NE(0, success); | 5560 CHECK_NE(0, success); |
| 5560 } else { | 5561 } else { |
| 5561 m.Call(*i); | 5562 m.Call(*i); |
| 5562 CHECK_EQ(0, success); | 5563 CHECK_EQ(0, success); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5578 } | 5579 } |
| 5579 } | 5580 } |
| 5580 | 5581 |
| 5581 | 5582 |
| 5582 TEST(RunTryTruncateFloat64ToUint64WithCheck) { | 5583 TEST(RunTryTruncateFloat64ToUint64WithCheck) { |
| 5583 int64_t success = 0; | 5584 int64_t success = 0; |
| 5584 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); | 5585 BufferedRawMachineAssemblerTester<int64_t> m(MachineType::Float64()); |
| 5585 Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0)); | 5586 Node* trunc = m.TryTruncateFloat64ToUint64(m.Parameter(0)); |
| 5586 Node* val = m.Projection(0, trunc); | 5587 Node* val = m.Projection(0, trunc); |
| 5587 Node* check = m.Projection(1, trunc); | 5588 Node* check = m.Projection(1, trunc); |
| 5588 m.StoreToPointer(&success, MachineType::Int64(), check); | 5589 m.StoreToPointer(&success, MachineRepresentation::kWord64, check); |
| 5589 m.Return(val); | 5590 m.Return(val); |
| 5590 | 5591 |
| 5591 FOR_FLOAT64_INPUTS(i) { | 5592 FOR_FLOAT64_INPUTS(i) { |
| 5592 if (*i < 18446744073709551616.0 && *i >= 0) { | 5593 if (*i < 18446744073709551616.0 && *i >= 0) { |
| 5593 // Conversions within this range should succeed. | 5594 // Conversions within this range should succeed. |
| 5594 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); | 5595 CHECK_EQ(static_cast<uint64_t>(*i), m.Call(*i)); |
| 5595 CHECK_NE(0, success); | 5596 CHECK_NE(0, success); |
| 5596 } else { | 5597 } else { |
| 5597 m.Call(*i); | 5598 m.Call(*i); |
| 5598 CHECK_EQ(0, success); | 5599 CHECK_EQ(0, success); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5808 CHECK_EQ(expected, m.Call()); | 5809 CHECK_EQ(expected, m.Call()); |
| 5809 } | 5810 } |
| 5810 } | 5811 } |
| 5811 | 5812 |
| 5812 | 5813 |
| 5813 TEST(RunBitcastInt32ToFloat32) { | 5814 TEST(RunBitcastInt32ToFloat32) { |
| 5814 int32_t input = 1; | 5815 int32_t input = 1; |
| 5815 float output = 0.0; | 5816 float output = 0.0; |
| 5816 RawMachineAssemblerTester<int32_t> m; | 5817 RawMachineAssemblerTester<int32_t> m; |
| 5817 m.StoreToPointer( | 5818 m.StoreToPointer( |
| 5818 &output, MachineType::Float32(), | 5819 &output, MachineRepresentation::kFloat32, |
| 5819 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); | 5820 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, MachineType::Int32()))); |
| 5820 m.Return(m.Int32Constant(11)); | 5821 m.Return(m.Int32Constant(11)); |
| 5821 FOR_INT32_INPUTS(i) { | 5822 FOR_INT32_INPUTS(i) { |
| 5822 input = *i; | 5823 input = *i; |
| 5823 CHECK_EQ(11, m.Call()); | 5824 CHECK_EQ(11, m.Call()); |
| 5824 float expected = bit_cast<float>(input); | 5825 float expected = bit_cast<float>(input); |
| 5825 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); | 5826 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); |
| 5826 } | 5827 } |
| 5827 } | 5828 } |
| 5828 | 5829 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5873 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5874 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 5874 r.Return(call); | 5875 r.Return(call); |
| 5875 | 5876 |
| 5876 CHECK_EQ(33, r.Call(1)); | 5877 CHECK_EQ(33, r.Call(1)); |
| 5877 CHECK_EQ(44, r.Call(0)); | 5878 CHECK_EQ(44, r.Call(0)); |
| 5878 } | 5879 } |
| 5879 | 5880 |
| 5880 } // namespace compiler | 5881 } // namespace compiler |
| 5881 } // namespace internal | 5882 } // namespace internal |
| 5882 } // namespace v8 | 5883 } // namespace v8 |
| OLD | NEW |