| Index: test/cctest/test-heap-profiler.cc
|
| diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
|
| index 87119b8571394118af54f9e48b6124faad2ca70d..2632593ec68282fbd88595a826e43372ad178fc7 100644
|
| --- a/test/cctest/test-heap-profiler.cc
|
| +++ b/test/cctest/test-heap-profiler.cc
|
| @@ -3010,3 +3010,28 @@ TEST(SamplingHeapProfilerApiAllocation) {
|
|
|
| heap_profiler->StopSamplingHeapProfiler();
|
| }
|
| +
|
| +TEST(SamplingHeapProfilerLeftTrimming) {
|
| + v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + LocalContext env;
|
| + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
| +
|
| + // Suppress randomness to avoid flakiness in tests.
|
| + v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;
|
| +
|
| + heap_profiler->StartSamplingHeapProfiler(64);
|
| +
|
| + CompileRun(
|
| + "for (var j = 0; j < 500; ++j) {\n"
|
| + " var a = [];\n"
|
| + " for (var i = 0; i < 5; ++i)\n"
|
| + " a[i] = i;\n"
|
| + " for (var i = 0; i < 3; ++i)\n"
|
| + " a.shift();\n"
|
| + "}\n");
|
| +
|
| + CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
|
| + // Should not crash.
|
| +
|
| + heap_profiler->StopSamplingHeapProfiler();
|
| +}
|
|
|