@yao-pkg/pkg-fetch 3.5.3
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/README.md +117 -0
- package/lib-es5/apply-patches.d.ts +3 -0
- package/lib-es5/apply-patches.js +91 -0
- package/lib-es5/bin.d.ts +3 -0
- package/lib-es5/bin.js +102 -0
- package/lib-es5/build.d.ts +4 -0
- package/lib-es5/build.js +436 -0
- package/lib-es5/expected-shas.json +67 -0
- package/lib-es5/expected.d.ts +2 -0
- package/lib-es5/expected.js +9 -0
- package/lib-es5/generate-expected-shas.d.ts +2 -0
- package/lib-es5/generate-expected-shas.js +83 -0
- package/lib-es5/index.d.ts +15 -0
- package/lib-es5/index.js +255 -0
- package/lib-es5/log.d.ts +20 -0
- package/lib-es5/log.js +112 -0
- package/lib-es5/places.d.ts +19 -0
- package/lib-es5/places.js +40 -0
- package/lib-es5/print-hashes.d.ts +2 -0
- package/lib-es5/print-hashes.js +13 -0
- package/lib-es5/system.d.ts +11 -0
- package/lib-es5/system.js +153 -0
- package/lib-es5/tsconfig.json +10 -0
- package/lib-es5/utils.d.ts +8 -0
- package/lib-es5/utils.js +167 -0
- package/lib-es5/verify.d.ts +2 -0
- package/lib-es5/verify.js +60 -0
- package/license.md +21 -0
- package/package.json +124 -0
- package/patches/node.v10.24.1.cpp.patch +568 -0
- package/patches/node.v12.22.11.cpp.patch +679 -0
- package/patches/node.v14.21.3.cpp.patch +560 -0
- package/patches/node.v16.19.1.cpp.patch +572 -0
- package/patches/node.v18.15.0.cpp.patch +581 -0
- package/patches/node.v19.8.1.cpp.patch +581 -0
- package/patches/node.v8.17.0.cpp.patch +549 -0
- package/patches/patches.json +9 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
diff --git node/common.gypi node/common.gypi
|
|
2
|
+
index b1d87780db..659da7c790 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 d7765ef6bd..3c15a61215 100755
|
|
16
|
+
--- node/configure.py
|
|
17
|
+
+++ node/configure.py
|
|
18
|
+
@@ -1265,9 +1265,7 @@ def configure_node(o):
|
|
19
|
+
|
|
20
|
+
o['variables']['want_separate_host_toolset'] = int(cross_compiling)
|
|
21
|
+
|
|
22
|
+
- # Enable branch protection for arm64
|
|
23
|
+
if target_arch == 'arm64':
|
|
24
|
+
- o['cflags']+=['-msign-return-address=all']
|
|
25
|
+
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
|
|
26
|
+
|
|
27
|
+
if options.node_snapshot_main is not None:
|
|
28
|
+
diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h
|
|
29
|
+
index d3e35d6ec5..6e9bbe3849 100644
|
|
30
|
+
--- node/deps/v8/include/v8-initialization.h
|
|
31
|
+
+++ node/deps/v8/include/v8-initialization.h
|
|
32
|
+
@@ -89,6 +89,10 @@ class V8_EXPORT V8 {
|
|
33
|
+
static void SetFlagsFromCommandLine(int* argc, char** argv,
|
|
34
|
+
bool remove_flags);
|
|
35
|
+
|
|
36
|
+
+ static void EnableCompilationForSourcelessUse();
|
|
37
|
+
+ static void DisableCompilationForSourcelessUse();
|
|
38
|
+
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
|
39
|
+
+
|
|
40
|
+
/** Get the version string. */
|
|
41
|
+
static const char* GetVersion();
|
|
42
|
+
|
|
43
|
+
diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
|
|
44
|
+
index a4a4381614..2998f3c49b 100644
|
|
45
|
+
--- node/deps/v8/src/api/api.cc
|
|
46
|
+
+++ node/deps/v8/src/api/api.cc
|
|
47
|
+
@@ -683,6 +683,29 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
|
48
|
+
HelpOptions(HelpOptions::kDontExit));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
+bool save_lazy;
|
|
52
|
+
+bool save_predictable;
|
|
53
|
+
+
|
|
54
|
+
+void V8::EnableCompilationForSourcelessUse() {
|
|
55
|
+
+ save_lazy = i::FLAG_lazy;
|
|
56
|
+
+ i::FLAG_lazy = false;
|
|
57
|
+
+ save_predictable = i::FLAG_predictable;
|
|
58
|
+
+ i::FLAG_predictable = true;
|
|
59
|
+
+}
|
|
60
|
+
+
|
|
61
|
+
+void V8::DisableCompilationForSourcelessUse() {
|
|
62
|
+
+ i::FLAG_lazy = save_lazy;
|
|
63
|
+
+ i::FLAG_predictable = save_predictable;
|
|
64
|
+
+}
|
|
65
|
+
+
|
|
66
|
+
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
|
67
|
+
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
|
68
|
+
+ auto function_info =
|
|
69
|
+
+ i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
|
|
70
|
+
+ i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
|
|
71
|
+
+ script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
|
|
72
|
+
+}
|
|
73
|
+
+
|
|
74
|
+
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
|
75
|
+
|
|
76
|
+
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
|
77
|
+
diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
|
|
78
|
+
index 5431deb83e..d11f04ccac 100644
|
|
79
|
+
--- node/deps/v8/src/codegen/compiler.cc
|
|
80
|
+
+++ node/deps/v8/src/codegen/compiler.cc
|
|
81
|
+
@@ -3497,7 +3497,7 @@ MaybeHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
|
|
82
|
+
maybe_script = lookup_result.script();
|
|
83
|
+
maybe_result = lookup_result.toplevel_sfi();
|
|
84
|
+
is_compiled_scope = lookup_result.is_compiled_scope();
|
|
85
|
+
- if (!maybe_result.is_null()) {
|
|
86
|
+
+ if (!maybe_result.is_null() && source->length()) {
|
|
87
|
+
compile_timer.set_hit_isolate_cache();
|
|
88
|
+
} else if (can_consume_code_cache) {
|
|
89
|
+
compile_timer.set_consuming_code_cache();
|
|
90
|
+
diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
|
|
91
|
+
index 62fe309a47..f1875ce023 100644
|
|
92
|
+
--- node/deps/v8/src/objects/js-function.cc
|
|
93
|
+
+++ node/deps/v8/src/objects/js-function.cc
|
|
94
|
+
@@ -1245,6 +1245,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
|
95
|
+
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
|
96
|
+
isolate, function, isolate->factory()->class_positions_symbol());
|
|
97
|
+
if (maybe_class_positions->IsClassPositions()) {
|
|
98
|
+
+ if (String::cast(Script::cast(shared_info->script()).source()).IsUndefined(isolate)) {
|
|
99
|
+
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
|
100
|
+
+ }
|
|
101
|
+
ClassPositions class_positions =
|
|
102
|
+
ClassPositions::cast(*maybe_class_positions);
|
|
103
|
+
int start_position = class_positions.start();
|
|
104
|
+
diff --git node/deps/v8/src/objects/shared-function-info-inl.h node/deps/v8/src/objects/shared-function-info-inl.h
|
|
105
|
+
index 43ef0d3d17..79b774463f 100644
|
|
106
|
+
--- node/deps/v8/src/objects/shared-function-info-inl.h
|
|
107
|
+
+++ node/deps/v8/src/objects/shared-function-info-inl.h
|
|
108
|
+
@@ -637,6 +637,14 @@ bool SharedFunctionInfo::ShouldFlushCode(
|
|
109
|
+
}
|
|
110
|
+
if (!data.IsBytecodeArray()) return false;
|
|
111
|
+
|
|
112
|
+
+ Object script_obj = script();
|
|
113
|
+
+ if (!script_obj.IsUndefined()) {
|
|
114
|
+
+ Script script = Script::cast(script_obj);
|
|
115
|
+
+ if (script.source().IsUndefined()) {
|
|
116
|
+
+ return false;
|
|
117
|
+
+ }
|
|
118
|
+
+ }
|
|
119
|
+
+
|
|
120
|
+
if (IsStressFlushingEnabled(code_flush_mode)) return true;
|
|
121
|
+
|
|
122
|
+
BytecodeArray bytecode = BytecodeArray::cast(data);
|
|
123
|
+
diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
|
|
124
|
+
index 8c55a6fb6e..70bf82a57d 100644
|
|
125
|
+
--- node/deps/v8/src/parsing/parsing.cc
|
|
126
|
+
+++ node/deps/v8/src/parsing/parsing.cc
|
|
127
|
+
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script,
|
|
128
|
+
Isolate* isolate, ReportStatisticsMode mode) {
|
|
129
|
+
DCHECK(info->flags().is_toplevel());
|
|
130
|
+
DCHECK_NULL(info->literal());
|
|
131
|
+
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
|
132
|
+
|
|
133
|
+
VMState<PARSER> state(isolate);
|
|
134
|
+
|
|
135
|
+
@@ -75,6 +76,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
|
136
|
+
|
|
137
|
+
// Create a character stream for the parser.
|
|
138
|
+
Handle<Script> script(Script::cast(shared_info->script()), isolate);
|
|
139
|
+
+ if (String::cast(script->source()).IsUndefined(isolate)) return false;
|
|
140
|
+
Handle<String> source(String::cast(script->source()), isolate);
|
|
141
|
+
std::unique_ptr<Utf16CharacterStream> stream(
|
|
142
|
+
ScannerStream::For(isolate, source, shared_info->StartPosition(),
|
|
143
|
+
diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
|
|
144
|
+
index 95352299f8..2dd794b855 100644
|
|
145
|
+
--- node/deps/v8/src/snapshot/code-serializer.cc
|
|
146
|
+
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
|
147
|
+
@@ -661,11 +661,7 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
|
|
151
|
+
- uint32_t expected_source_hash) const {
|
|
152
|
+
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
|
153
|
+
- if (source_hash != expected_source_hash) {
|
|
154
|
+
- return SerializedCodeSanityCheckResult::kSourceMismatch;
|
|
155
|
+
- }
|
|
156
|
+
+ uint32_t) const {
|
|
157
|
+
return SerializedCodeSanityCheckResult::kSuccess;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@@ -682,10 +678,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource()
|
|
161
|
+
if (version_hash != Version::Hash()) {
|
|
162
|
+
return SerializedCodeSanityCheckResult::kVersionMismatch;
|
|
163
|
+
}
|
|
164
|
+
- uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
|
165
|
+
- if (flags_hash != FlagList::Hash()) {
|
|
166
|
+
- return SerializedCodeSanityCheckResult::kFlagsMismatch;
|
|
167
|
+
- }
|
|
168
|
+
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
|
169
|
+
uint32_t max_payload_length = this->size_ - kHeaderSize;
|
|
170
|
+
if (payload_length > max_payload_length) {
|
|
171
|
+
diff --git node/lib/child_process.js node/lib/child_process.js
|
|
172
|
+
index 5d3e2d63a7..077b96a415 100644
|
|
173
|
+
--- node/lib/child_process.js
|
|
174
|
+
+++ node/lib/child_process.js
|
|
175
|
+
@@ -167,7 +167,7 @@ function fork(modulePath, args = [], options) {
|
|
176
|
+
throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
- return spawn(options.execPath, args, options);
|
|
180
|
+
+ return module.exports.spawn(options.execPath, args, options);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function _forkChild(fd, serializationMode) {
|
|
184
|
+
diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
|
|
185
|
+
new file mode 100644
|
|
186
|
+
index 0000000000..e97e9e524c
|
|
187
|
+
--- /dev/null
|
|
188
|
+
+++ node/lib/internal/bootstrap/pkg.js
|
|
189
|
+
@@ -0,0 +1,49 @@
|
|
190
|
+
+'use strict';
|
|
191
|
+
+
|
|
192
|
+
+const {
|
|
193
|
+
+ prepareWorkerThreadExecution,
|
|
194
|
+
+ prepareMainThreadExecution
|
|
195
|
+
+} = require('internal/process/pre_execution');
|
|
196
|
+
+
|
|
197
|
+
+if (internalBinding('worker').isMainThread) {
|
|
198
|
+
+ prepareMainThreadExecution(true);
|
|
199
|
+
+} else {
|
|
200
|
+
+ prepareWorkerThreadExecution();
|
|
201
|
+
+}
|
|
202
|
+
+
|
|
203
|
+
+(function () {
|
|
204
|
+
+ var __require__ = require;
|
|
205
|
+
+ var fs = __require__('fs');
|
|
206
|
+
+ var vm = __require__('vm');
|
|
207
|
+
+ function readPrelude (fd) {
|
|
208
|
+
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
|
209
|
+
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
|
210
|
+
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
|
211
|
+
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
|
212
|
+
+ if (!PRELUDE_POSITION) {
|
|
213
|
+
+ // no prelude - remove entrypoint from argv[1]
|
|
214
|
+
+ process.argv.splice(1, 1);
|
|
215
|
+
+ return { undoPatch: true };
|
|
216
|
+
+ }
|
|
217
|
+
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
|
218
|
+
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
|
219
|
+
+ if (read !== PRELUDE_SIZE) {
|
|
220
|
+
+ console.error('Pkg: Error reading from file.');
|
|
221
|
+
+ process.exit(1);
|
|
222
|
+
+ }
|
|
223
|
+
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
|
224
|
+
+ var fn = s.runInThisContext();
|
|
225
|
+
+ return fn(process, __require__,
|
|
226
|
+
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
|
227
|
+
+ }
|
|
228
|
+
+ (function () {
|
|
229
|
+
+ var fd = fs.openSync(process.execPath, 'r');
|
|
230
|
+
+ var result = readPrelude(fd);
|
|
231
|
+
+ if (result && result.undoPatch) {
|
|
232
|
+
+ var bindingFs = process.binding('fs');
|
|
233
|
+
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
|
234
|
+
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
|
235
|
+
+ fs.closeSync(fd);
|
|
236
|
+
+ }
|
|
237
|
+
+ }());
|
|
238
|
+
+}());
|
|
239
|
+
diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
|
|
240
|
+
index de83c69a70..f998e5a168 100644
|
|
241
|
+
--- node/lib/internal/modules/cjs/loader.js
|
|
242
|
+
+++ node/lib/internal/modules/cjs/loader.js
|
|
243
|
+
@@ -94,7 +94,7 @@ const fs = require('fs');
|
|
244
|
+
const internalFS = require('internal/fs/utils');
|
|
245
|
+
const path = require('path');
|
|
246
|
+
const { sep } = path;
|
|
247
|
+
-const { internalModuleStat } = internalBinding('fs');
|
|
248
|
+
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
|
249
|
+
const { safeGetenv } = internalBinding('credentials');
|
|
250
|
+
const {
|
|
251
|
+
privateSymbols: {
|
|
252
|
+
diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
|
|
253
|
+
index bb175d0df5..07f4834c07 100644
|
|
254
|
+
--- node/lib/internal/modules/package_json_reader.js
|
|
255
|
+
+++ node/lib/internal/modules/package_json_reader.js
|
|
256
|
+
@@ -1,7 +1,7 @@
|
|
257
|
+
'use strict';
|
|
258
|
+
|
|
259
|
+
const { SafeMap } = primordials;
|
|
260
|
+
-const { internalModuleReadJSON } = internalBinding('fs');
|
|
261
|
+
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
|
262
|
+
const { pathToFileURL } = require('url');
|
|
263
|
+
const { toNamespacedPath } = require('path');
|
|
264
|
+
|
|
265
|
+
diff --git node/lib/internal/process/pre_execution.js node/lib/internal/process/pre_execution.js
|
|
266
|
+
index ebc699ef1d..f109969a94 100644
|
|
267
|
+
--- node/lib/internal/process/pre_execution.js
|
|
268
|
+
+++ node/lib/internal/process/pre_execution.js
|
|
269
|
+
@@ -36,7 +36,12 @@ const {
|
|
270
|
+
},
|
|
271
|
+
} = require('internal/v8/startup_snapshot');
|
|
272
|
+
|
|
273
|
+
+let _alreadyPrepared = false;
|
|
274
|
+
+
|
|
275
|
+
function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
|
|
276
|
+
+ if (_alreadyPrepared === true) return;
|
|
277
|
+
+ _alreadyPrepared = true;
|
|
278
|
+
+
|
|
279
|
+
prepareExecution({
|
|
280
|
+
expandArgv1,
|
|
281
|
+
initializeModules,
|
|
282
|
+
@@ -147,7 +152,8 @@ function patchProcessObject(expandArgv1) {
|
|
283
|
+
process.argv[0] = process.execPath;
|
|
284
|
+
|
|
285
|
+
if (expandArgv1 && process.argv[1] &&
|
|
286
|
+
- !StringPrototypeStartsWith(process.argv[1], '-')) {
|
|
287
|
+
+ !StringPrototypeStartsWith(process.argv[1], '-') &&
|
|
288
|
+
+ process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
|
289
|
+
// Expand process.argv[1] into a full path.
|
|
290
|
+
const path = require('path');
|
|
291
|
+
try {
|
|
292
|
+
@@ -597,6 +603,7 @@ function loadPreloadModules() {
|
|
293
|
+
// For user code, we preload modules if `-r` is passed
|
|
294
|
+
const preloadModules = getOptionValue('--require');
|
|
295
|
+
if (preloadModules && preloadModules.length > 0) {
|
|
296
|
+
+ assert(false, '--require is not supported');
|
|
297
|
+
const {
|
|
298
|
+
Module: {
|
|
299
|
+
_preloadModules,
|
|
300
|
+
diff --git node/lib/vm.js node/lib/vm.js
|
|
301
|
+
index 19117bca5d..94a21205f1 100644
|
|
302
|
+
--- node/lib/vm.js
|
|
303
|
+
+++ node/lib/vm.js
|
|
304
|
+
@@ -79,6 +79,7 @@ class Script extends ContextifyScript {
|
|
305
|
+
produceCachedData = false,
|
|
306
|
+
importModuleDynamically,
|
|
307
|
+
[kParsingContext]: parsingContext,
|
|
308
|
+
+ sourceless = false,
|
|
309
|
+
} = options;
|
|
310
|
+
|
|
311
|
+
validateString(filename, 'options.filename');
|
|
312
|
+
@@ -103,7 +104,8 @@ class Script extends ContextifyScript {
|
|
313
|
+
columnOffset,
|
|
314
|
+
cachedData,
|
|
315
|
+
produceCachedData,
|
|
316
|
+
- parsingContext);
|
|
317
|
+
+ parsingContext,
|
|
318
|
+
+ sourceless);
|
|
319
|
+
} catch (e) {
|
|
320
|
+
throw e; /* node-do-not-add-exception-line */
|
|
321
|
+
}
|
|
322
|
+
diff --git node/node.gyp node/node.gyp
|
|
323
|
+
index 2e41a7bb22..6131b75467 100644
|
|
324
|
+
--- node/node.gyp
|
|
325
|
+
+++ node/node.gyp
|
|
326
|
+
@@ -110,6 +110,9 @@
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
'conditions': [
|
|
330
|
+
+ ['target_arch=="arm64"', {
|
|
331
|
+
+ 'cflags': ['-msign-return-address=all'], # Pointer authentication.
|
|
332
|
+
+ }],
|
|
333
|
+
['OS in "aix os400"', {
|
|
334
|
+
'ldflags': [
|
|
335
|
+
'-Wl,-bnoerrmsg',
|
|
336
|
+
diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
|
|
337
|
+
index 02842c7e5e..ff15f069c3 100644
|
|
338
|
+
--- node/src/inspector_agent.cc
|
|
339
|
+
+++ node/src/inspector_agent.cc
|
|
340
|
+
@@ -696,8 +696,6 @@ bool Agent::Start(const std::string& path,
|
|
341
|
+
StartIoThreadAsyncCallback));
|
|
342
|
+
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
|
343
|
+
start_io_thread_async.data = this;
|
|
344
|
+
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
|
345
|
+
- StartDebugSignalHandler();
|
|
346
|
+
|
|
347
|
+
parent_env_->AddCleanupHook([](void* data) {
|
|
348
|
+
Environment* env = static_cast<Environment*>(data);
|
|
349
|
+
diff --git node/src/node.cc node/src/node.cc
|
|
350
|
+
index 6bdcbb3de9..f94d3d396d 100644
|
|
351
|
+
--- node/src/node.cc
|
|
352
|
+
+++ node/src/node.cc
|
|
353
|
+
@@ -303,6 +303,8 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
|
|
354
|
+
return env->RunSnapshotDeserializeMain();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
+ StartExecution(env, "internal/bootstrap/pkg");
|
|
358
|
+
+
|
|
359
|
+
if (env->worker_context() != nullptr) {
|
|
360
|
+
return StartExecution(env, "internal/main/worker_thread");
|
|
361
|
+
}
|
|
362
|
+
@@ -506,14 +508,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
|
|
366
|
+
-#if HAVE_INSPECTOR
|
|
367
|
+
- sigset_t sigmask;
|
|
368
|
+
- sigemptyset(&sigmask);
|
|
369
|
+
- sigaddset(&sigmask, SIGUSR1);
|
|
370
|
+
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
|
371
|
+
- CHECK_EQ(err, 0);
|
|
372
|
+
-#endif // HAVE_INSPECTOR
|
|
373
|
+
-
|
|
374
|
+
ResetSignalHandlers();
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
diff --git node/src/node_contextify.cc node/src/node_contextify.cc
|
|
378
|
+
index 5aadefd84d..f9c307b178 100644
|
|
379
|
+
--- node/src/node_contextify.cc
|
|
380
|
+
+++ node/src/node_contextify.cc
|
|
381
|
+
@@ -75,6 +75,7 @@ using v8::ScriptOrigin;
|
|
382
|
+
using v8::String;
|
|
383
|
+
using v8::Uint32;
|
|
384
|
+
using v8::UnboundScript;
|
|
385
|
+
+using v8::V8;
|
|
386
|
+
using v8::Value;
|
|
387
|
+
using v8::WeakCallbackInfo;
|
|
388
|
+
using v8::WeakCallbackType;
|
|
389
|
+
@@ -771,11 +772,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
390
|
+
Local<ArrayBufferView> cached_data_buf;
|
|
391
|
+
bool produce_cached_data = false;
|
|
392
|
+
Local<Context> parsing_context = context;
|
|
393
|
+
+ bool sourceless = false;
|
|
394
|
+
|
|
395
|
+
if (argc > 2) {
|
|
396
|
+
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
|
397
|
+
// cachedData, produceCachedData, parsingContext)
|
|
398
|
+
- CHECK_EQ(argc, 7);
|
|
399
|
+
+ CHECK_EQ(argc, 8);
|
|
400
|
+
CHECK(args[2]->IsNumber());
|
|
401
|
+
line_offset = args[2].As<Int32>()->Value();
|
|
402
|
+
CHECK(args[3]->IsNumber());
|
|
403
|
+
@@ -794,6 +796,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
404
|
+
CHECK_NOT_NULL(sandbox);
|
|
405
|
+
parsing_context = sandbox->context();
|
|
406
|
+
}
|
|
407
|
+
+ sourceless = args[7]->IsTrue();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
ContextifyScript* contextify_script =
|
|
411
|
+
@@ -844,6 +847,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
412
|
+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
|
413
|
+
Context::Scope scope(parsing_context);
|
|
414
|
+
|
|
415
|
+
+ if (sourceless && produce_cached_data) {
|
|
416
|
+
+ V8::EnableCompilationForSourcelessUse();
|
|
417
|
+
+ }
|
|
418
|
+
+
|
|
419
|
+
MaybeLocal<UnboundScript> maybe_v8_script =
|
|
420
|
+
ScriptCompiler::CompileUnboundScript(isolate, &source, compile_options);
|
|
421
|
+
|
|
422
|
+
@@ -857,6 +864,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
423
|
+
"ContextifyScript::New");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
+
|
|
427
|
+
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
|
428
|
+
+ if (!source.GetCachedData()->rejected) {
|
|
429
|
+
+ V8::FixSourcelessScript(env->isolate(), v8_script);
|
|
430
|
+
+ }
|
|
431
|
+
+ }
|
|
432
|
+
+
|
|
433
|
+
contextify_script->script_.Reset(isolate, v8_script);
|
|
434
|
+
|
|
435
|
+
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data;
|
|
436
|
+
@@ -881,6 +895,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
437
|
+
.IsNothing())
|
|
438
|
+
return;
|
|
439
|
+
|
|
440
|
+
+ if (sourceless && produce_cached_data) {
|
|
441
|
+
+ V8::DisableCompilationForSourcelessUse();
|
|
442
|
+
+ }
|
|
443
|
+
+
|
|
444
|
+
TRACE_EVENT_END0(TRACING_CATEGORY_NODE2(vm, script), "ContextifyScript::New");
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
diff --git node/src/node_main.cc node/src/node_main.cc
|
|
448
|
+
index 56deaf47fa..e7ffa1baaa 100644
|
|
449
|
+
--- node/src/node_main.cc
|
|
450
|
+
+++ node/src/node_main.cc
|
|
451
|
+
@@ -22,6 +22,8 @@
|
|
452
|
+
#include "node.h"
|
|
453
|
+
#include <cstdio>
|
|
454
|
+
|
|
455
|
+
+int reorder(int argc, char** argv);
|
|
456
|
+
+
|
|
457
|
+
#ifdef _WIN32
|
|
458
|
+
#include <windows.h>
|
|
459
|
+
#include <VersionHelpers.h>
|
|
460
|
+
@@ -88,12 +90,95 @@ int wmain(int argc, wchar_t* wargv[]) {
|
|
461
|
+
}
|
|
462
|
+
argv[argc] = nullptr;
|
|
463
|
+
// Now that conversion is done, we can finally start.
|
|
464
|
+
- return node::Start(argc, argv);
|
|
465
|
+
+ return reorder(argc, argv);
|
|
466
|
+
}
|
|
467
|
+
#else
|
|
468
|
+
// UNIX
|
|
469
|
+
|
|
470
|
+
int main(int argc, char* argv[]) {
|
|
471
|
+
+ return reorder(argc, argv);
|
|
472
|
+
+}
|
|
473
|
+
+#endif
|
|
474
|
+
+
|
|
475
|
+
+#include <string.h>
|
|
476
|
+
+
|
|
477
|
+
+int strlen2 (char* s) {
|
|
478
|
+
+ int len = 0;
|
|
479
|
+
+ while (*s) {
|
|
480
|
+
+ len += 1;
|
|
481
|
+
+ s += 1;
|
|
482
|
+
+ }
|
|
483
|
+
+ return len;
|
|
484
|
+
+}
|
|
485
|
+
+
|
|
486
|
+
+bool should_set_dummy() {
|
|
487
|
+
+#ifdef _WIN32
|
|
488
|
+
+ #define MAX_ENV_LENGTH 32767
|
|
489
|
+
+ wchar_t execpath_env[MAX_ENV_LENGTH];
|
|
490
|
+
+ DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
|
491
|
+
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
|
492
|
+
+ return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
|
|
493
|
+
+#else
|
|
494
|
+
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
|
495
|
+
+ if (!execpath_env) return true;
|
|
496
|
+
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
|
497
|
+
+#endif
|
|
498
|
+
+}
|
|
499
|
+
+
|
|
500
|
+
+// for uv_setup_args
|
|
501
|
+
+int adjacent(int argc, char** argv) {
|
|
502
|
+
+ size_t size = 0;
|
|
503
|
+
+ for (int i = 0; i < argc; i++) {
|
|
504
|
+
+ size += strlen(argv[i]) + 1;
|
|
505
|
+
+ }
|
|
506
|
+
+ char* args = new char[size];
|
|
507
|
+
+ size_t pos = 0;
|
|
508
|
+
+ for (int i = 0; i < argc; i++) {
|
|
509
|
+
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
|
510
|
+
+ argv[i] = &args[pos];
|
|
511
|
+
+ pos += strlen(argv[i]) + 1;
|
|
512
|
+
+ }
|
|
513
|
+
return node::Start(argc, argv);
|
|
514
|
+
}
|
|
515
|
+
+
|
|
516
|
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
|
517
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
518
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
519
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
|
520
|
+
+
|
|
521
|
+
+#ifdef __clang__
|
|
522
|
+
+__attribute__((optnone))
|
|
523
|
+
+#elif defined(__GNUC__)
|
|
524
|
+
+__attribute__((optimize(0)))
|
|
525
|
+
#endif
|
|
526
|
+
+
|
|
527
|
+
+int load_baked(char** nargv) {
|
|
528
|
+
+ int c = 1;
|
|
529
|
+
+
|
|
530
|
+
+ char* bakery = (char*) BAKERY;
|
|
531
|
+
+ while (true) {
|
|
532
|
+
+ size_t width = strlen2(bakery);
|
|
533
|
+
+ if (width == 0) break;
|
|
534
|
+
+ nargv[c++] = bakery;
|
|
535
|
+
+ bakery += width + 1;
|
|
536
|
+
+ }
|
|
537
|
+
+
|
|
538
|
+
+ return c;
|
|
539
|
+
+}
|
|
540
|
+
+
|
|
541
|
+
+int reorder(int argc, char** argv) {
|
|
542
|
+
+ char** nargv = new char*[argc + 64];
|
|
543
|
+
+
|
|
544
|
+
+ nargv[0] = argv[0];
|
|
545
|
+
+ int c = load_baked(nargv);
|
|
546
|
+
+
|
|
547
|
+
+ if (should_set_dummy()) {
|
|
548
|
+
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
|
549
|
+
+ }
|
|
550
|
+
+
|
|
551
|
+
+ for (int i = 1; i < argc; i++) {
|
|
552
|
+
+ nargv[c++] = argv[i];
|
|
553
|
+
+ }
|
|
554
|
+
+
|
|
555
|
+
+ return adjacent(c, nargv);
|
|
556
|
+
+}
|
|
557
|
+
diff --git node/src/node_options.cc node/src/node_options.cc
|
|
558
|
+
index e7b0ba1073..530d56bd76 100644
|
|
559
|
+
--- node/src/node_options.cc
|
|
560
|
+
+++ node/src/node_options.cc
|
|
561
|
+
@@ -301,6 +301,7 @@ void Parse(
|
|
562
|
+
// TODO(addaleax): Make that unnecessary.
|
|
563
|
+
|
|
564
|
+
DebugOptionsParser::DebugOptionsParser() {
|
|
565
|
+
+ return;
|
|
566
|
+
#ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION
|
|
567
|
+
if (sea::IsSingleExecutable()) return;
|
|
568
|
+
#endif
|
|
569
|
+
diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
|
|
570
|
+
index db45e6fbdf..3e39f1fbdf 100644
|
|
571
|
+
--- node/tools/icu/icu-generic.gyp
|
|
572
|
+
+++ node/tools/icu/icu-generic.gyp
|
|
573
|
+
@@ -52,7 +52,7 @@
|
|
574
|
+
'conditions': [
|
|
575
|
+
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
|
576
|
+
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
|
577
|
+
- 'cflags_cc': [ '-frtti' ],
|
|
578
|
+
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
|
579
|
+
'cflags_cc!': [ '-fno-rtti' ],
|
|
580
|
+
}],
|
|
581
|
+
[ 'OS == "mac" or OS == "ios"', {
|