fix: support for v8.setHeapSnapshotNearHeapLimit api (#45606)

* fix: support for v8.setHeapSnapshotNearHeapLimit api

* docs: add  support
This commit is contained in:
Robo 2025-02-15 01:00:39 +09:00 committed by GitHub
parent a841d6484c
commit 137a552641
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 66 additions and 6 deletions

View file

@ -33,9 +33,15 @@ namespace electron {
namespace {
gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) {
gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate,
size_t* max_young_generation_size) {
std::unique_ptr<v8::Isolate::CreateParams> create_params =
gin::IsolateHolder::getDefaultIsolateParams();
// The value is needed to adjust heap limit when capturing
// snapshot via v8.setHeapSnapshotNearHeapLimit(limit) or
// --heapsnapshot-near-heap-limit=max_count.
*max_young_generation_size =
create_params->constraints.max_young_generation_size_in_bytes();
// Align behavior with V8 Isolate default for Node.js.
// This is necessary for important aspects of Node.js
// including heap and cpu profilers to function properly.
@ -55,7 +61,8 @@ gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) {
JavascriptEnvironment::JavascriptEnvironment(uv_loop_t* event_loop,
bool setup_wasm_streaming)
: isolate_holder_{CreateIsolateHolder(
Initialize(event_loop, setup_wasm_streaming))},
Initialize(event_loop, setup_wasm_streaming),
&max_young_generation_size_)},
isolate_{isolate_holder_.isolate()},
locker_{isolate_} {
isolate_->Enter();