Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: implement runtime option --no-node-snapshot for debugging #28567

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1052,16 +1052,21 @@ int Start(int argc, char** argv) {

{
Isolate::CreateParams params;
// TODO(joyeecheung): collect external references and set it in
// params.external_references.
std::vector<intptr_t> external_references = {
reinterpret_cast<intptr_t>(nullptr)};
v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob();
const std::vector<size_t>* indexes =
NodeMainInstance::GetIsolateDataIndexes();
if (blob != nullptr) {
params.external_references = external_references.data();
params.snapshot_blob = blob;
const std::vector<size_t>* indexes = nullptr;
std::vector<intptr_t> external_references;

bool force_no_snapshot =
per_process::cli_options->per_isolate->no_node_snapshot;
if (!force_no_snapshot) {
v8::StartupData* blob = NodeMainInstance::GetEmbeddedSnapshotBlob();
if (blob != nullptr) {
// TODO(joyeecheung): collect external references and set it in
// params.external_references.
external_references.push_back(reinterpret_cast<intptr_t>(nullptr));
params.external_references = external_references.data();
params.snapshot_blob = blob;
indexes = NodeMainInstance::GetIsolateDataIndexes();
}
}

NodeMainInstance main_instance(&params,
Expand Down
4 changes: 4 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
"track heap object allocations for heap snapshots",
&PerIsolateOptions::track_heap_objects,
kAllowedInEnvironment);
AddOption("--no-node-snapshot",
"", // It's a debug-only option.
&PerIsolateOptions::no_node_snapshot,
kAllowedInEnvironment);

// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS.
AddOption("--abort-on-uncaught-exception",
Expand Down
1 change: 1 addition & 0 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class PerIsolateOptions : public Options {
public:
std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() };
bool track_heap_objects = false;
bool no_node_snapshot = false;

#ifdef NODE_REPORT
bool report_uncaught_exception = false;
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-no-node-snapshot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

// Flags: --no-node-snapshot

require('../common');
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ const undocumented = difference(process.allowedNodeEnvironmentFlags,
// Remove intentionally undocumented options.
assert(undocumented.delete('--debug-arraybuffer-allocations'));
assert(undocumented.delete('--experimental-worker'));
assert(undocumented.delete('--no-node-snapshot'));

assert.strictEqual(undocumented.size, 0,
'The following options are not documented as allowed in ' +
`NODE_OPTIONS in ${cliMd}: ${[...undocumented].join(' ')}`);