@@ -83,6 +83,12 @@ size_t SeaSerializer::Write(const SeaResource& sea) {
83
83
written_total += WriteArithmetic<uint32_t >(flags);
84
84
DCHECK_EQ (written_total, SeaResource::kHeaderSize );
85
85
86
+ Debug (" Write SEA code path %p, size=%zu\n " ,
87
+ sea.code_path .data (),
88
+ sea.code_path .size ());
89
+ written_total +=
90
+ WriteStringView (sea.code_path , StringLogMode::kAddressAndContent );
91
+
86
92
Debug (" Write SEA resource code %p, size=%zu\n " ,
87
93
sea.code .data (),
88
94
sea.code .size ());
@@ -117,14 +123,19 @@ SeaResource SeaDeserializer::Read() {
117
123
Debug (" Read SEA flags %x\n " , static_cast <uint32_t >(flags));
118
124
CHECK_EQ (read_total, SeaResource::kHeaderSize );
119
125
126
+ std::string_view code_path =
127
+ ReadStringView (StringLogMode::kAddressAndContent );
128
+ Debug (
129
+ " Read SEA code path %p, size=%zu\n " , code_path.data (), code_path.size ());
130
+
120
131
std::string_view code = ReadStringView (StringLogMode::kAddressAndContent );
121
132
Debug (" Read SEA resource code %p, size=%zu\n " , code.data (), code.size ());
122
133
123
134
std::string_view code_cache = ReadStringView (StringLogMode::kAddressOnly );
124
135
Debug (" Read SEA resource code cache %p, size=%zu\n " ,
125
136
code_cache.data (),
126
137
code_cache.size ());
127
- return {flags, code, code_cache};
138
+ return {flags, code_path, code, code_cache};
128
139
}
129
140
130
141
std::string_view FindSingleExecutableBlob () {
@@ -208,6 +219,26 @@ void GetCodeCache(const FunctionCallbackInfo<Value>& args) {
208
219
args.GetReturnValue ().Set (buf);
209
220
}
210
221
222
+ void GetCodePath (const FunctionCallbackInfo<Value>& args) {
223
+ if (!IsSingleExecutable ()) {
224
+ return ;
225
+ }
226
+
227
+ Environment* env = Environment::GetCurrent (args);
228
+ Isolate* isolate = env->isolate ();
229
+ HandleScope scope (isolate);
230
+
231
+ SeaResource sea_resource = FindSingleExecutableResource ();
232
+
233
+ Local<String> code_path;
234
+ if (!String::NewFromUtf8 (isolate, sea_resource.code_path .data ())
235
+ .ToLocal (&code_path)) {
236
+ return ;
237
+ }
238
+
239
+ args.GetReturnValue ().Set (code_path);
240
+ }
241
+
211
242
std::tuple<int , char **> FixupArgsForSEA (int argc, char ** argv) {
212
243
// Repeats argv[0] at position 1 on argv as a replacement for the missing
213
244
// entry point file path.
@@ -346,7 +377,7 @@ ExitCode GenerateSingleExecutableBlob(const SeaConfig& config) {
346
377
}
347
378
std::string code_cache = optional_code_cache.value ();
348
379
349
- SeaResource sea{config.flags , main_script, code_cache};
380
+ SeaResource sea{config.flags , config. main_path , main_script, code_cache};
350
381
351
382
SeaSerializer serializer;
352
383
serializer.Write (sea);
@@ -386,11 +417,13 @@ void Initialize(Local<Object> target,
386
417
target,
387
418
" isExperimentalSeaWarningNeeded" ,
388
419
IsExperimentalSeaWarningNeeded);
420
+ SetMethod (context, target, " getCodePath" , GetCodePath);
389
421
SetMethod (context, target, " getCodeCache" , GetCodeCache);
390
422
}
391
423
392
424
void RegisterExternalReferences (ExternalReferenceRegistry* registry) {
393
425
registry->Register (IsExperimentalSeaWarningNeeded);
426
+ registry->Register (GetCodePath);
394
427
registry->Register (GetCodeCache);
395
428
}
396
429
0 commit comments