@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,568 @@
|
|
|
1
|
+
--- node/deps/v8/include/v8.h
|
|
2
|
+
+++ node/deps/v8/include/v8.h
|
|
3
|
+
@@ -8137,10 +8137,14 @@
|
|
4
|
+
*/
|
|
5
|
+
static void SetFlagsFromCommandLine(int* argc,
|
|
6
|
+
char** argv,
|
|
7
|
+
bool remove_flags);
|
|
8
|
+
|
|
9
|
+
+ static void EnableCompilationForSourcelessUse();
|
|
10
|
+
+ static void DisableCompilationForSourcelessUse();
|
|
11
|
+
+ static void FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script);
|
|
12
|
+
+
|
|
13
|
+
/** Get the version string. */
|
|
14
|
+
static const char* GetVersion();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializes V8. This function needs to be called before the first Isolate
|
|
18
|
+
--- node/deps/v8/src/api.cc
|
|
19
|
+
+++ node/deps/v8/src/api.cc
|
|
20
|
+
@@ -914,10 +914,42 @@
|
|
21
|
+
|
|
22
|
+
void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
|
23
|
+
i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
+bool save_lazy;
|
|
27
|
+
+bool save_predictable;
|
|
28
|
+
+
|
|
29
|
+
+
|
|
30
|
+
+void V8::EnableCompilationForSourcelessUse() {
|
|
31
|
+
+ save_lazy = i::FLAG_lazy;
|
|
32
|
+
+ i::FLAG_lazy = false;
|
|
33
|
+
+ save_predictable = i::FLAG_predictable;
|
|
34
|
+
+ i::FLAG_predictable = true;
|
|
35
|
+
+ i::CpuFeatures::Reinitialize();
|
|
36
|
+
+ i::CpuFeatures::Probe(true);
|
|
37
|
+
+}
|
|
38
|
+
+
|
|
39
|
+
+
|
|
40
|
+
+void V8::DisableCompilationForSourcelessUse() {
|
|
41
|
+
+ i::FLAG_lazy = save_lazy;
|
|
42
|
+
+ i::FLAG_predictable = save_predictable;
|
|
43
|
+
+ i::CpuFeatures::Reinitialize();
|
|
44
|
+
+ i::CpuFeatures::Probe(false);
|
|
45
|
+
+}
|
|
46
|
+
+
|
|
47
|
+
+
|
|
48
|
+
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> script) {
|
|
49
|
+
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
|
50
|
+
+ auto object = i::Handle<i::HeapObject>::cast(Utils::OpenHandle(*script));
|
|
51
|
+
+ i::Handle<i::SharedFunctionInfo> function_info(
|
|
52
|
+
+ i::SharedFunctionInfo::cast(*object), object->GetIsolate());
|
|
53
|
+
+ auto s = reinterpret_cast<i::Script*>(function_info->script());
|
|
54
|
+
+ s->set_source(isolate->heap()->undefined_value());
|
|
55
|
+
+}
|
|
56
|
+
+
|
|
57
|
+
+
|
|
58
|
+
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
|
59
|
+
|
|
60
|
+
RegisteredExtension::RegisteredExtension(Extension* extension)
|
|
61
|
+
: extension_(extension) { }
|
|
62
|
+
|
|
63
|
+
--- node/deps/v8/src/assembler.h
|
|
64
|
+
+++ node/deps/v8/src/assembler.h
|
|
65
|
+
@@ -302,10 +302,15 @@
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static void PrintTarget();
|
|
69
|
+
static void PrintFeatures();
|
|
70
|
+
|
|
71
|
+
+ static void Reinitialize() {
|
|
72
|
+
+ supported_ = 0;
|
|
73
|
+
+ initialized_ = false;
|
|
74
|
+
+ }
|
|
75
|
+
+
|
|
76
|
+
private:
|
|
77
|
+
friend class ExternalReference;
|
|
78
|
+
friend class AssemblerBase;
|
|
79
|
+
// Flush instruction cache.
|
|
80
|
+
static void FlushICache(void* start, size_t size);
|
|
81
|
+
--- node/deps/v8/src/objects.cc
|
|
82
|
+
+++ node/deps/v8/src/objects.cc
|
|
83
|
+
@@ -13179,10 +13179,13 @@
|
|
84
|
+
|
|
85
|
+
// Check if we should print {function} as a class.
|
|
86
|
+
Handle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
|
87
|
+
function, isolate->factory()->class_positions_symbol());
|
|
88
|
+
if (maybe_class_positions->IsTuple2()) {
|
|
89
|
+
+ if (Script::cast(shared_info->script())->source()->IsUndefined(isolate)) {
|
|
90
|
+
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
|
91
|
+
+ }
|
|
92
|
+
Tuple2* class_positions = Tuple2::cast(*maybe_class_positions);
|
|
93
|
+
int start_position = Smi::ToInt(class_positions->value1());
|
|
94
|
+
int end_position = Smi::ToInt(class_positions->value2());
|
|
95
|
+
Handle<String> script_source(
|
|
96
|
+
String::cast(Script::cast(shared_info->script())->source()), isolate);
|
|
97
|
+
--- node/deps/v8/src/parsing/parsing.cc
|
|
98
|
+
+++ node/deps/v8/src/parsing/parsing.cc
|
|
99
|
+
@@ -18,10 +18,11 @@
|
|
100
|
+
namespace parsing {
|
|
101
|
+
|
|
102
|
+
bool ParseProgram(ParseInfo* info, Isolate* isolate) {
|
|
103
|
+
DCHECK(info->is_toplevel());
|
|
104
|
+
DCHECK_NULL(info->literal());
|
|
105
|
+
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
|
106
|
+
|
|
107
|
+
VMState<PARSER> state(isolate);
|
|
108
|
+
|
|
109
|
+
// Create a character stream for the parser.
|
|
110
|
+
Handle<String> source(String::cast(info->script()->source()), isolate);
|
|
111
|
+
@@ -55,10 +56,11 @@
|
|
112
|
+
bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info,
|
|
113
|
+
Isolate* isolate) {
|
|
114
|
+
DCHECK(!info->is_toplevel());
|
|
115
|
+
DCHECK(!shared_info.is_null());
|
|
116
|
+
DCHECK_NULL(info->literal());
|
|
117
|
+
+ if (info->script()->source()->IsUndefined(isolate)) return false;
|
|
118
|
+
|
|
119
|
+
// Create a character stream for the parser.
|
|
120
|
+
Handle<String> source(String::cast(info->script()->source()), isolate);
|
|
121
|
+
source = String::Flatten(source);
|
|
122
|
+
isolate->counters()->total_parse_size()->Increment(source->length());
|
|
123
|
+
--- node/deps/v8/src/snapshot/code-serializer.cc
|
|
124
|
+
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
|
125
|
+
@@ -401,31 +401,46 @@
|
|
126
|
+
|
|
127
|
+
SerializedCodeData::SanityCheckResult SerializedCodeData::SanityCheck(
|
|
128
|
+
Isolate* isolate, uint32_t expected_source_hash) const {
|
|
129
|
+
if (this->size_ < kHeaderSize) return INVALID_HEADER;
|
|
130
|
+
uint32_t magic_number = GetMagicNumber();
|
|
131
|
+
- if (magic_number != ComputeMagicNumber(isolate)) return MAGIC_NUMBER_MISMATCH;
|
|
132
|
+
+ if (magic_number != ComputeMagicNumber(isolate)) {
|
|
133
|
+
+ // base::OS::PrintError("Pkg: MAGIC_NUMBER_MISMATCH\n"); // TODO enable after solving v8-cache/ncc issue
|
|
134
|
+
+ return MAGIC_NUMBER_MISMATCH;
|
|
135
|
+
+ }
|
|
136
|
+
uint32_t version_hash = GetHeaderValue(kVersionHashOffset);
|
|
137
|
+
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
|
138
|
+
uint32_t cpu_features = GetHeaderValue(kCpuFeaturesOffset);
|
|
139
|
+
uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
|
140
|
+
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
|
141
|
+
uint32_t c1 = GetHeaderValue(kChecksum1Offset);
|
|
142
|
+
uint32_t c2 = GetHeaderValue(kChecksum2Offset);
|
|
143
|
+
- if (version_hash != Version::Hash()) return VERSION_MISMATCH;
|
|
144
|
+
- if (source_hash != expected_source_hash) return SOURCE_MISMATCH;
|
|
145
|
+
- if (cpu_features != static_cast<uint32_t>(CpuFeatures::SupportedFeatures())) {
|
|
146
|
+
+ if (version_hash != Version::Hash()) {
|
|
147
|
+
+ base::OS::PrintError("Pkg: VERSION_MISMATCH\n");
|
|
148
|
+
+ return VERSION_MISMATCH;
|
|
149
|
+
+ }
|
|
150
|
+
+ uint32_t host_features = static_cast<uint32_t>(CpuFeatures::SupportedFeatures());
|
|
151
|
+
+ if (cpu_features & (~host_features)) {
|
|
152
|
+
+ base::OS::PrintError("Pkg: CPU_FEATURES_MISMATCH\n");
|
|
153
|
+
return CPU_FEATURES_MISMATCH;
|
|
154
|
+
}
|
|
155
|
+
- if (flags_hash != FlagList::Hash()) return FLAGS_MISMATCH;
|
|
156
|
+
+ if (flags_hash != FlagList::Hash()) {
|
|
157
|
+
+ base::OS::PrintError("Pkg: FLAGS_MISMATCH\n");
|
|
158
|
+
+ return FLAGS_MISMATCH;
|
|
159
|
+
+ }
|
|
160
|
+
uint32_t max_payload_length =
|
|
161
|
+
this->size_ -
|
|
162
|
+
POINTER_SIZE_ALIGN(kHeaderSize +
|
|
163
|
+
GetHeaderValue(kNumReservationsOffset) * kInt32Size +
|
|
164
|
+
GetHeaderValue(kNumCodeStubKeysOffset) * kInt32Size);
|
|
165
|
+
- if (payload_length > max_payload_length) return LENGTH_MISMATCH;
|
|
166
|
+
- if (!Checksum(DataWithoutHeader()).Check(c1, c2)) return CHECKSUM_MISMATCH;
|
|
167
|
+
+ if (payload_length > max_payload_length) {
|
|
168
|
+
+ base::OS::PrintError("Pkg: LENGTH_MISMATCH\n");
|
|
169
|
+
+ return LENGTH_MISMATCH;
|
|
170
|
+
+ }
|
|
171
|
+
+ if (!Checksum(DataWithoutHeader()).Check(c1, c2)) {
|
|
172
|
+
+ base::OS::PrintError("Pkg: CHECKSUM_MISMATCH\n");
|
|
173
|
+
+ return CHECKSUM_MISMATCH;
|
|
174
|
+
+ }
|
|
175
|
+
return CHECK_SUCCESS;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
uint32_t SerializedCodeData::SourceHash(Handle<String> source) {
|
|
179
|
+
return source->length();
|
|
180
|
+
--- node/lib/child_process.js
|
|
181
|
+
+++ node/lib/child_process.js
|
|
182
|
+
@@ -108,11 +108,11 @@
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
options.execPath = options.execPath || process.execPath;
|
|
186
|
+
options.shell = false;
|
|
187
|
+
|
|
188
|
+
- return spawn(options.execPath, args, options);
|
|
189
|
+
+ return exports.spawn(options.execPath, args, options);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
exports._forkChild = function _forkChild(fd) {
|
|
194
|
+
// set process.send()
|
|
195
|
+
--- node/lib/internal/bootstrap/loaders.js
|
|
196
|
+
+++ node/lib/internal/bootstrap/loaders.js
|
|
197
|
+
@@ -337,11 +337,11 @@
|
|
198
|
+
|
|
199
|
+
// (code, filename, lineOffset, columnOffset
|
|
200
|
+
// cachedData, produceCachedData, parsingContext)
|
|
201
|
+
const script = new ContextifyScript(
|
|
202
|
+
source, this.filename, 0, 0,
|
|
203
|
+
- cache, false, undefined
|
|
204
|
+
+ cache, false, undefined, false
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
// This will be used to create code cache in tools/generate_code_cache.js
|
|
208
|
+
this.script = script;
|
|
209
|
+
|
|
210
|
+
--- node/lib/internal/bootstrap/node.js
|
|
211
|
+
+++ node/lib/internal/bootstrap/node.js
|
|
212
|
+
@@ -213,10 +213,47 @@
|
|
213
|
+
|
|
214
|
+
// There are various modes that Node can run in. The most common two
|
|
215
|
+
// are running from a script and running the REPL - but there are a few
|
|
216
|
+
// others like the debugger or running --eval arguments. Here we decide
|
|
217
|
+
// which mode we run in.
|
|
218
|
+
+
|
|
219
|
+
+ (function () {
|
|
220
|
+
+ var fs = NativeModule.require('fs');
|
|
221
|
+
+ var vm = NativeModule.require('vm');
|
|
222
|
+
+ function readPrelude (fd) {
|
|
223
|
+
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
|
224
|
+
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
|
225
|
+
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
|
226
|
+
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
|
227
|
+
+ if (!PRELUDE_POSITION) {
|
|
228
|
+
+ // no prelude - remove entrypoint from argv[1]
|
|
229
|
+
+ process.argv.splice(1, 1);
|
|
230
|
+
+ return { undoPatch: true };
|
|
231
|
+
+ }
|
|
232
|
+
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
|
233
|
+
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
|
234
|
+
+ if (read !== PRELUDE_SIZE) {
|
|
235
|
+
+ console.error('Pkg: Error reading from file.');
|
|
236
|
+
+ process.exit(1);
|
|
237
|
+
+ }
|
|
238
|
+
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
|
239
|
+
+ var fn = s.runInThisContext();
|
|
240
|
+
+ return fn(process, NativeModule.require,
|
|
241
|
+
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
|
242
|
+
+ }
|
|
243
|
+
+ (function () {
|
|
244
|
+
+ var fd = fs.openSync(process.execPath, 'r');
|
|
245
|
+
+ var result = readPrelude(fd);
|
|
246
|
+
+ if (result && result.undoPatch) {
|
|
247
|
+
+ var bindingFs = process.binding('fs');
|
|
248
|
+
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
|
249
|
+
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
|
250
|
+
+ fs.closeSync(fd);
|
|
251
|
+
+ }
|
|
252
|
+
+ }());
|
|
253
|
+
+ }());
|
|
254
|
+
+
|
|
255
|
+
if (internalBinding('worker').getEnvMessagePort() !== undefined) {
|
|
256
|
+
// This means we are in a Worker context, and any script execution
|
|
257
|
+
// will be directed by the worker module.
|
|
258
|
+
NativeModule.require('internal/worker').setupChild(evalScript);
|
|
259
|
+
} else if (NativeModule.exists('_third_party_main')) {
|
|
260
|
+
--- node/lib/internal/modules/cjs/loader.js
|
|
261
|
+
+++ node/lib/internal/modules/cjs/loader.js
|
|
262
|
+
@@ -27,14 +27,12 @@
|
|
263
|
+
const vm = require('vm');
|
|
264
|
+
const assert = require('assert').ok;
|
|
265
|
+
const fs = require('fs');
|
|
266
|
+
const internalFS = require('internal/fs/utils');
|
|
267
|
+
const path = require('path');
|
|
268
|
+
-const {
|
|
269
|
+
- internalModuleReadJSON,
|
|
270
|
+
- internalModuleStat
|
|
271
|
+
-} = process.binding('fs');
|
|
272
|
+
+const internalModuleReadJSON = function (f) { return require('fs').internalModuleReadJSON(f); };
|
|
273
|
+
+const internalModuleStat = function (f) { return require('fs').internalModuleStat(f); };
|
|
274
|
+
const { safeGetenv } = process.binding('util');
|
|
275
|
+
const {
|
|
276
|
+
makeRequireFunction,
|
|
277
|
+
normalizeReferrerURL,
|
|
278
|
+
requireDepth,
|
|
279
|
+
--- node/lib/vm.js
|
|
280
|
+
+++ node/lib/vm.js
|
|
281
|
+
@@ -55,10 +55,11 @@
|
|
282
|
+
columnOffset = 0,
|
|
283
|
+
cachedData,
|
|
284
|
+
produceCachedData = false,
|
|
285
|
+
importModuleDynamically,
|
|
286
|
+
[kParsingContext]: parsingContext,
|
|
287
|
+
+ sourceless = false,
|
|
288
|
+
} = options;
|
|
289
|
+
|
|
290
|
+
if (typeof filename !== 'string') {
|
|
291
|
+
throw new ERR_INVALID_ARG_TYPE('options.filename', 'string', filename);
|
|
292
|
+
}
|
|
293
|
+
@@ -84,11 +85,12 @@
|
|
294
|
+
filename,
|
|
295
|
+
lineOffset,
|
|
296
|
+
columnOffset,
|
|
297
|
+
cachedData,
|
|
298
|
+
produceCachedData,
|
|
299
|
+
- parsingContext);
|
|
300
|
+
+ parsingContext,
|
|
301
|
+
+ sourceless);
|
|
302
|
+
} catch (e) {
|
|
303
|
+
throw e; /* node-do-not-add-exception-line */
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (importModuleDynamically !== undefined) {
|
|
307
|
+
--- node/src/inspector_agent.cc
|
|
308
|
+
+++ node/src/inspector_agent.cc
|
|
309
|
+
@@ -712,12 +712,10 @@
|
|
310
|
+
CHECK_EQ(0, uv_async_init(parent_env_->event_loop(),
|
|
311
|
+
&start_io_thread_async,
|
|
312
|
+
StartIoThreadAsyncCallback));
|
|
313
|
+
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
|
314
|
+
start_io_thread_async.data = this;
|
|
315
|
+
- // Ignore failure, SIGUSR1 won't work, but that should not block node start.
|
|
316
|
+
- StartDebugSignalHandler();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
bool wait_for_connect = options->wait_for_connect();
|
|
320
|
+
if (parent_handle_) {
|
|
321
|
+
wait_for_connect = parent_handle_->WaitForConnect();
|
|
322
|
+
--- node/src/node.cc
|
|
323
|
+
+++ node/src/node.cc
|
|
324
|
+
@@ -2369,17 +2369,10 @@
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
inline void PlatformInit() {
|
|
329
|
+
#ifdef __POSIX__
|
|
330
|
+
-#if HAVE_INSPECTOR
|
|
331
|
+
- sigset_t sigmask;
|
|
332
|
+
- sigemptyset(&sigmask);
|
|
333
|
+
- sigaddset(&sigmask, SIGUSR1);
|
|
334
|
+
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
|
335
|
+
-#endif // HAVE_INSPECTOR
|
|
336
|
+
-
|
|
337
|
+
// Make sure file descriptors 0-2 are valid before we start logging anything.
|
|
338
|
+
for (int fd = STDIN_FILENO; fd <= STDERR_FILENO; fd += 1) {
|
|
339
|
+
struct stat ignored;
|
|
340
|
+
if (fstat(fd, &ignored) == 0)
|
|
341
|
+
continue;
|
|
342
|
+
@@ -2389,14 +2382,10 @@
|
|
343
|
+
ABORT();
|
|
344
|
+
if (fd != open("/dev/null", O_RDWR))
|
|
345
|
+
ABORT();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
-#if HAVE_INSPECTOR
|
|
349
|
+
- CHECK_EQ(err, 0);
|
|
350
|
+
-#endif // HAVE_INSPECTOR
|
|
351
|
+
-
|
|
352
|
+
#ifndef NODE_SHARED_MODE
|
|
353
|
+
// Restore signal dispositions, the parent process may have changed them.
|
|
354
|
+
struct sigaction act;
|
|
355
|
+
memset(&act, 0, sizeof(act));
|
|
356
|
+
|
|
357
|
+
--- node/src/node_contextify.cc
|
|
358
|
+
+++ node/src/node_contextify.cc
|
|
359
|
+
@@ -63,10 +63,11 @@
|
|
360
|
+
using v8::String;
|
|
361
|
+
using v8::Symbol;
|
|
362
|
+
using v8::TryCatch;
|
|
363
|
+
using v8::Uint32;
|
|
364
|
+
using v8::UnboundScript;
|
|
365
|
+
+using v8::V8;
|
|
366
|
+
using v8::Value;
|
|
367
|
+
using v8::WeakCallbackInfo;
|
|
368
|
+
using v8::WeakCallbackType;
|
|
369
|
+
|
|
370
|
+
// The vm module executes code in a sandboxed environment with a different
|
|
371
|
+
@@ -638,15 +639,16 @@
|
|
372
|
+
Local<Integer> line_offset;
|
|
373
|
+
Local<Integer> column_offset;
|
|
374
|
+
Local<ArrayBufferView> cached_data_buf;
|
|
375
|
+
bool produce_cached_data = false;
|
|
376
|
+
Local<Context> parsing_context = context;
|
|
377
|
+
+ bool sourceless = false;
|
|
378
|
+
|
|
379
|
+
if (argc > 2) {
|
|
380
|
+
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
|
381
|
+
// cachedData, produceCachedData, parsingContext)
|
|
382
|
+
- CHECK_EQ(argc, 7);
|
|
383
|
+
+ CHECK_EQ(argc, 8);
|
|
384
|
+
CHECK(args[2]->IsNumber());
|
|
385
|
+
line_offset = args[2].As<Integer>();
|
|
386
|
+
CHECK(args[3]->IsNumber());
|
|
387
|
+
column_offset = args[3].As<Integer>();
|
|
388
|
+
if (!args[4]->IsUndefined()) {
|
|
389
|
+
@@ -661,10 +663,11 @@
|
|
390
|
+
ContextifyContext::ContextFromContextifiedSandbox(
|
|
391
|
+
env, args[6].As<Object>());
|
|
392
|
+
CHECK_NOT_NULL(sandbox);
|
|
393
|
+
parsing_context = sandbox->context();
|
|
394
|
+
}
|
|
395
|
+
+ sourceless = args[7]->IsTrue();
|
|
396
|
+
} else {
|
|
397
|
+
line_offset = Integer::New(isolate, 0);
|
|
398
|
+
column_offset = Integer::New(isolate, 0);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
@@ -715,10 +718,14 @@
|
|
402
|
+
|
|
403
|
+
TryCatch try_catch(isolate);
|
|
404
|
+
Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
|
405
|
+
Context::Scope scope(parsing_context);
|
|
406
|
+
|
|
407
|
+
+ if (sourceless && produce_cached_data) {
|
|
408
|
+
+ V8::EnableCompilationForSourcelessUse();
|
|
409
|
+
+ }
|
|
410
|
+
+
|
|
411
|
+
MaybeLocal<UnboundScript> v8_script = ScriptCompiler::CompileUnboundScript(
|
|
412
|
+
isolate,
|
|
413
|
+
&source,
|
|
414
|
+
compile_options);
|
|
415
|
+
|
|
416
|
+
@@ -730,10 +737,17 @@
|
|
417
|
+
TRACING_CATEGORY_NODE2(vm, script),
|
|
418
|
+
"ContextifyScript::New",
|
|
419
|
+
contextify_script);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
+
|
|
423
|
+
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
|
424
|
+
+ if (!source.GetCachedData()->rejected) {
|
|
425
|
+
+ V8::FixSourcelessScript(env->isolate(), v8_script.ToLocalChecked());
|
|
426
|
+
+ }
|
|
427
|
+
+ }
|
|
428
|
+
+
|
|
429
|
+
contextify_script->script_.Reset(isolate, v8_script.ToLocalChecked());
|
|
430
|
+
|
|
431
|
+
if (compile_options == ScriptCompiler::kConsumeCodeCache) {
|
|
432
|
+
args.This()->Set(
|
|
433
|
+
env->cached_data_rejected_string(),
|
|
434
|
+
@@ -751,10 +765,15 @@
|
|
435
|
+
}
|
|
436
|
+
args.This()->Set(
|
|
437
|
+
env->cached_data_produced_string(),
|
|
438
|
+
Boolean::New(isolate, cached_data_produced));
|
|
439
|
+
}
|
|
440
|
+
+
|
|
441
|
+
+ if (sourceless && produce_cached_data) {
|
|
442
|
+
+ V8::DisableCompilationForSourcelessUse();
|
|
443
|
+
+ }
|
|
444
|
+
+
|
|
445
|
+
TRACE_EVENT_NESTABLE_ASYNC_END0(
|
|
446
|
+
TRACING_CATEGORY_NODE2(vm, script),
|
|
447
|
+
"ContextifyScript::New",
|
|
448
|
+
contextify_script);
|
|
449
|
+
}
|
|
450
|
+
--- node/src/node_main.cc
|
|
451
|
+
+++ node/src/node_main.cc
|
|
452
|
+
@@ -20,10 +20,12 @@
|
|
453
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
454
|
+
|
|
455
|
+
#include "node.h"
|
|
456
|
+
#include <stdio.h>
|
|
457
|
+
|
|
458
|
+
+int reorder(int argc, char** argv);
|
|
459
|
+
+
|
|
460
|
+
#ifdef _WIN32
|
|
461
|
+
#include <windows.h>
|
|
462
|
+
#include <VersionHelpers.h>
|
|
463
|
+
#include <WinError.h>
|
|
464
|
+
|
|
465
|
+
@@ -67,11 +69,11 @@
|
|
466
|
+
exit(1);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
argv[argc] = nullptr;
|
|
470
|
+
// Now that conversion is done, we can finally start.
|
|
471
|
+
- return node::Start(argc, argv);
|
|
472
|
+
+ return reorder(argc, argv);
|
|
473
|
+
}
|
|
474
|
+
#else
|
|
475
|
+
// UNIX
|
|
476
|
+
#ifdef __linux__
|
|
477
|
+
#include <elf.h>
|
|
478
|
+
@@ -119,8 +121,75 @@
|
|
479
|
+
#endif
|
|
480
|
+
// Disable stdio buffering, it interacts poorly with printf()
|
|
481
|
+
// calls elsewhere in the program (e.g., any logging from V8.)
|
|
482
|
+
setvbuf(stdout, nullptr, _IONBF, 0);
|
|
483
|
+
setvbuf(stderr, nullptr, _IONBF, 0);
|
|
484
|
+
- return node::Start(argc, argv);
|
|
485
|
+
+ return reorder(argc, argv);
|
|
486
|
+
}
|
|
487
|
+
#endif
|
|
488
|
+
+
|
|
489
|
+
+#include <string.h>
|
|
490
|
+
+
|
|
491
|
+
+int strlen2 (char* s) {
|
|
492
|
+
+ int len = 0;
|
|
493
|
+
+ while (*s) {
|
|
494
|
+
+ len += 1;
|
|
495
|
+
+ s += 1;
|
|
496
|
+
+ }
|
|
497
|
+
+ return len;
|
|
498
|
+
+}
|
|
499
|
+
+
|
|
500
|
+
+bool should_set_dummy() {
|
|
501
|
+
+#ifdef _WIN32
|
|
502
|
+
+ #define MAX_ENV_LENGTH 32767
|
|
503
|
+
+ char execpath_env[MAX_ENV_LENGTH];
|
|
504
|
+
+ DWORD result = GetEnvironmentVariable("PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
|
505
|
+
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
|
506
|
+
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
|
507
|
+
+#else
|
|
508
|
+
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
|
509
|
+
+ if (!execpath_env) return true;
|
|
510
|
+
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
|
511
|
+
+#endif
|
|
512
|
+
+}
|
|
513
|
+
+
|
|
514
|
+
+// for uv_setup_args
|
|
515
|
+
+int adjacent(int argc, char** argv) {
|
|
516
|
+
+ size_t size = 0;
|
|
517
|
+
+ for (int i = 0; i < argc; i++) {
|
|
518
|
+
+ size += strlen(argv[i]) + 1;
|
|
519
|
+
+ }
|
|
520
|
+
+ char* args = new char[size];
|
|
521
|
+
+ size_t pos = 0;
|
|
522
|
+
+ for (int i = 0; i < argc; i++) {
|
|
523
|
+
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
|
524
|
+
+ argv[i] = &args[pos];
|
|
525
|
+
+ pos += strlen(argv[i]) + 1;
|
|
526
|
+
+ }
|
|
527
|
+
+ return node::Start(argc, argv);
|
|
528
|
+
+}
|
|
529
|
+
+
|
|
530
|
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
|
531
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
532
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
533
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
|
534
|
+
+
|
|
535
|
+
+int reorder(int argc, char** argv) {
|
|
536
|
+
+ int i;
|
|
537
|
+
+ char** nargv = new char*[argc + 64];
|
|
538
|
+
+ int c = 0;
|
|
539
|
+
+ nargv[c++] = argv[0];
|
|
540
|
+
+ char* bakery = (char*) BAKERY;
|
|
541
|
+
+ while (true) {
|
|
542
|
+
+ size_t width = strlen2(bakery);
|
|
543
|
+
+ if (width == 0) break;
|
|
544
|
+
+ nargv[c++] = bakery;
|
|
545
|
+
+ bakery += width + 1;
|
|
546
|
+
+ }
|
|
547
|
+
+ if (should_set_dummy()) {
|
|
548
|
+
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
|
549
|
+
+ }
|
|
550
|
+
+ for (i = 1; i < argc; i++) {
|
|
551
|
+
+ nargv[c++] = argv[i];
|
|
552
|
+
+ }
|
|
553
|
+
+ return adjacent(c, nargv);
|
|
554
|
+
+}
|
|
555
|
+
--- node/src/node_options.cc
|
|
556
|
+
+++ node/src/node_options.cc
|
|
557
|
+
@@ -55,10 +55,11 @@
|
|
558
|
+
// XXX: If you add an option here, please also add it to doc/node.1 and
|
|
559
|
+
// doc/api/cli.md
|
|
560
|
+
// TODO(addaleax): Make that unnecessary.
|
|
561
|
+
|
|
562
|
+
DebugOptionsParser::DebugOptionsParser() {
|
|
563
|
+
+ return;
|
|
564
|
+
#if HAVE_INSPECTOR
|
|
565
|
+
AddOption("--inspect-port",
|
|
566
|
+
"set host:port for inspector",
|
|
567
|
+
&DebugOptions::host_port,
|
|
568
|
+
kAllowedInEnvironment);
|