Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+568
@@ -0,0 +1,568 @@
|
||||
--- node/deps/v8/include/v8.h
|
||||
+++ node/deps/v8/include/v8.h
|
||||
@@ -8137,10 +8137,14 @@
|
||||
*/
|
||||
static void SetFlagsFromCommandLine(int* argc,
|
||||
char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
/**
|
||||
* Initializes V8. This function needs to be called before the first Isolate
|
||||
--- node/deps/v8/src/api.cc
|
||||
+++ node/deps/v8/src/api.cc
|
||||
@@ -914,10 +914,42 @@
|
||||
|
||||
void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
||||
}
|
||||
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+ i::CpuFeatures::Reinitialize();
|
||||
+ i::CpuFeatures::Probe(true);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+ i::CpuFeatures::Reinitialize();
|
||||
+ i::CpuFeatures::Probe(false);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto object = i::Handle<i::HeapObject>::cast(Utils::OpenHandle(*script));
|
||||
+ i::Handle<i::SharedFunctionInfo> function_info(
|
||||
+ i::SharedFunctionInfo::cast(*object), object->GetIsolate());
|
||||
+ auto s = reinterpret_cast<i::Script*>(function_info->script());
|
||||
+ s->set_source(isolate->heap()->undefined_value());
|
||||
+}
|
||||
+
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
||||
|
||||
RegisteredExtension::RegisteredExtension(Extension* extension)
|
||||
: extension_(extension) { }
|
||||
|
||||
--- node/deps/v8/src/assembler.h
|
||||
+++ node/deps/v8/src/assembler.h
|
||||
@@ -302,10 +302,15 @@
|
||||
}
|
||||
|
||||
static void PrintTarget();
|
||||
static void PrintFeatures();
|
||||
|
||||
+ static void Reinitialize() {
|
||||
+ supported_ = 0;
|
||||
+ initialized_ = false;
|
||||
+ }
|
||||
+
|
||||
private:
|
||||
friend class ExternalReference;
|
||||
friend class AssemblerBase;
|
||||
// Flush instruction cache.
|
||||
static void FlushICache(void* start, size_t size);
|
||||
--- node/deps/v8/src/objects.cc
|
||||
+++ node/deps/v8/src/objects.cc
|
||||
@@ -13179,10 +13179,13 @@
|
||||
|
||||
// Check if we should print {function} as a class.
|
||||
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_positions_symbol());
|
||||
if (maybe_class_positions->IsTuple2()) {
|
||||
+ if (Script::cast(shared_info->script())->source()->IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
Tuple2* class_positions = Tuple2::cast(*maybe_class_positions);
|
||||
int start_position = Smi::ToInt(class_positions->value1());
|
||||
int end_position = Smi::ToInt(class_positions->value2());
|
||||
Handle<String> script_source(
|
||||
String::cast(Script::cast(shared_info->script())->source()), isolate);
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -18,10 +18,11 @@
|
||||
namespace parsing {
|
||||
|
||||
bool ParseProgram(ParseInfo* info, Isolate* isolate) {
|
||||
DCHECK(info->is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<String> source(String::cast(info->script()->source()), isolate);
|
||||
@@ -55,10 +56,11 @@
|
||||
bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
DCHECK(!info->is_toplevel());
|
||||
DCHECK(!shared_info.is_null());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<String> source(String::cast(info->script()->source()), isolate);
|
||||
source = String::Flatten(source);
|
||||
isolate->counters()->total_parse_size()->Increment(source->length());
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -401,31 +401,46 @@
|
||||
|
||||
SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
||||
Isolate* isolate, uint32_t expected_source_hash) const {
|
||||
if (this->size_ < kHeaderSize) return INVALID_HEADER;
|
||||
uint32_t magic_number = GetMagicNumber();
|
||||
- if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH;
|
||||
+ if (magic_number != ComputeMagicNumber(isolate)) {
|
||||
+ // base::OS::PrintError("Pkg: MAGIC_NUMBER_MISMATCH\n"); // TODO enable after solving v8-cache/ncc issue
|
||||
+ return MAGIC_NUMBER_MISMATCH;
|
||||
+ }
|
||||
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
|
||||
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t c1 = GetHeaderValue(kChecksum1Offset);
|
||||
uint32_t c2 = GetHeaderValue(kChecksum2Offset);
|
||||
- if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
||||
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
||||
- if (cpu_features != static_cast<uint32_t>(CpuFeatures::SupportedFeatures())) {
|
||||
+ if (version_hash != Version::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
|
||||
+ return VERSION_MISMATCH;
|
||||
+ }
|
||||
+ uint32_t host_features = static_cast<uint32_t>(CpuFeatures::SupportedFeatures());
|
||||
+ if (cpu_features & (~host_features)) {
|
||||
+ base::OS::PrintError("Pkg: CPU_FEATURES_MISMATCH\n");
|
||||
return CPU_FEATURES_MISMATCH;
|
||||
}
|
||||
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
||||
+ if (flags_hash != FlagList::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
|
||||
+ return FLAGS_MISMATCH;
|
||||
+ }
|
||||
uint32_t max_payload_length =
|
||||
this->size_ -
|
||||
POINTER_SIZE_ALIGN(kHeaderSize +
|
||||
GetHeaderValue(kNumReservationsOffset) * kInt32Size +
|
||||
GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size);
|
||||
- if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
||||
- if (!Checksum(DataWithoutHeader()).Check(c1, c2)) return CHECKSUM_MISMATCH;
|
||||
+ if (payload_length > max_payload_length) {
|
||||
+ base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
|
||||
+ return LENGTH_MISMATCH;
|
||||
+ }
|
||||
+ if (!Checksum(DataWithoutHeader()).Check(c1, c2)) {
|
||||
+ base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
|
||||
+ return CHECKSUM_MISMATCH;
|
||||
+ }
|
||||
return CHECK_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t SerializedCodeData::SourceHash(Handle<String> source) {
|
||||
return source->length();
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -108,11 +108,11 @@
|
||||
}
|
||||
|
||||
options.execPath = options.execPath || process.execPath;
|
||||
options.shell = false;
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return exports.spawn(options.execPath, args, options);
|
||||
};
|
||||
|
||||
|
||||
exports._forkChild = function _forkChild(fd) {
|
||||
// set process.send()
|
||||
--- node/lib/internal/bootstrap/loaders.js
|
||||
+++ node/lib/internal/bootstrap/loaders.js
|
||||
@@ -337,11 +337,11 @@
|
||||
|
||||
// (code, filename, lineOffset, columnOffset
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
const script = new ContextifyScript(
|
||||
source, this.filename, 0, 0,
|
||||
- cache, false, undefined
|
||||
+ cache, false, undefined, false
|
||||
);
|
||||
|
||||
// This will be used to create code cache in tools/generate_code_cache.js
|
||||
this.script = script;
|
||||
|
||||
--- node/lib/internal/bootstrap/node.js
|
||||
+++ node/lib/internal/bootstrap/node.js
|
||||
@@ -213,10 +213,47 @@
|
||||
|
||||
// There are various modes that Node can run in. The most common two
|
||||
// are running from a script and running the REPL - but there are a few
|
||||
// others like the debugger or running --eval arguments. Here we decide
|
||||
// which mode we run in.
|
||||
+
|
||||
+ (function () {
|
||||
+ var fs = NativeModule.require('fs');
|
||||
+ var vm = NativeModule.require('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, NativeModule.require,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+ }());
|
||||
+
|
||||
if (internalBinding('worker').getEnvMessagePort() !== undefined) {
|
||||
// This means we are in a Worker context, and any script execution
|
||||
// will be directed by the worker module.
|
||||
NativeModule.require('internal/worker').setupChild(evalScript);
|
||||
} else if (NativeModule.exists('_third_party_main')) {
|
||||
--- node/lib/internal/modules/cjs/loader.js
|
||||
+++ node/lib/internal/modules/cjs/loader.js
|
||||
@@ -27,14 +27,12 @@
|
||||
const vm = require('vm');
|
||||
const assert = require('assert').ok;
|
||||
const fs = require('fs');
|
||||
const internalFS = require('internal/fs/utils');
|
||||
const path = require('path');
|
||||
-const {
|
||||
- internalModuleReadJSON,
|
||||
- internalModuleStat
|
||||
-} = process.binding('fs');
|
||||
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const { safeGetenv } = process.binding('util');
|
||||
const {
|
||||
makeRequireFunction,
|
||||
normalizeReferrerURL,
|
||||
requireDepth,
|
||||
--- node/lib/vm.js
|
||||
+++ node/lib/vm.js
|
||||
@@ -55,10 +55,11 @@
|
||||
columnOffset = 0,
|
||||
cachedData,
|
||||
produceCachedData = false,
|
||||
importModuleDynamically,
|
||||
[kParsingContext]: parsingContext,
|
||||
+ sourceless = false,
|
||||
} = options;
|
||||
|
||||
if (typeof filename !== 'string') {
|
||||
throw new ERR_INVALID_ARG_TYPE('options.filename', 'string', filename);
|
||||
}
|
||||
@@ -84,11 +85,12 @@
|
||||
filename,
|
||||
lineOffset,
|
||||
columnOffset,
|
||||
cachedData,
|
||||
produceCachedData,
|
||||
- parsingContext);
|
||||
+ parsingContext,
|
||||
+ sourceless);
|
||||
} catch (e) {
|
||||
throw e; /* node-do-not-add-exception-line */
|
||||
}
|
||||
|
||||
if (importModuleDynamically !== undefined) {
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -705,12 +705,10 @@
|
||||
CHECK_EQ(0, uv_async_init(parent_env_->event_loop(),
|
||||
&start_io_thread_async,
|
||||
StartIoThreadAsyncCallback));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
start_io_thread_async.data = this;
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
}
|
||||
|
||||
bool wait_for_connect = options->wait_for_connect();
|
||||
if (parent_handle_) {
|
||||
wait_for_connect = parent_handle_->WaitForConnect();
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -2369,17 +2369,10 @@
|
||||
}
|
||||
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (int fd = STDIN_FILENO; fd <= STDERR_FILENO; fd += 1) {
|
||||
struct stat ignored;
|
||||
if (fstat(fd, &ignored) == 0)
|
||||
continue;
|
||||
@@ -2389,14 +2382,10 @@
|
||||
ABORT();
|
||||
if (fd != open("/dev/null", O_RDWR))
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -63,10 +63,11 @@
|
||||
using v8::String;
|
||||
using v8::Symbol;
|
||||
using v8::TryCatch;
|
||||
using v8::Uint32;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
using v8::WeakCallbackType;
|
||||
|
||||
// The vm module executes code in a sandboxed environment with a different
|
||||
@@ -638,15 +639,16 @@
|
||||
Local<Integer> line_offset;
|
||||
Local<Integer> column_offset;
|
||||
Local<ArrayBufferView> cached_data_buf;
|
||||
bool produce_cached_data = false;
|
||||
Local<Context> parsing_context = context;
|
||||
+ bool sourceless = false;
|
||||
|
||||
if (argc > 2) {
|
||||
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
- CHECK_EQ(argc, 7);
|
||||
+ CHECK_EQ(argc, 8);
|
||||
CHECK(args[2]->IsNumber());
|
||||
line_offset = args[2].As<Integer>();
|
||||
CHECK(args[3]->IsNumber());
|
||||
column_offset = args[3].As<Integer>();
|
||||
if (!args[4]->IsUndefined()) {
|
||||
@@ -661,10 +663,11 @@
|
||||
ContextifyContext::ContextFromContextifiedSandbox(
|
||||
env, args[6].As<Object>());
|
||||
CHECK_NOT_NULL(sandbox);
|
||||
parsing_context = sandbox->context();
|
||||
}
|
||||
+ sourceless = args[7]->IsTrue();
|
||||
} else {
|
||||
line_offset = Integer::New(isolate, 0);
|
||||
column_offset = Integer::New(isolate, 0);
|
||||
}
|
||||
|
||||
@@ -715,10 +718,14 @@
|
||||
|
||||
TryCatch try_catch(isolate);
|
||||
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
||||
Context::Scope scope(parsing_context);
|
||||
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
isolate,
|
||||
&source,
|
||||
compile_options);
|
||||
|
||||
@@ -730,10 +737,17 @@
|
||||
TRACING_CATEGORY_NODE2(vm, script),
|
||||
"ContextifyScript::New",
|
||||
contextify_script);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
||||
|
||||
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
args.This()->Set(
|
||||
env->cached_data_rejected_string(),
|
||||
@@ -751,10 +765,15 @@
|
||||
}
|
||||
args.This()->Set(
|
||||
env->cached_data_produced_string(),
|
||||
Boolean::New(isolate, cached_data_produced));
|
||||
}
|
||||
+
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
||||
TRACING_CATEGORY_NODE2(vm, script),
|
||||
"ContextifyScript::New",
|
||||
contextify_script);
|
||||
}
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -20,10 +20,12 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "node.h"
|
||||
#include <stdio.h>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include <WinError.h>
|
||||
|
||||
@@ -67,11 +69,11 @@
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
#ifdef __linux__
|
||||
#include <elf.h>
|
||||
@@ -119,8 +121,75 @@
|
||||
#endif
|
||||
// Disable stdio buffering, it interacts poorly with printf()
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ char execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ return node::Start(argc, argv);
|
||||
+}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ int i;
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+ int c = 0;
|
||||
+ nargv[c++] = argv[0];
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+ for (i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
--- node/src/node_options.cc
|
||||
+++ node/src/node_options.cc
|
||||
@@ -55,10 +55,11 @@
|
||||
// XXX: If you add an option here, please also add it to doc/node.1 and
|
||||
// doc/api/cli.md
|
||||
// TODO(addaleax): Make that unnecessary.
|
||||
|
||||
DebugOptionsParser::DebugOptionsParser() {
|
||||
+ return;
|
||||
#if HAVE_INSPECTOR
|
||||
AddOption("--inspect-port",
|
||||
"set host:port for inspector",
|
||||
&DebugOptions::host_port,
|
||||
kAllowedInEnvironment);
|
||||
+679
@@ -0,0 +1,679 @@
|
||||
--- node/common.gypi
|
||||
+++ node/common.gypi
|
||||
@@ -188,17 +188,28 @@
|
||||
'v8_enable_handle_zapping': 0,
|
||||
'pgo_generate': ' -fprofile-generate ',
|
||||
'pgo_use': ' -fprofile-use -fprofile-correction ',
|
||||
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ',
|
||||
'conditions': [
|
||||
['node_shared != "true"', {
|
||||
'MSVC_runtimeType': 0 # MultiThreaded (/MT)
|
||||
}, {
|
||||
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
|
||||
}],
|
||||
+ ['llvm_version=="0.0"', {
|
||||
+ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
|
||||
+ }, {
|
||||
+ 'lto': ' -flto ', # Clang
|
||||
+ }],
|
||||
],
|
||||
},
|
||||
'cflags': [ '-O3' ],
|
||||
'conditions': [
|
||||
+ ['enable_lto=="true"', {
|
||||
+ 'cflags': ['<(lto)'],
|
||||
+ 'ldflags': ['<(lto)'],
|
||||
+ 'xcode_settings': {
|
||||
+ 'LLVM_LTO': 'YES',
|
||||
+ },
|
||||
+ }],
|
||||
['OS=="solaris"', {
|
||||
# pull in V8's postmortem metadata
|
||||
'ldflags': [ '-Wl,-z,allextract' ]
|
||||
@@ -216,10 +227,6 @@
|
||||
'cflags': ['<(pgo_use)'],
|
||||
'ldflags': ['<(pgo_use)'],
|
||||
},],
|
||||
- ['enable_lto=="true"', {
|
||||
- 'cflags': ['<(lto)'],
|
||||
- 'ldflags': ['<(lto)'],
|
||||
- },],
|
||||
],
|
||||
},],
|
||||
['OS == "android"', {
|
||||
--- node/configure.py
|
||||
+++ node/configure.py
|
||||
@@ -154,7 +154,7 @@ parser.add_option("--enable-lto",
|
||||
action="store_true",
|
||||
dest="enable_lto",
|
||||
help="Enable compiling with lto of a binary. This feature is only available "
|
||||
- "on linux with gcc and g++ 5.4.1 or newer.")
|
||||
+ "with gcc 5.4.1+ or clang 3.9.1+.")
|
||||
|
||||
parser.add_option("--link-module",
|
||||
action="append",
|
||||
@@ -842,6 +842,7 @@ def get_gas_version(cc):
|
||||
# quite prepared to go that far yet.
|
||||
def check_compiler(o):
|
||||
if sys.platform == 'win32':
|
||||
+ o['variables']['llvm_version'] = '0.0'
|
||||
if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
|
||||
nasm_version = get_nasm_version('nasm')
|
||||
o['variables']['nasm_version'] = nasm_version
|
||||
@@ -1021,12 +1022,19 @@ def configure_mips(o, target_arch):
|
||||
host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big'
|
||||
o['variables']['v8_host_byteorder'] = host_byteorder
|
||||
|
||||
+def clang_version_ge(version_checked):
|
||||
+ for compiler in [(CC, 'c'), (CXX, 'c++')]:
|
||||
+ ok, is_clang, clang_version, gcc_version = \
|
||||
+ try_check_compiler(compiler[0], compiler[1])
|
||||
+ if is_clang and clang_version >= version_checked:
|
||||
+ return True
|
||||
+ return False
|
||||
|
||||
def gcc_version_ge(version_checked):
|
||||
for compiler in [(CC, 'c'), (CXX, 'c++')]:
|
||||
- ok, is_clang, clang_version, compiler_version = \
|
||||
+ ok, is_clang, clang_version, gcc_version = \
|
||||
try_check_compiler(compiler[0], compiler[1])
|
||||
- if is_clang or compiler_version < version_checked:
|
||||
+ if is_clang or gcc_version < version_checked:
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -1103,18 +1111,19 @@ def configure_node(o):
|
||||
o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate)
|
||||
o['variables']['enable_pgo_use'] = b(options.enable_pgo_use)
|
||||
|
||||
- if flavor != 'linux' and (options.enable_lto):
|
||||
+ if flavor == 'win' and (options.enable_lto):
|
||||
raise Exception(
|
||||
- 'The lto option is supported only on linux.')
|
||||
-
|
||||
- if flavor == 'linux':
|
||||
- if options.enable_lto:
|
||||
- version_checked = (5, 4, 1)
|
||||
- if not gcc_version_ge(version_checked):
|
||||
- version_checked_str = ".".join(map(str, version_checked))
|
||||
- raise Exception(
|
||||
- 'The option --enable-lto is supported for gcc and gxx %s'
|
||||
- ' or newer only.' % (version_checked_str))
|
||||
+ 'Use Link Time Code Generation instead.')
|
||||
+
|
||||
+ if options.enable_lto:
|
||||
+ gcc_version_checked = (5, 4, 1)
|
||||
+ clang_version_checked = (3, 9, 1)
|
||||
+ if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked):
|
||||
+ gcc_version_checked_str = ".".join(map(str, gcc_version_checked))
|
||||
+ clang_version_checked_str = ".".join(map(str, clang_version_checked))
|
||||
+ raise Exception(
|
||||
+ 'The option --enable-lto is supported for gcc %s+'
|
||||
+ 'or clang %s+ only.' % (gcc_version_checked_str, clang_version_checked_str))
|
||||
|
||||
o['variables']['enable_lto'] = b(options.enable_lto)
|
||||
|
||||
--- node/deps/v8/include/v8.h
|
||||
+++ node/deps/v8/include/v8.h
|
||||
@@ -9047,6 +9047,10 @@ class V8_EXPORT V8 {
|
||||
char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
--- node/deps/v8/src/api/api.cc
|
||||
+++ node/deps/v8/src/api/api.cc
|
||||
@@ -915,6 +915,34 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
||||
}
|
||||
|
||||
+
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto function_info =
|
||||
+ i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
||||
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
||||
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
||||
+}
|
||||
+
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
||||
|
||||
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
||||
--- node/deps/v8/src/codegen/compiler.cc
|
||||
+++ node/deps/v8/src/codegen/compiler.cc
|
||||
@@ -2010,7 +2010,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
|
||||
source, script_details.name_obj, script_details.line_offset,
|
||||
script_details.column_offset, origin_options, isolate->native_context(),
|
||||
language_mode);
|
||||
- if (!maybe_result.is_null()) {
|
||||
+ if (!maybe_result.is_null() && source_length) {
|
||||
compile_timer.set_hit_isolate_cache();
|
||||
} else if (can_consume_code_cache) {
|
||||
compile_timer.set_consuming_code_cache();
|
||||
--- node/deps/v8/src/objects/js-objects.cc
|
||||
+++ node/deps/v8/src/objects/js-objects.cc
|
||||
@@ -5480,6 +5480,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
||||
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_positions_symbol());
|
||||
if (maybe_class_positions->IsClassPositions()) {
|
||||
+ if (String::cast(Script::cast(shared_info->script()).source())->IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
ClassPositions class_positions =
|
||||
ClassPositions::cast(*maybe_class_positions);
|
||||
int start_position = class_positions.start();
|
||||
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
@@ -508,6 +508,14 @@ bool SharedFunctionInfo::ShouldFlushBytecode(BytecodeFlushMode mode) {
|
||||
Object data = function_data();
|
||||
if (!data.IsBytecodeArray()) return false;
|
||||
|
||||
+ Object script_obj = script();
|
||||
+ if (!script_obj.IsUndefined()) {
|
||||
+ Script script = Script::cast(script_obj);
|
||||
+ if (script.source().IsUndefined()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (mode == BytecodeFlushMode::kStressFlushBytecode) return true;
|
||||
|
||||
BytecodeArray bytecode = BytecodeArray::cast(data);
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -22,6 +22,7 @@ bool ParseProgram(ParseInfo* info, Isolate* isolate,
|
||||
ReportErrorsAndStatisticsMode mode) {
|
||||
DCHECK(info->is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (String::cast(info->script()->source())->IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
@@ -62,6 +63,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
DCHECK(!info->is_toplevel());
|
||||
DCHECK(!shared_info.is_null());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (String::cast(info->script()->source())->IsUndefined(isolate)) return false;
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<String> source(String::cast(info->script()->source()), isolate);
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -412,22 +412,35 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
||||
Isolate* isolate, uint32_t expected_source_hash) const {
|
||||
if (this->size_ < kHeaderSize) return INVALID_HEADER;
|
||||
uint32_t magic_number = GetMagicNumber();
|
||||
- if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
|
||||
+ if (magic_number != kMagicNumber) {
|
||||
+ // base::OS::PrintError("Pkg: MAGIC_NUMBER_MISMATCH\n"); // TODO enable after solving v8-cache/ncc issue
|
||||
+ return MAGIC_NUMBER_MISMATCH;
|
||||
+ }
|
||||
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t c1 = GetHeaderValue(kChecksumPartAOffset);
|
||||
uint32_t c2 = GetHeaderValue(kChecksumPartBOffset);
|
||||
- if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
||||
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
||||
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
||||
+ if (version_hash != Version::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
|
||||
+ return VERSION_MISMATCH;
|
||||
+ }
|
||||
+ if (flags_hash != FlagList::Hash()) {
|
||||
+ // base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
|
||||
+ return FLAGS_MISMATCH;
|
||||
+ }
|
||||
uint32_t max_payload_length =
|
||||
this->size_ -
|
||||
POINTER_SIZE_ALIGN(kHeaderSize +
|
||||
GetHeaderValue(kNumReservationsOffset) * kInt32Size);
|
||||
- if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
||||
- if (!Checksum(ChecksummedContent()).Check(c1, c2)) return CHECKSUM_MISMATCH;
|
||||
+ if (payload_length > max_payload_length) {
|
||||
+ base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
|
||||
+ return LENGTH_MISMATCH;
|
||||
+ }
|
||||
+ if (!Checksum(ChecksummedContent()).Check(c1, c2)) {
|
||||
+ base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
|
||||
+ return CHECKSUM_MISMATCH;
|
||||
+ }
|
||||
return CHECK_SUCCESS;
|
||||
}
|
||||
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -118,7 +118,7 @@ function fork(modulePath /* , args, options */) {
|
||||
options.execPath = options.execPath || process.execPath;
|
||||
options.shell = false;
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return module.exports.spawn(options.execPath, args, options);
|
||||
}
|
||||
|
||||
function _forkChild(fd, serializationMode) {
|
||||
index 0000000000..fb2d47f52b
|
||||
--- /dev/null
|
||||
+++ node/lib/internal/bootstrap/pkg.js
|
||||
@@ -0,0 +1,44 @@
|
||||
+'use strict';
|
||||
+
|
||||
+const {
|
||||
+ prepareMainThreadExecution
|
||||
+} = require('internal/bootstrap/pre_execution');
|
||||
+
|
||||
+prepareMainThreadExecution(true);
|
||||
+
|
||||
+(function () {
|
||||
+ var __require__ = require;
|
||||
+ var fs = __require__('fs');
|
||||
+ var vm = __require__('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, __require__,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+}());
|
||||
--- node/lib/internal/bootstrap/pre_execution.js
|
||||
+++ node/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -14,7 +14,12 @@ const { Buffer } = require('buffer');
|
||||
const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
|
||||
const assert = require('internal/assert');
|
||||
|
||||
+let _alreadyPrepared = false;
|
||||
+
|
||||
function prepareMainThreadExecution(expandArgv1 = false) {
|
||||
+ if (_alreadyPrepared === true) return;
|
||||
+ _alreadyPrepared = true;
|
||||
+
|
||||
// Patch the process object with legacy properties and normalizations
|
||||
patchProcessObject(expandArgv1);
|
||||
setupTraceCategoryState();
|
||||
@@ -89,7 +94,7 @@ function patchProcessObject(expandArgv1) {
|
||||
});
|
||||
process.argv[0] = process.execPath;
|
||||
|
||||
- if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-')) {
|
||||
+ if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-') && process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
||||
// Expand process.argv[1] into a full path.
|
||||
const path = require('path');
|
||||
try {
|
||||
--- node/lib/internal/modules/cjs/loader.js
|
||||
+++ node/lib/internal/modules/cjs/loader.js
|
||||
@@ -66,7 +66,7 @@ const fs = require('fs');
|
||||
const internalFS = require('internal/fs/utils');
|
||||
const path = require('path');
|
||||
const { sep } = path;
|
||||
-const { internalModuleStat } = internalBinding('fs');
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
const {
|
||||
--- node/lib/internal/modules/package_json_reader.js
|
||||
+++ node/lib/internal/modules/package_json_reader.js
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { SafeMap } = primordials;
|
||||
-const { internalModuleReadJSON } = internalBinding('fs');
|
||||
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
||||
const { pathToFileURL } = require('url');
|
||||
const { toNamespacedPath } = require('path');
|
||||
|
||||
--- node/lib/vm.js
|
||||
+++ node/lib/vm.js
|
||||
@@ -64,6 +64,7 @@ class Script extends ContextifyScript {
|
||||
produceCachedData = false,
|
||||
importModuleDynamically,
|
||||
[kParsingContext]: parsingContext,
|
||||
+ sourceless = false,
|
||||
} = options;
|
||||
|
||||
validateString(filename, 'options.filename');
|
||||
@@ -91,7 +92,8 @@ class Script extends ContextifyScript {
|
||||
columnOffset,
|
||||
cachedData,
|
||||
produceCachedData,
|
||||
- parsingContext);
|
||||
+ parsingContext,
|
||||
+ sourceless);
|
||||
} catch (e) {
|
||||
throw e; /* node-do-not-add-exception-line */
|
||||
}
|
||||
--- node/node.gyp
|
||||
+++ node/node.gyp
|
||||
@@ -30,6 +30,7 @@
|
||||
'lib/internal/bootstrap/environment.js',
|
||||
'lib/internal/bootstrap/loaders.js',
|
||||
'lib/internal/bootstrap/node.js',
|
||||
+ 'lib/internal/bootstrap/pkg.js',
|
||||
'lib/internal/bootstrap/pre_execution.js',
|
||||
'lib/internal/bootstrap/switches/does_own_process_state.js',
|
||||
'lib/internal/bootstrap/switches/does_not_own_process_state.js',
|
||||
@@ -430,6 +431,19 @@
|
||||
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
|
||||
},
|
||||
}],
|
||||
+ [ 'enable_lto=="true"', {
|
||||
+ 'xcode_settings': {
|
||||
+ 'OTHER_LDFLAGS': [
|
||||
+ # man ld -export_dynamic:
|
||||
+ # Preserves all global symbols in main executables during LTO.
|
||||
+ # Without this option, Link Time Optimization is allowed to
|
||||
+ # inline and remove global functions. This option is used when
|
||||
+ # a main executable may load a plug-in which requires certain
|
||||
+ # symbols from the main executable.
|
||||
+ '-Wl,-export_dynamic',
|
||||
+ ],
|
||||
+ },
|
||||
+ }],
|
||||
['OS=="win"', {
|
||||
'libraries': [
|
||||
'Dbghelp.lib',
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -760,8 +760,6 @@ bool Agent::Start(const std::string& path,
|
||||
StartIoThreadAsyncCallback));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
start_io_thread_async.data = this;
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
|
||||
parent_env_->AddCleanupHook([](void* data) {
|
||||
Environment* env = static_cast<Environment*>(data);
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -332,6 +332,9 @@ MaybeLocal<Value> Environment::BootstrapNode() {
|
||||
return scope.EscapeMaybe(result);
|
||||
}
|
||||
|
||||
+static
|
||||
+MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id);
|
||||
+
|
||||
MaybeLocal<Value> Environment::RunBootstrapping() {
|
||||
EscapableHandleScope scope(isolate_);
|
||||
|
||||
@@ -355,6 +358,8 @@ MaybeLocal<Value> Environment::RunBootstrapping() {
|
||||
|
||||
set_has_run_bootstrapping_code(true);
|
||||
|
||||
+ USE(StartExecution(this, "internal/bootstrap/pkg"));
|
||||
+
|
||||
return scope.Escape(result);
|
||||
}
|
||||
|
||||
@@ -515,13 +520,6 @@ static struct {
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (auto& s : stdio) {
|
||||
const int fd = &s - stdio;
|
||||
@@ -537,10 +535,6 @@ inline void PlatformInit() {
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -69,6 +69,7 @@ using v8::ScriptOrModule;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
using v8::WeakCallbackType;
|
||||
@@ -660,11 +661,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
Local<ArrayBufferView> cached_data_buf;
|
||||
bool produce_cached_data = false;
|
||||
Local<Context> parsing_context = context;
|
||||
+ bool sourceless = false;
|
||||
|
||||
if (argc > 2) {
|
||||
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
- CHECK_EQ(argc, 7);
|
||||
+ CHECK_EQ(argc, 8);
|
||||
CHECK(args[2]->IsNumber());
|
||||
line_offset = args[2].As<Integer>();
|
||||
CHECK(args[3]->IsNumber());
|
||||
@@ -683,6 +685,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK_NOT_NULL(sandbox);
|
||||
parsing_context = sandbox->context();
|
||||
}
|
||||
+ sourceless = args[7]->IsTrue();
|
||||
} else {
|
||||
line_offset = Integer::New(isolate, 0);
|
||||
column_offset = Integer::New(isolate, 0);
|
||||
@@ -737,6 +740,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
||||
Context::Scope scope(parsing_context);
|
||||
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
isolate,
|
||||
&source,
|
||||
@@ -753,6 +760,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
contextify_script);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
||||
|
||||
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
@@ -778,6 +792,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
env->cached_data_produced_string(),
|
||||
Boolean::New(isolate, cached_data_produced)).Check();
|
||||
}
|
||||
+
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
||||
TRACING_CATEGORY_NODE2(vm, script),
|
||||
"ContextifyScript::New",
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "node.h"
|
||||
#include <cstdio>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
@@ -69,7 +71,7 @@ int wmain(int argc, wchar_t* wargv[]) {
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
@@ -123,6 +125,88 @@ int main(int argc, char* argv[]) {
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
+ return reorder(argc, argv);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ char execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
return node::Start(argc, argv);
|
||||
}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+#ifdef __clang__
|
||||
+__attribute__((optnone))
|
||||
+#elif defined(__GNUC__)
|
||||
+__attribute__((optimize(0)))
|
||||
#endif
|
||||
+int load_baked(char** nargv) {
|
||||
+ int c = 1;
|
||||
+
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+
|
||||
+ nargv[0] = argv[0];
|
||||
+ int c = load_baked(nargv);
|
||||
+
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
--- node/src/node_options.cc
|
||||
+++ node/src/node_options.cc
|
||||
@@ -234,6 +234,7 @@ void Parse(
|
||||
// TODO(addaleax): Make that unnecessary.
|
||||
|
||||
DebugOptionsParser::DebugOptionsParser() {
|
||||
+ return;
|
||||
AddOption("--inspect-port",
|
||||
"set host:port for inspector",
|
||||
&DebugOptions::host_port,
|
||||
--- node/tools/icu/icu-generic.gyp
|
||||
+++ node/tools/icu/icu-generic.gyp
|
||||
@@ -52,7 +52,7 @@
|
||||
'conditions': [
|
||||
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
||||
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
||||
- 'cflags_cc': [ '-frtti' ],
|
||||
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
||||
'cflags_cc!': [ '-fno-rtti' ],
|
||||
}],
|
||||
[ 'OS == "mac" or OS == "ios"', {
|
||||
+560
@@ -0,0 +1,560 @@
|
||||
--- node/common.gypi
|
||||
+++ node/common.gypi
|
||||
@@ -171,7 +171,7 @@
|
||||
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
|
||||
}],
|
||||
['llvm_version=="0.0"', {
|
||||
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
|
||||
+ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
|
||||
}, {
|
||||
'lto': ' -flto ', # Clang
|
||||
}],
|
||||
--- node/deps/v8/include/v8.h
|
||||
+++ node/deps/v8/include/v8.h
|
||||
@@ -9633,6 +9633,10 @@ class V8_EXPORT V8 {
|
||||
char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
--- node/deps/v8/src/api/api.cc
|
||||
+++ node/deps/v8/src/api/api.cc
|
||||
@@ -840,6 +840,34 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
||||
}
|
||||
|
||||
+
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto function_info =
|
||||
+ i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
||||
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
||||
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
||||
+}
|
||||
+
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
||||
|
||||
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
||||
--- node/deps/v8/src/codegen/compiler.cc
|
||||
+++ node/deps/v8/src/codegen/compiler.cc
|
||||
@@ -2365,7 +2365,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
|
||||
source, script_details.name_obj, script_details.line_offset,
|
||||
script_details.column_offset, origin_options, isolate->native_context(),
|
||||
language_mode);
|
||||
- if (!maybe_result.is_null()) {
|
||||
+ if (!maybe_result.is_null() && source_length) {
|
||||
compile_timer.set_hit_isolate_cache();
|
||||
} else if (can_consume_code_cache) {
|
||||
compile_timer.set_consuming_code_cache();
|
||||
--- node/deps/v8/src/objects/js-objects.cc
|
||||
+++ node/deps/v8/src/objects/js-objects.cc
|
||||
@@ -5514,6 +5514,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
||||
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_positions_symbol());
|
||||
if (maybe_class_positions->IsClassPositions()) {
|
||||
+ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
ClassPositions class_positions =
|
||||
ClassPositions::cast(*maybe_class_positions);
|
||||
int start_position = class_positions.start();
|
||||
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
@@ -505,6 +505,14 @@ bool SharedFunctionInfo::ShouldFlushBytecode(BytecodeFlushMode mode) {
|
||||
Object data = function_data();
|
||||
if (!data.IsBytecodeArray()) return false;
|
||||
|
||||
+ Object script_obj = script();
|
||||
+ if (!script_obj.IsUndefined()) {
|
||||
+ Script script = Script::cast(script_obj);
|
||||
+ if (script.source().IsUndefined()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (mode == BytecodeFlushMode::kStressFlushBytecode) return true;
|
||||
|
||||
BytecodeArray bytecode = BytecodeArray::cast(data);
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
|
||||
Isolate* isolate, ReportErrorsAndStatisticsMode mode) {
|
||||
DCHECK(info->flags().is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
@@ -76,6 +77,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<Script> script(Script::cast(shared_info->script()), isolate);
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
Handle<String> source(String::cast(script->source()), isolate);
|
||||
isolate->counters()->total_parse_size()->Increment(source->length());
|
||||
std::unique_ptr<Utf16CharacterStream> stream(
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -409,19 +409,29 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
||||
uint32_t magic_number = GetMagicNumber();
|
||||
if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
|
||||
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t c = GetHeaderValue(kChecksumOffset);
|
||||
- if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
||||
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
||||
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
||||
+ if (version_hash != Version::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
|
||||
+ return VERSION_MISMATCH;
|
||||
+ }
|
||||
+ if (flags_hash != FlagList::Hash()) {
|
||||
+ // base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
|
||||
+ return FLAGS_MISMATCH;
|
||||
+ }
|
||||
uint32_t max_payload_length =
|
||||
this->size_ -
|
||||
POINTER_SIZE_ALIGN(kHeaderSize +
|
||||
GetHeaderValue(kNumReservationsOffset) * kInt32Size);
|
||||
- if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
||||
- if (Checksum(ChecksummedContent()) != c) return CHECKSUM_MISMATCH;
|
||||
+ if (payload_length > max_payload_length) {
|
||||
+ base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
|
||||
+ return LENGTH_MISMATCH;
|
||||
+ }
|
||||
+ if (Checksum(ChecksummedContent()) != c) {
|
||||
+ base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
|
||||
+ return CHECKSUM_MISMATCH;
|
||||
+ }
|
||||
return CHECK_SUCCESS;
|
||||
}
|
||||
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -150,7 +150,7 @@ function fork(modulePath /* , args, options */) {
|
||||
options.execPath = options.execPath || process.execPath;
|
||||
options.shell = false;
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return module.exports.spawn(options.execPath, args, options);
|
||||
}
|
||||
|
||||
function _forkChild(fd, serializationMode) {
|
||||
index 0000000000..fb2d47f52b
|
||||
--- /dev/null
|
||||
+++ node/lib/internal/bootstrap/pkg.js
|
||||
@@ -0,0 +1,44 @@
|
||||
+'use strict';
|
||||
+
|
||||
+const {
|
||||
+ prepareMainThreadExecution
|
||||
+} = require('internal/bootstrap/pre_execution');
|
||||
+
|
||||
+prepareMainThreadExecution(true);
|
||||
+
|
||||
+(function () {
|
||||
+ var __require__ = require;
|
||||
+ var fs = __require__('fs');
|
||||
+ var vm = __require__('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, __require__,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+}());
|
||||
--- node/lib/internal/bootstrap/pre_execution.js
|
||||
+++ node/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -18,7 +18,12 @@ const { Buffer } = require('buffer');
|
||||
const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
|
||||
const assert = require('internal/assert');
|
||||
|
||||
+let _alreadyPrepared = false;
|
||||
+
|
||||
function prepareMainThreadExecution(expandArgv1 = false) {
|
||||
+ if (_alreadyPrepared === true) return;
|
||||
+ _alreadyPrepared = true;
|
||||
+
|
||||
// Patch the process object with legacy properties and normalizations
|
||||
patchProcessObject(expandArgv1);
|
||||
setupTraceCategoryState();
|
||||
@@ -88,7 +93,7 @@ function patchProcessObject(expandArgv1) {
|
||||
process.argv[0] = process.execPath;
|
||||
|
||||
if (expandArgv1 && process.argv[1] &&
|
||||
- !StringPrototypeStartsWith(process.argv[1], '-')) {
|
||||
+ !StringPrototypeStartsWith(process.argv[1], '-') && process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
||||
// Expand process.argv[1] into a full path.
|
||||
const path = require('path');
|
||||
try {
|
||||
--- node/lib/internal/modules/cjs/loader.js
|
||||
+++ node/lib/internal/modules/cjs/loader.js
|
||||
@@ -83,7 +83,7 @@ const fs = require('fs');
|
||||
const internalFS = require('internal/fs/utils');
|
||||
const path = require('path');
|
||||
const { sep } = path;
|
||||
-const { internalModuleStat } = internalBinding('fs');
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
const {
|
||||
--- node/lib/internal/modules/package_json_reader.js
|
||||
+++ node/lib/internal/modules/package_json_reader.js
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { SafeMap } = primordials;
|
||||
-const { internalModuleReadJSON } = internalBinding('fs');
|
||||
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
||||
const { pathToFileURL } = require('url');
|
||||
const { toNamespacedPath } = require('path');
|
||||
|
||||
--- node/lib/vm.js
|
||||
+++ node/lib/vm.js
|
||||
@@ -78,6 +78,7 @@ class Script extends ContextifyScript {
|
||||
produceCachedData = false,
|
||||
importModuleDynamically,
|
||||
[kParsingContext]: parsingContext,
|
||||
+ sourceless = false,
|
||||
} = options;
|
||||
|
||||
validateString(filename, 'options.filename');
|
||||
@@ -105,7 +106,8 @@ class Script extends ContextifyScript {
|
||||
columnOffset,
|
||||
cachedData,
|
||||
produceCachedData,
|
||||
- parsingContext);
|
||||
+ parsingContext,
|
||||
+ sourceless);
|
||||
} catch (e) {
|
||||
throw e; /* node-do-not-add-exception-line */
|
||||
}
|
||||
--- node/node.gyp
|
||||
+++ node/node.gyp
|
||||
@@ -236,6 +236,19 @@
|
||||
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
|
||||
},
|
||||
}],
|
||||
+ [ 'enable_lto=="true"', {
|
||||
+ 'xcode_settings': {
|
||||
+ 'OTHER_LDFLAGS': [
|
||||
+ # man ld -export_dynamic:
|
||||
+ # Preserves all global symbols in main executables during LTO.
|
||||
+ # Without this option, Link Time Optimization is allowed to
|
||||
+ # inline and remove global functions. This option is used when
|
||||
+ # a main executable may load a plug-in which requires certain
|
||||
+ # symbols from the main executable.
|
||||
+ '-Wl,-export_dynamic',
|
||||
+ ],
|
||||
+ },
|
||||
+ }],
|
||||
['OS=="win"', {
|
||||
'libraries': [
|
||||
'Dbghelp.lib',
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -683,8 +683,6 @@ bool Agent::Start(const std::string& path,
|
||||
StartIoThreadAsyncCallback));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
start_io_thread_async.data = this;
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
|
||||
parent_env_->AddCleanupHook([](void* data) {
|
||||
Environment* env = static_cast<Environment*>(data);
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -386,6 +386,9 @@ MaybeLocal<Value> Environment::BootstrapNode() {
|
||||
return scope.EscapeMaybe(result);
|
||||
}
|
||||
|
||||
+static
|
||||
+MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id);
|
||||
+
|
||||
MaybeLocal<Value> Environment::RunBootstrapping() {
|
||||
EscapableHandleScope scope(isolate_);
|
||||
|
||||
@@ -409,6 +412,8 @@ MaybeLocal<Value> Environment::RunBootstrapping() {
|
||||
|
||||
set_has_run_bootstrapping_code(true);
|
||||
|
||||
+ USE(StartExecution(this, "internal/bootstrap/pkg"));
|
||||
+
|
||||
return scope.Escape(result);
|
||||
}
|
||||
|
||||
@@ -573,13 +578,6 @@ static struct {
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (auto& s : stdio) {
|
||||
const int fd = &s - stdio;
|
||||
@@ -595,10 +593,6 @@ inline void PlatformInit() {
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -74,6 +74,7 @@ using v8::ScriptOrModule;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
using v8::WeakCallbackType;
|
||||
@@ -691,11 +692,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
Local<ArrayBufferView> cached_data_buf;
|
||||
bool produce_cached_data = false;
|
||||
Local<Context> parsing_context = context;
|
||||
+ bool sourceless = false;
|
||||
|
||||
if (argc > 2) {
|
||||
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
- CHECK_EQ(argc, 7);
|
||||
+ CHECK_EQ(argc, 8);
|
||||
CHECK(args[2]->IsNumber());
|
||||
line_offset = args[2].As<Integer>();
|
||||
CHECK(args[3]->IsNumber());
|
||||
@@ -714,6 +716,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK_NOT_NULL(sandbox);
|
||||
parsing_context = sandbox->context();
|
||||
}
|
||||
+ sourceless = args[7]->IsTrue();
|
||||
} else {
|
||||
line_offset = Integer::New(isolate, 0);
|
||||
column_offset = Integer::New(isolate, 0);
|
||||
@@ -768,6 +771,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
||||
Context::Scope scope(parsing_context);
|
||||
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
isolate,
|
||||
&source,
|
||||
@@ -784,6 +791,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
contextify_script);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
||||
|
||||
Local<Context> env_context = env->context();
|
||||
@@ -810,6 +824,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
env->cached_data_produced_string(),
|
||||
Boolean::New(isolate, cached_data_produced)).Check();
|
||||
}
|
||||
+
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
||||
TRACING_CATEGORY_NODE2(vm, script),
|
||||
"ContextifyScript::New",
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "node.h"
|
||||
#include <cstdio>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
@@ -84,7 +86,7 @@ int wmain(int argc, wchar_t* wargv[]) {
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
@@ -138,6 +140,88 @@ int main(int argc, char* argv[]) {
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
+ return reorder(argc, argv);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ char execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
return node::Start(argc, argv);
|
||||
}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+#ifdef __clang__
|
||||
+__attribute__((optnone))
|
||||
+#elif defined(__GNUC__)
|
||||
+__attribute__((optimize(0)))
|
||||
#endif
|
||||
+int load_baked(char** nargv) {
|
||||
+ int c = 1;
|
||||
+
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+
|
||||
+ nargv[0] = argv[0];
|
||||
+ int c = load_baked(nargv);
|
||||
+
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
--- node/src/node_options.cc
|
||||
+++ node/src/node_options.cc
|
||||
@@ -236,6 +236,7 @@ void Parse(
|
||||
// TODO(addaleax): Make that unnecessary.
|
||||
|
||||
DebugOptionsParser::DebugOptionsParser() {
|
||||
+ return;
|
||||
AddOption("--inspect-port",
|
||||
"set host:port for inspector",
|
||||
&DebugOptions::host_port,
|
||||
--- node/tools/icu/icu-generic.gyp
|
||||
+++ node/tools/icu/icu-generic.gyp
|
||||
@@ -52,7 +52,7 @@
|
||||
'conditions': [
|
||||
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
||||
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
||||
- 'cflags_cc': [ '-frtti' ],
|
||||
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
||||
'cflags_cc!': [ '-fno-rtti' ],
|
||||
}],
|
||||
[ 'OS == "mac" or OS == "ios"', {
|
||||
+502
@@ -0,0 +1,502 @@
|
||||
--- node/common.gypi
|
||||
+++ node/common.gypi
|
||||
@@ -183,7 +183,7 @@
|
||||
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
|
||||
}],
|
||||
['llvm_version=="0.0"', {
|
||||
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
|
||||
+ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
|
||||
}, {
|
||||
'lto': ' -flto ', # Clang
|
||||
}],
|
||||
--- node/deps/v8/include/v8.h
|
||||
+++ node/deps/v8/include/v8.h
|
||||
@@ -10092,6 +10092,10 @@ class V8_EXPORT V8 {
|
||||
char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
--- node/deps/v8/src/api/api.cc
|
||||
+++ node/deps/v8/src/api/api.cc
|
||||
@@ -647,6 +647,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
HelpOptions(HelpOptions::kDontExit));
|
||||
}
|
||||
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+}
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+}
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto function_info =
|
||||
+ i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
||||
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
||||
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
||||
+}
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
||||
|
||||
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
||||
--- node/deps/v8/src/codegen/compiler.cc
|
||||
+++ node/deps/v8/src/codegen/compiler.cc
|
||||
@@ -2840,7 +2840,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
|
||||
// First check per-isolate compilation cache.
|
||||
maybe_result =
|
||||
compilation_cache->LookupScript(source, script_details, language_mode);
|
||||
- if (!maybe_result.is_null()) {
|
||||
+ if (!maybe_result.is_null() && source_length) {
|
||||
compile_timer.set_hit_isolate_cache();
|
||||
} else if (can_consume_code_cache) {
|
||||
compile_timer.set_consuming_code_cache();
|
||||
--- node/deps/v8/src/objects/js-function.cc
|
||||
+++ node/deps/v8/src/objects/js-function.cc
|
||||
@@ -953,6 +953,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
||||
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_positions_symbol());
|
||||
if (maybe_class_positions->IsClassPositions()) {
|
||||
+ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
ClassPositions class_positions =
|
||||
ClassPositions::cast(*maybe_class_positions);
|
||||
int start_position = class_positions.start();
|
||||
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
@@ -631,6 +631,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
|
||||
}
|
||||
if (!data.IsBytecodeArray()) return false;
|
||||
|
||||
+ Object script_obj = script();
|
||||
+ if (!script_obj.IsUndefined()) {
|
||||
+ Script script = Script::cast(script_obj);
|
||||
+ if (script.source().IsUndefined()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (IsStressFlushingEnabled(code_flush_mode)) return true;
|
||||
|
||||
BytecodeArray bytecode = BytecodeArray::cast(data);
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
|
||||
Isolate* isolate, ReportStatisticsMode mode) {
|
||||
DCHECK(info->flags().is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
@@ -76,6 +77,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<Script> script(Script::cast(shared_info->script()), isolate);
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
Handle<String> source(String::cast(script->source()), isolate);
|
||||
isolate->counters()->total_parse_size()->Increment(source->length());
|
||||
std::unique_ptr<Utf16CharacterStream> stream(
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -471,13 +471,9 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
||||
uint32_t magic_number = GetMagicNumber();
|
||||
if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
|
||||
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
- uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t c = GetHeaderValue(kChecksumOffset);
|
||||
if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
||||
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
||||
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
||||
uint32_t max_payload_length = this->size_ - kHeaderSize;
|
||||
if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
||||
if (Checksum(ChecksummedContent()) != c) return CHECKSUM_MISMATCH;
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -163,7 +163,7 @@ function fork(modulePath, args = [], options) {
|
||||
options.execPath = options.execPath || process.execPath;
|
||||
options.shell = false;
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return module.exports.spawn(options.execPath, args, options);
|
||||
}
|
||||
|
||||
function _forkChild(fd, serializationMode) {
|
||||
index 0000000000..fb2d47f52b
|
||||
--- /dev/null
|
||||
+++ node/lib/internal/bootstrap/pkg.js
|
||||
@@ -0,0 +1,44 @@
|
||||
+'use strict';
|
||||
+
|
||||
+const {
|
||||
+ prepareMainThreadExecution
|
||||
+} = require('internal/bootstrap/pre_execution');
|
||||
+
|
||||
+prepareMainThreadExecution(true);
|
||||
+
|
||||
+(function () {
|
||||
+ var __require__ = require;
|
||||
+ var fs = __require__('fs');
|
||||
+ var vm = __require__('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, __require__,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+}());
|
||||
--- node/lib/internal/bootstrap/pre_execution.js
|
||||
+++ node/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -25,7 +25,12 @@ const { Buffer } = require('buffer');
|
||||
const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
|
||||
const assert = require('internal/assert');
|
||||
|
||||
+let _alreadyPrepared = false;
|
||||
+
|
||||
function prepareMainThreadExecution(expandArgv1 = false) {
|
||||
+ if (_alreadyPrepared === true) return;
|
||||
+ _alreadyPrepared = true;
|
||||
+
|
||||
// TODO(joyeecheung): this is also necessary for workers when they deserialize
|
||||
// this toggle from the snapshot.
|
||||
reconnectZeroFillToggle();
|
||||
@@ -100,7 +105,8 @@ function patchProcessObject(expandArgv1) {
|
||||
process.argv[0] = process.execPath;
|
||||
|
||||
if (expandArgv1 && process.argv[1] &&
|
||||
- !StringPrototypeStartsWith(process.argv[1], '-')) {
|
||||
+ !StringPrototypeStartsWith(process.argv[1], '-') &&
|
||||
+ process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
||||
// Expand process.argv[1] into a full path.
|
||||
const path = require('path');
|
||||
try {
|
||||
--- node/lib/internal/modules/cjs/loader.js
|
||||
+++ node/lib/internal/modules/cjs/loader.js
|
||||
@@ -86,7 +86,7 @@ const fs = require('fs');
|
||||
const internalFS = require('internal/fs/utils');
|
||||
const path = require('path');
|
||||
const { sep } = path;
|
||||
-const { internalModuleStat } = internalBinding('fs');
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
const {
|
||||
--- node/lib/internal/modules/package_json_reader.js
|
||||
+++ node/lib/internal/modules/package_json_reader.js
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { SafeMap } = primordials;
|
||||
-const { internalModuleReadJSON } = internalBinding('fs');
|
||||
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
||||
const { pathToFileURL } = require('url');
|
||||
const { toNamespacedPath } = require('path');
|
||||
|
||||
--- node/lib/vm.js
|
||||
+++ node/lib/vm.js
|
||||
@@ -79,6 +79,7 @@ class Script extends ContextifyScript {
|
||||
produceCachedData = false,
|
||||
importModuleDynamically,
|
||||
[kParsingContext]: parsingContext,
|
||||
+ sourceless = false,
|
||||
} = options;
|
||||
|
||||
validateString(filename, 'options.filename');
|
||||
@@ -103,7 +104,8 @@ class Script extends ContextifyScript {
|
||||
columnOffset,
|
||||
cachedData,
|
||||
produceCachedData,
|
||||
- parsingContext);
|
||||
+ parsingContext,
|
||||
+ sourceless);
|
||||
} catch (e) {
|
||||
throw e; /* node-do-not-add-exception-line */
|
||||
}
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -690,8 +690,6 @@ bool Agent::Start(const std::string& path,
|
||||
StartIoThreadAsyncCallback));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
start_io_thread_async.data = this;
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
|
||||
parent_env_->AddCleanupHook([](void* data) {
|
||||
Environment* env = static_cast<Environment*>(data);
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -473,6 +473,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
|
||||
return scope.EscapeMaybe(cb(info));
|
||||
}
|
||||
|
||||
+ StartExecution(env, "internal/bootstrap/pkg");
|
||||
+
|
||||
if (env->worker_context() != nullptr) {
|
||||
return StartExecution(env, "internal/main/worker_thread");
|
||||
}
|
||||
@@ -583,13 +585,6 @@ static struct {
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (auto& s : stdio) {
|
||||
const int fd = &s - stdio;
|
||||
@@ -605,10 +600,6 @@ inline void PlatformInit() {
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -74,6 +74,7 @@ using v8::ScriptOrModule;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
using v8::WeakCallbackType;
|
||||
@@ -709,11 +710,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
Local<ArrayBufferView> cached_data_buf;
|
||||
bool produce_cached_data = false;
|
||||
Local<Context> parsing_context = context;
|
||||
+ bool sourceless = false;
|
||||
|
||||
if (argc > 2) {
|
||||
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
- CHECK_EQ(argc, 7);
|
||||
+ CHECK_EQ(argc, 8);
|
||||
CHECK(args[2]->IsNumber());
|
||||
line_offset = args[2].As<Int32>()->Value();
|
||||
CHECK(args[3]->IsNumber());
|
||||
@@ -732,6 +734,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK_NOT_NULL(sandbox);
|
||||
parsing_context = sandbox->context();
|
||||
}
|
||||
+ sourceless = args[7]->IsTrue();
|
||||
}
|
||||
|
||||
ContextifyScript* contextify_script =
|
||||
@@ -784,6 +787,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
||||
Context::Scope scope(parsing_context);
|
||||
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
isolate,
|
||||
&source,
|
||||
@@ -800,6 +807,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
contextify_script);
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
||||
|
||||
Local<Context> env_context = env->context();
|
||||
@@ -826,6 +840,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
env->cached_data_produced_string(),
|
||||
Boolean::New(isolate, cached_data_produced)).Check();
|
||||
}
|
||||
+
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
||||
TRACING_CATEGORY_NODE2(vm, script),
|
||||
"ContextifyScript::New",
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "node.h"
|
||||
#include <cstdio>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
@@ -84,7 +86,7 @@ int wmain(int argc, wchar_t* wargv[]) {
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
@@ -124,6 +126,88 @@ int main(int argc, char* argv[]) {
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
+ return reorder(argc, argv);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ char execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
return node::Start(argc, argv);
|
||||
}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+#ifdef __clang__
|
||||
+__attribute__((optnone))
|
||||
+#elif defined(__GNUC__)
|
||||
+__attribute__((optimize(0)))
|
||||
#endif
|
||||
+int load_baked(char** nargv) {
|
||||
+ int c = 1;
|
||||
+
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+
|
||||
+ nargv[0] = argv[0];
|
||||
+ int c = load_baked(nargv);
|
||||
+
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
--- node/src/node_options.cc
|
||||
+++ node/src/node_options.cc
|
||||
@@ -254,6 +254,7 @@ void Parse(
|
||||
// TODO(addaleax): Make that unnecessary.
|
||||
|
||||
DebugOptionsParser::DebugOptionsParser() {
|
||||
+ return;
|
||||
AddOption("--inspect-port",
|
||||
"set host:port for inspector",
|
||||
&DebugOptions::host_port,
|
||||
--- node/tools/icu/icu-generic.gyp
|
||||
+++ node/tools/icu/icu-generic.gyp
|
||||
@@ -52,7 +52,7 @@
|
||||
'conditions': [
|
||||
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
||||
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
||||
- 'cflags_cc': [ '-frtti' ],
|
||||
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
||||
'cflags_cc!': [ '-fno-rtti' ],
|
||||
}],
|
||||
[ 'OS == "mac" or OS == "ios"', {
|
||||
+521
@@ -0,0 +1,521 @@
|
||||
--- node/common.gypi
|
||||
+++ node/common.gypi
|
||||
@@ -174,7 +174,7 @@
|
||||
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
|
||||
}],
|
||||
['llvm_version=="0.0"', {
|
||||
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
|
||||
+ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
|
||||
}, {
|
||||
'lto': ' -flto ', # Clang
|
||||
}],
|
||||
--- node/deps/v8/include/v8-initialization.h
|
||||
+++ node/deps/v8/include/v8-initialization.h
|
||||
@@ -89,6 +89,10 @@ class V8_EXPORT V8 {
|
||||
static void SetFlagsFromCommandLine(int* argc, char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
--- node/deps/v8/src/api/api.cc
|
||||
+++ node/deps/v8/src/api/api.cc
|
||||
@@ -706,6 +706,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
HelpOptions(HelpOptions::kDontExit));
|
||||
}
|
||||
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+}
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+}
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto function_info =
|
||||
+ i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
||||
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
||||
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
||||
+}
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
||||
|
||||
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
||||
--- node/deps/v8/src/codegen/compiler.cc
|
||||
+++ node/deps/v8/src/codegen/compiler.cc
|
||||
@@ -3026,7 +3026,7 @@ MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
|
||||
// First check per-isolate compilation cache.
|
||||
maybe_result =
|
||||
compilation_cache->LookupScript(source, script_details, language_mode);
|
||||
- if (!maybe_result.is_null()) {
|
||||
+ if (!maybe_result.is_null() && source_length) {
|
||||
compile_timer.set_hit_isolate_cache();
|
||||
} else if (can_consume_code_cache) {
|
||||
compile_timer.set_consuming_code_cache();
|
||||
--- node/deps/v8/src/objects/js-function.cc
|
||||
+++ node/deps/v8/src/objects/js-function.cc
|
||||
@@ -1207,6 +1207,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
||||
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
||||
isolate, function, isolate->factory()->class_positions_symbol());
|
||||
if (maybe_class_positions->IsClassPositions()) {
|
||||
+ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
ClassPositions class_positions =
|
||||
ClassPositions::cast(*maybe_class_positions);
|
||||
int start_position = class_positions.start();
|
||||
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
||||
@@ -636,6 +636,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
|
||||
}
|
||||
if (!data.IsBytecodeArray()) return false;
|
||||
|
||||
+ Object script_obj = script();
|
||||
+ if (!script_obj.IsUndefined()) {
|
||||
+ Script script = Script::cast(script_obj);
|
||||
+ if (script.source().IsUndefined()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (IsStressFlushingEnabled(code_flush_mode)) return true;
|
||||
|
||||
BytecodeArray bytecode = BytecodeArray::cast(data);
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
|
||||
Isolate* isolate, ReportStatisticsMode mode) {
|
||||
DCHECK(info->flags().is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
@@ -76,6 +77,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<Script> script(Script::cast(shared_info->script()), isolate);
|
||||
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
||||
Handle<String> source(String::cast(script->source()), isolate);
|
||||
isolate->counters()->total_parse_size()->Increment(source->length());
|
||||
std::unique_ptr<Utf16CharacterStream> stream(
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -615,11 +615,7 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
|
||||
}
|
||||
|
||||
SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
|
||||
- uint32_t expected_source_hash) const {
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
- if (source_hash != expected_source_hash) {
|
||||
- return SerializedCodeSanityCheckResult::kSourceMismatch;
|
||||
- }
|
||||
+ uint32_t) const {
|
||||
return SerializedCodeSanityCheckResult::kSuccess;
|
||||
}
|
||||
|
||||
@@ -636,10 +632,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource()
|
||||
if (version_hash != Version::Hash()) {
|
||||
return SerializedCodeSanityCheckResult::kVersionMismatch;
|
||||
}
|
||||
- uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
- if (flags_hash != FlagList::Hash()) {
|
||||
- return SerializedCodeSanityCheckResult::kFlagsMismatch;
|
||||
- }
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t max_payload_length = this->size_ - kHeaderSize;
|
||||
if (payload_length > max_payload_length) {
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -160,7 +160,7 @@ function fork(modulePath, args = [], options) {
|
||||
throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
|
||||
}
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return module.exports.spawn(options.execPath, args, options);
|
||||
}
|
||||
|
||||
function _forkChild(fd, serializationMode) {
|
||||
index 00000000000..fb2d47f52b6
|
||||
--- /dev/null
|
||||
+++ node/lib/internal/bootstrap/pkg.js
|
||||
@@ -0,0 +1,44 @@
|
||||
+'use strict';
|
||||
+
|
||||
+const {
|
||||
+ prepareMainThreadExecution
|
||||
+} = require('internal/bootstrap/pre_execution');
|
||||
+
|
||||
+prepareMainThreadExecution(true);
|
||||
+
|
||||
+(function () {
|
||||
+ var __require__ = require;
|
||||
+ var fs = __require__('fs');
|
||||
+ var vm = __require__('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, __require__,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+}());
|
||||
--- node/lib/internal/bootstrap/pre_execution.js
|
||||
+++ node/lib/internal/bootstrap/pre_execution.js
|
||||
@@ -29,8 +29,13 @@ const {
|
||||
} = require('internal/errors').codes;
|
||||
const assert = require('internal/assert');
|
||||
|
||||
+let _alreadyPrepared = false;
|
||||
+
|
||||
function prepareMainThreadExecution(expandArgv1 = false,
|
||||
initialzeModules = true) {
|
||||
+ if (_alreadyPrepared === true) return;
|
||||
+ _alreadyPrepared = true;
|
||||
+
|
||||
refreshRuntimeOptions();
|
||||
|
||||
// TODO(joyeecheung): this is also necessary for workers when they deserialize
|
||||
@@ -119,7 +124,8 @@ function patchProcessObject(expandArgv1) {
|
||||
process.argv[0] = process.execPath;
|
||||
|
||||
if (expandArgv1 && process.argv[1] &&
|
||||
- !StringPrototypeStartsWith(process.argv[1], '-')) {
|
||||
+ !StringPrototypeStartsWith(process.argv[1], '-') &&
|
||||
+ process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
||||
// Expand process.argv[1] into a full path.
|
||||
const path = require('path');
|
||||
try {
|
||||
@@ -574,6 +580,7 @@ function loadPreloadModules() {
|
||||
// For user code, we preload modules if `-r` is passed
|
||||
const preloadModules = getOptionValue('--require');
|
||||
if (preloadModules && preloadModules.length > 0) {
|
||||
+ assert(false, '--require is not supported');
|
||||
const {
|
||||
Module: {
|
||||
_preloadModules
|
||||
--- node/lib/internal/modules/cjs/loader.js
|
||||
+++ node/lib/internal/modules/cjs/loader.js
|
||||
@@ -86,7 +86,7 @@ const fs = require('fs');
|
||||
const internalFS = require('internal/fs/utils');
|
||||
const path = require('path');
|
||||
const { sep } = path;
|
||||
-const { internalModuleStat } = internalBinding('fs');
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const packageJsonReader = require('internal/modules/package_json_reader');
|
||||
const { safeGetenv } = internalBinding('credentials');
|
||||
const {
|
||||
--- node/lib/internal/modules/package_json_reader.js
|
||||
+++ node/lib/internal/modules/package_json_reader.js
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { SafeMap } = primordials;
|
||||
-const { internalModuleReadJSON } = internalBinding('fs');
|
||||
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
||||
const { pathToFileURL } = require('url');
|
||||
const { toNamespacedPath } = require('path');
|
||||
|
||||
--- node/lib/vm.js
|
||||
+++ node/lib/vm.js
|
||||
@@ -79,6 +79,7 @@ class Script extends ContextifyScript {
|
||||
produceCachedData = false,
|
||||
importModuleDynamically,
|
||||
[kParsingContext]: parsingContext,
|
||||
+ sourceless = false,
|
||||
} = options;
|
||||
|
||||
validateString(filename, 'options.filename');
|
||||
@@ -103,7 +104,8 @@ class Script extends ContextifyScript {
|
||||
columnOffset,
|
||||
cachedData,
|
||||
produceCachedData,
|
||||
- parsingContext);
|
||||
+ parsingContext,
|
||||
+ sourceless);
|
||||
} catch (e) {
|
||||
throw e; /* node-do-not-add-exception-line */
|
||||
}
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -690,8 +690,6 @@ bool Agent::Start(const std::string& path,
|
||||
StartIoThreadAsyncCallback));
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
start_io_thread_async.data = this;
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
|
||||
parent_env_->AddCleanupHook([](void* data) {
|
||||
Environment* env = static_cast<Environment*>(data);
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -482,6 +482,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
|
||||
return scope.EscapeMaybe(cb(info));
|
||||
}
|
||||
|
||||
+ StartExecution(env, "internal/bootstrap/pkg");
|
||||
+
|
||||
if (env->worker_context() != nullptr) {
|
||||
return StartExecution(env, "internal/main/worker_thread");
|
||||
}
|
||||
@@ -600,13 +602,6 @@ static struct {
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (auto& s : stdio) {
|
||||
const int fd = &s - stdio;
|
||||
@@ -622,10 +617,6 @@ inline void PlatformInit() {
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -74,6 +74,7 @@ using v8::ScriptOrModule;
|
||||
using v8::String;
|
||||
using v8::Uint32;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
using v8::WeakCallbackType;
|
||||
@@ -701,11 +702,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
Local<ArrayBufferView> cached_data_buf;
|
||||
bool produce_cached_data = false;
|
||||
Local<Context> parsing_context = context;
|
||||
+ bool sourceless = false;
|
||||
|
||||
if (argc > 2) {
|
||||
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
||||
// cachedData, produceCachedData, parsingContext)
|
||||
- CHECK_EQ(argc, 7);
|
||||
+ CHECK_EQ(argc, 8);
|
||||
CHECK(args[2]->IsNumber());
|
||||
line_offset = args[2].As<Int32>()->Value();
|
||||
CHECK(args[3]->IsNumber());
|
||||
@@ -724,6 +726,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
CHECK_NOT_NULL(sandbox);
|
||||
parsing_context = sandbox->context();
|
||||
}
|
||||
+ sourceless = args[7]->IsTrue();
|
||||
}
|
||||
|
||||
ContextifyScript* contextify_script =
|
||||
@@ -775,6 +778,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
||||
Context::Scope scope(parsing_context);
|
||||
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
isolate,
|
||||
&source,
|
||||
@@ -789,6 +796,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
"ContextifyScript::New");
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
||||
|
||||
Local<Context> env_context = env->context();
|
||||
@@ -815,6 +829,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
||||
env->cached_data_produced_string(),
|
||||
Boolean::New(isolate, cached_data_produced)).Check();
|
||||
}
|
||||
+
|
||||
+ if (sourceless && produce_cached_data) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
|
||||
}
|
||||
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "node.h"
|
||||
#include <cstdio>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
@@ -84,7 +86,7 @@ int wmain(int argc, wchar_t* wargv[]) {
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
@@ -124,6 +126,88 @@ int main(int argc, char* argv[]) {
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
+ return reorder(argc, argv);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ wchar_t execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
return node::Start(argc, argv);
|
||||
}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+#ifdef __clang__
|
||||
+__attribute__((optnone))
|
||||
+#elif defined(__GNUC__)
|
||||
+__attribute__((optimize(0)))
|
||||
#endif
|
||||
+int load_baked(char** nargv) {
|
||||
+ int c = 1;
|
||||
+
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+
|
||||
+ return c;
|
||||
+}
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+
|
||||
+ nargv[0] = argv[0];
|
||||
+ int c = load_baked(nargv);
|
||||
+
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
--- node/src/node_options.cc
|
||||
+++ node/src/node_options.cc
|
||||
@@ -275,6 +275,7 @@ void Parse(
|
||||
// TODO(addaleax): Make that unnecessary.
|
||||
|
||||
DebugOptionsParser::DebugOptionsParser() {
|
||||
+ return;
|
||||
AddOption("--inspect-port",
|
||||
"set host:port for inspector",
|
||||
&DebugOptions::host_port,
|
||||
--- node/tools/icu/icu-generic.gyp
|
||||
+++ node/tools/icu/icu-generic.gyp
|
||||
@@ -52,7 +52,7 @@
|
||||
'conditions': [
|
||||
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
||||
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
||||
- 'cflags_cc': [ '-frtti' ],
|
||||
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
||||
'cflags_cc!': [ '-fno-rtti' ],
|
||||
}],
|
||||
[ 'OS == "mac" or OS == "ios"', {
|
||||
+549
@@ -0,0 +1,549 @@
|
||||
--- node/deps/v8/include/v8.h
|
||||
+++ node/deps/v8/include/v8.h
|
||||
@@ -7911,10 +7911,14 @@
|
||||
*/
|
||||
static void SetFlagsFromCommandLine(int* argc,
|
||||
char** argv,
|
||||
bool remove_flags);
|
||||
|
||||
+ static void EnableCompilationForSourcelessUse();
|
||||
+ static void DisableCompilationForSourcelessUse();
|
||||
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
||||
+
|
||||
/** Get the version string. */
|
||||
static const char* GetVersion();
|
||||
|
||||
/** Callback function for reporting failed access checks.*/
|
||||
V8_INLINE static V8_DEPRECATED(
|
||||
--- node/deps/v8/src/api.cc
|
||||
+++ node/deps/v8/src/api.cc
|
||||
@@ -830,10 +830,46 @@
|
||||
void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
||||
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
||||
}
|
||||
|
||||
|
||||
+bool save_lazy;
|
||||
+bool save_predictable;
|
||||
+bool save_serialize_toplevel;
|
||||
+
|
||||
+
|
||||
+void V8::EnableCompilationForSourcelessUse() {
|
||||
+ save_lazy = i::FLAG_lazy;
|
||||
+ i::FLAG_lazy = false;
|
||||
+ save_predictable = i::FLAG_predictable;
|
||||
+ i::FLAG_predictable = true;
|
||||
+ save_serialize_toplevel = i::FLAG_serialize_toplevel;
|
||||
+ i::FLAG_serialize_toplevel = true;
|
||||
+ i::CpuFeatures::Reinitialize();
|
||||
+ i::CpuFeatures::Probe(true);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::DisableCompilationForSourcelessUse() {
|
||||
+ i::FLAG_lazy = save_lazy;
|
||||
+ i::FLAG_predictable = save_predictable;
|
||||
+ i::FLAG_serialize_toplevel = save_serialize_toplevel;
|
||||
+ i::CpuFeatures::Reinitialize();
|
||||
+ i::CpuFeatures::Probe(false);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script) {
|
||||
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
||||
+ auto object = i::Handle<i::HeapObject>::cast(Utils::OpenHandle(*script));
|
||||
+ i::Handle<i::SharedFunctionInfo> function_info(
|
||||
+ i::SharedFunctionInfo::cast(*object), object->GetIsolate());
|
||||
+ auto s = reinterpret_cast<i::Script*>(function_info->script());
|
||||
+ s->set_source(isolate->heap()->undefined_value());
|
||||
+}
|
||||
+
|
||||
+
|
||||
RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
|
||||
|
||||
|
||||
RegisteredExtension::RegisteredExtension(Extension* extension)
|
||||
: extension_(extension) { }
|
||||
--- node/deps/v8/src/assembler.h
|
||||
+++ node/deps/v8/src/assembler.h
|
||||
@@ -297,10 +297,15 @@
|
||||
}
|
||||
|
||||
static void PrintTarget();
|
||||
static void PrintFeatures();
|
||||
|
||||
+ static void Reinitialize() {
|
||||
+ supported_ = 0;
|
||||
+ initialized_ = false;
|
||||
+ }
|
||||
+
|
||||
private:
|
||||
friend class ExternalReference;
|
||||
friend class AssemblerBase;
|
||||
// Flush instruction cache.
|
||||
static void FlushICache(void* start, size_t size);
|
||||
--- node/deps/v8/src/objects.cc
|
||||
+++ node/deps/v8/src/objects.cc
|
||||
@@ -13206,10 +13206,13 @@
|
||||
|
||||
// Check if we should print {function} as a class.
|
||||
Handle<Object> class_start_position = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_start_position_symbol());
|
||||
if (class_start_position->IsSmi()) {
|
||||
+ if (Script::cast(shared_info->script())->source()->IsUndefined(isolate)) {
|
||||
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
||||
+ }
|
||||
Handle<Object> class_end_position = JSReceiver::GetDataProperty(
|
||||
function, isolate->factory()->class_end_position_symbol());
|
||||
Handle<String> script_source(
|
||||
String::cast(Script::cast(shared_info->script())->source()), isolate);
|
||||
return isolate->factory()->NewSubString(
|
||||
--- node/deps/v8/src/parsing/parsing.cc
|
||||
+++ node/deps/v8/src/parsing/parsing.cc
|
||||
@@ -18,10 +18,11 @@
|
||||
namespace parsing {
|
||||
|
||||
bool ParseProgram(ParseInfo* info, Isolate* isolate) {
|
||||
DCHECK(info->is_toplevel());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
||||
|
||||
VMState<PARSER> state(isolate);
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<String> source(String::cast(info->script()->source()));
|
||||
@@ -52,10 +53,11 @@
|
||||
bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
DCHECK(!info->is_toplevel());
|
||||
DCHECK(!shared_info.is_null());
|
||||
DCHECK_NULL(info->literal());
|
||||
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
||||
|
||||
// Create a character stream for the parser.
|
||||
Handle<String> source(String::cast(info->script()->source()));
|
||||
source = String::Flatten(source);
|
||||
isolate->counters()->total_parse_size()->Increment(source->length());
|
||||
--- node/deps/v8/src/snapshot/code-serializer.cc
|
||||
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
||||
@@ -392,31 +392,46 @@
|
||||
|
||||
SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
||||
Isolate* isolate, uint32_t expected_source_hash) const {
|
||||
if (this->size_ < kHeaderSize) return INVALID_HEADER;
|
||||
uint32_t magic_number = GetMagicNumber();
|
||||
- if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH;
|
||||
+ if (magic_number != ComputeMagicNumber(isolate)) {
|
||||
+ // base::OS::PrintError("Pkg: MAGIC_NUMBER_MISMATCH\n"); // TODO enable after solving v8-cache/ncc issue
|
||||
+ return MAGIC_NUMBER_MISMATCH;
|
||||
+ }
|
||||
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
||||
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
||||
uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
|
||||
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
||||
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
||||
uint32_t c1 = GetHeaderValue(kChecksum1Offset);
|
||||
uint32_t c2 = GetHeaderValue(kChecksum2Offset);
|
||||
- if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
||||
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
||||
- if (cpu_features != static_cast<uint32_t>(CpuFeatures::SupportedFeatures())) {
|
||||
+ if (version_hash != Version::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
|
||||
+ return VERSION_MISMATCH;
|
||||
+ }
|
||||
+ uint32_t host_features = static_cast<uint32_t>(CpuFeatures::SupportedFeatures());
|
||||
+ if (cpu_features & (~host_features)) {
|
||||
+ base::OS::PrintError("Pkg: CPU_FEATURES_MISMATCH\n");
|
||||
return CPU_FEATURES_MISMATCH;
|
||||
}
|
||||
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
||||
+ if (flags_hash != FlagList::Hash()) {
|
||||
+ base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
|
||||
+ return FLAGS_MISMATCH;
|
||||
+ }
|
||||
uint32_t max_payload_length =
|
||||
this->size_ -
|
||||
POINTER_SIZE_ALIGN(kHeaderSize +
|
||||
GetHeaderValue(kNumReservationsOffset) * kInt32Size +
|
||||
GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size);
|
||||
- if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
||||
- if (!Checksum(DataWithoutHeader()).Check(c1, c2)) return CHECKSUM_MISMATCH;
|
||||
+ if (payload_length > max_payload_length) {
|
||||
+ base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
|
||||
+ return LENGTH_MISMATCH;
|
||||
+ }
|
||||
+ if (!Checksum(DataWithoutHeader()).Check(c1, c2)) {
|
||||
+ base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
|
||||
+ return CHECKSUM_MISMATCH;
|
||||
+ }
|
||||
return CHECK_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t SerializedCodeData::SourceHash(Handle<String> source) {
|
||||
return source->length();
|
||||
--- node/lib/child_process.js
|
||||
+++ node/lib/child_process.js
|
||||
@@ -104,11 +104,11 @@
|
||||
}
|
||||
|
||||
options.execPath = options.execPath || process.execPath;
|
||||
options.shell = false;
|
||||
|
||||
- return spawn(options.execPath, args, options);
|
||||
+ return exports.spawn(options.execPath, args, options);
|
||||
};
|
||||
|
||||
|
||||
exports._forkChild = function(fd) {
|
||||
// set process.send()
|
||||
--- node/lib/internal/bootstrap_node.js
|
||||
+++ node/lib/internal/bootstrap_node.js
|
||||
@@ -122,10 +122,46 @@
|
||||
// There are various modes that Node can run in. The most common two
|
||||
// are running from a script and running the REPL - but there are a few
|
||||
// others like the debugger or running --eval arguments. Here we decide
|
||||
// which mode we run in.
|
||||
|
||||
+ (function () {
|
||||
+ var fs = NativeModule.require('fs');
|
||||
+ var vm = NativeModule.require('vm');
|
||||
+ function readPrelude (fd) {
|
||||
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
||||
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
||||
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
||||
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
||||
+ if (!PRELUDE_POSITION) {
|
||||
+ // no prelude - remove entrypoint from argv[1]
|
||||
+ process.argv.splice(1, 1);
|
||||
+ return { undoPatch: true };
|
||||
+ }
|
||||
+ var prelude = new Buffer(PRELUDE_SIZE);
|
||||
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
||||
+ if (read !== PRELUDE_SIZE) {
|
||||
+ console.error('Pkg: Error reading from file.');
|
||||
+ process.exit(1);
|
||||
+ }
|
||||
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
||||
+ var fn = s.runInThisContext();
|
||||
+ return fn(process, NativeModule.require,
|
||||
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
||||
+ }
|
||||
+ (function () {
|
||||
+ var fd = fs.openSync(process.execPath, 'r');
|
||||
+ var result = readPrelude(fd);
|
||||
+ if (result && result.undoPatch) {
|
||||
+ var bindingFs = process.binding('fs');
|
||||
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
||||
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;
|
||||
+ fs.closeSync(fd);
|
||||
+ }
|
||||
+ }());
|
||||
+ }());
|
||||
+
|
||||
if (NativeModule.exists('_third_party_main')) {
|
||||
// To allow people to extend Node in different ways, this hook allows
|
||||
// one to drop a file lib/_third_party_main.js into the build
|
||||
// directory which will be executed instead of Node's normal loading.
|
||||
process.nextTick(function() {
|
||||
--- node/lib/module.js
|
||||
+++ node/lib/module.js
|
||||
@@ -28,14 +28,12 @@
|
||||
const vm = require('vm');
|
||||
const assert = require('assert').ok;
|
||||
const fs = require('fs');
|
||||
const internalFS = require('internal/fs');
|
||||
const path = require('path');
|
||||
-const {
|
||||
- internalModuleReadFile,
|
||||
- internalModuleStat
|
||||
-} = process.binding('fs');
|
||||
+const internalModuleReadFile = function (f) { return require('fs').internalModuleReadFile(f); };
|
||||
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
||||
const preserveSymlinks = !!process.binding('config').preserveSymlinks;
|
||||
const experimentalModules = !!process.binding('config').experimentalModules;
|
||||
|
||||
const errors = require('internal/errors');
|
||||
|
||||
--- node/src/env.h
|
||||
+++ node/src/env.h
|
||||
@@ -266,10 +266,11 @@
|
||||
V(shell_string, "shell") \
|
||||
V(signal_string, "signal") \
|
||||
V(size_string, "size") \
|
||||
V(sni_context_err_string, "Invalid SNI context") \
|
||||
V(sni_context_string, "sni_context") \
|
||||
+ V(sourceless_string, "sourceless") \
|
||||
V(speed_string, "speed") \
|
||||
V(stack_string, "stack") \
|
||||
V(status_string, "status") \
|
||||
V(stdio_string, "stdio") \
|
||||
V(stream_string, "stream") \
|
||||
--- node/src/inspector_agent.cc
|
||||
+++ node/src/inspector_agent.cc
|
||||
@@ -485,12 +485,10 @@
|
||||
&start_io_thread_async,
|
||||
StartIoThreadAsyncCallback));
|
||||
start_io_thread_async.data = this;
|
||||
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
||||
|
||||
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
||||
- StartDebugSignalHandler();
|
||||
if (options.inspector_enabled()) {
|
||||
// This will return false if listen failed on the inspector port.
|
||||
return StartIoThread(options.wait_for_connect());
|
||||
}
|
||||
return true;
|
||||
--- node/src/node.cc
|
||||
+++ node/src/node.cc
|
||||
@@ -3726,17 +3726,10 @@
|
||||
}
|
||||
|
||||
|
||||
inline void PlatformInit() {
|
||||
#ifdef __POSIX__
|
||||
-#if HAVE_INSPECTOR
|
||||
- sigset_t sigmask;
|
||||
- sigemptyset(&sigmask);
|
||||
- sigaddset(&sigmask, SIGUSR1);
|
||||
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
||||
for (int fd = STDIN_FILENO; fd <= STDERR_FILENO; fd += 1) {
|
||||
struct stat ignored;
|
||||
if (fstat(fd, &ignored) == 0)
|
||||
continue;
|
||||
@@ -3746,14 +3739,10 @@
|
||||
ABORT();
|
||||
if (fd != open("/dev/null", O_RDWR))
|
||||
ABORT();
|
||||
}
|
||||
|
||||
-#if HAVE_INSPECTOR
|
||||
- CHECK_EQ(err, 0);
|
||||
-#endif // HAVE_INSPECTOR
|
||||
-
|
||||
#ifndef NODE_SHARED_MODE
|
||||
// Restore signal dispositions, the parent process may have changed them.
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(act));
|
||||
|
||||
--- node/src/node_contextify.cc
|
||||
+++ node/src/node_contextify.cc
|
||||
@@ -57,10 +57,11 @@
|
||||
using v8::String;
|
||||
using v8::Symbol;
|
||||
using v8::TryCatch;
|
||||
using v8::Uint8Array;
|
||||
using v8::UnboundScript;
|
||||
+using v8::V8;
|
||||
using v8::Value;
|
||||
using v8::WeakCallbackInfo;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -573,18 +574,20 @@
|
||||
MaybeLocal<Integer> lineOffset = GetLineOffsetArg(env, options);
|
||||
MaybeLocal<Integer> columnOffset = GetColumnOffsetArg(env, options);
|
||||
Maybe<bool> maybe_display_errors = GetDisplayErrorsArg(env, options);
|
||||
MaybeLocal<Uint8Array> cached_data_buf = GetCachedData(env, options);
|
||||
Maybe<bool> maybe_produce_cached_data = GetProduceCachedData(env, options);
|
||||
+ Maybe<bool> maybe_sourceless = GetSourceless(env, options);
|
||||
MaybeLocal<Context> maybe_context = GetContext(env, options);
|
||||
if (try_catch.HasCaught()) {
|
||||
try_catch.ReThrow();
|
||||
return;
|
||||
}
|
||||
|
||||
bool display_errors = maybe_display_errors.ToChecked();
|
||||
bool produce_cached_data = maybe_produce_cached_data.ToChecked();
|
||||
+ bool sourceless = maybe_sourceless.ToChecked();
|
||||
|
||||
ScriptCompiler::CachedData* cached_data = nullptr;
|
||||
Local<Uint8Array> ui8;
|
||||
if (cached_data_buf.ToLocal(&ui8)) {
|
||||
ArrayBuffer::Contents contents = ui8->Buffer()->GetContents();
|
||||
@@ -604,22 +607,37 @@
|
||||
else if (produce_cached_data)
|
||||
compile_options = ScriptCompiler::kProduceCodeCache;
|
||||
|
||||
Context::Scope scope(maybe_context.FromMaybe(env->context()));
|
||||
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kProduceCodeCache) {
|
||||
+ V8::EnableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
||||
env->isolate(),
|
||||
&source,
|
||||
compile_options);
|
||||
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kProduceCodeCache) {
|
||||
+ V8::DisableCompilationForSourcelessUse();
|
||||
+ }
|
||||
+
|
||||
if (v8_script.IsEmpty()) {
|
||||
if (display_errors) {
|
||||
DecorateErrorStack(env, try_catch);
|
||||
}
|
||||
try_catch.ReThrow();
|
||||
return;
|
||||
}
|
||||
+
|
||||
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
+ if (!source.GetCachedData()->rejected) {
|
||||
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
contextify_script->script_.Reset(env->isolate(),
|
||||
v8_script.ToLocalChecked());
|
||||
|
||||
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
|
||||
args.This()->Set(
|
||||
@@ -913,10 +931,26 @@
|
||||
Local<Value> value = maybe_value.ToLocalChecked();
|
||||
return Just(value->IsTrue());
|
||||
}
|
||||
|
||||
|
||||
+ static Maybe<bool> GetSourceless(Environment* env, Local<Value> options) {
|
||||
+ if (!options->IsObject()) {
|
||||
+ return Just(false);
|
||||
+ }
|
||||
+
|
||||
+ MaybeLocal<Value> maybe_value =
|
||||
+ options.As<Object>()->Get(env->context(),
|
||||
+ env->sourceless_string());
|
||||
+ if (maybe_value.IsEmpty())
|
||||
+ return Nothing<bool>();
|
||||
+
|
||||
+ Local<Value> value = maybe_value.ToLocalChecked();
|
||||
+ return Just(value->IsTrue());
|
||||
+ }
|
||||
+
|
||||
+
|
||||
static MaybeLocal<Integer> GetLineOffsetArg(Environment* env,
|
||||
Local<Value> options) {
|
||||
Local<Integer> defaultLineOffset = Integer::New(env->isolate(), 0);
|
||||
|
||||
if (!options->IsObject()) {
|
||||
--- node/src/node_debug_options.cc
|
||||
+++ node/src/node_debug_options.cc
|
||||
@@ -59,10 +59,11 @@
|
||||
deprecated_debug_(false),
|
||||
break_first_line_(false),
|
||||
host_name_("127.0.0.1"), port_(-1) { }
|
||||
|
||||
bool DebugOptions::ParseOption(const char* argv0, const std::string& option) {
|
||||
+ return false;
|
||||
bool has_argument = false;
|
||||
std::string option_name;
|
||||
std::string argument;
|
||||
|
||||
auto pos = option.find("=");
|
||||
--- node/src/node_main.cc
|
||||
+++ node/src/node_main.cc
|
||||
@@ -20,10 +20,12 @@
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "node.h"
|
||||
#include <stdio.h>
|
||||
|
||||
+int reorder(int argc, char** argv);
|
||||
+
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include <WinError.h>
|
||||
|
||||
@@ -67,11 +69,11 @@
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
argv[argc] = nullptr;
|
||||
// Now that conversion is done, we can finally start.
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#else
|
||||
// UNIX
|
||||
#ifdef __linux__
|
||||
#include <elf.h>
|
||||
@@ -119,8 +121,75 @@
|
||||
#endif
|
||||
// Disable stdio buffering, it interacts poorly with printf()
|
||||
// calls elsewhere in the program (e.g., any logging from V8.)
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
- return node::Start(argc, argv);
|
||||
+ return reorder(argc, argv);
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
+int strlen2 (char* s) {
|
||||
+ int len = 0;
|
||||
+ while (*s) {
|
||||
+ len += 1;
|
||||
+ s += 1;
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+bool should_set_dummy() {
|
||||
+#ifdef _WIN32
|
||||
+ #define MAX_ENV_LENGTH 32767
|
||||
+ char execpath_env[MAX_ENV_LENGTH];
|
||||
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
||||
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#else
|
||||
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
||||
+ if (!execpath_env) return true;
|
||||
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+// for uv_setup_args
|
||||
+int adjacent(int argc, char** argv) {
|
||||
+ size_t size = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ size += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ char* args = new char[size];
|
||||
+ size_t pos = 0;
|
||||
+ for (int i = 0; i < argc; i++) {
|
||||
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
||||
+ argv[i] = &args[pos];
|
||||
+ pos += strlen(argv[i]) + 1;
|
||||
+ }
|
||||
+ return node::Start(argc, argv);
|
||||
+}
|
||||
+
|
||||
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
||||
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
||||
+
|
||||
+int reorder(int argc, char** argv) {
|
||||
+ int i;
|
||||
+ char** nargv = new char*[argc + 64];
|
||||
+ int c = 0;
|
||||
+ nargv[c++] = argv[0];
|
||||
+ char* bakery = (char*) BAKERY;
|
||||
+ while (true) {
|
||||
+ size_t width = strlen2(bakery);
|
||||
+ if (width == 0) break;
|
||||
+ nargv[c++] = bakery;
|
||||
+ bakery += width + 1;
|
||||
+ }
|
||||
+ if (should_set_dummy()) {
|
||||
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
||||
+ }
|
||||
+ for (i = 1; i < argc; i++) {
|
||||
+ nargv[c++] = argv[i];
|
||||
+ }
|
||||
+ return adjacent(c, nargv);
|
||||
+}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"v18.5.0": ["node.v18.5.0.cpp.patch"],
|
||||
"v16.16.0": ["node.v16.16.0.cpp.patch"],
|
||||
"v14.20.0": ["node.v14.20.0.cpp.patch"],
|
||||
"v12.22.11": ["node.v12.22.11.cpp.patch"],
|
||||
"v10.24.1": ["node.v10.24.1.cpp.patch"],
|
||||
"v8.17.0": ["node.v8.17.0.cpp.patch"]
|
||||
}
|
||||
Reference in new issue
Block a user