@yao-pkg/pkg-fetch 3.6.0 → 3.6.1
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 +28 -20
- package/lib-es5/apply-patches.js +19 -78
- package/lib-es5/bin.js +40 -89
- package/lib-es5/build.js +205 -374
- package/lib-es5/expected-shas.json +53 -34
- package/lib-es5/expected.js +1 -1
- package/lib-es5/generate-expected-shas.js +31 -72
- package/lib-es5/index.js +125 -203
- package/lib-es5/log.js +41 -61
- package/lib-es5/parse-update-shas.d.ts +3 -0
- package/lib-es5/parse-update-shas.js +106 -0
- package/lib-es5/places.js +13 -15
- package/lib-es5/print-hashes.js +4 -5
- package/lib-es5/system.js +18 -20
- package/lib-es5/utils.js +82 -140
- package/lib-es5/verify.js +133 -53
- package/package.json +12 -57
- package/patches/node.v16.20.2.cpp.patch +1 -1
- package/patches/{node.v18.18.2.cpp.patch → node.v18.20.8.cpp.patch} +207 -60
- package/patches/{node.v20.10.0.cpp.patch → node.v20.20.2.cpp.patch} +87 -50
- package/patches/{node.v19.8.1.cpp.patch → node.v22.22.3.cpp.patch} +316 -167
- package/patches/node.v24.15.0.cpp.patch +863 -0
- package/patches/node.v26.2.0.cpp.patch +809 -0
- package/patches/patches.json +5 -3
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
diff --git node/deps/v8/include/v8-initialization.h node/deps/v8/include/v8-initialization.h
|
|
2
|
+
index 406f1d0ba5..fb8eea420d 100644
|
|
3
|
+
--- node/deps/v8/include/v8-initialization.h
|
|
4
|
+
+++ node/deps/v8/include/v8-initialization.h
|
|
5
|
+
@@ -98,6 +98,10 @@ class V8_EXPORT V8 {
|
|
6
|
+
static void SetFlagsFromCommandLine(int* argc, 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
|
+
diff --git node/deps/v8/src/api/api.cc node/deps/v8/src/api/api.cc
|
|
17
|
+
index 9ef4e3b4a6..34cabe171c 100644
|
|
18
|
+
--- node/deps/v8/src/api/api.cc
|
|
19
|
+
+++ node/deps/v8/src/api/api.cc
|
|
20
|
+
@@ -469,6 +469,28 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
|
|
21
|
+
HelpOptions(HelpOptions::kDontExit));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
+bool save_lazy;
|
|
25
|
+
+bool save_predictable;
|
|
26
|
+
+
|
|
27
|
+
+void V8::EnableCompilationForSourcelessUse() {
|
|
28
|
+
+ save_lazy = i::v8_flags.lazy;
|
|
29
|
+
+ i::v8_flags.lazy = false;
|
|
30
|
+
+ save_predictable = i::v8_flags.predictable;
|
|
31
|
+
+ i::v8_flags.predictable = true;
|
|
32
|
+
+}
|
|
33
|
+
+
|
|
34
|
+
+void V8::DisableCompilationForSourcelessUse() {
|
|
35
|
+
+ i::v8_flags.lazy = save_lazy;
|
|
36
|
+
+ i::v8_flags.predictable = save_predictable;
|
|
37
|
+
+}
|
|
38
|
+
+
|
|
39
|
+
+void V8::FixSourcelessScript(Isolate* v8_isolate, Local<UnboundScript> unbound_script) {
|
|
40
|
+
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
|
41
|
+
+ auto function_info = i::Cast<i::SharedFunctionInfo>(Utils::OpenHandle(*unbound_script));
|
|
42
|
+
+ i::Handle<i::Script> script(i::Cast<i::Script>(function_info->script()), isolate);
|
|
43
|
+
+ script->SetSource(isolate, script, isolate->factory()->empty_string());
|
|
44
|
+
+}
|
|
45
|
+
+
|
|
46
|
+
RegisteredExtension* RegisteredExtension::first_extension_ = nullptr;
|
|
47
|
+
|
|
48
|
+
RegisteredExtension::RegisteredExtension(std::unique_ptr<Extension> extension)
|
|
49
|
+
diff --git node/deps/v8/src/codegen/compiler.cc node/deps/v8/src/codegen/compiler.cc
|
|
50
|
+
index 2dc782458e..0cddfbbbc4 100644
|
|
51
|
+
--- node/deps/v8/src/codegen/compiler.cc
|
|
52
|
+
+++ node/deps/v8/src/codegen/compiler.cc
|
|
53
|
+
@@ -3988,7 +3988,7 @@ MaybeDirectHandle<SharedFunctionInfo> GetSharedFunctionInfoForScriptImpl(
|
|
54
|
+
maybe_script = lookup_result.script();
|
|
55
|
+
maybe_result = lookup_result.toplevel_sfi();
|
|
56
|
+
is_compiled_scope = lookup_result.is_compiled_scope();
|
|
57
|
+
- if (!maybe_result.is_null()) {
|
|
58
|
+
+ if (!maybe_result.is_null() && source->length()) {
|
|
59
|
+
compile_timer.set_hit_isolate_cache();
|
|
60
|
+
} else if (can_consume_code_cache) {
|
|
61
|
+
compile_timer.set_consuming_code_cache();
|
|
62
|
+
diff --git node/deps/v8/src/compiler/wasm-compiler.cc node/deps/v8/src/compiler/wasm-compiler.cc
|
|
63
|
+
index 632d54de8c..cbf91f9d6c 100644
|
|
64
|
+
--- node/deps/v8/src/compiler/wasm-compiler.cc
|
|
65
|
+
+++ node/deps/v8/src/compiler/wasm-compiler.cc
|
|
66
|
+
@@ -1090,11 +1090,15 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
|
|
67
|
+
"wasm-to-js-%d-", static_cast<int>(kind));
|
|
68
|
+
PrintSignature(base::VectorOf(func_name, kMaxNameLen) + name_prefix_len, sig,
|
|
69
|
+
'-');
|
|
70
|
+
+ wasm::WrapperCompilationInfo info;
|
|
71
|
+
+ info.code_kind = CodeKind::WASM_TO_JS_FUNCTION;
|
|
72
|
+
+ info.import_kind = kind;
|
|
73
|
+
+ info.expected_arity = expected_arity;
|
|
74
|
+
+ info.suspend = suspend;
|
|
75
|
+
|
|
76
|
+
auto result = Pipeline::GenerateCodeForWasmNativeStubFromTurboshaft(
|
|
77
|
+
sig,
|
|
78
|
+
- wasm::WrapperCompilationInfo{CodeKind::WASM_TO_JS_FUNCTION, kind,
|
|
79
|
+
- expected_arity, suspend},
|
|
80
|
+
+ info,
|
|
81
|
+
func_name, WasmStubAssemblerOptions());
|
|
82
|
+
|
|
83
|
+
if (V8_UNLIKELY(v8_flags.trace_wasm_compilation_times)) {
|
|
84
|
+
diff --git node/deps/v8/src/heap/marking-visitor-inl.h node/deps/v8/src/heap/marking-visitor-inl.h
|
|
85
|
+
index 8ac9d6d49b..7a241f2de7 100644
|
|
86
|
+
--- node/deps/v8/src/heap/marking-visitor-inl.h
|
|
87
|
+
+++ node/deps/v8/src/heap/marking-visitor-inl.h
|
|
88
|
+
@@ -517,6 +517,13 @@ bool MarkingVisitorBase<ConcreteVisitor>::HasBytecodeArrayForFlushing(
|
|
89
|
+
template <typename ConcreteVisitor>
|
|
90
|
+
bool MarkingVisitorBase<ConcreteVisitor>::ShouldFlushCode(
|
|
91
|
+
Tagged<SharedFunctionInfo> sfi) const {
|
|
92
|
+
+ auto script_obj = sfi->script();
|
|
93
|
+
+ if (!IsUndefined(script_obj)) {
|
|
94
|
+
+ auto script = Cast<Script>(script_obj);
|
|
95
|
+
+ if (IsUndefined(script->source())) {
|
|
96
|
+
+ return false;
|
|
97
|
+
+ }
|
|
98
|
+
+ }
|
|
99
|
+
// This method is used both for flushing bytecode and baseline code.
|
|
100
|
+
// During last resort GCs and stress testing we consider all code old.
|
|
101
|
+
return IsOld(sfi) || V8_UNLIKELY(IsForceFlushingEnabled(code_flush_mode_));
|
|
102
|
+
diff --git node/deps/v8/src/objects/js-function.cc node/deps/v8/src/objects/js-function.cc
|
|
103
|
+
index a44e3fd6c0..e220a5bc0f 100644
|
|
104
|
+
--- node/deps/v8/src/objects/js-function.cc
|
|
105
|
+
+++ node/deps/v8/src/objects/js-function.cc
|
|
106
|
+
@@ -1417,6 +1417,9 @@ DirectHandle<String> JSFunction::ToString(Isolate* isolate,
|
|
107
|
+
DirectHandle<Object> maybe_class_positions = JSReceiver::GetDataProperty(
|
|
108
|
+
isolate, function, isolate->factory()->class_positions_symbol());
|
|
109
|
+
if (IsClassPositions(*maybe_class_positions)) {
|
|
110
|
+
+ if (IsUndefined(Cast<String>(Cast<Script>(shared_info->script())->source()))) {
|
|
111
|
+
+ return isolate->factory()->NewStringFromAsciiChecked("class {}");
|
|
112
|
+
+ }
|
|
113
|
+
Tagged<ClassPositions> class_positions =
|
|
114
|
+
Cast<ClassPositions>(*maybe_class_positions);
|
|
115
|
+
int start_position = class_positions->start();
|
|
116
|
+
diff --git node/deps/v8/src/objects/script.cc node/deps/v8/src/objects/script.cc
|
|
117
|
+
index a2078b538c..1468ece463 100644
|
|
118
|
+
--- node/deps/v8/src/objects/script.cc
|
|
119
|
+
+++ node/deps/v8/src/objects/script.cc
|
|
120
|
+
@@ -118,7 +118,11 @@ void Script::InitLineEndsInternal(IsolateT* isolate,
|
|
121
|
+
|
|
122
|
+
void Script::SetSource(Isolate* isolate, DirectHandle<Script> script,
|
|
123
|
+
DirectHandle<String> source) {
|
|
124
|
+
- script->set_source(*source);
|
|
125
|
+
+ if (source->length() > 0) {
|
|
126
|
+
+ script->set_source(*source);
|
|
127
|
+
+ } else {
|
|
128
|
+
+ script->set_source(*isolate->factory()->undefined_value());
|
|
129
|
+
+ }
|
|
130
|
+
if (isolate->NeedsSourcePositions()) {
|
|
131
|
+
InitLineEnds(isolate, script);
|
|
132
|
+
} else if (script->line_ends() ==
|
|
133
|
+
diff --git node/deps/v8/src/parsing/parsing.cc node/deps/v8/src/parsing/parsing.cc
|
|
134
|
+
index 31758fdfed..483192fc35 100644
|
|
135
|
+
--- node/deps/v8/src/parsing/parsing.cc
|
|
136
|
+
+++ node/deps/v8/src/parsing/parsing.cc
|
|
137
|
+
@@ -42,6 +42,7 @@ bool ParseProgram(ParseInfo* info, DirectHandle<Script> script,
|
|
138
|
+
DCHECK(info->flags().is_toplevel());
|
|
139
|
+
DCHECK_NULL(info->literal());
|
|
140
|
+
|
|
141
|
+
+ if (IsUndefined(Cast<String>(script->source()))) return false;
|
|
142
|
+
VMState<PARSER> state(isolate);
|
|
143
|
+
|
|
144
|
+
// Create a character stream for the parser.
|
|
145
|
+
@@ -75,6 +76,8 @@ bool ParseFunction(ParseInfo* info,
|
|
146
|
+
|
|
147
|
+
// Create a character stream for the parser.
|
|
148
|
+
DirectHandle<Script> script(Cast<Script>(shared_info->script()), isolate);
|
|
149
|
+
+ if (IsUndefined(Cast<String>(script->source()))) return false;
|
|
150
|
+
+
|
|
151
|
+
Handle<String> source(Cast<String>(script->source()), isolate);
|
|
152
|
+
uint32_t start_pos = shared_info->StartPosition();
|
|
153
|
+
uint32_t end_pos = shared_info->EndPosition();
|
|
154
|
+
diff --git node/deps/v8/src/snapshot/code-serializer.cc node/deps/v8/src/snapshot/code-serializer.cc
|
|
155
|
+
index 6149ee8f1d..133659e328 100644
|
|
156
|
+
--- node/deps/v8/src/snapshot/code-serializer.cc
|
|
157
|
+
+++ node/deps/v8/src/snapshot/code-serializer.cc
|
|
158
|
+
@@ -776,10 +776,6 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheck(
|
|
159
|
+
|
|
160
|
+
SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckJustSource(
|
|
161
|
+
uint32_t expected_source_hash) const {
|
|
162
|
+
- uint32_t source_hash = GetHeaderValue(kSourceHashOffset);
|
|
163
|
+
- if (source_hash != expected_source_hash) {
|
|
164
|
+
- return SerializedCodeSanityCheckResult::kSourceMismatch;
|
|
165
|
+
- }
|
|
166
|
+
return SerializedCodeSanityCheckResult::kSuccess;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@@ -796,13 +792,12 @@ SerializedCodeSanityCheckResult SerializedCodeData::SanityCheckWithoutSource(
|
|
170
|
+
if (version_hash != Version::Hash()) {
|
|
171
|
+
return SerializedCodeSanityCheckResult::kVersionMismatch;
|
|
172
|
+
}
|
|
173
|
+
- uint32_t flags_hash = GetHeaderValue(kFlagHashOffset);
|
|
174
|
+
- if (flags_hash != FlagList::Hash()) {
|
|
175
|
+
- return SerializedCodeSanityCheckResult::kFlagsMismatch;
|
|
176
|
+
- }
|
|
177
|
+
uint32_t ro_snapshot_checksum =
|
|
178
|
+
GetHeaderValue(kReadOnlySnapshotChecksumOffset);
|
|
179
|
+
if (ro_snapshot_checksum != expected_ro_snapshot_checksum) {
|
|
180
|
+
+ // for debugging snapshot checkum issues
|
|
181
|
+
+ // PrintF("[pkg] ReadOnlySnapshotChecksum mismatch: code=%08x built=%08x\n",
|
|
182
|
+
+ // ro_snapshot_checksum, expected_ro_snapshot_checksum);
|
|
183
|
+
return SerializedCodeSanityCheckResult::kReadOnlySnapshotChecksumMismatch;
|
|
184
|
+
}
|
|
185
|
+
uint32_t payload_length = GetHeaderValue(kPayloadLengthOffset);
|
|
186
|
+
diff --git node/deps/v8/src/snapshot/read-only-serializer.cc node/deps/v8/src/snapshot/read-only-serializer.cc
|
|
187
|
+
index 6732808e85..ebb7938f64 100644
|
|
188
|
+
--- node/deps/v8/src/snapshot/read-only-serializer.cc
|
|
189
|
+
+++ node/deps/v8/src/snapshot/read-only-serializer.cc
|
|
190
|
+
@@ -14,6 +14,9 @@
|
|
191
|
+
#include "src/objects/slots.h"
|
|
192
|
+
#include "src/snapshot/read-only-serializer-deserializer.h"
|
|
193
|
+
|
|
194
|
+
+// for debugging readonly heap serialization
|
|
195
|
+
+// #define PKG_TRACE_READONLY_HEAP 1
|
|
196
|
+
+
|
|
197
|
+
namespace v8 {
|
|
198
|
+
namespace internal {
|
|
199
|
+
|
|
200
|
+
@@ -226,6 +229,10 @@ ro::EncodedTagged Encode(Isolate* isolate, Tagged<HeapObject> o) {
|
|
201
|
+
uint32_t offset = static_cast<int>(chunk->Offset(o_address));
|
|
202
|
+
DCHECK(IsAligned(offset, kTaggedSize));
|
|
203
|
+
|
|
204
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
205
|
+
+ PrintF(" [PKGTRACE] encode tagged page_index=%d offset=%u offidx=%u\n",
|
|
206
|
+
+ index, offset, offset / kTaggedSize);
|
|
207
|
+
+ #endif
|
|
208
|
+
return ro::EncodedTagged(index, offset / kTaggedSize);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@@ -325,6 +332,11 @@ class EncodeRelocationsVisitor final : public ObjectVisitor {
|
|
212
|
+
|
|
213
|
+
// Encode:
|
|
214
|
+
ro::EncodedTagged encoded = Encode(isolate_, o.GetHeapObject());
|
|
215
|
+
+
|
|
216
|
+
+ #ifndef V8_COMPRESS_POINTERS
|
|
217
|
+
+ memset(segment_->contents.get() + slot_offset, 0, kTaggedSize);
|
|
218
|
+
+ #endif
|
|
219
|
+
+
|
|
220
|
+
memcpy(segment_->contents.get() + slot_offset, &encoded,
|
|
221
|
+
ro::EncodedTagged::kSize);
|
|
222
|
+
|
|
223
|
+
@@ -357,8 +369,18 @@ void ReadOnlySegmentForSerialization::EncodeTaggedSlots(Isolate* isolate) {
|
|
224
|
+
const Address segment_end = segment_start + segment_size;
|
|
225
|
+
ReadOnlyPageObjectIterator it(page, segment_start,
|
|
226
|
+
SkipFreeSpaceOrFiller::kNo);
|
|
227
|
+
+
|
|
228
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
229
|
+
+ uint32_t counter = 0;
|
|
230
|
+
+ #endif
|
|
231
|
+
+
|
|
232
|
+
for (Tagged<HeapObject> o = it.Next(); !o.is_null(); o = it.Next()) {
|
|
233
|
+
if (o.address() >= segment_end) break;
|
|
234
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
235
|
+
+ Tagged<Map> map = o->map(isolate);
|
|
236
|
+
+ PrintF(" [PKGTRACE] tag heapobj i=%d so=%zu s=%d t=%d\n",
|
|
237
|
+
+ counter++, o.address()-segment_start, o->Size(), map->instance_type());
|
|
238
|
+
+ #endif
|
|
239
|
+
VisitObject(isolate, o, &v);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
@@ -384,7 +406,14 @@ class ReadOnlyHeapImageSerializer {
|
|
243
|
+
DCHECK_EQ(sink_->Position(), 0);
|
|
244
|
+
|
|
245
|
+
ReadOnlySpace* ro_space = isolate_->read_only_heap()->read_only_space();
|
|
246
|
+
-
|
|
247
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
248
|
+
+ #ifdef V8_COMPRESS_POINTERS
|
|
249
|
+
+ bool pce = true;
|
|
250
|
+
+ #else
|
|
251
|
+
+ bool pce = false;
|
|
252
|
+
+ #endif
|
|
253
|
+
+ PrintF("[PKGTRACE] BEGIN SERIALIZE READONLY ro_space=%p pce=%d\n", ro_space, pce);
|
|
254
|
+
+ #endif
|
|
255
|
+
// Allocate all pages first s.t. the deserializer can easily handle forward
|
|
256
|
+
// references (e.g.: an object on page i points at an object on page i+1).
|
|
257
|
+
for (const ReadOnlyPage* page : ro_space->pages()) {
|
|
258
|
+
@@ -399,6 +428,10 @@ class ReadOnlyHeapImageSerializer {
|
|
259
|
+
EmitReadOnlyRootsTable();
|
|
260
|
+
sink_->Put(Bytecode::kFinalizeReadOnlySpace, "space end");
|
|
261
|
+
sink_->PutUint30(isolate_->next_unique_sfi_id(), "shared function info ID");
|
|
262
|
+
+
|
|
263
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
264
|
+
+ PrintF("[PKGTRACE] END SERIALIZE READONLY\n");
|
|
265
|
+
+ #endif
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
uint32_t IndexOf(const ReadOnlyPage* page) {
|
|
269
|
+
@@ -416,6 +449,13 @@ class ReadOnlyHeapImageSerializer {
|
|
270
|
+
sink_->PutUint30(
|
|
271
|
+
static_cast<uint32_t>(page->HighWaterMark() - page->area_start()),
|
|
272
|
+
"area size in bytes");
|
|
273
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
274
|
+
+ PrintF("[PKGTRACE] emit allocate page area_ro_space_off=%zu area_start=%lx idx=%d size=%d \n",
|
|
275
|
+
+ ((uint8_t*)(page->area_start()))-((uint8_t*)(isolate_->read_only_heap()->read_only_space())),
|
|
276
|
+
+ page->area_start(),
|
|
277
|
+
+ IndexOf(page),
|
|
278
|
+
+ static_cast<uint32_t>(page->HighWaterMark() - page->area_start()));
|
|
279
|
+
+ #endif
|
|
280
|
+
if (V8_STATIC_ROOTS_BOOL) {
|
|
281
|
+
auto page_addr = page->ChunkAddress();
|
|
282
|
+
sink_->PutUint32(V8HeapCompressionScheme::CompressAny(page_addr),
|
|
283
|
+
@@ -447,6 +487,9 @@ class ReadOnlyHeapImageSerializer {
|
|
284
|
+
|
|
285
|
+
void SerializePage(const ReadOnlyPage* page) {
|
|
286
|
+
Address pos = page->area_start();
|
|
287
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
288
|
+
+ PrintF("[PKGTRACE] serialize page addr=%lx\n", page->area_start());
|
|
289
|
+
+ #endif
|
|
290
|
+
if (v8_flags.trace_serializer) {
|
|
291
|
+
PrintF("[ro serializer] Serializing page %p -> %p\n",
|
|
292
|
+
reinterpret_cast<char*>(page->area_start()),
|
|
293
|
+
@@ -479,6 +522,9 @@ class ReadOnlyHeapImageSerializer {
|
|
294
|
+
isolate_, page, pos, segment_size, &pre_processor_);
|
|
295
|
+
EmitSegment(&segment);
|
|
296
|
+
}
|
|
297
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
298
|
+
+ PrintF("[PKGTRACE] last segment\n");
|
|
299
|
+
+ #endif
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@@ -511,6 +557,11 @@ class ReadOnlyHeapImageSerializer {
|
|
304
|
+
|
|
305
|
+
void EmitSegment(const ReadOnlySegmentForSerialization* segment) {
|
|
306
|
+
if (segment->segment_size == 0) return;
|
|
307
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
308
|
+
+ PrintF(" [PKGTRACE] segment segment_start=%lx page_index=%d offset=%zu size=%zu tagged_slots=%zu\n",
|
|
309
|
+
+ segment->segment_start, IndexOf(segment->page), segment->segment_offset,
|
|
310
|
+
+ segment->segment_size, segment->tagged_slots.size_in_bytes());
|
|
311
|
+
+ #endif
|
|
312
|
+
if (v8_flags.trace_serializer) {
|
|
313
|
+
PrintF("[ro serializer] * Serializing segment %p -> %p\n",
|
|
314
|
+
reinterpret_cast<char*>(segment->segment_start),
|
|
315
|
+
@@ -525,11 +576,29 @@ class ReadOnlyHeapImageSerializer {
|
|
316
|
+
"segment byte size");
|
|
317
|
+
sink_->PutRaw(segment->contents.get(),
|
|
318
|
+
static_cast<int>(segment->segment_size), "page");
|
|
319
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
320
|
+
+ PrintF(" [PKGTRACE] segment_contents: ");
|
|
321
|
+
+ const uint8_t* cdata = reinterpret_cast<const uint8_t*>(segment->contents.get());
|
|
322
|
+
+ for (size_t i = 0; i < segment->segment_size; i++) {
|
|
323
|
+
+ if (i%128==0) {PrintF("\n [PKGTRACE] ");}
|
|
324
|
+
+ PrintF("%02x", cdata[i]);
|
|
325
|
+
+ }
|
|
326
|
+
+ PrintF("\n");
|
|
327
|
+
+ #endif
|
|
328
|
+
if (!V8_STATIC_ROOTS_BOOL) {
|
|
329
|
+
sink_->Put(Bytecode::kRelocateSegment, "relocate segment");
|
|
330
|
+
sink_->PutRaw(segment->tagged_slots.data(),
|
|
331
|
+
static_cast<int>(segment->tagged_slots.size_in_bytes()),
|
|
332
|
+
"tagged_slots");
|
|
333
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
334
|
+
+ PrintF(" [PKGTRACE] tagged_slots: ");
|
|
335
|
+
+ const uint8_t* tdata = segment->tagged_slots.data();
|
|
336
|
+
+ for (size_t i = 0; i < segment->tagged_slots.size_in_bytes(); i++) {
|
|
337
|
+
+ if (i%128==0) {PrintF("\n [PKGTRACE] ");}
|
|
338
|
+
+ PrintF("%02x", tdata[i]);
|
|
339
|
+
+ }
|
|
340
|
+
+ PrintF("\n");
|
|
341
|
+
+ #endif
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@@ -537,11 +606,20 @@ class ReadOnlyHeapImageSerializer {
|
|
346
|
+
sink_->Put(Bytecode::kReadOnlyRootsTable, "read only roots table");
|
|
347
|
+
if (!V8_STATIC_ROOTS_BOOL) {
|
|
348
|
+
ReadOnlyRoots roots(isolate_);
|
|
349
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
350
|
+
+ PrintF("[PKGTRACE] readonly roots %lu\n", ReadOnlyRoots::kEntriesCount);
|
|
351
|
+
+ #endif
|
|
352
|
+
for (size_t i = 0; i < ReadOnlyRoots::kEntriesCount; i++) {
|
|
353
|
+
RootIndex rudi = static_cast<RootIndex>(i);
|
|
354
|
+
Tagged<HeapObject> rudolf = Cast<HeapObject>(roots.object_at(rudi));
|
|
355
|
+
ro::EncodedTagged encoded = Encode(isolate_, rudolf);
|
|
356
|
+
sink_->PutUint32(encoded.ToUint32(), "read only roots entry");
|
|
357
|
+
+ #ifdef PKG_TRACE_READONLY_HEAP
|
|
358
|
+
+ Tagged<Map> map = rudolf->map(isolate_);
|
|
359
|
+
+ InstanceType instance_type = map->instance_type();
|
|
360
|
+
+ PrintF(" [PKGTRACE] readonly root i=%zu e=%x s=%d t=%d\n",
|
|
361
|
+
+ i, encoded.ToUint32(), rudolf->Size(), instance_type);
|
|
362
|
+
+ #endif
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
diff --git node/lib/child_process.js node/lib/child_process.js
|
|
367
|
+
index 824af65556..8393ee812f 100644
|
|
368
|
+
--- node/lib/child_process.js
|
|
369
|
+
+++ node/lib/child_process.js
|
|
370
|
+
@@ -171,7 +171,7 @@ function fork(modulePath, args = [], options) {
|
|
371
|
+
throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
- return spawn(options.execPath, args, options);
|
|
375
|
+
+ return module.exports.spawn(options.execPath, args, options);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function _forkChild(fd, serializationMode) {
|
|
379
|
+
diff --git node/lib/internal/bootstrap/pkg.js node/lib/internal/bootstrap/pkg.js
|
|
380
|
+
new file mode 100644
|
|
381
|
+
index 0000000000..a697294fdf
|
|
382
|
+
--- /dev/null
|
|
383
|
+
+++ node/lib/internal/bootstrap/pkg.js
|
|
384
|
+
@@ -0,0 +1,49 @@
|
|
385
|
+
+'use strict';
|
|
386
|
+
+
|
|
387
|
+
+const {
|
|
388
|
+
+ prepareWorkerThreadExecution,
|
|
389
|
+
+ prepareMainThreadExecution
|
|
390
|
+
+} = require('internal/process/pre_execution');
|
|
391
|
+
+
|
|
392
|
+
+if (internalBinding('worker').isMainThread) {
|
|
393
|
+
+ prepareMainThreadExecution(true);
|
|
394
|
+
+} else {
|
|
395
|
+
+ prepareWorkerThreadExecution();
|
|
396
|
+
+}
|
|
397
|
+
+
|
|
398
|
+
+(function () {
|
|
399
|
+
+ var __require__ = require;
|
|
400
|
+
+ var fs = __require__('fs');
|
|
401
|
+
+ var vm = __require__('vm');
|
|
402
|
+
+ function readPrelude (fd) {
|
|
403
|
+
+ var PAYLOAD_POSITION = '// PAYLOAD_POSITION //' | 0;
|
|
404
|
+
+ var PAYLOAD_SIZE = '// PAYLOAD_SIZE //' | 0;
|
|
405
|
+
+ var PRELUDE_POSITION = '// PRELUDE_POSITION //' | 0;
|
|
406
|
+
+ var PRELUDE_SIZE = '// PRELUDE_SIZE //' | 0;
|
|
407
|
+
+ if (!PRELUDE_POSITION) {
|
|
408
|
+
+ // no prelude - remove entrypoint from argv[1]
|
|
409
|
+
+ process.argv.splice(1, 1);
|
|
410
|
+
+ return { undoPatch: true };
|
|
411
|
+
+ }
|
|
412
|
+
+ var prelude = Buffer.alloc(PRELUDE_SIZE);
|
|
413
|
+
+ var read = fs.readSync(fd, prelude, 0, PRELUDE_SIZE, PRELUDE_POSITION);
|
|
414
|
+
+ if (read !== PRELUDE_SIZE) {
|
|
415
|
+
+ console.error('Pkg: Error reading from file.');
|
|
416
|
+
+ process.exit(1);
|
|
417
|
+
+ }
|
|
418
|
+
+ var s = new vm.Script(prelude, { filename: 'pkg/prelude/bootstrap.js' });
|
|
419
|
+
+ var fn = s.runInThisContext();
|
|
420
|
+
+ return fn(process, __require__,
|
|
421
|
+
+ console, fd, PAYLOAD_POSITION, PAYLOAD_SIZE);
|
|
422
|
+
+ }
|
|
423
|
+
+ (function () {
|
|
424
|
+
+ var fd = fs.openSync(process.execPath, 'r');
|
|
425
|
+
+ var result = readPrelude(fd);
|
|
426
|
+
+ if (result && result.undoPatch) {
|
|
427
|
+
+ var bindingFs = process.binding('fs');
|
|
428
|
+
+ fs.internalModuleStat = bindingFs.internalModuleStat;
|
|
429
|
+
+ fs.internalModuleReadJSON = bindingFs.internalModuleReadJSON;
|
|
430
|
+
+ fs.closeSync(fd);
|
|
431
|
+
+ }
|
|
432
|
+
+ }());
|
|
433
|
+
+}());
|
|
434
|
+
diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
|
|
435
|
+
index 65a35299eb..025eb1c92f 100644
|
|
436
|
+
--- node/lib/internal/modules/cjs/loader.js
|
|
437
|
+
+++ node/lib/internal/modules/cjs/loader.js
|
|
438
|
+
@@ -267,12 +267,15 @@ function stat(filename) {
|
|
439
|
+
// Guard against internal bugs where a non-string filename is passed in by mistake.
|
|
440
|
+
assert(typeof filename === 'string');
|
|
441
|
+
|
|
442
|
+
+ const origFilename = filename;
|
|
443
|
+
filename = path.toNamespacedPath(filename);
|
|
444
|
+
if (statCache !== null) {
|
|
445
|
+
const result = statCache.get(filename);
|
|
446
|
+
if (result !== undefined) { return result; }
|
|
447
|
+
}
|
|
448
|
+
- const result = internalFsBinding.internalModuleStat(filename);
|
|
449
|
+
+ const fs = require('fs');
|
|
450
|
+
+ const result = fs.existsSync(origFilename) ?
|
|
451
|
+
+ (fs.statSync(origFilename).isDirectory() ? 1 : 0) : -1;
|
|
452
|
+
if (statCache !== null && result >= 0) {
|
|
453
|
+
// Only set cache when `internalModuleStat(filename)` succeeds.
|
|
454
|
+
statCache.set(filename, result);
|
|
455
|
+
diff --git node/lib/internal/modules/package_json_reader.js node/lib/internal/modules/package_json_reader.js
|
|
456
|
+
index 6c6bf0383b..25db3d9f43 100644
|
|
457
|
+
--- node/lib/internal/modules/package_json_reader.js
|
|
458
|
+
+++ node/lib/internal/modules/package_json_reader.js
|
|
459
|
+
@@ -120,17 +120,20 @@ const requiresJSONParse = (value) => (value !== undefined && (value[0] === '[' |
|
|
460
|
+
* @returns {PackageConfig}
|
|
461
|
+
*/
|
|
462
|
+
function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
|
|
463
|
+
- // This function will be called by both CJS and ESM, so we need to make sure
|
|
464
|
+
- // non-null attributes are converted to strings.
|
|
465
|
+
- const parsed = modulesBinding.readPackageJSON(
|
|
466
|
+
- jsonPath,
|
|
467
|
+
- isESM,
|
|
468
|
+
- base == null ? undefined : `${base}`,
|
|
469
|
+
- specifier == null ? undefined : `${specifier}`,
|
|
470
|
+
- );
|
|
471
|
+
-
|
|
472
|
+
- const result = deserializePackageJSON(jsonPath, parsed);
|
|
473
|
+
-
|
|
474
|
+
+ const fs = require('fs');
|
|
475
|
+
+ let result;
|
|
476
|
+
+ if (fs.existsSync(jsonPath)) {
|
|
477
|
+
+ const json = JSONParse(fs.readFileSync(jsonPath, { encoding: "utf8" }).trim());
|
|
478
|
+
+ result = deserializePackageJSON(jsonPath, [
|
|
479
|
+
+ json['name'],
|
|
480
|
+
+ json['main'],
|
|
481
|
+
+ json['type'],
|
|
482
|
+
+ json['imports'],
|
|
483
|
+
+ json['exports'],
|
|
484
|
+
+ ]);
|
|
485
|
+
+ } else {
|
|
486
|
+
+ result = deserializePackageJSON(jsonPath, undefined);
|
|
487
|
+
+ }
|
|
488
|
+
return {
|
|
489
|
+
__proto__: null,
|
|
490
|
+
...result.data,
|
|
491
|
+
diff --git node/lib/internal/process/pre_execution.js node/lib/internal/process/pre_execution.js
|
|
492
|
+
index 16a80c2d4f..4f6232e8b8 100644
|
|
493
|
+
--- node/lib/internal/process/pre_execution.js
|
|
494
|
+
+++ node/lib/internal/process/pre_execution.js
|
|
495
|
+
@@ -42,7 +42,11 @@ const {
|
|
496
|
+
runDeserializeCallbacks,
|
|
497
|
+
} = require('internal/v8/startup_snapshot');
|
|
498
|
+
|
|
499
|
+
+let _alreadyPrepared = false;
|
|
500
|
+
+
|
|
501
|
+
function prepareMainThreadExecution(expandArgv1 = false, initializeModules = true) {
|
|
502
|
+
+ if (_alreadyPrepared === true) return;
|
|
503
|
+
+ _alreadyPrepared = true;
|
|
504
|
+
return prepareExecution({
|
|
505
|
+
expandArgv1,
|
|
506
|
+
initializeModules,
|
|
507
|
+
@@ -281,7 +285,8 @@ function patchProcessObject(expandArgv1) {
|
|
508
|
+
let mainEntry;
|
|
509
|
+
// If requested, update process.argv[1] to replace whatever the user provided with the resolved absolute file path of
|
|
510
|
+
// the entry point.
|
|
511
|
+
- if (expandArgv1 && process.argv[1] && process.argv[1][0] !== '-') {
|
|
512
|
+
+ if (expandArgv1 && process.argv[1] && process.argv[1][0] !== '-' &&
|
|
513
|
+
+ process.argv[1] !== 'PKG_DUMMY_ENTRYPOINT') {
|
|
514
|
+
// Expand process.argv[1] into a full path.
|
|
515
|
+
const path = require('path');
|
|
516
|
+
try {
|
|
517
|
+
@@ -755,6 +760,7 @@ function loadPreloadModules() {
|
|
518
|
+
// For user code, we preload modules if `-r` is passed
|
|
519
|
+
const preloadModules = getOptionValue('--require');
|
|
520
|
+
if (preloadModules && preloadModules.length > 0) {
|
|
521
|
+
+ assert(false, '--require is not supported');
|
|
522
|
+
const {
|
|
523
|
+
Module: {
|
|
524
|
+
_preloadModules,
|
|
525
|
+
diff --git node/lib/vm.js node/lib/vm.js
|
|
526
|
+
index ae71080620..b05638de75 100644
|
|
527
|
+
--- node/lib/vm.js
|
|
528
|
+
+++ node/lib/vm.js
|
|
529
|
+
@@ -98,6 +98,7 @@ class Script extends ContextifyScript {
|
|
530
|
+
produceCachedData = false,
|
|
531
|
+
importModuleDynamically,
|
|
532
|
+
[kParsingContext]: parsingContext,
|
|
533
|
+
+ sourceless = false,
|
|
534
|
+
} = options;
|
|
535
|
+
|
|
536
|
+
validateString(filename, 'options.filename');
|
|
537
|
+
@@ -121,7 +122,8 @@ class Script extends ContextifyScript {
|
|
538
|
+
cachedData,
|
|
539
|
+
produceCachedData,
|
|
540
|
+
parsingContext,
|
|
541
|
+
- hostDefinedOptionId);
|
|
542
|
+
+ hostDefinedOptionId,
|
|
543
|
+
+ sourceless);
|
|
544
|
+
} catch (e) {
|
|
545
|
+
throw e; /* node-do-not-add-exception-line */
|
|
546
|
+
}
|
|
547
|
+
diff --git node/src/inspector_agent.cc node/src/inspector_agent.cc
|
|
548
|
+
index 5e1d9149dc..1426160ac0 100644
|
|
549
|
+
--- node/src/inspector_agent.cc
|
|
550
|
+
+++ node/src/inspector_agent.cc
|
|
551
|
+
@@ -858,11 +858,6 @@ bool Agent::Start(const std::string& path,
|
|
552
|
+
StartIoThreadAsyncCallback));
|
|
553
|
+
uv_unref(reinterpret_cast<uv_handle_t*>(&start_io_thread_async));
|
|
554
|
+
start_io_thread_async.data = this;
|
|
555
|
+
- if (parent_env_->should_start_debug_signal_handler()) {
|
|
556
|
+
- // Ignore failure, SIGUSR1 won't work, but that should not block node
|
|
557
|
+
- // start.
|
|
558
|
+
- StartDebugSignalHandler();
|
|
559
|
+
- }
|
|
560
|
+
|
|
561
|
+
parent_env_->AddCleanupHook([](void* data) {
|
|
562
|
+
Environment* env = static_cast<Environment*>(data);
|
|
563
|
+
diff --git node/src/node.cc node/src/node.cc
|
|
564
|
+
index 4ba019ddca..b30d716a41 100644
|
|
565
|
+
--- node/src/node.cc
|
|
566
|
+
+++ node/src/node.cc
|
|
567
|
+
@@ -351,6 +351,8 @@ MaybeLocal<Value> StartExecution(Environment* env,
|
|
568
|
+
return env->RunSnapshotDeserializeMain();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
+ StartExecution(env, "internal/bootstrap/pkg");
|
|
572
|
+
+
|
|
573
|
+
if (env->worker_context() != nullptr) {
|
|
574
|
+
return StartExecution(env, "internal/main/worker_thread");
|
|
575
|
+
}
|
|
576
|
+
@@ -575,14 +577,6 @@ static void PlatformInit(ProcessInitializationFlags::Flags flags) {
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
|
|
580
|
+
-#if HAVE_INSPECTOR
|
|
581
|
+
- sigset_t sigmask;
|
|
582
|
+
- sigemptyset(&sigmask);
|
|
583
|
+
- sigaddset(&sigmask, SIGUSR1);
|
|
584
|
+
- const int err = pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
|
585
|
+
- CHECK_EQ(err, 0);
|
|
586
|
+
-#endif // HAVE_INSPECTOR
|
|
587
|
+
-
|
|
588
|
+
ResetSignalHandlers();
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
diff --git node/src/node_contextify.cc node/src/node_contextify.cc
|
|
592
|
+
index 14534ab896..dad27d634e 100644
|
|
593
|
+
--- node/src/node_contextify.cc
|
|
594
|
+
+++ node/src/node_contextify.cc
|
|
595
|
+
@@ -88,6 +88,7 @@ using v8::String;
|
|
596
|
+
using v8::Symbol;
|
|
597
|
+
using v8::UnboundScript;
|
|
598
|
+
using v8::Value;
|
|
599
|
+
+using v8::V8;
|
|
600
|
+
|
|
601
|
+
// The vm module executes code in a sandboxed environment with a different
|
|
602
|
+
// global object than the rest of the code. This is achieved by applying
|
|
603
|
+
@@ -982,13 +983,13 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
604
|
+
Local<ArrayBufferView> cached_data_buf;
|
|
605
|
+
bool produce_cached_data = false;
|
|
606
|
+
Local<Context> parsing_context = context;
|
|
607
|
+
-
|
|
608
|
+
+ bool sourceless = false;
|
|
609
|
+
Local<Symbol> id_symbol;
|
|
610
|
+
if (argc > 2) {
|
|
611
|
+
// new ContextifyScript(code, filename, lineOffset, columnOffset,
|
|
612
|
+
// cachedData, produceCachedData, parsingContext,
|
|
613
|
+
- // hostDefinedOptionId)
|
|
614
|
+
- CHECK_EQ(argc, 8);
|
|
615
|
+
+ // hostDefinedOptionId, sourceless)
|
|
616
|
+
+ CHECK_GE(argc, 8);
|
|
617
|
+
CHECK(args[2]->IsNumber());
|
|
618
|
+
line_offset = args[2].As<Int32>()->Value();
|
|
619
|
+
CHECK(args[3]->IsNumber());
|
|
620
|
+
@@ -1009,6 +1010,11 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
621
|
+
}
|
|
622
|
+
CHECK(args[7]->IsSymbol());
|
|
623
|
+
id_symbol = args[7].As<Symbol>();
|
|
624
|
+
+
|
|
625
|
+
+ if (argc > 8) {
|
|
626
|
+
+ CHECK(args[8]->IsBoolean());
|
|
627
|
+
+ sourceless = args[8]->IsTrue();
|
|
628
|
+
+ }
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
ContextifyScript* contextify_script = New(env, args.This());
|
|
632
|
+
@@ -1055,6 +1061,10 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
633
|
+
ShouldNotAbortOnUncaughtScope no_abort_scope(env);
|
|
634
|
+
Context::Scope scope(parsing_context);
|
|
635
|
+
|
|
636
|
+
+ if (sourceless && produce_cached_data) {
|
|
637
|
+
+ V8::EnableCompilationForSourcelessUse();
|
|
638
|
+
+ }
|
|
639
|
+
+
|
|
640
|
+
MaybeLocal<UnboundScript> maybe_v8_script =
|
|
641
|
+
ScriptCompiler::CompileUnboundScript(isolate, &source, compile_options);
|
|
642
|
+
|
|
643
|
+
@@ -1069,6 +1079,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
+ if (sourceless && compile_options == ScriptCompiler::kConsumeCodeCache) {
|
|
648
|
+
+ if (!source.GetCachedData()->rejected) {
|
|
649
|
+
+ V8::FixSourcelessScript(env->isolate(), v8_script);
|
|
650
|
+
+ }
|
|
651
|
+
+ }
|
|
652
|
+
+
|
|
653
|
+
contextify_script->set_unbound_script(v8_script);
|
|
654
|
+
|
|
655
|
+
std::unique_ptr<ScriptCompiler::CachedData> new_cached_data;
|
|
656
|
+
@@ -1081,7 +1097,7 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
657
|
+
if (contextify_script->object()
|
|
658
|
+
->SetPrivate(context, env->host_defined_option_symbol(), id_symbol)
|
|
659
|
+
.IsNothing()) {
|
|
660
|
+
- return;
|
|
661
|
+
+return;
|
|
662
|
+
}
|
|
663
|
+
if (StoreCodeCacheResult(env,
|
|
664
|
+
self,
|
|
665
|
+
@@ -1092,6 +1108,9 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
|
|
666
|
+
.IsNothing()) {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
+ if (sourceless && produce_cached_data) {
|
|
670
|
+
+ V8::DisableCompilationForSourcelessUse();
|
|
671
|
+
+ }
|
|
672
|
+
if (self->Set(env->context(),
|
|
673
|
+
env->source_url_string(),
|
|
674
|
+
v8_script->GetSourceURL())
|
|
675
|
+
diff --git node/src/node_main.cc node/src/node_main.cc
|
|
676
|
+
index 3295121b87..bfe838b8c1 100644
|
|
677
|
+
--- node/src/node_main.cc
|
|
678
|
+
+++ node/src/node_main.cc
|
|
679
|
+
@@ -22,6 +22,8 @@
|
|
680
|
+
#include "node.h"
|
|
681
|
+
#include <cstdio>
|
|
682
|
+
|
|
683
|
+
+int reorder(int argc, char** argv);
|
|
684
|
+
+
|
|
685
|
+
#ifdef _WIN32
|
|
686
|
+
#include <windows.h>
|
|
687
|
+
#include <VersionHelpers.h>
|
|
688
|
+
@@ -88,12 +90,95 @@ int wmain(int argc, wchar_t* wargv[]) {
|
|
689
|
+
}
|
|
690
|
+
argv[argc] = nullptr;
|
|
691
|
+
// Now that conversion is done, we can finally start.
|
|
692
|
+
- return node::Start(argc, argv);
|
|
693
|
+
+ return reorder(argc, argv);
|
|
694
|
+
}
|
|
695
|
+
#else
|
|
696
|
+
// UNIX
|
|
697
|
+
|
|
698
|
+
int main(int argc, char* argv[]) {
|
|
699
|
+
+ return reorder(argc, argv);
|
|
700
|
+
+}
|
|
701
|
+
+#endif
|
|
702
|
+
+
|
|
703
|
+
+#include <string.h>
|
|
704
|
+
+
|
|
705
|
+
+int strlen2 (char* s) {
|
|
706
|
+
+ int len = 0;
|
|
707
|
+
+ while (*s) {
|
|
708
|
+
+ len += 1;
|
|
709
|
+
+ s += 1;
|
|
710
|
+
+ }
|
|
711
|
+
+ return len;
|
|
712
|
+
+}
|
|
713
|
+
+
|
|
714
|
+
+bool should_set_dummy() {
|
|
715
|
+
+#ifdef _WIN32
|
|
716
|
+
+ #define MAX_ENV_LENGTH 32767
|
|
717
|
+
+ wchar_t execpath_env[MAX_ENV_LENGTH];
|
|
718
|
+
+ DWORD result = GetEnvironmentVariableW(L"PKG_EXECPATH", execpath_env, MAX_ENV_LENGTH);
|
|
719
|
+
+ if (result == 0 && GetLastError() != ERROR_SUCCESS) return true;
|
|
720
|
+
+ return wcscmp(execpath_env, L"PKG_INVOKE_NODEJS") != 0;
|
|
721
|
+
+#else
|
|
722
|
+
+ const char* execpath_env = getenv("PKG_EXECPATH");
|
|
723
|
+
+ if (!execpath_env) return true;
|
|
724
|
+
+ return strcmp(execpath_env, "PKG_INVOKE_NODEJS") != 0;
|
|
725
|
+
+#endif
|
|
726
|
+
+}
|
|
727
|
+
+
|
|
728
|
+
+// for uv_setup_args
|
|
729
|
+
+int adjacent(int argc, char** argv) {
|
|
730
|
+
+ size_t size = 0;
|
|
731
|
+
+ for (int i = 0; i < argc; i++) {
|
|
732
|
+
+ size += strlen(argv[i]) + 1;
|
|
733
|
+
+ }
|
|
734
|
+
+ char* args = new char[size];
|
|
735
|
+
+ size_t pos = 0;
|
|
736
|
+
+ for (int i = 0; i < argc; i++) {
|
|
737
|
+
+ memcpy(&args[pos], argv[i], strlen(argv[i]) + 1);
|
|
738
|
+
+ argv[i] = &args[pos];
|
|
739
|
+
+ pos += strlen(argv[i]) + 1;
|
|
740
|
+
+ }
|
|
741
|
+
return node::Start(argc, argv);
|
|
742
|
+
}
|
|
743
|
+
+
|
|
744
|
+
+volatile char* BAKERY = (volatile char*) "\0// BAKERY // BAKERY " \
|
|
745
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
746
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY " \
|
|
747
|
+
+ "// BAKERY // BAKERY // BAKERY // BAKERY // BAKERY // BAKERY ";
|
|
748
|
+
+
|
|
749
|
+
+#ifdef __clang__
|
|
750
|
+
+__attribute__((optnone))
|
|
751
|
+
+#elif defined(__GNUC__)
|
|
752
|
+
+__attribute__((optimize(0)))
|
|
753
|
+
#endif
|
|
754
|
+
+
|
|
755
|
+
+int load_baked(char** nargv) {
|
|
756
|
+
+ int c = 1;
|
|
757
|
+
+
|
|
758
|
+
+ char* bakery = (char*) BAKERY;
|
|
759
|
+
+ while (true) {
|
|
760
|
+
+ size_t width = strlen2(bakery);
|
|
761
|
+
+ if (width == 0) break;
|
|
762
|
+
+ nargv[c++] = bakery;
|
|
763
|
+
+ bakery += width + 1;
|
|
764
|
+
+ }
|
|
765
|
+
+
|
|
766
|
+
+ return c;
|
|
767
|
+
+}
|
|
768
|
+
+
|
|
769
|
+
+int reorder(int argc, char** argv) {
|
|
770
|
+
+ char** nargv = new char*[argc + 64];
|
|
771
|
+
+
|
|
772
|
+
+ nargv[0] = argv[0];
|
|
773
|
+
+ int c = load_baked(nargv);
|
|
774
|
+
+
|
|
775
|
+
+ if (should_set_dummy()) {
|
|
776
|
+
+ nargv[c++] = (char*) "PKG_DUMMY_ENTRYPOINT";
|
|
777
|
+
+ }
|
|
778
|
+
+
|
|
779
|
+
+ for (int i = 1; i < argc; i++) {
|
|
780
|
+
+ nargv[c++] = argv[i];
|
|
781
|
+
+ }
|
|
782
|
+
+
|
|
783
|
+
+ return adjacent(c, nargv);
|
|
784
|
+
+}
|
|
785
|
+
diff --git node/src/node_options.cc node/src/node_options.cc
|
|
786
|
+
index 99c5a7dbe4..b0ae409120 100644
|
|
787
|
+
--- node/src/node_options.cc
|
|
788
|
+
+++ node/src/node_options.cc
|
|
789
|
+
@@ -466,6 +466,7 @@ void Parse(
|
|
790
|
+
// TODO(addaleax): Make that unnecessary.
|
|
791
|
+
|
|
792
|
+
DebugOptionsParser::DebugOptionsParser() {
|
|
793
|
+
+ return;
|
|
794
|
+
AddOption("--inspect-port",
|
|
795
|
+
"set host:port for inspector",
|
|
796
|
+
&DebugOptions::host_port,
|
|
797
|
+
diff --git node/tools/icu/icu-generic.gyp node/tools/icu/icu-generic.gyp
|
|
798
|
+
index f49b4ddba7..eb1e4c0f9b 100644
|
|
799
|
+
--- node/tools/icu/icu-generic.gyp
|
|
800
|
+
+++ node/tools/icu/icu-generic.gyp
|
|
801
|
+
@@ -52,7 +52,7 @@
|
|
802
|
+
'conditions': [
|
|
803
|
+
[ 'os_posix == 1 and OS != "mac" and OS != "ios"', {
|
|
804
|
+
'cflags': [ '-Wno-deprecated-declarations', '-Wno-strict-aliasing' ],
|
|
805
|
+
- 'cflags_cc': [ '-frtti' ],
|
|
806
|
+
+ 'cflags_cc': [ '-frtti', '-fno-lto' ],
|
|
807
|
+
'cflags_cc!': [ '-fno-rtti' ],
|
|
808
|
+
}],
|
|
809
|
+
[ 'OS == "mac" or OS == "ios"', {
|