| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| 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.17', | ||
| 41 | + 'v8_embedder_string': '-node.18', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1001,6 +1001,13 @@ class V8_EXPORT Isolate { | |||
| 1001 | 1001 | */ | |
| 1002 | 1002 | void GetHeapStatistics(HeapStatistics* heap_statistics); | |
| 1003 | 1003 | ||
| 1004 | + /** | ||
| 1005 | + * Get total allocated bytes since isolate creation. | ||
| 1006 | + * This should be used only by Node.JS, since it's a temporary method | ||
| 1007 | + * to avoid breaking ABI on HeapStatistics. | ||
| 1008 | + */ | ||
| 1009 | + uint64_t GetTotalAllocatedBytes(); | ||
| 1010 | + | ||
| 1004 | 1011 | /** | |
| 1005 | 1012 | * Returns the number of spaces in the heap. | |
| 1006 | 1013 | */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,13 +154,6 @@ class V8_EXPORT HeapStatistics { | |||
| 154 | 154 | size_t number_of_native_contexts() { return number_of_native_contexts_; } | |
| 155 | 155 | size_t number_of_detached_contexts() { return number_of_detached_contexts_; } | |
| 156 | 156 | ||
| 157 | - /** | ||
| 158 | - * Returns the total number of bytes allocated since the Isolate was created. | ||
| 159 | - * This includes all heap objects allocated in any space (new, old, code, | ||
| 160 | - * etc.). | ||
| 161 | - */ | ||
| 162 | - uint64_t total_allocated_bytes() { return total_allocated_bytes_; } | ||
| 163 | - | ||
| 164 | 157 | /** | |
| 165 | 158 | * Returns a 0/1 boolean, which signifies whether the V8 overwrite heap | |
| 166 | 159 | * garbage with a bit pattern. | |
@@ -182,7 +175,6 @@ class V8_EXPORT HeapStatistics { | |||
| 182 | 175 | size_t number_of_detached_contexts_; | |
| 183 | 176 | size_t total_global_handles_size_; | |
| 184 | 177 | size_t used_global_handles_size_; | |
| 185 | - uint64_t total_allocated_bytes_; | ||
| 186 | 178 | ||
| 187 | 179 | friend class V8; | |
| 188 | 180 | friend class Isolate; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6584,8 +6584,7 @@ HeapStatistics::HeapStatistics() | |||
| 6584 | 6584 | peak_malloced_memory_(0), | |
| 6585 | 6585 | does_zap_garbage_(false), | |
| 6586 | 6586 | number_of_native_contexts_(0), | |
| 6587 | - number_of_detached_contexts_(0), | ||
| 6588 | - total_allocated_bytes_(0) {} | ||
| 6587 | + number_of_detached_contexts_(0) {} | ||
| 6589 | 6588 | ||
| 6590 | 6589 | HeapSpaceStatistics::HeapSpaceStatistics() | |
| 6591 | 6590 | : space_name_(nullptr), | |
@@ -10439,7 +10438,6 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | |||
| 10439 | 10438 | heap_statistics->number_of_native_contexts_ = heap->NumberOfNativeContexts(); | |
| 10440 | 10439 | heap_statistics->number_of_detached_contexts_ = | |
| 10441 | 10440 | heap->NumberOfDetachedContexts(); | |
| 10442 | - heap_statistics->total_allocated_bytes_ = heap->GetTotalAllocatedBytes(); | ||
| 10443 | 10441 | heap_statistics->does_zap_garbage_ = i::heap::ShouldZapGarbage(); | |
| 10444 | 10442 | ||
| 10445 | 10443 | #if V8_ENABLE_WEBASSEMBLY | |
@@ -10450,6 +10448,11 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | |||
| 10450 | 10448 | #endif // V8_ENABLE_WEBASSEMBLY | |
| 10451 | 10449 | } | |
| 10452 | 10450 | ||
| 10451 | + uint64_t Isolate::GetTotalAllocatedBytes() { | ||
| 10452 | + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this); | ||
| 10453 | + return i_isolate->heap()->GetTotalAllocatedBytes(); | ||
| 10454 | + } | ||
| 10455 | + | ||
| 10453 | 10456 | size_t Isolate::NumberOfHeapSpaces() { | |
| 10454 | 10457 | return i::LAST_SPACE - i::FIRST_SPACE + 1; | |
| 10455 | 10458 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17656,152 +17656,6 @@ TEST(GetHeapSpaceStatistics) { | |||
| 17656 | 17656 | CHECK_EQ(total_physical_size, heap_statistics.total_physical_size()); | |
| 17657 | 17657 | } | |
| 17658 | 17658 | ||
| 17659 | - UNINITIALIZED_TEST(GetHeapTotalAllocatedBytes) { | ||
| 17660 | - // This test is incompatible with concurrent allocation, which may occur | ||
| 17661 | - // while collecting the statistics and break the final `CHECK_EQ`s. | ||
| 17662 | - if (i::v8_flags.stress_concurrent_allocation) return; | ||
| 17663 | - | ||
| 17664 | - v8::Isolate::CreateParams create_params; | ||
| 17665 | - create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | ||
| 17666 | - v8::Isolate* isolate = v8::Isolate::New(create_params); | ||
| 17667 | - | ||
| 17668 | - const uint32_t number_of_elements = 1; | ||
| 17669 | - const uint32_t allocation_size = i::FixedArray::SizeFor(number_of_elements); | ||
| 17670 | - const uint32_t trusted_allocation_size = | ||
| 17671 | - i::TrustedFixedArray::SizeFor(number_of_elements); | ||
| 17672 | - const uint32_t lo_number_of_elements = 256 * 1024; | ||
| 17673 | - const uint32_t lo_allocation_size = | ||
| 17674 | - i::FixedArray::SizeFor(lo_number_of_elements); | ||
| 17675 | - const uint32_t trusted_lo_allocation_size = | ||
| 17676 | - i::TrustedFixedArray::SizeFor(lo_number_of_elements); | ||
| 17677 | - const uint32_t expected_allocation_size = | ||
| 17678 | - allocation_size * 2 + lo_allocation_size * 2 + trusted_allocation_size + | ||
| 17679 | - trusted_lo_allocation_size; | ||
| 17680 | - | ||
| 17681 | - { | ||
| 17682 | - v8::Isolate::Scope isolate_scope(isolate); | ||
| 17683 | - v8::HandleScope handle_scope(isolate); | ||
| 17684 | - LocalContext env(isolate); | ||
| 17685 | - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | ||
| 17686 | - | ||
| 17687 | - v8::HeapStatistics heap_stats_before; | ||
| 17688 | - isolate->GetHeapStatistics(&heap_stats_before); | ||
| 17689 | - size_t initial_allocated = heap_stats_before.total_allocated_bytes(); | ||
| 17690 | - | ||
| 17691 | - i::MaybeHandle<i::FixedArray> young_alloc = | ||
| 17692 | - i_isolate->factory()->TryNewFixedArray(number_of_elements, | ||
| 17693 | - i::AllocationType::kYoung); | ||
| 17694 | - USE(young_alloc); | ||
| 17695 | - i::MaybeHandle<i::FixedArray> old_alloc = | ||
| 17696 | - i_isolate->factory()->TryNewFixedArray(number_of_elements, | ||
| 17697 | - i::AllocationType::kOld); | ||
| 17698 | - USE(old_alloc); | ||
| 17699 | - i::Handle<i::TrustedFixedArray> trusted_alloc = | ||
| 17700 | - i_isolate->factory()->NewTrustedFixedArray(number_of_elements, | ||
| 17701 | - i::AllocationType::kTrusted); | ||
| 17702 | - USE(trusted_alloc); | ||
| 17703 | - i::MaybeHandle<i::FixedArray> old_lo_alloc = | ||
| 17704 | - i_isolate->factory()->TryNewFixedArray(lo_number_of_elements, | ||
| 17705 | - i::AllocationType::kOld); | ||
| 17706 | - USE(old_lo_alloc); | ||
| 17707 | - | ||
| 17708 | - { | ||
| 17709 | - v8::HandleScope inner_handle_scope(isolate); | ||
| 17710 | - auto young_lo_alloc = i_isolate->factory()->TryNewFixedArray( | ||
| 17711 | - lo_number_of_elements, i::AllocationType::kYoung); | ||
| 17712 | - USE(young_lo_alloc); | ||
| 17713 | - } | ||
| 17714 | - | ||
| 17715 | - auto trusted_lo_alloc = i_isolate->factory()->NewTrustedFixedArray( | ||
| 17716 | - lo_number_of_elements, i::AllocationType::kTrusted); | ||
| 17717 | - USE(trusted_lo_alloc); | ||
| 17718 | - | ||
| 17719 | - v8::HeapStatistics heap_stats_after; | ||
| 17720 | - isolate->GetHeapStatistics(&heap_stats_after); | ||
| 17721 | - uint64_t final_allocated = heap_stats_after.total_allocated_bytes(); | ||
| 17722 | - | ||
| 17723 | - CHECK_GT(final_allocated, initial_allocated); | ||
| 17724 | - uint64_t allocated_diff = final_allocated - initial_allocated; | ||
| 17725 | - CHECK_GE(allocated_diff, expected_allocation_size); | ||
| 17726 | - | ||
| 17727 | - // This either tests counting happening when a LAB freed and validate | ||
| 17728 | - // there's no double counting on evacuated/promoted objects. | ||
| 17729 | - v8::internal::heap::InvokeAtomicMajorGC(i_isolate->heap()); | ||
| 17730 | - | ||
| 17731 | - v8::HeapStatistics heap_stats_after_gc; | ||
| 17732 | - isolate->GetHeapStatistics(&heap_stats_after_gc); | ||
| 17733 | - uint64_t total_allocation_after_gc = | ||
| 17734 | - heap_stats_after_gc.total_allocated_bytes(); | ||
| 17735 | - | ||
| 17736 | - CHECK_EQ(total_allocation_after_gc, final_allocated); | ||
| 17737 | - } | ||
| 17738 | - | ||
| 17739 | - isolate->Dispose(); | ||
| 17740 | - } | ||
| 17741 | - | ||
| 17742 | - #if V8_CAN_CREATE_SHARED_HEAP_BOOL | ||
| 17743 | - | ||
| 17744 | - UNINITIALIZED_TEST(GetHeapTotalAllocatedBytesSharedSpaces) { | ||
| 17745 | - // This test is incompatible with concurrent allocation, which may occur | ||
| 17746 | - // while collecting the statistics and break the final `CHECK_EQ`s. | ||
| 17747 | - if (i::v8_flags.stress_concurrent_allocation) return; | ||
| 17748 | - if (COMPRESS_POINTERS_IN_MULTIPLE_CAGES_BOOL) return; | ||
| 17749 | - | ||
| 17750 | - i::v8_flags.shared_heap = true; | ||
| 17751 | - i::FlagList::EnforceFlagImplications(); | ||
| 17752 | - | ||
| 17753 | - v8::Isolate::CreateParams create_params; | ||
| 17754 | - create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | ||
| 17755 | - v8::Isolate* isolate = v8::Isolate::New(create_params); | ||
| 17756 | - | ||
| 17757 | - { | ||
| 17758 | - v8::Isolate::Scope isolate_scope(isolate); | ||
| 17759 | - v8::HandleScope handle_scope(isolate); | ||
| 17760 | - LocalContext env(isolate); | ||
| 17761 | - | ||
| 17762 | - v8::HeapStatistics heap_stats_before; | ||
| 17763 | - isolate->GetHeapStatistics(&heap_stats_before); | ||
| 17764 | - size_t initial_allocated = heap_stats_before.total_allocated_bytes(); | ||
| 17765 | - | ||
| 17766 | - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | ||
| 17767 | - | ||
| 17768 | - const uint32_t number_of_elements = 1; | ||
| 17769 | - const uint32_t allocation_size = i::FixedArray::SizeFor(number_of_elements); | ||
| 17770 | - const uint32_t trusted_allocation_size = | ||
| 17771 | - i::TrustedFixedArray::SizeFor(number_of_elements); | ||
| 17772 | - const uint32_t lo_number_of_elements = 256 * 1024; | ||
| 17773 | - const uint32_t lo_allocation_size = | ||
| 17774 | - i::FixedArray::SizeFor(lo_number_of_elements); | ||
| 17775 | - const uint32_t expected_allocation_size = | ||
| 17776 | - allocation_size + trusted_allocation_size + lo_allocation_size; | ||
| 17777 | - | ||
| 17778 | - i::MaybeHandle<i::FixedArray> shared_alloc = | ||
| 17779 | - i_isolate->factory()->TryNewFixedArray(number_of_elements, | ||
| 17780 | - i::AllocationType::kSharedOld); | ||
| 17781 | - USE(shared_alloc); | ||
| 17782 | - i::Handle<i::TrustedFixedArray> shared_trusted_alloc = | ||
| 17783 | - i_isolate->factory()->NewTrustedFixedArray( | ||
| 17784 | - number_of_elements, i::AllocationType::kSharedTrusted); | ||
| 17785 | - USE(shared_trusted_alloc); | ||
| 17786 | - i::MaybeHandle<i::FixedArray> shared_lo_alloc = | ||
| 17787 | - i_isolate->factory()->TryNewFixedArray(lo_number_of_elements, | ||
| 17788 | - i::AllocationType::kSharedOld); | ||
| 17789 | - USE(shared_lo_alloc); | ||
| 17790 | - | ||
| 17791 | - v8::HeapStatistics heap_stats_after; | ||
| 17792 | - isolate->GetHeapStatistics(&heap_stats_after); | ||
| 17793 | - uint64_t final_allocated = heap_stats_after.total_allocated_bytes(); | ||
| 17794 | - | ||
| 17795 | - CHECK_GT(final_allocated, initial_allocated); | ||
| 17796 | - uint64_t allocated_diff = final_allocated - initial_allocated; | ||
| 17797 | - CHECK_GE(allocated_diff, expected_allocation_size); | ||
| 17798 | - } | ||
| 17799 | - | ||
| 17800 | - isolate->Dispose(); | ||
| 17801 | - } | ||
| 17802 | - | ||
| 17803 | - #endif // V8_CAN_CREATE_SHARED_HEAP_BOOL | ||
| 17804 | - | ||
| 17805 | 17659 | TEST(NumberOfNativeContexts) { | |
| 17806 | 17660 | static const size_t kNumTestContexts = 10; | |
| 17807 | 17661 | i::Isolate* isolate = CcTest::i_isolate(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -265,7 +265,7 @@ used memory size of V8 global handles. | |||
| 265 | 265 | buffers and external strings. | |
| 266 | 266 | ||
| 267 | 267 | `total_allocated_bytes` The value of total allocated bytes since the Isolate | |
| 268 | - creation | ||
| 268 | + creation. | ||
| 269 | 269 | ||
| 270 | 270 | <!-- eslint-skip --> | |
| 271 | 271 | ||
@@ -284,7 +284,8 @@ creation | |||
| 284 | 284 | number_of_detached_contexts: 0, | |
| 285 | 285 | total_global_handles_size: 8192, | |
| 286 | 286 | used_global_handles_size: 3296, | |
| 287 | - external_memory: 318824 | ||
| 287 | + external_memory: 318824, | ||
| 288 | + total_allocated_bytes: 45224088 | ||
| 288 | 289 | } | |
| 289 | 290 | ``` | |
| 290 | 291 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,7 @@ const { | |||
| 117 | 117 | stopCpuProfile: _stopCpuProfile, | |
| 118 | 118 | isStringOneByteRepresentation: _isStringOneByteRepresentation, | |
| 119 | 119 | updateHeapStatisticsBuffer, | |
| 120 | + getTotalAllocatedBytes, | ||
| 120 | 121 | updateHeapSpaceStatisticsBuffer, | |
| 121 | 122 | updateHeapCodeStatisticsBuffer, | |
| 122 | 123 | setHeapSnapshotNearHeapLimit: _setHeapSnapshotNearHeapLimit, | |
@@ -136,7 +137,6 @@ const { | |||
| 136 | 137 | kTotalGlobalHandlesSizeIndex, | |
| 137 | 138 | kUsedGlobalHandlesSizeIndex, | |
| 138 | 139 | kExternalMemoryIndex, | |
| 139 | - kTotalAllocatedBytes, | ||
| 140 | 140 | ||
| 141 | 141 | // Properties for heap spaces statistics buffer extraction. | |
| 142 | 142 | kHeapSpaces, | |
@@ -247,7 +247,7 @@ function getHeapStatistics() { | |||
| 247 | 247 | total_global_handles_size: buffer[kTotalGlobalHandlesSizeIndex], | |
| 248 | 248 | used_global_handles_size: buffer[kUsedGlobalHandlesSizeIndex], | |
| 249 | 249 | external_memory: buffer[kExternalMemoryIndex], | |
| 250 | - total_allocated_bytes: buffer[kTotalAllocatedBytes], | ||
| 250 | + total_allocated_bytes: getTotalAllocatedBytes(), | ||
| 251 | 251 | }; | |
| 252 | 252 | } | |
| 253 | 253 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,8 +73,7 @@ using v8::Value; | |||
| 73 | 73 | V(10, number_of_detached_contexts, kNumberOfDetachedContextsIndex) \ | |
| 74 | 74 | V(11, total_global_handles_size, kTotalGlobalHandlesSizeIndex) \ | |
| 75 | 75 | V(12, used_global_handles_size, kUsedGlobalHandlesSizeIndex) \ | |
| 76 | - V(13, external_memory, kExternalMemoryIndex) \ | ||
| 77 | - V(14, total_allocated_bytes, kTotalAllocatedBytes) | ||
| 76 | + V(13, external_memory, kExternalMemoryIndex) | ||
| 78 | 77 | ||
| 79 | 78 | #define V(a, b, c) +1 | |
| 80 | 79 | static constexpr size_t kHeapStatisticsPropertiesCount = | |
@@ -213,6 +212,12 @@ void UpdateHeapStatisticsBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 213 | 212 | #undef V | |
| 214 | 213 | } | |
| 215 | 214 | ||
| 215 | + void GetTotalAllocatedBytes(const FunctionCallbackInfo<Value>& args) { | ||
| 216 | + Isolate* isolate = args.GetIsolate(); | ||
| 217 | + uint64_t allocated_bytes = isolate->GetTotalAllocatedBytes(); | ||
| 218 | + args.GetReturnValue().Set(Number::New(isolate, allocated_bytes)); | ||
| 219 | + } | ||
| 220 | + | ||
| 216 | 221 | ||
| 217 | 222 | void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo<Value>& args) { | |
| 218 | 223 | BindingData* data = Realm::GetBindingData<BindingData>(args); | |
@@ -693,6 +698,11 @@ void Initialize(Local<Object> target, | |||
| 693 | 698 | "updateHeapStatisticsBuffer", | |
| 694 | 699 | UpdateHeapStatisticsBuffer); | |
| 695 | 700 | ||
| 701 | + SetMethod(context, | ||
| 702 | + target, | ||
| 703 | + "getTotalAllocatedBytes", | ||
| 704 | + GetTotalAllocatedBytes); | ||
| 705 | + | ||
| 696 | 706 | SetMethod(context, | |
| 697 | 707 | target, | |
| 698 | 708 | "updateHeapCodeStatisticsBuffer", | |
@@ -774,6 +784,7 @@ void Initialize(Local<Object> target, | |||
| 774 | 784 | void RegisterExternalReferences(ExternalReferenceRegistry* registry) { | |
| 775 | 785 | registry->Register(CachedDataVersionTag); | |
| 776 | 786 | registry->Register(UpdateHeapStatisticsBuffer); | |
| 787 | + registry->Register(GetTotalAllocatedBytes); | ||
| 777 | 788 | registry->Register(UpdateHeapCodeStatisticsBuffer); | |
| 778 | 789 | registry->Register(UpdateHeapSpaceStatisticsBuffer); | |
| 779 | 790 | registry->Register(SetFlagsFromString); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1284,7 +1284,7 @@ void Worker::GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { | |||
| 1284 | 1284 | Number::New(isolate, heap_stats->total_global_handles_size()), | |
| 1285 | 1285 | Number::New(isolate, heap_stats->used_global_handles_size()), | |
| 1286 | 1286 | Number::New(isolate, heap_stats->external_memory()), | |
| 1287 | - Number::New(isolate, heap_stats->total_allocated_bytes())}; | ||
| 1287 | + Number::New(isolate, isolate->GetTotalAllocatedBytes())}; | ||
| 1288 | 1288 | ||
| 1289 | 1289 | Local<Object> obj; | |
| 1290 | 1290 | if (!NewDictionaryInstanceNullProto( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments