Skip to content

Commit

Permalink
sea: expose only isExperimentalSeaWarningNeeded to JS from the binding
Browse files Browse the repository at this point in the history
Refs: nodejs#47588 (comment)
Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Apr 26, 2023
1 parent ce5e999 commit fa9df64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/internal/main/embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const {
prepareMainThreadExecution,
markBootstrapComplete,
} = require('internal/process/pre_execution');
const { isExperimentalSeaWarningDisabled, isSea } = internalBinding('sea');
const { isExperimentalSeaWarningNeeded } = internalBinding('sea');
const { emitExperimentalWarning } = require('internal/util');
const { embedderRequire, embedderRunCjs } = require('internal/util/embedding');
const { getEmbedderEntryFunction } = internalBinding('mksnapshot');

prepareMainThreadExecution(false, true);
markBootstrapComplete();

if (isSea() && !isExperimentalSeaWarningDisabled()) {
if (isExperimentalSeaWarningNeeded()) {
emitExperimentalWarning('Single executable application');
}

Expand Down
16 changes: 5 additions & 11 deletions src/node_sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,9 @@ bool IsSingleExecutable() {
return postject_has_resource();
}

void IsSingleExecutable(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(IsSingleExecutable());
}

void IsExperimentalSeaWarningDisabled(const FunctionCallbackInfo<Value>& args) {
void IsExperimentalSeaWarningNeeded(const FunctionCallbackInfo<Value>& args) {
SeaResource sea_resource = FindSingleExecutableResource();
args.GetReturnValue().Set(static_cast<bool>(
args.GetReturnValue().Set(!static_cast<bool>(
sea_resource.flags & SeaFlags::kDisableExperimentalSeaWarning));
}

Expand Down Expand Up @@ -243,16 +239,14 @@ void Initialize(Local<Object> target,
Local<Value> unused,
Local<Context> context,
void* priv) {
SetMethod(context, target, "isSea", IsSingleExecutable);
SetMethod(context,
target,
"isExperimentalSeaWarningDisabled",
IsExperimentalSeaWarningDisabled);
"isExperimentalSeaWarningNeeded",
IsExperimentalSeaWarningNeeded);
}

void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(IsSingleExecutable);
registry->Register(IsExperimentalSeaWarningDisabled);
registry->Register(IsExperimentalSeaWarningNeeded);
}

} // namespace sea
Expand Down

0 comments on commit fa9df64

Please sign in to comment.