summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-heap-profiler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/test-heap-profiler.cc')
-rw-r--r--deps/v8/test/cctest/test-heap-profiler.cc62
1 files changed, 9 insertions, 53 deletions
diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc
index 76b8e8eddf..9eff4cbfc1 100644
--- a/deps/v8/test/cctest/test-heap-profiler.cc
+++ b/deps/v8/test/cctest/test-heap-profiler.cc
@@ -55,6 +55,7 @@ using i::ArrayVector;
using i::SourceLocation;
using i::Vector;
using v8::base::Optional;
+using v8::internal::heap::GrowNewSpaceToMaximumCapacity;
namespace {
@@ -1263,6 +1264,9 @@ static TestStatsStream GetHeapStatsUpdate(
TEST(HeapSnapshotObjectsStats) {
+ // Concurrent allocation might break results
+ v8::internal::FLAG_stress_concurrent_allocation = false;
+
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
@@ -2442,27 +2446,18 @@ bool HasWeakGlobalHandle() {
}
-static void PersistentHandleCallback(
- const v8::WeakCallbackInfo<v8::Persistent<v8::Object> >& data) {
- data.GetParameter()->Reset();
-}
-
-
TEST(WeakGlobalHandle) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
CHECK(!HasWeakGlobalHandle());
- v8::Persistent<v8::Object> handle;
+ v8::Global<v8::Object> handle;
handle.Reset(env->GetIsolate(), v8::Object::New(env->GetIsolate()));
- handle.SetWeak(&handle, PersistentHandleCallback,
- v8::WeakCallbackType::kParameter);
+ handle.SetWeak();
CHECK(HasWeakGlobalHandle());
- CcTest::CollectAllGarbage();
- EmptyMessageQueues(env->GetIsolate());
}
@@ -3893,7 +3888,8 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
CcTest::InitializeVM();
if (!CcTest::i_isolate()->use_optimizer() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction ||
- i::FLAG_stress_incremental_marking) {
+ i::FLAG_stress_incremental_marking ||
+ i::FLAG_stress_concurrent_allocation) {
return;
}
@@ -3904,10 +3900,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
// Suppress randomness to avoid flakiness in tests.
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;
- // Grow new space until maximum capacity reached.
- while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
- CcTest::heap()->new_space()->Grow();
- }
+ GrowNewSpaceToMaximumCapacity(CcTest::heap());
i::ScopedVector<char> source(1024);
i::SNPrintF(source,
@@ -4126,40 +4119,3 @@ TEST(Bug8373_2) {
heap_profiler->StopTrackingHeapObjects();
}
-
-TEST(HeapSnapshotDeleteDuringTakeSnapshot) {
- // Check that a heap snapshot can be deleted during GC while another one
- // is being taken.
-
- LocalContext env;
- v8::HandleScope scope(env->GetIsolate());
- v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
- int gc_calls = 0;
- v8::Global<v8::Object> handle;
-
- {
- struct WeakData {
- const v8::HeapSnapshot* snapshot;
- int* gc_calls;
- v8::Global<v8::Object>* handle;
- };
- WeakData* data =
- new WeakData{heap_profiler->TakeHeapSnapshot(), &gc_calls, &handle};
-
- v8::HandleScope scope(env->GetIsolate());
- handle.Reset(env->GetIsolate(), v8::Object::New(env->GetIsolate()));
- handle.SetWeak(
- data,
- [](const v8::WeakCallbackInfo<WeakData>& data) {
- std::unique_ptr<WeakData> weakdata{data.GetParameter()};
- const_cast<v8::HeapSnapshot*>(weakdata->snapshot)->Delete();
- ++*weakdata->gc_calls;
- weakdata->handle->Reset();
- },
- v8::WeakCallbackType::kParameter);
- }
- CHECK_EQ(gc_calls, 0);
-
- CHECK(ValidateSnapshot(heap_profiler->TakeHeapSnapshot()));
- CHECK_EQ(gc_calls, 1);
-}