OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2016 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 FOR_INT32_INPUTS(i) { | 244 FOR_INT32_INPUTS(i) { |
245 buffer[0] = *i; | 245 buffer[0] = *i; |
246 | 246 |
247 CHECK_EQ(static_cast<int8_t>(*i & 0xff), m.Call()); | 247 CHECK_EQ(static_cast<int8_t>(*i & 0xff), m.Call()); |
248 CHECK_EQ(static_cast<int8_t>(*i & 0xff), buffer[1]); | 248 CHECK_EQ(static_cast<int8_t>(*i & 0xff), buffer[1]); |
249 CHECK_EQ(static_cast<int16_t>(*i & 0xffff), buffer[2]); | 249 CHECK_EQ(static_cast<int16_t>(*i & 0xffff), buffer[2]); |
250 CHECK_EQ(*i, buffer[3]); | 250 CHECK_EQ(*i, buffer[3]); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
| 254 TEST(RunLoadEliminationWithCompareAndTest) { |
| 255 int8_t byte = 0x81; |
| 256 int16_t word = 0xf00f; |
| 257 RawMachineAssemblerTester<int32_t> m; |
| 258 Node* load8 = m.LoadFromPointer(&byte, MachineType::Int8()); |
| 259 RawMachineLabel a, b, c, d; |
| 260 m.Branch(m.Word32And(load8, m.Int32Constant(-0x80)), &b, &a); |
| 261 m.Bind(&a); |
| 262 m.Return(m.Int32Constant(0)); |
| 263 m.Bind(&b); |
| 264 Node* load16 = m.LoadFromPointer(&word, MachineType::Int16()); |
| 265 m.Branch(m.Word32And(load16, m.Int32Constant(-0x7fff)), &d, &c); |
| 266 m.Bind(&c); |
| 267 m.Return(m.Int32Constant(0)); |
| 268 m.Bind(&d); |
| 269 m.Return(m.Int32Constant(1)); |
| 270 |
| 271 CHECK_EQ(1, m.Call()); |
| 272 } |
| 273 |
254 TEST(RunLoadStoreZeroExtend32) { | 274 TEST(RunLoadStoreZeroExtend32) { |
255 uint32_t buffer[4]; | 275 uint32_t buffer[4]; |
256 RawMachineAssemblerTester<uint32_t> m; | 276 RawMachineAssemblerTester<uint32_t> m; |
257 Node* load8 = m.LoadFromPointer(LSB(&buffer[0], 1), MachineType::Uint8()); | 277 Node* load8 = m.LoadFromPointer(LSB(&buffer[0], 1), MachineType::Uint8()); |
258 Node* load16 = m.LoadFromPointer(LSB(&buffer[0], 2), MachineType::Uint16()); | 278 Node* load16 = m.LoadFromPointer(LSB(&buffer[0], 2), MachineType::Uint16()); |
259 Node* load32 = m.LoadFromPointer(&buffer[0], MachineType::Uint32()); | 279 Node* load32 = m.LoadFromPointer(&buffer[0], MachineType::Uint32()); |
260 m.StoreToPointer(&buffer[1], MachineRepresentation::kWord32, load8); | 280 m.StoreToPointer(&buffer[1], MachineRepresentation::kWord32, load8); |
261 m.StoreToPointer(&buffer[2], MachineRepresentation::kWord32, load16); | 281 m.StoreToPointer(&buffer[2], MachineRepresentation::kWord32, load16); |
262 m.StoreToPointer(&buffer[3], MachineRepresentation::kWord32, load32); | 282 m.StoreToPointer(&buffer[3], MachineRepresentation::kWord32, load32); |
263 m.Return(load8); | 283 m.Return(load8); |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); | 930 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); |
911 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); | 931 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); |
912 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); | 932 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); |
913 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); | 933 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); |
914 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); | 934 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); |
915 } | 935 } |
916 | 936 |
917 } // namespace compiler | 937 } // namespace compiler |
918 } // namespace internal | 938 } // namespace internal |
919 } // namespace v8 | 939 } // namespace v8 |
OLD | NEW |