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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 // randomize memory. | 981 // randomize memory. |
982 v8::base::RandomNumberGenerator rng; | 982 v8::base::RandomNumberGenerator rng; |
983 rng.SetSeed(100); | 983 rng.SetSeed(100); |
984 rng.NextBytes(&buffer[0], sizeof(buffer)); | 984 rng.NextBytes(&buffer[0], sizeof(buffer)); |
985 } | 985 } |
986 | 986 |
987 // in-bounds accesses. | 987 // in-bounds accesses. |
988 for (uint32_t i = 0; i < kNumElems; i++) { | 988 for (uint32_t i = 0; i < kNumElems; i++) { |
989 uint32_t offset = static_cast<uint32_t>(i * sizeof(int32_t)); | 989 uint32_t offset = static_cast<uint32_t>(i * sizeof(int32_t)); |
990 uint32_t expected = buffer[i]; | 990 uint32_t expected = buffer[i]; |
991 CHECK_EQ(expected, m.Call(offset + pseudo_base, kLength)); | 991 CHECK_EQ(expected, |
| 992 static_cast<uint32_t>(m.Call(offset + pseudo_base, kLength))); |
992 } | 993 } |
993 | 994 |
994 // slightly out-of-bounds accesses. | 995 // slightly out-of-bounds accesses. |
995 for (int32_t i = kNumElems; i < kNumElems + 30; i++) { | 996 for (uint32_t i = kNumElems; i < kNumElems + 30; i++) { |
996 uint32_t offset = static_cast<uint32_t>(i * sizeof(int32_t)); | 997 uint32_t offset = i * sizeof(int32_t); |
997 CheckOobValue(m.Call(offset + pseudo_base, kLength)); | 998 CheckOobValue(m.Call(offset + pseudo_base, kLength)); |
998 } | 999 } |
999 | 1000 |
1000 // way out-of-bounds accesses. | 1001 // way out-of-bounds accesses. |
1001 for (uint64_t i = pseudo_base + sizeof(buffer); i < 0xFFFFFFFF; | 1002 for (uint64_t i = pseudo_base + sizeof(buffer); i < 0xFFFFFFFF; |
1002 i += A_BILLION) { | 1003 i += A_BILLION) { |
1003 uint32_t offset = static_cast<uint32_t>(i); | 1004 uint32_t offset = static_cast<uint32_t>(i); |
1004 CheckOobValue(m.Call(offset, kLength)); | 1005 CheckOobValue(m.Call(offset, kLength)); |
1005 } | 1006 } |
1006 } | 1007 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); | 1182 TestRunOobCheckedLoadT_pseudo<int32_t>(4 * A_BILLION, true); |
1182 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); | 1183 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, false); |
1183 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); | 1184 TestRunOobCheckedLoadT_pseudo<float>(4 * A_BILLION, true); |
1184 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); | 1185 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, false); |
1185 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); | 1186 TestRunOobCheckedLoadT_pseudo<double>(4 * A_BILLION, true); |
1186 } | 1187 } |
1187 | 1188 |
1188 } // namespace compiler | 1189 } // namespace compiler |
1189 } // namespace internal | 1190 } // namespace internal |
1190 } // namespace v8 | 1191 } // namespace v8 |
OLD | NEW |