Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup! fixup! src: share common code paths for SEA and embedder script
  • Loading branch information
addaleax committed Feb 25, 2023
commit eeccbe543a9ddaa45b9232f8a4f424776afb21b2
29 changes: 7 additions & 22 deletions src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,14 @@ static std::string OnDiskFileName(const char* id) {
MaybeLocal<String> BuiltinLoader::LoadBuiltinSource(Isolate* isolate,
const char* id) const {
auto source = source_.read();
#ifdef NODE_BUILTIN_MODULES_PATH
if (strncmp(id, "embedder_main_", strlen("embedder_main_")) == 0) {
#endif // NODE_BUILTIN_MODULES_PATH
const auto source_it = source->find(id);
if (UNLIKELY(source_it == source->end())) {
fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id);
ABORT();
}
return source_it->second.ToStringChecked(isolate);
#ifdef NODE_BUILTIN_MODULES_PATH
#ifndef NODE_BUILTIN_MODULES_PATH
const auto source_it = source->find(id);
if (UNLIKELY(source_it == source->end())) {
fprintf(stderr, "Cannot find native builtin: \"%s\".\n", id);
ABORT();
}
return source_it->second.ToStringChecked(isolate);
#else // !NODE_BUILTIN_MODULES_PATH
std::string filename = OnDiskFileName(id);

std::string contents;
Expand Down Expand Up @@ -395,12 +392,6 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(Local<Context> context,
FIXED_ONE_BYTE_STRING(isolate, "internalBinding"),
FIXED_ONE_BYTE_STRING(isolate, "primordials"),
};
} else if (strncmp(id, "embedder_main_", strlen("embedder_main_")) == 0) {
// Synthetic embedder main scripts from LoadEnvironment(): process, require
parameters = {
FIXED_ONE_BYTE_STRING(isolate, "process"),
FIXED_ONE_BYTE_STRING(isolate, "require"),
};
} else {
// others: exports, require, module, process, internalBinding, primordials
parameters = {
Expand Down Expand Up @@ -457,12 +448,6 @@ MaybeLocal<Value> BuiltinLoader::CompileAndCall(Local<Context> context,
realm->builtin_module_require(),
realm->internal_binding_loader(),
realm->primordials()};
} else if (strncmp(id, "embedder_main_", strlen("embedder_main_")) == 0) {
// Synthetic embedder main scripts from LoadEnvironment(): process, require
arguments = {
realm->process_object(),
realm->builtin_module_require(),
};
} else {
// This should be invoked with the other CompileAndCall() methods, as
// we are unable to generate the arguments.
Expand Down
1 change: 1 addition & 0 deletions src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void NodeMainInstance::Run(ExitCode* exit_code, Environment* env) {
bool is_sea = false;
#ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION
if (sea::IsSingleExecutable()) {
is_sea = true;
LoadEnvironment(env, sea::FindSingleExecutableCode());
}
#endif
Expand Down
3 changes: 0 additions & 3 deletions src/node_sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "node_external_reference.h"
#include "node_internals.h"
#include "node_union_bytes.h"
#include "simdutf.h"
#include "v8.h"

// The POSTJECT_SENTINEL_FUSE macro is a string of random characters selected by
// the Node.js project that is present only once in the entire binary. It is
Expand All @@ -19,7 +17,6 @@
#include <memory>
#include <string_view>
#include <tuple>
#include <vector>

#if !defined(DISABLE_SINGLE_EXECUTABLE_APPLICATION)

Expand Down
2 changes: 1 addition & 1 deletion src/node_snapshotable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ void SerializeSnapshotableObjects(Realm* realm,

namespace mksnapshot {

// NB: This is also use by the regular embedding codepath.
// NB: This is also used by the regular embedding codepath.
void GetEmbedderEntryFunction(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = env->isolate();
Expand Down