summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/compiler/test-basic-block-profiler.cc')
-rw-r--r--deps/v8/test/cctest/compiler/test-basic-block-profiler.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc
index 795c1f1bd2..561f9a68b7 100644
--- a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc
+++ b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc
@@ -28,9 +28,21 @@ class BasicBlockProfilerTest : public RawMachineAssemblerTester<int32_t> {
CHECK_NE(0, static_cast<int>(l->size()));
const BasicBlockProfilerData* data = l->back().get();
CHECK_EQ(static_cast<int>(size), static_cast<int>(data->n_blocks()));
- const double* counts = data->counts();
+ const uint32_t* counts = data->counts();
for (size_t i = 0; i < size; ++i) {
- CHECK_EQ(static_cast<double>(expected[i]), counts[i]);
+ CHECK_EQ(expected[i], counts[i]);
+ }
+ }
+
+ void SetCounts(size_t size, uint32_t* new_counts) {
+ const BasicBlockProfiler::DataList* l =
+ BasicBlockProfiler::Get()->data_list();
+ CHECK_NE(0, static_cast<int>(l->size()));
+ BasicBlockProfilerData* data = l->back().get();
+ CHECK_EQ(static_cast<int>(size), static_cast<int>(data->n_blocks()));
+ uint32_t* counts = const_cast<uint32_t*>(data->counts());
+ for (size_t i = 0; i < size; ++i) {
+ counts[i] = new_counts[i];
}
}
};
@@ -73,6 +85,21 @@ TEST(ProfileDiamond) {
uint32_t expected[] = {2, 1, 1, 1, 1, 2};
m.Expect(arraysize(expected), expected);
}
+
+ // Set the counters very high, to verify that they saturate rather than
+ // overflowing.
+ uint32_t near_overflow[] = {UINT32_MAX - 1, UINT32_MAX - 1, UINT32_MAX - 1,
+ UINT32_MAX - 1, UINT32_MAX - 1, UINT32_MAX - 1};
+ m.SetCounts(arraysize(near_overflow), near_overflow);
+ m.Expect(arraysize(near_overflow), near_overflow);
+
+ m.Call(0);
+ m.Call(0);
+ {
+ uint32_t expected[] = {UINT32_MAX, UINT32_MAX, UINT32_MAX,
+ UINT32_MAX - 1, UINT32_MAX - 1, UINT32_MAX};
+ m.Expect(arraysize(expected), expected);
+ }
}