@yao-pkg/pkg-fetch 3.5.6 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-es5/expected-shas.json +12 -1
- package/lib-es5/verify.js +1 -1
- package/package.json +1 -1
- package/patches/node.v20.10.0.cpp.patch +565 -0
- package/patches/patches.json +1 -0
|
@@ -43,5 +43,16 @@
|
|
|
43
43
|
"node-v19.8.1-macos-x64": "7288e53e6afe4d07bc5f32965ca7a051d7e72a67f09979c561dc8dabff88a5b2",
|
|
44
44
|
"node-v19.8.1-win-arm64": "f288732fc5f5493367a5d60d1e227347099de3db26fd651607df07d37fb8222e",
|
|
45
45
|
"node-v19.8.1-win-x64": "98b22116864d72e1ccb4d557dc36785cf731051543c5c876f1bf547872de2d1d",
|
|
46
|
-
"node-v19.8.1-macos-arm64": "69c1113d1fbcce01e0062af12a4a1b81f6c3746ff32a8b307f8632788109c94a"
|
|
46
|
+
"node-v19.8.1-macos-arm64": "69c1113d1fbcce01e0062af12a4a1b81f6c3746ff32a8b307f8632788109c94a",
|
|
47
|
+
"node-v20.10.0-alpine-arm64": "909d88e166499dd9311e9d8d72cce1c2ae1f81ca7f5602e5ee2d5c4eeb39d99b",
|
|
48
|
+
"node-v20.10.0-alpine-x64": "1bcce476efb0b797cd67f4ebb3d5f824241d67246654cf18e94465a473290d6f",
|
|
49
|
+
"node-v20.10.0-linux-x64": "d17d0a9477cd702ba0de16f903d4ffbcef1898833568c24cbf2c6ef3b0c052a4",
|
|
50
|
+
"node-v20.10.0-linuxstatic-arm64": "38df4a161b347b481e9cbbe78a5830bdcc776183bc9cbde152f6bb60b90f9dd0",
|
|
51
|
+
"node-v20.10.0-linuxstatic-armv7": "64d3543fae52e92c191dfd187679b28c234ff67cee17fddb1444a1fad58f4983",
|
|
52
|
+
"node-v20.10.0-linuxstatic-x64": "345ed15e21298b206df5c102aa0225108344ae183414cd967c6b517c9671c501",
|
|
53
|
+
"node-v20.10.0-macos-x64": "e7d7d837ea3f373b347106118d2ce187e4990534f28d9c8cfdff68084b36a69b",
|
|
54
|
+
"node-v20.10.0-win-arm64": "13ca46f22f159d3c83357ad1f75482556abefeba1eeb15e7dc7747a29e82aba5",
|
|
55
|
+
"node-v20.10.0-win-x64": "27472c7a532a51ab2089a35f5afbeefd1075f4939fe3f4a8dc594439bf708117",
|
|
56
|
+
"node-v20.10.0-linux-arm64": "0162ad9d9eb1e4ce01b3a5fe519be3032d8f6e66d77cdb18105654cde28433b6",
|
|
57
|
+
"node-v20.10.0-macos-arm64": "c61c9ddd7218ddd28e38c5d88b13cd2f972b6aaef244d0b2518bf33bfbdad997"
|
|
47
58
|
}
|
package/lib-es5/verify.js
CHANGED
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.verify = void 0;
|
|
40
40
|
var child_process_1 = require("child_process");
|
|
41
41
|
var utils_1 = require("./utils");
|
|
42
|
-
var script = "\n var vm = require('vm');\n var assert = require('assert');\n var text = '(function () { return 42; })';\n var cd, fn, result;\n var modules = process.versions.modules | 0;\n var v8 = process.versions.v8.split('.').slice(0, 2).join('.');\n\n var s1 = new vm.Script(text, { filename: 's1', produceCachedData: true, sourceless: true });\n assert(s1.cachedDataProduced);\n cd = s1.cachedData;\n\n var kCpuFeaturesOffset, cpuFeatures;\n\n if (modules === 14) {\n } else\n if (modules === 46 || modules === 48 || modules === 51) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 57) {\n if (v8 === '6.2') {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (v8 === '5.8') {\n kCpuFeaturesOffset = 0x0c;\n } else {\n kCpuFeaturesOffset = 0x10;\n }\n } else\n if (modules === 59) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 64) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 72) {\n // no cpu features anymore\n } else\n if (modules === 79) {\n // no cpu features anymore\n } else\n if (modules === 83) {\n // no cpu features anymore\n } else\n if (modules === 93) {\n // no cpu features anymore\n } else\n if (modules === 108) {\n // no cpu features anymore\n } else\n if (modules === 111) {\n // no cpu features anymore\n } else {\n assert(false, modules);\n }\n\n if (modules >= 46 && // no cpu_features field in 0.12\n process.arch !== 'arm' && // non-zero features even in sourceless mode in arm\n modules < 72) { // no cpu_features field in 12+\n cpuFeatures = cd.readUInt32LE(kCpuFeaturesOffset);\n assert(cpuFeatures === 0, 'CPU_FEATURES must be zero');\n }\n\n var s2 = new vm.Script(undefined, { filename: 's2', cachedData: cd, sourceless: true });\n fn = s2.runInThisContext();\n result = fn();\n assert.equal(result, 42);\n\n if (modules === 14) {\n } else\n if (modules === 46 || modules === 48 ||\n modules === 51 || modules === 57 || modules === 59 || modules === 64) {\n var paddedPayloadOffset = 0x48; // see SerializedCodeData::Payload()\n var index = paddedPayloadOffset + 10;\n cd[index] ^= 0xf0;\n var s3 = new vm.Script(undefined, { filename: 's3', cachedData: cd, sourceless: true });\n assert(s3.cachedDataRejected, 's3.cachedDataRejected must be true');\n } else\n if (modules === 72) {\n } else\n if (modules === 79) {\n } else\n if (modules === 83) {\n } else\n if (modules === 93) {\n } else\n if (modules === 108) {\n } else\n if (modules === 111) {\n } else {\n assert(false, modules);\n }\n\n var s4 = new vm.Script(text, { filename: 's4', produceCachedData: true });\n assert(s4.cachedDataProduced, 's4.cachedDataProduced must be true');\n cd = s4.cachedData;\n\n if (modules >= 46 && // no cpu_features field in 0.12\n process.arch !== 'arm' && // zero features even in non-sourceless mode in arm\n modules < 72) { // no cpu_features field in 12+\n cpuFeatures = cd.readUInt32LE(kCpuFeaturesOffset);\n assert(cpuFeatures !== 0, 'CPU_FEATURES must be non-zero');\n }\n\n console.log('ok');\n";
|
|
42
|
+
var script = "\n var vm = require('vm');\n var assert = require('assert');\n var text = '(function () { return 42; })';\n var cd, fn, result;\n var modules = process.versions.modules | 0;\n var v8 = process.versions.v8.split('.').slice(0, 2).join('.');\n\n var s1 = new vm.Script(text, { filename: 's1', produceCachedData: true, sourceless: true });\n assert(s1.cachedDataProduced);\n cd = s1.cachedData;\n\n var kCpuFeaturesOffset, cpuFeatures;\n\n if (modules === 14) {\n } else\n if (modules === 46 || modules === 48 || modules === 51) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 57) {\n if (v8 === '6.2') {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (v8 === '5.8') {\n kCpuFeaturesOffset = 0x0c;\n } else {\n kCpuFeaturesOffset = 0x10;\n }\n } else\n if (modules === 59) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 64) {\n kCpuFeaturesOffset = 0x0c;\n } else\n if (modules === 72) {\n // no cpu features anymore\n } else\n if (modules === 79) {\n // no cpu features anymore\n } else\n if (modules === 83) {\n // no cpu features anymore\n } else\n if (modules === 93) {\n // no cpu features anymore\n } else\n if (modules === 108) {\n // no cpu features anymore\n } else\n if (modules === 111) {\n // no cpu features anymore\n } else\n if (modules === 115) {\n // no cpu features anymore\n } else {\n assert(false, modules);\n }\n\n if (modules >= 46 && // no cpu_features field in 0.12\n process.arch !== 'arm' && // non-zero features even in sourceless mode in arm\n modules < 72) { // no cpu_features field in 12+\n cpuFeatures = cd.readUInt32LE(kCpuFeaturesOffset);\n assert(cpuFeatures === 0, 'CPU_FEATURES must be zero');\n }\n\n var s2 = new vm.Script(undefined, { filename: 's2', cachedData: cd, sourceless: true });\n fn = s2.runInThisContext();\n result = fn();\n assert.equal(result, 42);\n\n if (modules === 14) {\n } else\n if (modules === 46 || modules === 48 ||\n modules === 51 || modules === 57 || modules === 59 || modules === 64) {\n var paddedPayloadOffset = 0x48; // see SerializedCodeData::Payload()\n var index = paddedPayloadOffset + 10;\n cd[index] ^= 0xf0;\n var s3 = new vm.Script(undefined, { filename: 's3', cachedData: cd, sourceless: true });\n assert(s3.cachedDataRejected, 's3.cachedDataRejected must be true');\n } else\n if (modules === 72) {\n } else\n if (modules === 79) {\n } else\n if (modules === 83) {\n } else\n if (modules === 93) {\n } else\n if (modules === 108) {\n } else\n if (modules === 111) {\n } else\n if (modules === 115) {\n } else {\n assert(false, modules);\n }\n\n var s4 = new vm.Script(text, { filename: 's4', produceCachedData: true });\n assert(s4.cachedDataProduced, 's4.cachedDataProduced must be true');\n cd = s4.cachedData;\n\n if (modules >= 46 && // no cpu_features field in 0.12\n process.arch !== 'arm' && // zero features even in non-sourceless mode in arm\n modules < 72) { // no cpu_features field in 12+\n cpuFeatures = cd.readUInt32LE(kCpuFeaturesOffset);\n assert(cpuFeatures !== 0, 'CPU_FEATURES must be non-zero');\n }\n\n console.log('ok');\n";
|
|
43
43
|
function verify(local) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
return __generator(this, function (_a) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
diff --git node/common.gypi node/common.gypi
|
|
2
|
+
index 4589f51517..97555b4c0b 100644
|
|
3
|
+
--- node/common.gypi
|
|
4
|
+
+++ node/common.gypi
|
|
5
|
+
@@ -174,7 +174,7 @@
|
|
6
|
+
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
|
|
7
|
+
}],
|
|
8
|
+
['llvm_version=="0.0"', {
|
|
9
|
+
- 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', # GCC
|
|
10
|
+
+ 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
|
|
11
|
+
}, {
|
|
12
|
+
'lto': ' -flto ', # Clang
|
|
13
|
+
}],
|
|
14
|
+
diff --git node/configure.py node/configure.py
|
|
15
|
+
index 62f041ce52..4688ec0fdd 100755
|
|
16
|
+
--- node/configure.py
|
|
17
|
+
+++ node/configure.py
|
|
18
|
+
@@ -1270,7 +1270,6 @@ def configure_node(o):
|
|
19
|
+
|
|
20
|
+
# Enable branch protection for arm64
|
|
21
|
+
if target_arch == 'arm64':
|
|
22
|
+
- o['cflags']+=['-msign-return-address=all']
|
|
23
|
+
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
|
|
24
|
+
|
|
25
|
+
if options.node_snapshot_main is not None:
|
|
26
|
+
diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h
|
|
27
|
+
index d3e35d6ec5..6e9bbe3849 100644
|
|
28
|
+
--- node/deps/v8/include/v8-initialization.h
|
|
29
|
+
+++ node/deps/v8/include/v8-initialization.h
|
|
30
|
+
@@ -89,6 +89,10 @@ class V8_EXPORT V8 {
|
|
31
|
+
static void SetFlagsFromCommandLine(int* argc, char** argv,
|
|
32
|
+
bool remove_flags);
|
|
33
|
+
|
|
34
|
+
+ static void EnableCompilationForSourcelessUse();
|
|
35
|
+
+ static void DisableCompilationForSourcelessUse();
|
|
36
|
+
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
|
37
|
+
+
|
|
38
|
+
/** Get the version string. */
|
|
39
|
+
static const char* GetVersion();
|
|
40
|
+
|
|
41
|
+
diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
|
|
42
|
+
index a91dfc271c..a4cd4eeb31 100644
|
|
43
|
+
--- node/deps/v8/src/api/api.cc
|
|
44
|
+
+++ node/deps/v8/src/api/api.cc
|
|
45
|
+
@@ -806,6 +806,28 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
|
46
|
+
HelpOptions(HelpOptions::kDontExit));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
+bool save_lazy;
|
|
50
|
+
+bool save_predictable;
|
|
51
|
+
+
|
|
52
|
+
+void V8::EnableCompilationForSourcelessUse() {
|
|
53
|
+
+ save_lazy = i::v8_flags.lazy;
|
|
54
|
+
+ i::v8_flags.lazy = false;
|
|
55
|
+
+ save_predictable = i::v8_flags.predictable;
|
|
56
|
+
+ i::v8_flags.predictable = true;
|
|
57
|
+
+}
|
|
58
|
+
+
|
|
59
|
+
+void V8::DisableCompilationForSourcelessUse() {
|
|
60
|
+
+ i::v8_flags.lazy = save_lazy;
|
|
61
|
+
+ i::v8_flags.predictable = save_predictable;
|
|
62
|
+
+}
|
|
63
|
+
+
|
|
64
|
+
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
|
65
|
+
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
|
66
|
+
+ auto function_info = i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
|
67
|
+
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
|
68
|
+
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
|
69
|
+
+}
|
|
70
|
+
+
|
|
71
|
+
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
|
72
|
+
|
|
73
|
+
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
|
74
|
+
diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
|
|
75
|
+
index 31c5acceeb..56cad8671f 100644
|
|
76
|
+
--- node/deps/v8/src/codegen/compiler.cc
|
|
77
|
+
+++ node/deps/v8/src/codegen/compiler.cc
|
|
78
|
+
@@ -3475,7 +3475,7 @@ MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
|
|
79
|
+
maybe_script = lookup_result.script();
|
|
80
|
+
maybe_result = lookup_result.toplevel_sfi();
|
|
81
|
+
is_compiled_scope = lookup_result.is_compiled_scope();
|
|
82
|
+
- if (!maybe_result.is_null()) {
|
|
83
|
+
+ if (!maybe_result.is_null() && source->length()) {
|
|
84
|
+
compile_timer.set_hit_isolate_cache();
|
|
85
|
+
} else if (can_consume_code_cache) {
|
|
86
|
+
compile_timer.set_consuming_code_cache();
|
|
87
|
+
diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
|
|
88
|
+
index 94f7a672a7..57bb3fc7f1 100644
|
|
89
|
+
--- node/deps/v8/src/objects/js-function.cc
|
|
90
|
+
+++ node/deps/v8/src/objects/js-function.cc
|
|
91
|
+
@@ -1280,6 +1280,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
|
92
|
+
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
|
93
|
+
isolate, function, isolate->factory()->class_positions_symbol());
|
|
94
|
+
if (maybe_class_positions->IsClassPositions()) {
|
|
95
|
+
+ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
|
|
96
|
+
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
|
97
|
+
+ }
|
|
98
|
+
ClassPositions class_positions =
|
|
99
|
+
ClassPositions::cast(*maybe_class_positions);
|
|
100
|
+
int start_position = class_positions.start();
|
|
101
|
+
diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h
|
|
102
|
+
index 5621b15d98..722e1d18cb 100644
|
|
103
|
+
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
|
104
|
+
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
|
105
|
+
@@ -635,6 +635,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
|
|
106
|
+
}
|
|
107
|
+
if (!data.IsBytecodeArray()) return false;
|
|
108
|
+
|
|
109
|
+
+ Object script_obj = script();
|
|
110
|
+
+ if (!script_obj.IsUndefined()) {
|
|
111
|
+
+ Script script = Script::cast(script_obj);
|
|
112
|
+
+ if (script.source().IsUndefined()) {
|
|
113
|
+
+ return false;
|
|
114
|
+
+ }
|
|
115
|
+
+ }
|
|
116
|
+
+
|
|
117
|
+
if (IsStressFlushingEnabled(code_flush_mode)) return true;
|
|
118
|
+
|
|
119
|
+
BytecodeArray bytecode = BytecodeArray::cast(data);
|
|
120
|
+
diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
|
|
121
|
+
index 8c55a6fb6e..70bf82a57d 100644
|
|
122
|
+
--- node/deps/v8/src/parsing/parsing.cc
|
|
123
|
+
+++ node/deps/v8/src/parsing/parsing.cc
|
|
124
|
+
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
|
|
125
|
+
Isolate* isolate, ReportStatisticsMode mode) {
|
|
126
|
+
DCHECK(info->flags().is_toplevel());
|
|
127
|
+
DCHECK_NULL(info->literal());
|
|
128
|
+
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
|
129
|
+
|
|
130
|
+
VMState<PARSER> state(isolate);
|
|
131
|
+
|
|
132
|
+
@@ -75,6 +76,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
|
133
|
+
|
|
134
|
+
// Create a character stream for the parser.
|
|
135
|
+
Handle<Script> script(Script::cast(shared_info->script()), isolate);
|
|
136
|
+
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
|
137
|
+
Handle<String> source(String::cast(script->source()), isolate);
|
|
138
|
+
std::unique_ptr<Utf16CharacterStream> stream(
|
|
139
|
+
ScannerStream::For(isolate, source, shared_info->StartPosition(),
|
|
140
|
+
diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
|
|
141
|
+
index c83e8e4581..8cb451e147 100644
|
|
142
|
+
--- node/deps/v8/src/snapshot/code-serializer.cc
|
|
143
|
+
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
|
144
|
+
@@ -659,10 +659,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
|
|
145
|
+
|
|
146
|
+
SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
|
|
147
|
+
uint32_t expected_source_hash) const {
|
|
148
|
+
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
|
149
|
+
- if (source_hash != expected_source_hash) {
|
|
150
|
+
- return SerializedCodeSanityCheckResult::kSourceMismatch;
|
|
151
|
+
- }
|
|
152
|
+
return SerializedCodeSanityCheckResult::kSuccess;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@@ -679,10 +675,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource()
|
|
156
|
+
if (version_hash != Version::Hash()) {
|
|
157
|
+
return SerializedCodeSanityCheckResult::kVersionMismatch;
|
|
158
|
+
}
|
|
159
|
+
- uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
|
160
|
+
- if (flags_hash != FlagList::Hash()) {
|
|
161
|
+
- return SerializedCodeSanityCheckResult::kFlagsMismatch;
|
|
162
|
+
- }
|
|
163
|
+
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
|
164
|
+
uint32_t max_payload_length = this->size_ - kHeaderSize;
|
|
165
|
+
if (payload_length > max_payload_length) {
|
|
166
|
+
diff --git node/lib/child_process.js node/lib/child_process.js
|
|
167
|
+
index 449013906e..3a85e4a541 100644
|
|
168
|
+
--- node/lib/child_process.js
|
|
169
|
+
+++ node/lib/child_process.js
|
|
170
|
+
@@ -169,7 +169,7 @@ function fork(modulePath, args = [], options) {
|
|
171
|
+
throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
- return spawn(options.execPath, args, options);
|
|
175
|
+
+ return module.exports.spawn(options.execPath, args, options);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function _forkChild(fd, serializationMode) {
|
|
179
|
+
diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
|
|
180
|
+
new file mode 100644
|
|
181
|
+
index 0000000000..a697294fdf
|
|
182
|
+
--- /dev/null
|
|
183
|
+
+++ node/lib/internal/bootstrap/pkg.js
|
|
184
|
+
@@ -0,0 +1,49 @@
|
|
185
|
+
+'use strict';
|
|
186
|
+
+
|
|
187
|
+
+const {
|
|
188
|
+
+ prepareWorkerThreadExecution,
|
|
189
|
+
+ prepareMainThreadExecution
|
|
190
|
+
+} = require('internal/process/pre_execution');
|
|
191
|
+
+
|
|
192
|
+
+if (internalBinding('worker').isMainThread) {
|
|
193
|
+
+ prepareMainThreadExecution(true);
|
|
194
|
+
+} else {
|
|
195
|
+
+ prepareWorkerThreadExecution();
|
|
196
|
+
+}
|
|
197
|
+
+
|
|
198
|
+
+(function () {
|
|
199
|
+
+ var __require__ = require;
|
|
200
|
+
+ var fs = __require__('fs');
|
|
201
|
+
+ var vm = __require__('vm');
|
|
202
|
+
+ function readPrelude (fd) {
|
|
203
|
+
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
|
204
|
+
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
|
205
|
+
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
|
206
|
+
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
|
207
|
+
+ if (!PRELUDE_POSITION) {
|
|
208
|
+
+ // no prelude - remove entrypoint from argv[1]
|
|
209
|
+
+ process.argv.splice(1, 1);
|
|
210
|
+
+ return { undoPatch: true };
|
|
211
|
+
+ }
|
|
212
|
+
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
|
213
|
+
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
|
214
|
+
+ if (read !== PRELUDE_SIZE) {
|
|
215
|
+
+ console.error('Pkg: Error reading from file.');
|
|
216
|
+
+ process.exit(1);
|
|
217
|
+
+ }
|
|
218
|
+
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
|
219
|
+
+ var fn = s.runInThisContext();
|
|
220
|
+
+ return fn(process, __require__,
|
|
221
|
+
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
|
222
|
+
+ }
|
|
223
|
+
+ (function () {
|
|
224
|
+
+ var fd = fs.openSync(process.execPath, 'r');
|
|
225
|
+
+ var result = readPrelude(fd);
|
|
226
|
+
+ if (result && result.undoPatch) {
|
|
227
|
+
+ var bindingFs = process.binding('fs');
|
|
228
|
+
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
|
229
|
+
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
|
230
|
+
+ fs.closeSync(fd);
|
|
231
|
+
+ }
|
|
232
|
+
+ }());
|
|
233
|
+
+}());
|
|
234
|
+
diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
|
|
235
|
+
index b077ee386b..b4271b5951 100644
|
|
236
|
+
--- node/lib/internal/modules/cjs/loader.js
|
|
237
|
+
+++ node/lib/internal/modules/cjs/loader.js
|
|
238
|
+
@@ -95,7 +95,7 @@ const { containsModuleSyntax } = internalBinding('contextify');
|
|
239
|
+
const assert = require('internal/assert');
|
|
240
|
+
const fs = require('fs');
|
|
241
|
+
const path = require('path');
|
|
242
|
+
-const { internalModuleStat } = internalBinding('fs');
|
|
243
|
+
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); }
|
|
244
|
+
const { safeGetenv } = internalBinding('credentials');
|
|
245
|
+
const {
|
|
246
|
+
privateSymbols: {
|
|
247
|
+
diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
|
|
248
|
+
index 88c079d10d..a7eaca0574 100644
|
|
249
|
+
--- node/lib/internal/modules/package_json_reader.js
|
|
250
|
+
+++ node/lib/internal/modules/package_json_reader.js
|
|
251
|
+
@@ -12,7 +12,7 @@ const {
|
|
252
|
+
const {
|
|
253
|
+
ERR_INVALID_PACKAGE_CONFIG,
|
|
254
|
+
} = require('internal/errors').codes;
|
|
255
|
+
-const { internalModuleReadJSON } = internalBinding('fs');
|
|
256
|
+
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); }
|
|
257
|
+
const { resolve, sep, toNamespacedPath } = require('path');
|
|
258
|
+
const permission = require('internal/process/permission');
|
|
259
|
+
const { kEmptyObject } = require('internal/util');
|
|
260
|
+
diff --git node/lib/internal/process/pre_execution.js node/lib/internal/process/pre_execution.js
|
|
261
|
+
index 917ba90a1c..c69638deba 100644
|
|
262
|
+
--- node/lib/internal/process/pre_execution.js
|
|
263
|
+
+++ node/lib/internal/process/pre_execution.js
|
|
264
|
+
@@ -51,7 +51,11 @@ const {
|
|
265
|
+
},
|
|
266
|
+
} = require('internal/v8/startup_snapshot');
|
|
267
|
+
|
|
268
|
+
+let _alreadyPrepared = false;
|
|
269
|
+
+
|
|
270
|
+
function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
|
|
271
|
+
+ if (_alreadyPrepared === true) return;
|
|
272
|
+
+ _alreadyPrepared = true;
|
|
273
|
+
return prepareExecution({
|
|
274
|
+
expandArgv1,
|
|
275
|
+
initializeModules,
|
|
276
|
+
@@ -209,7 +213,8 @@ function patchProcessObject(expandArgv1) {
|
|
277
|
+
// If requested, update process.argv[1] to replace whatever the user provided with the resolved absolute file path of
|
|
278
|
+
// the entry point.
|
|
279
|
+
if (expandArgv1 && process.argv[1] &&
|
|
280
|
+
- !StringPrototypeStartsWith(process.argv[1], '-')) {
|
|
281
|
+
+ !StringPrototypeStartsWith(process.argv[1], '-') &&
|
|
282
|
+
+ process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
|
283
|
+
// Expand process.argv[1] into a full path.
|
|
284
|
+
const path = require('path');
|
|
285
|
+
try {
|
|
286
|
+
@@ -723,6 +728,7 @@ function loadPreloadModules() {
|
|
287
|
+
// For user code, we preload modules if `-r` is passed
|
|
288
|
+
const preloadModules = getOptionValue('--require');
|
|
289
|
+
if (preloadModules && preloadModules.length > 0) {
|
|
290
|
+
+ assert(false, '--require is not supported');
|
|
291
|
+
const {
|
|
292
|
+
Module: {
|
|
293
|
+
_preloadModules,
|
|
294
|
+
diff --git node/lib/vm.js node/lib/vm.js
|
|
295
|
+
index d396a3df8c..74419c83c1 100644
|
|
296
|
+
--- node/lib/vm.js
|
|
297
|
+
+++ node/lib/vm.js
|
|
298
|
+
@@ -80,6 +80,7 @@ class Script extends ContextifyScript {
|
|
299
|
+
produceCachedData = false,
|
|
300
|
+
importModuleDynamically,
|
|
301
|
+
[kParsingContext]: parsingContext,
|
|
302
|
+
+ sourceless = false,
|
|
303
|
+
} = options;
|
|
304
|
+
|
|
305
|
+
validateString(filename, 'options.filename');
|
|
306
|
+
@@ -103,7 +104,8 @@ class Script extends ContextifyScript {
|
|
307
|
+
cachedData,
|
|
308
|
+
produceCachedData,
|
|
309
|
+
parsingContext,
|
|
310
|
+
- hostDefinedOptionId);
|
|
311
|
+
+ hostDefinedOptionId,
|
|
312
|
+
+ sourceless);
|
|
313
|
+
} catch (e) {
|
|
314
|
+
throw e; /* node-do-not-add-exception-line */
|
|
315
|
+
}
|
|
316
|
+
diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
|
|
317
|
+
index de372400fd..2538afa37d 100644
|
|
318
|
+
--- node/src/inspector_agent.cc
|
|
319
|
+
+++ node/src/inspector_agent.cc
|
|
320
|
+
@@ -707,8 +707,6 @@ bool Agent::Start(const std::string& path,
|
|
321
|
+
StartIoThreadAsyncCallback));
|
|
322
|
+
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
|
323
|
+
start_io_thread_async.data = this;
|
|
324
|
+
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
|
325
|
+
- StartDebugSignalHandler();
|
|
326
|
+
|
|
327
|
+
parent_env_->AddCleanupHook([](void* data) {
|
|
328
|
+
Environment* env = static_cast<Environment*>(data);
|
|
329
|
+
diff --git node/src/node.cc node/src/node.cc
|
|
330
|
+
index a9336a1430..c4a97eb85a 100644
|
|
331
|
+
--- node/src/node.cc
|
|
332
|
+
+++ node/src/node.cc
|
|
333
|
+
@@ -322,6 +322,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
|
|
334
|
+
return env->RunSnapshotDeserializeMain();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
+ StartExecution(env, "internal/bootstrap/pkg");
|
|
338
|
+
+
|
|
339
|
+
if (env->worker_context() != nullptr) {
|
|
340
|
+
return StartExecution(env, "internal/main/worker_thread");
|
|
341
|
+
}
|
|
342
|
+
@@ -543,14 +545,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
|
|
346
|
+
-#if HAVE_INSPECTOR
|
|
347
|
+
- sigset_t sigmask;
|
|
348
|
+
- sigemptyset(&sigmask);
|
|
349
|
+
- sigaddset(&sigmask, SIGUSR1);
|
|
350
|
+
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
|
351
|
+
- CHECK_EQ(err, 0);
|
|
352
|
+
-#endif // HAVE_INSPECTOR
|
|
353
|
+
-
|
|
354
|
+
ResetSignalHandlers();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
diff --git node/src/node_contextify.cc node/src/node_contextify.cc
|
|
358
|
+
index 64860d7e56..abdb5593ba 100644
|
|
359
|
+
--- node/src/node_contextify.cc
|
|
360
|
+
+++ node/src/node_contextify.cc
|
|
361
|
+
@@ -75,6 +75,7 @@ using v8::String;
|
|
362
|
+
using v8::Symbol;
|
|
363
|
+
using v8::Uint32;
|
|
364
|
+
using v8::UnboundScript;
|
|
365
|
+
+using v8::V8;
|
|
366
|
+
using v8::Value;
|
|
367
|
+
using v8::WeakCallbackInfo;
|
|
368
|
+
|
|
369
|
+
@@ -772,13 +773,14 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
370
|
+
Local<ArrayBufferView> cached_data_buf;
|
|
371
|
+
bool produce_cached_data = false;
|
|
372
|
+
Local<Context> parsing_context = context;
|
|
373
|
+
+ bool sourceless = false;
|
|
374
|
+
|
|
375
|
+
Local<Symbol> id_symbol;
|
|
376
|
+
if (argc > 2) {
|
|
377
|
+
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
|
378
|
+
// cachedData, produceCachedData, parsingContext,
|
|
379
|
+
- // hostDefinedOptionId)
|
|
380
|
+
- CHECK_EQ(argc, 8);
|
|
381
|
+
+ // hostDefinedOptionId, sourceless)
|
|
382
|
+
+ CHECK_GE(argc, 8);
|
|
383
|
+
CHECK(args[2]->IsNumber());
|
|
384
|
+
line_offset = args[2].As<Int32>()->Value();
|
|
385
|
+
CHECK(args[3]->IsNumber());
|
|
386
|
+
@@ -799,6 +801,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
387
|
+
}
|
|
388
|
+
CHECK(args[7]->IsSymbol());
|
|
389
|
+
id_symbol = args[7].As<Symbol>();
|
|
390
|
+
+ if (argc > 8) {
|
|
391
|
+
+ CHECK(args[8]->IsBoolean());
|
|
392
|
+
+ sourceless = args[8]->IsTrue();
|
|
393
|
+
+ }
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
ContextifyScript* contextify_script =
|
|
397
|
+
@@ -847,6 +853,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
398
|
+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
|
399
|
+
Context::Scope scope(parsing_context);
|
|
400
|
+
|
|
401
|
+
+ if (sourceless && produce_cached_data) {
|
|
402
|
+
+ V8::EnableCompilationForSourcelessUse();
|
|
403
|
+
+ }
|
|
404
|
+
+
|
|
405
|
+
MaybeLocal<UnboundScript> maybe_v8_script =
|
|
406
|
+
ScriptCompiler::CompileUnboundScript(isolate, &source, compile_options);
|
|
407
|
+
|
|
408
|
+
@@ -861,6 +871,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
|
413
|
+
+ if (!source.GetCachedData()->rejected) {
|
|
414
|
+
+ V8::FixSourcelessScript(env->isolate(), v8_script);
|
|
415
|
+
+ }
|
|
416
|
+
+ }
|
|
417
|
+
contextify_script->script_.Reset(isolate, v8_script);
|
|
418
|
+
contextify_script->script_.SetWeak();
|
|
419
|
+
contextify_script->object()->SetInternalFieldForNodeCore(kUnboundScriptSlot,
|
|
420
|
+
@@ -894,6 +909,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
421
|
+
.IsNothing())
|
|
422
|
+
return;
|
|
423
|
+
|
|
424
|
+
+ if (sourceless && produce_cached_data) {
|
|
425
|
+
+ V8::DisableCompilationForSourcelessUse();
|
|
426
|
+
+ }
|
|
427
|
+
+
|
|
428
|
+
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
diff --git node/src/node_main.cc node/src/node_main.cc
|
|
432
|
+
index f66099a557..4048f6bd93 100644
|
|
433
|
+
--- node/src/node_main.cc
|
|
434
|
+
+++ node/src/node_main.cc
|
|
435
|
+
@@ -22,6 +22,8 @@
|
|
436
|
+
#include "node.h"
|
|
437
|
+
#include <cstdio>
|
|
438
|
+
|
|
439
|
+
+int reorder(int argc, char** argv);
|
|
440
|
+
+
|
|
441
|
+
#ifdef _WIN32
|
|
442
|
+
#include <windows.h>
|
|
443
|
+
#include <VersionHelpers.h>
|
|
444
|
+
@@ -88,12 +90,95 @@ int wmain(int argc, wchar_t* wargv[]) {
|
|
445
|
+
}
|
|
446
|
+
argv[argc] = nullptr;
|
|
447
|
+
// Now that conversion is done, we can finally start.
|
|
448
|
+
- return node::Start(argc, argv);
|
|
449
|
+
+ return reorder(argc, argv);
|
|
450
|
+
}
|
|
451
|
+
#else
|
|
452
|
+
// UNIX
|
|
453
|
+
|
|
454
|
+
int main(int argc, char* argv[]) {
|
|
455
|
+
+ return reorder(argc, argv);
|
|
456
|
+
+}
|
|
457
|
+
+#endif
|
|
458
|
+
+
|
|
459
|
+
+#include <string.h>
|
|
460
|
+
+
|
|
461
|
+
+int strlen2 (char* s) {
|
|
462
|
+
+ int len = 0;
|
|
463
|
+
+ while (*s) {
|
|
464
|
+
+ len += 1;
|
|
465
|
+
+ s += 1;
|
|
466
|
+
+ }
|
|
467
|
+
+ return len;
|
|
468
|
+
+}
|
|
469
|
+
+
|
|
470
|
+
+bool should_set_dummy() {
|
|
471
|
+
+#ifdef _WIN32
|
|
472
|
+
+ #define MAX_ENV_LENGTH 32767
|
|
473
|
+
+ wchar_t execpath_env[MAX_ENV_LENGTH];
|
|
474
|
+
+ DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
|
475
|
+
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
|
476
|
+
+ return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
|
|
477
|
+
+#else
|
|
478
|
+
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
|
479
|
+
+ if (!execpath_env) return true;
|
|
480
|
+
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
|
481
|
+
+#endif
|
|
482
|
+
+}
|
|
483
|
+
+
|
|
484
|
+
+// for uv_setup_args
|
|
485
|
+
+int adjacent(int argc, char** argv) {
|
|
486
|
+
+ size_t size = 0;
|
|
487
|
+
+ for (int i = 0; i < argc; i++) {
|
|
488
|
+
+ size += strlen(argv[i]) + 1;
|
|
489
|
+
+ }
|
|
490
|
+
+ char* args = new char[size];
|
|
491
|
+
+ size_t pos = 0;
|
|
492
|
+
+ for (int i = 0; i < argc; i++) {
|
|
493
|
+
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
|
494
|
+
+ argv[i] = &args[pos];
|
|
495
|
+
+ pos += strlen(argv[i]) + 1;
|
|
496
|
+
+ }
|
|
497
|
+
return node::Start(argc, argv);
|
|
498
|
+
}
|
|
499
|
+
+
|
|
500
|
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
|
501
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
502
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
503
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
|
504
|
+
+
|
|
505
|
+
+#ifdef __clang__
|
|
506
|
+
+__attribute__((optnone))
|
|
507
|
+
+#elif defined(__GNUC__)
|
|
508
|
+
+__attribute__((optimize(0)))
|
|
509
|
+
#endif
|
|
510
|
+
+
|
|
511
|
+
+int load_baked(char** nargv) {
|
|
512
|
+
+ int c = 1;
|
|
513
|
+
+
|
|
514
|
+
+ char* bakery = (char*) BAKERY;
|
|
515
|
+
+ while (true) {
|
|
516
|
+
+ size_t width = strlen2(bakery);
|
|
517
|
+
+ if (width == 0) break;
|
|
518
|
+
+ nargv[c++] = bakery;
|
|
519
|
+
+ bakery += width + 1;
|
|
520
|
+
+ }
|
|
521
|
+
+
|
|
522
|
+
+ return c;
|
|
523
|
+
+}
|
|
524
|
+
+
|
|
525
|
+
+int reorder(int argc, char** argv) {
|
|
526
|
+
+ char** nargv = new char*[argc + 64];
|
|
527
|
+
+
|
|
528
|
+
+ nargv[0] = argv[0];
|
|
529
|
+
+ int c = load_baked(nargv);
|
|
530
|
+
+
|
|
531
|
+
+ if (should_set_dummy()) {
|
|
532
|
+
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
|
533
|
+
+ }
|
|
534
|
+
+
|
|
535
|
+
+ for (int i = 1; i < argc; i++) {
|
|
536
|
+
+ nargv[c++] = argv[i];
|
|
537
|
+
+ }
|
|
538
|
+
+
|
|
539
|
+
+ return adjacent(c, nargv);
|
|
540
|
+
+}
|
|
541
|
+
diff --git node/src/node_options.cc node/src/node_options.cc
|
|
542
|
+
index 29cb7fc6b2..7a27f506f5 100644
|
|
543
|
+
--- node/src/node_options.cc
|
|
544
|
+
+++ node/src/node_options.cc
|
|
545
|
+
@@ -302,6 +302,7 @@ void Parse(
|
|
546
|
+
// TODO(addaleax): Make that unnecessary.
|
|
547
|
+
|
|
548
|
+
DebugOptionsParser::DebugOptionsParser() {
|
|
549
|
+
+ return;
|
|
550
|
+
#ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION
|
|
551
|
+
if (sea::IsSingleExecutable()) return;
|
|
552
|
+
#endif
|
|
553
|
+
diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
|
|
554
|
+
index 2655b9e694..1d951571c7 100644
|
|
555
|
+
--- node/tools/icu/icu-generic.gyp
|
|
556
|
+
+++ node/tools/icu/icu-generic.gyp
|
|
557
|
+
@@ -52,7 +52,7 @@
|
|
558
|
+
'conditions': [
|
|
559
|
+
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
|
560
|
+
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
|
561
|
+
- 'cflags_cc': [ '-frtti' ],
|
|
562
|
+
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
|
563
|
+
'cflags_cc!': [ '-fno-rtti' ],
|
|
564
|
+
}],
|
|
565
|
+
[ 'OS == "mac" or OS == "ios"', {
|