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,doc: Experimental support for SEA #42334

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
squash: avoid running in repl like environment
- address comment that we should not be running in
repl like environment

Signed-off-by: Michael Dawson <mdawson@devrus.com>
  • Loading branch information
mhdawson committed Jul 4, 2022
commit 073bc889d389c5eb87e5a2b20f6a0050ced6784e
26 changes: 26 additions & 0 deletions lib/internal/main/single_executable_application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const {
prepareMainThreadExecution
} = require('internal/bootstrap/pre_execution');

const { getOptionValue } = require('internal/options');

const {
evalModule,
evalScript,
readStdin
} = require('internal/process/execution');

prepareMainThreadExecution();
markBootstrapComplete();

const source = getOptionValue('--eval');
const print = getOptionValue('--print');
if (getOptionValue('--input-type') === 'module')
evalModule(source, print);
else
evalScript('[eval]',
source,
getOptionValue('--inspect-brk'),
print);
8 changes: 8 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ PVOID old_vectored_exception_handler;

// node_v8_platform-inl.h
struct V8Platform v8_platform;

bool single_executable_application = false;
} // namespace per_process

// The section in the OpenSSL configuration file to be loaded.
Expand Down Expand Up @@ -520,6 +522,11 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
return StartExecution(env, "internal/main/prof_process");
}

if (env->options()->has_eval_string &&
per_process::single_executable_application) {
return StartExecution(env, "internal/main/single_executable_application");
}

// -e/--eval without -i/--interactive
if (env->options()->has_eval_string && !env->options()->force_repl) {
return StartExecution(env, "internal/main/eval_string");
Expand Down Expand Up @@ -1191,6 +1198,7 @@ int Start(int argc, char** argv) {
if (!new_args->single_executable_application) {
result = InitializeOncePerProcess(argc, argv);
} else {
per_process::single_executable_application = true;
result = InitializeOncePerProcess(new_args->argc, new_args->argv);
}
if (result.early_return) {
Expand Down