@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.
@@ -0,0 +1,679 @@
1
+ --- node/common.gypi
2
+ +++ node/common.gypi
3
+ @@ -188,17 +188,28 @@
4
+ 'v8_enable_handle_zapping': 0,
5
+ 'pgo_generate': ' -fprofile-generate ',
6
+ 'pgo_use': ' -fprofile-use -fprofile-correction ',
7
+ - 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ',
8
+ 'conditions': [
9
+ ['node_shared != "true"', {
10
+ 'MSVC_runtimeType': 0 # MultiThreaded (/MT)
11
+ }, {
12
+ 'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
13
+ }],
14
+ + ['llvm_version=="0.0"', {
15
+ + 'lto': ' -flto=4 -ffat-lto-objects ', # GCC
16
+ + }, {
17
+ + 'lto': ' -flto ', # Clang
18
+ + }],
19
+ ],
20
+ },
21
+ 'cflags': [ '-O3' ],
22
+ 'conditions': [
23
+ + ['enable_lto=="true"', {
24
+ + 'cflags': ['<(lto)'],
25
+ + 'ldflags': ['<(lto)'],
26
+ + 'xcode_settings': {
27
+ + 'LLVM_LTO': 'YES',
28
+ + },
29
+ + }],
30
+ ['OS=="solaris"', {
31
+ # pull in V8's postmortem metadata
32
+ 'ldflags': [ '-Wl,-z,allextract' ]
33
+ @@ -216,10 +227,6 @@
34
+ 'cflags': ['<(pgo_use)'],
35
+ 'ldflags': ['<(pgo_use)'],
36
+ },],
37
+ - ['enable_lto=="true"', {
38
+ - 'cflags': ['<(lto)'],
39
+ - 'ldflags': ['<(lto)'],
40
+ - },],
41
+ ],
42
+ },],
43
+ ['OS == "android"', {
44
+ --- node/configure.py
45
+ +++ node/configure.py
46
+ @@ -154,7 +154,7 @@ parser.add_option("--enable-lto",
47
+ action="store_true",
48
+ dest="enable_lto",
49
+ help="Enable compiling with lto of a binary. This feature is only available "
50
+ - "on linux with gcc and g++ 5.4.1 or newer.")
51
+ + "with gcc 5.4.1+ or clang 3.9.1+.")
52
+
53
+ parser.add_option("--link-module",
54
+ action="append",
55
+ @@ -842,6 +842,7 @@ def get_gas_version(cc):
56
+ # quite prepared to go that far yet.
57
+ def check_compiler(o):
58
+ if sys.platform == 'win32':
59
+ + o['variables']['llvm_version'] = '0.0'
60
+ if not options.openssl_no_asm and options.dest_cpu in ('x86', 'x64'):
61
+ nasm_version = get_nasm_version('nasm')
62
+ o['variables']['nasm_version'] = nasm_version
63
+ @@ -1021,12 +1022,19 @@ def configure_mips(o, target_arch):
64
+ host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big'
65
+ o['variables']['v8_host_byteorder'] = host_byteorder
66
+
67
+ +def clang_version_ge(version_checked):
68
+ + for compiler in [(CC, 'c'), (CXX, 'c++')]:
69
+ + ok, is_clang, clang_version, gcc_version = \
70
+ + try_check_compiler(compiler[0], compiler[1])
71
+ + if is_clang and clang_version >= version_checked:
72
+ + return True
73
+ + return False
74
+
75
+ def gcc_version_ge(version_checked):
76
+ for compiler in [(CC, 'c'), (CXX, 'c++')]:
77
+ - ok, is_clang, clang_version, compiler_version = \
78
+ + ok, is_clang, clang_version, gcc_version = \
79
+ try_check_compiler(compiler[0], compiler[1])
80
+ - if is_clang or compiler_version < version_checked:
81
+ + if is_clang or gcc_version < version_checked:
82
+ return False
83
+ return True
84
+
85
+ @@ -1103,18 +1111,19 @@ def configure_node(o):
86
+ o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate)
87
+ o['variables']['enable_pgo_use'] = b(options.enable_pgo_use)
88
+
89
+ - if flavor != 'linux' and (options.enable_lto):
90
+ + if flavor == 'win' and (options.enable_lto):
91
+ raise Exception(
92
+ - 'The lto option is supported only on linux.')
93
+ -
94
+ - if flavor == 'linux':
95
+ - if options.enable_lto:
96
+ - version_checked = (5, 4, 1)
97
+ - if not gcc_version_ge(version_checked):
98
+ - version_checked_str = ".".join(map(str, version_checked))
99
+ - raise Exception(
100
+ - 'The option --enable-lto is supported for gcc and gxx %s'
101
+ - ' or newer only.' % (version_checked_str))
102
+ + 'Use Link Time Code Generation instead.')
103
+ +
104
+ + if options.enable_lto:
105
+ + gcc_version_checked = (5, 4, 1)
106
+ + clang_version_checked = (3, 9, 1)
107
+ + if not gcc_version_ge(gcc_version_checked) and not clang_version_ge(clang_version_checked):
108
+ + gcc_version_checked_str = ".".join(map(str, gcc_version_checked))
109
+ + clang_version_checked_str = ".".join(map(str, clang_version_checked))
110
+ + raise Exception(
111
+ + 'The option --enable-lto is supported for gcc %s+'
112
+ + 'or clang %s+ only.' % (gcc_version_checked_str, clang_version_checked_str))
113
+
114
+ o['variables']['enable_lto'] = b(options.enable_lto)
115
+
116
+ --- node/deps/v8/include/v8.h
117
+ +++ node/deps/v8/include/v8.h
118
+ @@ -9047,6 +9047,10 @@ class V8_EXPORT V8 {
119
+ char** argv,
120
+ bool remove_flags);
121
+
122
+ + static void EnableCompilationForSourcelessUse();
123
+ + static void DisableCompilationForSourcelessUse();
124
+ + static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
125
+ +
126
+ /** Get the version string. */
127
+ static const char* GetVersion();
128
+
129
+ --- node/deps/v8/src/api/api.cc
130
+ +++ node/deps/v8/src/api/api.cc
131
+ @@ -915,6 +915,34 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
132
+ i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
133
+ }
134
+
135
+ +
136
+ +bool save_lazy;
137
+ +bool save_predictable;
138
+ +
139
+ +
140
+ +void V8::EnableCompilationForSourcelessUse() {
141
+ + save_lazy = i::FLAG_lazy;
142
+ + i::FLAG_lazy = false;
143
+ + save_predictable = i::FLAG_predictable;
144
+ + i::FLAG_predictable = true;
145
+ +}
146
+ +
147
+ +
148
+ +void V8::DisableCompilationForSourcelessUse() {
149
+ + i::FLAG_lazy = save_lazy;
150
+ + i::FLAG_predictable = save_predictable;
151
+ +}
152
+ +
153
+ +
154
+ +void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
155
+ + auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
156
+ + auto function_info =
157
+ + i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(*unbound_script));
158
+ + i::Handle<i::Script> script(i::Script::cast(function_info->script()), isolate);
159
+ + script->set_source(i::ReadOnlyRoots(isolate).undefined_value());
160
+ +}
161
+ +
162
+ +
163
+ RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
164
+
165
+ RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
166
+ --- node/deps/v8/src/codegen/compiler.cc
167
+ +++ node/deps/v8/src/codegen/compiler.cc
168
+ @@ -2010,7 +2010,7 @@ MaybeHandle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
169
+ source, script_details.name_obj, script_details.line_offset,
170
+ script_details.column_offset, origin_options, isolate->native_context(),
171
+ language_mode);
172
+ - if (!maybe_result.is_null()) {
173
+ + if (!maybe_result.is_null() && source_length) {
174
+ compile_timer.set_hit_isolate_cache();
175
+ } else if (can_consume_code_cache) {
176
+ compile_timer.set_consuming_code_cache();
177
+ --- node/deps/v8/src/objects/js-objects.cc
178
+ +++ node/deps/v8/src/objects/js-objects.cc
179
+ @@ -5480,6 +5480,9 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
180
+ Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
181
+ function, isolate->factory()->class_positions_symbol());
182
+ if (maybe_class_positions->IsClassPositions()) {
183
+ + if (String::cast(Script::cast(shared_info->script()).source())->IsUndefined(isolate)) {
184
+ + return isolate->factory()->NewStringFromAsciiChecked("class {}");
185
+ + }
186
+ ClassPositions class_positions =
187
+ ClassPositions::cast(*maybe_class_positions);
188
+ int start_position = class_positions.start();
189
+ --- node/deps/v8/src/objects/shared-function-info-inl.h
190
+ +++ node/deps/v8/src/objects/shared-function-info-inl.h
191
+ @@ -508,6 +508,14 @@ bool SharedFunctionInfo::ShouldFlushBytecode(BytecodeFlushMode mode) {
192
+ Object data = function_data();
193
+ if (!data.IsBytecodeArray()) return false;
194
+
195
+ + Object script_obj = script();
196
+ + if (!script_obj.IsUndefined()) {
197
+ + Script script = Script::cast(script_obj);
198
+ + if (script.source().IsUndefined()) {
199
+ + return false;
200
+ + }
201
+ + }
202
+ +
203
+ if (mode == BytecodeFlushMode::kStressFlushBytecode) return true;
204
+
205
+ BytecodeArray bytecode = BytecodeArray::cast(data);
206
+ --- node/deps/v8/src/parsing/parsing.cc
207
+ +++ node/deps/v8/src/parsing/parsing.cc
208
+ @@ -22,6 +22,7 @@ bool ParseProgram(ParseInfo* info, Isolate* isolate,
209
+ ReportErrorsAndStatisticsMode mode) {
210
+ DCHECK(info->is_toplevel());
211
+ DCHECK_NULL(info->literal());
212
+ + if (String::cast(info->script()->source())->IsUndefined(isolate)) return false;
213
+
214
+ VMState<PARSER> state(isolate);
215
+
216
+ @@ -62,6 +63,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
217
+ DCHECK(!info->is_toplevel());
218
+ DCHECK(!shared_info.is_null());
219
+ DCHECK_NULL(info->literal());
220
+ + if (String::cast(info->script()->source())->IsUndefined(isolate)) return false;
221
+
222
+ // Create a character stream for the parser.
223
+ Handle<String> source(String::cast(info->script()->source()), isolate);
224
+ --- node/deps/v8/src/snapshot/code-serializer.cc
225
+ +++ node/deps/v8/src/snapshot/code-serializer.cc
226
+ @@ -412,22 +412,35 @@ SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
227
+ Isolate* isolate, uint32_t expected_source_hash) const {
228
+ if (this->size_ < kHeaderSize) return INVALID_HEADER;
229
+ uint32_t magic_number = GetMagicNumber();
230
+ - if (magic_number != kMagicNumber) return MAGIC_NUMBER_MISMATCH;
231
+ + if (magic_number != kMagicNumber) {
232
+ + // base::OS::PrintError("Pkg: MAGIC_NUMBER_MISMATCH\n"); // TODO enable after solving v8-cache/ncc issue
233
+ + return MAGIC_NUMBER_MISMATCH;
234
+ + }
235
+ uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
236
+ - uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
237
+ uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
238
+ uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
239
+ uint32_t c1 = GetHeaderValue(kChecksumPartAOffset);
240
+ uint32_t c2 = GetHeaderValue(kChecksumPartBOffset);
241
+ - if (version_hash != Version::Hash()) return VERSION_MISMATCH;
242
+ - if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
243
+ - if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
244
+ + if (version_hash != Version::Hash()) {
245
+ + base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
246
+ + return VERSION_MISMATCH;
247
+ + }
248
+ + if (flags_hash != FlagList::Hash()) {
249
+ + // base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
250
+ + return FLAGS_MISMATCH;
251
+ + }
252
+ uint32_t max_payload_length =
253
+ this->size_ -
254
+ POINTER_SIZE_ALIGN(kHeaderSize +
255
+ GetHeaderValue(kNumReservationsOffset) * kInt32Size);
256
+ - if (payload_length > max_payload_length) return LENGTH_MISMATCH;
257
+ - if (!Checksum(ChecksummedContent()).Check(c1, c2)) return CHECKSUM_MISMATCH;
258
+ + if (payload_length > max_payload_length) {
259
+ + base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
260
+ + return LENGTH_MISMATCH;
261
+ + }
262
+ + if (!Checksum(ChecksummedContent()).Check(c1, c2)) {
263
+ + base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
264
+ + return CHECKSUM_MISMATCH;
265
+ + }
266
+ return CHECK_SUCCESS;
267
+ }
268
+
269
+ --- node/lib/child_process.js
270
+ +++ node/lib/child_process.js
271
+ @@ -118,7 +118,7 @@ function fork(modulePath /* , args, options */) {
272
+ options.execPath = options.execPath || process.execPath;
273
+ options.shell = false;
274
+
275
+ - return spawn(options.execPath, args, options);
276
+ + return module.exports.spawn(options.execPath, args, options);
277
+ }
278
+
279
+ function _forkChild(fd, serializationMode) {
280
+ index 0000000000..fb2d47f52b
281
+ --- /dev/null
282
+ +++ node/lib/internal/bootstrap/pkg.js
283
+ @@ -0,0 +1,44 @@
284
+ +'use strict';
285
+ +
286
+ +const {
287
+ + prepareMainThreadExecution
288
+ +} = require('internal/bootstrap/pre_execution');
289
+ +
290
+ +prepareMainThreadExecution(true);
291
+ +
292
+ +(function () {
293
+ + var __require__ = require;
294
+ + var fs = __require__('fs');
295
+ + var vm = __require__('vm');
296
+ + function readPrelude (fd) {
297
+ + var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
298
+ + var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
299
+ + var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
300
+ + var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
301
+ + if (!PRELUDE_POSITION) {
302
+ + // no prelude - remove entrypoint from argv[1]
303
+ + process.argv.splice(1, 1);
304
+ + return { undoPatch: true };
305
+ + }
306
+ + var prelude = Buffer.alloc(PRELUDE_SIZE);
307
+ + var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
308
+ + if (read !== PRELUDE_SIZE) {
309
+ + console.error('Pkg: Error reading from file.');
310
+ + process.exit(1);
311
+ + }
312
+ + var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
313
+ + var fn = s.runInThisContext();
314
+ + return fn(process, __require__,
315
+ + console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
316
+ + }
317
+ + (function () {
318
+ + var fd = fs.openSync(process.execPath, 'r');
319
+ + var result = readPrelude(fd);
320
+ + if (result && result.undoPatch) {
321
+ + var bindingFs = process.binding('fs');
322
+ + fs.internalModuleStat = bindingFs.internalModuleStat;
323
+ + fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
324
+ + fs.closeSync(fd);
325
+ + }
326
+ + }());
327
+ +}());
328
+ --- node/lib/internal/bootstrap/pre_execution.js
329
+ +++ node/lib/internal/bootstrap/pre_execution.js
330
+ @@ -14,7 +14,12 @@ const { Buffer } = require('buffer');
331
+ const { ERR_MANIFEST_ASSERT_INTEGRITY } = require('internal/errors').codes;
332
+ const assert = require('internal/assert');
333
+
334
+ +let _alreadyPrepared = false;
335
+ +
336
+ function prepareMainThreadExecution(expandArgv1 = false) {
337
+ + if (_alreadyPrepared === true) return;
338
+ + _alreadyPrepared = true;
339
+ +
340
+ // Patch the process object with legacy properties and normalizations
341
+ patchProcessObject(expandArgv1);
342
+ setupTraceCategoryState();
343
+ @@ -89,7 +94,7 @@ function patchProcessObject(expandArgv1) {
344
+ });
345
+ process.argv[0] = process.execPath;
346
+
347
+ - if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-')) {
348
+ + if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-') && process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
349
+ // Expand process.argv[1] into a full path.
350
+ const path = require('path');
351
+ try {
352
+ --- node/lib/internal/modules/cjs/loader.js
353
+ +++ node/lib/internal/modules/cjs/loader.js
354
+ @@ -66,7 +66,7 @@ const fs = require('fs');
355
+ const internalFS = require('internal/fs/utils');
356
+ const path = require('path');
357
+ const { sep } = path;
358
+ -const { internalModuleStat } = internalBinding('fs');
359
+ +const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
360
+ const packageJsonReader = require('internal/modules/package_json_reader');
361
+ const { safeGetenv } = internalBinding('credentials');
362
+ const {
363
+ --- node/lib/internal/modules/package_json_reader.js
364
+ +++ node/lib/internal/modules/package_json_reader.js
365
+ @@ -1,7 +1,7 @@
366
+ 'use strict';
367
+
368
+ const { SafeMap } = primordials;
369
+ -const { internalModuleReadJSON } = internalBinding('fs');
370
+ +const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
371
+ const { pathToFileURL } = require('url');
372
+ const { toNamespacedPath } = require('path');
373
+
374
+ --- node/lib/vm.js
375
+ +++ node/lib/vm.js
376
+ @@ -64,6 +64,7 @@ class Script extends ContextifyScript {
377
+ produceCachedData = false,
378
+ importModuleDynamically,
379
+ [kParsingContext]: parsingContext,
380
+ + sourceless = false,
381
+ } = options;
382
+
383
+ validateString(filename, 'options.filename');
384
+ @@ -91,7 +92,8 @@ class Script extends ContextifyScript {
385
+ columnOffset,
386
+ cachedData,
387
+ produceCachedData,
388
+ - parsingContext);
389
+ + parsingContext,
390
+ + sourceless);
391
+ } catch (e) {
392
+ throw e; /* node-do-not-add-exception-line */
393
+ }
394
+ --- node/node.gyp
395
+ +++ node/node.gyp
396
+ @@ -30,6 +30,7 @@
397
+ 'lib/internal/bootstrap/environment.js',
398
+ 'lib/internal/bootstrap/loaders.js',
399
+ 'lib/internal/bootstrap/node.js',
400
+ + 'lib/internal/bootstrap/pkg.js',
401
+ 'lib/internal/bootstrap/pre_execution.js',
402
+ 'lib/internal/bootstrap/switches/does_own_process_state.js',
403
+ 'lib/internal/bootstrap/switches/does_not_own_process_state.js',
404
+ @@ -430,6 +431,19 @@
405
+ 'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
406
+ },
407
+ }],
408
+ + [ 'enable_lto=="true"', {
409
+ + 'xcode_settings': {
410
+ + 'OTHER_LDFLAGS': [
411
+ + # man ld -export_dynamic:
412
+ + # Preserves all global symbols in main executables during LTO.
413
+ + # Without this option, Link Time Optimization is allowed to
414
+ + # inline and remove global functions. This option is used when
415
+ + # a main executable may load a plug-in which requires certain
416
+ + # symbols from the main executable.
417
+ + '-Wl,-export_dynamic',
418
+ + ],
419
+ + },
420
+ + }],
421
+ ['OS=="win"', {
422
+ 'libraries': [
423
+ 'Dbghelp.lib',
424
+ --- node/src/inspector_agent.cc
425
+ +++ node/src/inspector_agent.cc
426
+ @@ -760,8 +760,6 @@ bool Agent::Start(const std::string& path,
427
+ StartIoThreadAsyncCallback));
428
+ uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
429
+ start_io_thread_async.data = this;
430
+ - // Ignore failure, SIGUSR1 won't work, but that should not block node start.
431
+ - StartDebugSignalHandler();
432
+
433
+ parent_env_->AddCleanupHook([](void* data) {
434
+ Environment* env = static_cast<Environment*>(data);
435
+ --- node/src/node.cc
436
+ +++ node/src/node.cc
437
+ @@ -332,6 +332,9 @@ MaybeLocal<Value> Environment::BootstrapNode() {
438
+ return scope.EscapeMaybe(result);
439
+ }
440
+
441
+ +static
442
+ +MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id);
443
+ +
444
+ MaybeLocal<Value> Environment::RunBootstrapping() {
445
+ EscapableHandleScope scope(isolate_);
446
+
447
+ @@ -355,6 +358,8 @@ MaybeLocal<Value> Environment::RunBootstrapping() {
448
+
449
+ set_has_run_bootstrapping_code(true);
450
+
451
+ + USE(StartExecution(this, "internal/bootstrap/pkg"));
452
+ +
453
+ return scope.Escape(result);
454
+ }
455
+
456
+ @@ -515,13 +520,6 @@ static struct {
457
+
458
+ inline void PlatformInit() {
459
+ #ifdef __POSIX__
460
+ -#if HAVE_INSPECTOR
461
+ - sigset_t sigmask;
462
+ - sigemptyset(&sigmask);
463
+ - sigaddset(&sigmask, SIGUSR1);
464
+ - const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
465
+ -#endif // HAVE_INSPECTOR
466
+ -
467
+ // Make sure file descriptors 0-2 are valid before we start logging anything.
468
+ for (auto& s : stdio) {
469
+ const int fd = &s - stdio;
470
+ @@ -537,10 +535,6 @@ inline void PlatformInit() {
471
+ ABORT();
472
+ }
473
+
474
+ -#if HAVE_INSPECTOR
475
+ - CHECK_EQ(err, 0);
476
+ -#endif // HAVE_INSPECTOR
477
+ -
478
+ // TODO(addaleax): NODE_SHARED_MODE does not really make sense here.
479
+ #ifndef NODE_SHARED_MODE
480
+ // Restore signal dispositions, the parent process may have changed them.
481
+ --- node/src/node_contextify.cc
482
+ +++ node/src/node_contextify.cc
483
+ @@ -69,6 +69,7 @@ using v8::ScriptOrModule;
484
+ using v8::String;
485
+ using v8::Uint32;
486
+ using v8::UnboundScript;
487
+ +using v8::V8;
488
+ using v8::Value;
489
+ using v8::WeakCallbackInfo;
490
+ using v8::WeakCallbackType;
491
+ @@ -660,11 +661,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
492
+ Local<ArrayBufferView> cached_data_buf;
493
+ bool produce_cached_data = false;
494
+ Local<Context> parsing_context = context;
495
+ + bool sourceless = false;
496
+
497
+ if (argc > 2) {
498
+ // new ContextifyScript(code, filename, lineOffset, columnOffset,
499
+ // cachedData, produceCachedData, parsingContext)
500
+ - CHECK_EQ(argc, 7);
501
+ + CHECK_EQ(argc, 8);
502
+ CHECK(args[2]->IsNumber());
503
+ line_offset = args[2].As<Integer>();
504
+ CHECK(args[3]->IsNumber());
505
+ @@ -683,6 +685,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
506
+ CHECK_NOT_NULL(sandbox);
507
+ parsing_context = sandbox->context();
508
+ }
509
+ + sourceless = args[7]->IsTrue();
510
+ } else {
511
+ line_offset = Integer::New(isolate, 0);
512
+ column_offset = Integer::New(isolate, 0);
513
+ @@ -737,6 +740,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
514
+ ShouldNotAbortOnUncaughtScope no_abort_scope(env);
515
+ Context::Scope scope(parsing_context);
516
+
517
+ + if (sourceless && produce_cached_data) {
518
+ + V8::EnableCompilationForSourcelessUse();
519
+ + }
520
+ +
521
+ MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
522
+ isolate,
523
+ &source,
524
+ @@ -753,6 +760,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
525
+ contextify_script);
526
+ return;
527
+ }
528
+ +
529
+ + if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
530
+ + if (!source.GetCachedData()->rejected) {
531
+ + V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
532
+ + }
533
+ + }
534
+ +
535
+ contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
536
+
537
+ if (compile_options == ScriptCompiler::kConsumeCodeCache) {
538
+ @@ -778,6 +792,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
539
+ env->cached_data_produced_string(),
540
+ Boolean::New(isolate, cached_data_produced)).Check();
541
+ }
542
+ +
543
+ + if (sourceless && produce_cached_data) {
544
+ + V8::DisableCompilationForSourcelessUse();
545
+ + }
546
+ +
547
+ TRACE_EVENT_NESTABLE_ASYNC_END0(
548
+ TRACING_CATEGORY_NODE2(vm, script),
549
+ "ContextifyScript::New",
550
+ --- node/src/node_main.cc
551
+ +++ node/src/node_main.cc
552
+ @@ -22,6 +22,8 @@
553
+ #include "node.h"
554
+ #include <cstdio>
555
+
556
+ +int reorder(int argc, char** argv);
557
+ +
558
+ #ifdef _WIN32
559
+ #include <windows.h>
560
+ #include <VersionHelpers.h>
561
+ @@ -69,7 +71,7 @@ int wmain(int argc, wchar_t* wargv[]) {
562
+ }
563
+ argv[argc] = nullptr;
564
+ // Now that conversion is done, we can finally start.
565
+ - return node::Start(argc, argv);
566
+ + return reorder(argc, argv);
567
+ }
568
+ #else
569
+ // UNIX
570
+ @@ -123,6 +125,88 @@ int main(int argc, char* argv[]) {
571
+ // calls elsewhere in the program (e.g., any logging from V8.)
572
+ setvbuf(stdout, nullptr, _IONBF, 0);
573
+ setvbuf(stderr, nullptr, _IONBF, 0);
574
+ + return reorder(argc, argv);
575
+ +}
576
+ +#endif
577
+ +
578
+ +#include <string.h>
579
+ +
580
+ +int strlen2 (char* s) {
581
+ + int len = 0;
582
+ + while (*s) {
583
+ + len += 1;
584
+ + s += 1;
585
+ + }
586
+ + return len;
587
+ +}
588
+ +
589
+ +bool should_set_dummy() {
590
+ +#ifdef _WIN32
591
+ + #define MAX_ENV_LENGTH 32767
592
+ + char execpath_env[MAX_ENV_LENGTH];
593
+ + DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
594
+ + if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
595
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
596
+ +#else
597
+ + const char* execpath_env = getenv("PKG_EXECPATH");
598
+ + if (!execpath_env) return true;
599
+ + return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
600
+ +#endif
601
+ +}
602
+ +
603
+ +// for uv_setup_args
604
+ +int adjacent(int argc, char** argv) {
605
+ + size_t size = 0;
606
+ + for (int i = 0; i < argc; i++) {
607
+ + size += strlen(argv[i]) + 1;
608
+ + }
609
+ + char* args = new char[size];
610
+ + size_t pos = 0;
611
+ + for (int i = 0; i < argc; i++) {
612
+ + memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
613
+ + argv[i] = &args[pos];
614
+ + pos += strlen(argv[i]) + 1;
615
+ + }
616
+ return node::Start(argc, argv);
617
+ }
618
+ +
619
+ +volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
620
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
621
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
622
+ + "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
623
+ +
624
+ +#ifdef __clang__
625
+ +__attribute__((optnone))
626
+ +#elif defined(__GNUC__)
627
+ +__attribute__((optimize(0)))
628
+ #endif
629
+ +int load_baked(char** nargv) {
630
+ + int c = 1;
631
+ +
632
+ + char* bakery = (char*) BAKERY;
633
+ + while (true) {
634
+ + size_t width = strlen2(bakery);
635
+ + if (width == 0) break;
636
+ + nargv[c++] = bakery;
637
+ + bakery += width + 1;
638
+ + }
639
+ +
640
+ + return c;
641
+ +}
642
+ +
643
+ +int reorder(int argc, char** argv) {
644
+ + char** nargv = new char*[argc + 64];
645
+ +
646
+ + nargv[0] = argv[0];
647
+ + int c = load_baked(nargv);
648
+ +
649
+ + if (should_set_dummy()) {
650
+ + nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
651
+ + }
652
+ +
653
+ + for (int i = 1; i < argc; i++) {
654
+ + nargv[c++] = argv[i];
655
+ + }
656
+ +
657
+ + return adjacent(c, nargv);
658
+ +}
659
+ --- node/src/node_options.cc
660
+ +++ node/src/node_options.cc
661
+ @@ -234,6 +234,7 @@ void Parse(
662
+ // TODO(addaleax): Make that unnecessary.
663
+
664
+ DebugOptionsParser::DebugOptionsParser() {
665
+ + return;
666
+ AddOption("--inspect-port",
667
+ "set host:port for inspector",
668
+ &DebugOptions::host_port,
669
+ --- node/tools/icu/icu-generic.gyp
670
+ +++ node/tools/icu/icu-generic.gyp
671
+ @@ -52,7 +52,7 @@
672
+ 'conditions': [
673
+ [ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
674
+ 'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
675
+ - 'cflags_cc': [ '-frtti' ],
676
+ + 'cflags_cc': [ '-frtti', '-fno-lto' ],
677
+ 'cflags_cc!': [ '-fno-rtti' ],
678
+ }],
679
+ [ 'OS == "mac" or OS == "ios"', {