| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f6ce381 commit dae2219
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.18', | ||
| 41 | + 'v8_embedder_string': '-node.19', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,6 +155,7 @@ Huáng Jùnliàng <jlhwung@gmail.com> | |||
| 155 | 155 | HyeockJin Kim <kherootz@gmail.com> | |
| 156 | 156 | Iain Ireland <iireland@mozilla.com> | |
| 157 | 157 | Ilya Gavrilin <ilya.gavrilin@syntacore.com> | |
| 158 | + Ilyas Shabi <ilyasshabi94@gmail.com> | ||
| 158 | 159 | Ingvar Stepanyan <me@rreverser.com> | |
| 159 | 160 | Ioseb Dzmanashvili <ioseb.dzmanashvili@gmail.com> | |
| 160 | 161 | Isiah Meadows <impinball@gmail.com> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -830,6 +830,12 @@ class V8_EXPORT AllocationProfile { | |||
| 830 | 830 | * what samples were added or removed between two snapshots. | |
| 831 | 831 | */ | |
| 832 | 832 | uint64_t sample_id; | |
| 833 | + | ||
| 834 | + /** | ||
| 835 | + * Indicates whether the sampled allocation is still live or has already | ||
| 836 | + * been collected by GC. | ||
| 837 | + */ | ||
| 838 | + bool is_live; | ||
| 833 | 839 | }; | |
| 834 | 840 | ||
| 835 | 841 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -312,9 +312,10 @@ SamplingHeapProfiler::BuildSamples() const { | |||
| 312 | 312 | samples.reserve(samples_.size()); | |
| 313 | 313 | for (const auto& it : samples_) { | |
| 314 | 314 | const Sample* sample = it.second.get(); | |
| 315 | + const bool is_live = !sample->global.IsEmpty(); | ||
| 315 | 316 | samples.emplace_back(v8::AllocationProfile::Sample{ | |
| 316 | 317 | sample->owner->id_, sample->size, ScaleSample(sample->size, 1).count, | |
| 317 | - sample->sample_id}); | ||
| 318 | + sample->sample_id, is_live}); | ||
| 318 | 319 | } | |
| 319 | 320 | return samples; | |
| 320 | 321 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4442,6 +4442,82 @@ TEST(SamplingHeapProfilerLargeInterval) { | |||
| 4442 | 4442 | heap_profiler->StopSamplingHeapProfiler(); | |
| 4443 | 4443 | } | |
| 4444 | 4444 | ||
| 4445 | + TEST(SamplingHeapProfilerSampleWithoutGCFlags) { | ||
| 4446 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 4447 | + LocalContext env; | ||
| 4448 | + v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler(); | ||
| 4449 | + | ||
| 4450 | + // Suppress randomness to avoid flakiness in tests. | ||
| 4451 | + i::v8_flags.sampling_heap_profiler_suppress_randomness = true; | ||
| 4452 | + | ||
| 4453 | + heap_profiler->StartSamplingHeapProfiler(1024); | ||
| 4454 | + | ||
| 4455 | + // Allocate objects that will be retained | ||
| 4456 | + CompileRun( | ||
| 4457 | + "var retained = [];\n" | ||
| 4458 | + "for (var i = 0; i < 500; i++) retained.push(new Array(10));\n"); | ||
| 4459 | + | ||
| 4460 | + CompileRun("for (var i = 0; i < 500; i++) new Array(10);\n"); | ||
| 4461 | + | ||
| 4462 | + std::unique_ptr<v8::AllocationProfile> profile( | ||
| 4463 | + heap_profiler->GetAllocationProfile()); | ||
| 4464 | + CHECK(profile); | ||
| 4465 | + | ||
| 4466 | + const auto& samples = profile->GetSamples(); | ||
| 4467 | + CHECK(!samples.empty()); | ||
| 4468 | + | ||
| 4469 | + for (const auto& sample : samples) { | ||
| 4470 | + CHECK(sample.is_live); | ||
| 4471 | + } | ||
| 4472 | + | ||
| 4473 | + heap_profiler->StopSamplingHeapProfiler(); | ||
| 4474 | + } | ||
| 4475 | + | ||
| 4476 | + TEST(SamplingHeapProfilerSampleIsLive) { | ||
| 4477 | + v8::HandleScope scope(CcTest::isolate()); | ||
| 4478 | + LocalContext env; | ||
| 4479 | + v8::HeapProfiler* heap_profiler = env.isolate()->GetHeapProfiler(); | ||
| 4480 | + | ||
| 4481 | + // Suppress randomness to avoid flakiness in tests. | ||
| 4482 | + i::v8_flags.sampling_heap_profiler_suppress_randomness = true; | ||
| 4483 | + | ||
| 4484 | + heap_profiler->StartSamplingHeapProfiler( | ||
| 4485 | + 64, 16, | ||
| 4486 | + static_cast<v8::HeapProfiler::SamplingFlags>( | ||
| 4487 | + v8::HeapProfiler::kSamplingForceGC | | ||
| 4488 | + v8::HeapProfiler::kSamplingIncludeObjectsCollectedByMajorGC)); | ||
| 4489 | + | ||
| 4490 | + // Allocate objects that will be retained | ||
| 4491 | + CompileRun( | ||
| 4492 | + "var retained = [];\n" | ||
| 4493 | + "for (var i = 0; i < 500; i++) retained.push(new Array(10));\n"); | ||
| 4494 | + | ||
| 4495 | + CompileRun("for (var i = 0; i < 500; i++) new Array(10);\n"); | ||
| 4496 | + | ||
| 4497 | + std::unique_ptr<v8::AllocationProfile> profile( | ||
| 4498 | + heap_profiler->GetAllocationProfile()); | ||
| 4499 | + CHECK(profile); | ||
| 4500 | + | ||
| 4501 | + const auto& samples = profile->GetSamples(); | ||
| 4502 | + CHECK(!samples.empty()); | ||
| 4503 | + | ||
| 4504 | + int live_samples = 0; | ||
| 4505 | + int dead_samples = 0; | ||
| 4506 | + for (const auto& sample : samples) { | ||
| 4507 | + if (sample.is_live) { | ||
| 4508 | + ++live_samples; | ||
| 4509 | + } else { | ||
| 4510 | + ++dead_samples; | ||
| 4511 | + } | ||
| 4512 | + } | ||
| 4513 | + | ||
| 4514 | + // We expect both retained and collected allocations in this profile. | ||
| 4515 | + CHECK_GT(live_samples, 0); | ||
| 4516 | + CHECK_GT(dead_samples, 0); | ||
| 4517 | + | ||
| 4518 | + heap_profiler->StopSamplingHeapProfiler(); | ||
| 4519 | + } | ||
| 4520 | + | ||
| 4445 | 4521 | TEST(HeapSnapshotPrototypeNotJSReceiver) { | |
| 4446 | 4522 | LocalContext env; | |
| 4447 | 4523 | v8::HandleScope scope(env.isolate()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments