| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 template <typename CType> | 274 template <typename CType> |
| 275 void RunUnalignedLoadStoreUnalignedAccess(MachineType rep) { | 275 void RunUnalignedLoadStoreUnalignedAccess(MachineType rep) { |
| 276 CType in, out; | 276 CType in, out; |
| 277 CType in_buffer[2]; | 277 CType in_buffer[2]; |
| 278 CType out_buffer[2]; | 278 CType out_buffer[2]; |
| 279 byte* raw; | 279 byte* raw; |
| 280 | 280 |
| 281 for (int x = 0; x < sizeof(CType); x++) { | 281 for (int x = 0; x < static_cast<int>(sizeof(CType)); x++) { |
| 282 int y = sizeof(CType) - x; | 282 int y = sizeof(CType) - x; |
| 283 | 283 |
| 284 raw = reinterpret_cast<byte*>(&in); | 284 raw = reinterpret_cast<byte*>(&in); |
| 285 for (size_t i = 0; i < sizeof(CType); i++) { | 285 for (size_t i = 0; i < sizeof(CType); i++) { |
| 286 raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); | 286 raw[i] = static_cast<byte>((i + sizeof(CType)) ^ 0xAA); |
| 287 } | 287 } |
| 288 | 288 |
| 289 raw = reinterpret_cast<byte*>(in_buffer); | 289 raw = reinterpret_cast<byte*>(in_buffer); |
| 290 MemCopy(raw + x, &in, sizeof(CType)); | 290 MemCopy(raw + x, &in, sizeof(CType)); |
| 291 | 291 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 CHECK_EQ(static_cast<int8_t>(*i & 0xff), buffer[1]); | 516 CHECK_EQ(static_cast<int8_t>(*i & 0xff), buffer[1]); |
| 517 CHECK_EQ(static_cast<int16_t>(*i & 0xffff), buffer[2]); | 517 CHECK_EQ(static_cast<int16_t>(*i & 0xffff), buffer[2]); |
| 518 CHECK_EQ(static_cast<int32_t>(*i & 0xffffffff), buffer[3]); | 518 CHECK_EQ(static_cast<int32_t>(*i & 0xffffffff), buffer[3]); |
| 519 CHECK_EQ(*i, buffer[4]); | 519 CHECK_EQ(*i, buffer[4]); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 | 522 |
| 523 void RunLoadStoreZeroExtend64(TestAlignment t) { | 523 void RunLoadStoreZeroExtend64(TestAlignment t) { |
| 524 if (kPointerSize < 8) return; | 524 if (kPointerSize < 8) return; |
| 525 uint64_t buffer[5]; | 525 uint64_t buffer[5]; |
| 526 RawMachineAssemblerTester<int64_t> m; | 526 RawMachineAssemblerTester<uint64_t> m; |
| 527 Node* load8 = m.LoadFromPointer(LSB(&buffer[0], 1), MachineType::Uint8()); | 527 Node* load8 = m.LoadFromPointer(LSB(&buffer[0], 1), MachineType::Uint8()); |
| 528 if (t == TestAlignment::kAligned) { | 528 if (t == TestAlignment::kAligned) { |
| 529 Node* load16 = m.LoadFromPointer(LSB(&buffer[0], 2), MachineType::Uint16()); | 529 Node* load16 = m.LoadFromPointer(LSB(&buffer[0], 2), MachineType::Uint16()); |
| 530 Node* load32 = m.LoadFromPointer(LSB(&buffer[0], 4), MachineType::Uint32()); | 530 Node* load32 = m.LoadFromPointer(LSB(&buffer[0], 4), MachineType::Uint32()); |
| 531 Node* load64 = m.LoadFromPointer(&buffer[0], MachineType::Uint64()); | 531 Node* load64 = m.LoadFromPointer(&buffer[0], MachineType::Uint64()); |
| 532 m.StoreToPointer(&buffer[1], MachineRepresentation::kWord64, load8); | 532 m.StoreToPointer(&buffer[1], MachineRepresentation::kWord64, load8); |
| 533 m.StoreToPointer(&buffer[2], MachineRepresentation::kWord64, load16); | 533 m.StoreToPointer(&buffer[2], MachineRepresentation::kWord64, load16); |
| 534 m.StoreToPointer(&buffer[3], MachineRepresentation::kWord64, load32); | 534 m.StoreToPointer(&buffer[3], MachineRepresentation::kWord64, load32); |
| 535 m.StoreToPointer(&buffer[4], MachineRepresentation::kWord64, load64); | 535 m.StoreToPointer(&buffer[4], MachineRepresentation::kWord64, load64); |
| 536 } else if (t == TestAlignment::kUnaligned) { | 536 } else if (t == TestAlignment::kUnaligned) { |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 | 1083 |
| 1084 // in-bounds accesses. | 1084 // in-bounds accesses. |
| 1085 for (uint32_t i = 0; i < kNumElems; i++) { | 1085 for (uint32_t i = 0; i < kNumElems; i++) { |
| 1086 uint32_t offset = static_cast<uint32_t>(i * sizeof(MemType)); | 1086 uint32_t offset = static_cast<uint32_t>(i * sizeof(MemType)); |
| 1087 MemType expected = buffer[i]; | 1087 MemType expected = buffer[i]; |
| 1088 CHECK_EQ(kReturn, m.Call(offset + pseudo_base, kLength)); | 1088 CHECK_EQ(kReturn, m.Call(offset + pseudo_base, kLength)); |
| 1089 CHECK_EQ(expected, result); | 1089 CHECK_EQ(expected, result); |
| 1090 } | 1090 } |
| 1091 | 1091 |
| 1092 // slightly out-of-bounds accesses. | 1092 // slightly out-of-bounds accesses. |
| 1093 for (int32_t i = kNumElems; i < kNumElems + 30; i++) { | 1093 for (uint32_t i = kNumElems; i < kNumElems + 30; i++) { |
| 1094 uint32_t offset = static_cast<uint32_t>(i * sizeof(MemType)); | 1094 uint32_t offset = static_cast<uint32_t>(i * sizeof(MemType)); |
| 1095 CHECK_EQ(kReturn, m.Call(offset + pseudo_base, kLength)); | 1095 CHECK_EQ(kReturn, m.Call(offset + pseudo_base, kLength)); |
| 1096 CheckOobValue(result); | 1096 CheckOobValue(result); |
| 1097 } | 1097 } |
| 1098 | 1098 |
| 1099 // way out-of-bounds accesses. | 1099 // way out-of-bounds accesses. |
| 1100 for (uint64_t i = pseudo_base + sizeof(buffer); i < 0xFFFFFFFF; | 1100 for (uint64_t i = pseudo_base + sizeof(buffer); i < 0xFFFFFFFF; |
| 1101 i += A_BILLION) { | 1101 i += A_BILLION) { |
| 1102 uint32_t offset = static_cast<uint32_t>(i); | 1102 uint32_t offset = static_cast<uint32_t>(i); |
| 1103 CHECK_EQ(kReturn, m.Call(offset, kLength)); | 1103 CHECK_EQ(kReturn, m.Call(offset, kLength)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); | 1182 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); |
| 1183 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); | 1183 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); |
| 1184 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); | 1184 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); |
| 1185 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); | 1185 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); |
| 1186 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); | 1186 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 } // namespace compiler | 1189 } // namespace compiler |
| 1190 } // namespace internal | 1190 } // namespace internal |
| 1191 } // namespace v8 | 1191 } // namespace v8 |
| OLD | NEW |