Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a193f08

Browse files
authored
[fuchsia] Switch from core-jit to core snapshots. (#30744)
1 parent fab1982 commit a193f08

File tree

10 files changed

+37
-95
lines changed

10 files changed

+37
-95
lines changed

shell/platform/fuchsia/dart_runner/BUILD.gn

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,11 @@ template("jit_runner_package") {
223223
rebase_path("$target_gen_dir/kernel/vm_data${product_suffix}.bin")
224224
dest = "vm_snapshot_data.bin"
225225
},
226-
{
227-
path = rebase_path(
228-
"$target_gen_dir/kernel/vm_instructions${product_suffix}.bin")
229-
dest = "vm_snapshot_instructions.bin"
230-
},
231226
{
232227
path = rebase_path(
233228
"$target_gen_dir/kernel/isolate_data${product_suffix}.bin")
234229
dest = "isolate_core_snapshot_data.bin"
235230
},
236-
{
237-
path = rebase_path(
238-
"$target_gen_dir/kernel/isolate_instructions${product_suffix}.bin")
239-
dest = "isolate_core_snapshot_instructions.bin"
240-
},
241231
]
242232

243233
if (!invoker.product) {

shell/platform/fuchsia/dart_runner/dart_component_controller.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,10 @@ bool DartComponentController::SetupFromKernel() {
205205
isolate_snapshot_data_)) {
206206
return false;
207207
}
208-
if (!dart_utils::MappedResource::LoadFromNamespace(
209-
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
210-
isolate_snapshot_instructions_, true /* executable */)) {
211-
return false;
212-
}
213208

209+
// The core snapshot does not separate instructions from data.
214210
if (!CreateIsolate(isolate_snapshot_data_.address(),
215-
isolate_snapshot_instructions_.address())) {
211+
nullptr /* isolate_snapshot_instructions */)) {
216212
return false;
217213
}
218214

@@ -276,16 +272,16 @@ bool DartComponentController::SetupFromAppSnapshot() {
276272
return false;
277273
}
278274
} else {
275+
// TODO(fxb/91200): This code path was broken for over a year and is
276+
// probably not used.
279277
if (!dart_utils::MappedResource::LoadFromNamespace(
280278
namespace_, data_path_ + "/isolate_snapshot_data.bin",
281279
isolate_snapshot_data_)) {
282280
return false;
283281
}
284-
if (!dart_utils::MappedResource::LoadFromNamespace(
285-
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
286-
isolate_snapshot_instructions_, true /* executable */)) {
287-
return false;
288-
}
282+
isolate_data = isolate_snapshot_data_.address();
283+
// We don't separate instructions from data in 'core' snapshots.
284+
isolate_instructions = nullptr;
289285
}
290286
return CreateIsolate(isolate_data, isolate_instructions);
291287
#endif // defined(AOT_RUNTIME)

shell/platform/fuchsia/dart_runner/dart_component_controller_v2.cc

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ bool DartComponentControllerV2::CreateAndBindNamespace() {
213213

214214
bool DartComponentControllerV2::SetUpFromKernel() {
215215
dart_utils::MappedResource manifest;
216+
216217
if (!dart_utils::MappedResource::LoadFromNamespace(
217218
namespace_, data_path_ + "/app.dilplist", manifest)) {
218219
return false;
@@ -223,14 +224,10 @@ bool DartComponentControllerV2::SetUpFromKernel() {
223224
isolate_snapshot_data_)) {
224225
return false;
225226
}
226-
if (!dart_utils::MappedResource::LoadFromNamespace(
227-
nullptr, "/pkg/data/isolate_core_snapshot_instructions.bin",
228-
isolate_snapshot_instructions_, true /* executable */)) {
229-
return false;
230-
}
231227

228+
// The core snapshot does not separate instructions from data.
232229
if (!CreateIsolate(isolate_snapshot_data_.address(),
233-
isolate_snapshot_instructions_.address())) {
230+
nullptr /* isolate_snapshot_instructions */)) {
234231
return false;
235232
}
236233

@@ -295,16 +292,16 @@ bool DartComponentControllerV2::SetUpFromAppSnapshot() {
295292
return false;
296293
}
297294
} else {
295+
// TODO(fxb/91200): This code path was broken for over a year and is
296+
// probably not used.
298297
if (!dart_utils::MappedResource::LoadFromNamespace(
299298
namespace_, data_path_ + "/isolate_snapshot_data.bin",
300299
isolate_snapshot_data_)) {
301300
return false;
302301
}
303-
if (!dart_utils::MappedResource::LoadFromNamespace(
304-
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
305-
isolate_snapshot_instructions_, true /* executable */)) {
306-
return false;
307-
}
302+
isolate_data = isolate_snapshot_data_.address();
303+
// We don't separate instructions from data in 'core' snapshots.
304+
isolate_instructions = nullptr;
308305
}
309306
return CreateIsolate(isolate_data, isolate_instructions);
310307
#endif // defined(AOT_RUNTIME)

shell/platform/fuchsia/dart_runner/dart_runner.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,7 @@ DartRunner::DartRunner(sys::ComponentContext* context) : context_(context) {
200200
nullptr, "/pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
201201
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
202202
}
203-
if (!dart_utils::MappedResource::LoadFromNamespace(
204-
nullptr, "/pkg/data/vm_snapshot_instructions.bin",
205-
vm_snapshot_instructions_, true /* executable */)) {
206-
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
207-
}
208203
params.vm_snapshot_data = vm_snapshot_data_.address();
209-
params.vm_snapshot_instructions = vm_snapshot_instructions_.address();
210204
#endif
211205
params.create_group = IsolateGroupCreateCallback;
212206
params.shutdown_isolate = IsolateShutdownCallback;

shell/platform/fuchsia/dart_runner/kernel/BUILD.gn

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,11 @@ template("create_kernel_core_snapshot") {
4040
inputs = [ platform_dill ]
4141

4242
vm_snapshot_data = "$target_gen_dir/vm_data${product_suffix}.bin"
43-
vm_snapshot_instructions =
44-
"$target_gen_dir/vm_instructions${product_suffix}.bin"
4543
isolate_snapshot_data = "$target_gen_dir/isolate_data${product_suffix}.bin"
46-
isolate_snapshot_instructions =
47-
"$target_gen_dir/isolate_instructions${product_suffix}.bin"
4844
snapshot_profile = "$target_gen_dir/snapshot_profile${product_suffix}.json"
4945
outputs = [
5046
vm_snapshot_data,
51-
vm_snapshot_instructions,
5247
isolate_snapshot_data,
53-
isolate_snapshot_instructions,
5448
snapshot_profile,
5549
]
5650

@@ -65,14 +59,10 @@ template("create_kernel_core_snapshot") {
6559
"--lazy_async_stacks",
6660
"--enable_mirrors=false",
6761
"--deterministic",
68-
"--snapshot_kind=core-jit",
62+
"--snapshot_kind=core",
6963
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
70-
"--vm_snapshot_instructions=" +
71-
rebase_path(vm_snapshot_instructions, root_build_dir),
7264
"--isolate_snapshot_data=" +
7365
rebase_path(isolate_snapshot_data, root_build_dir),
74-
"--isolate_snapshot_instructions=" +
75-
rebase_path(isolate_snapshot_instructions, root_build_dir),
7666
"--write_v8_snapshot_profile_to=" +
7767
rebase_path(snapshot_profile, root_build_dir),
7868
]

shell/platform/fuchsia/dart_runner/service_isolate.cc

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ Dart_Isolate CreateServiceIsolate(
9696
"/pkg/data/vmservice_isolate_snapshot_data.bin";
9797
const char* snapshot_instructions_path =
9898
"/pkg/data/vmservice_isolate_snapshot_instructions.bin";
99-
#else
100-
// The VM service is embedded in the core snapshot.
101-
const char* snapshot_data_path = "/pkg/data/isolate_core_snapshot_data.bin";
102-
const char* snapshot_instructions_path =
103-
"/pkg/data/isolate_core_snapshot_instructions.bin";
104-
#endif
10599

106100
if (!dart_utils::MappedResource::LoadFromNamespace(
107101
nullptr, snapshot_data_path, mapped_isolate_snapshot_data)) {
@@ -119,8 +113,21 @@ Dart_Isolate CreateServiceIsolate(
119113

120114
vmservice_data = mapped_isolate_snapshot_data.address();
121115
vmservice_instructions = mapped_isolate_snapshot_instructions.address();
122-
#if defined(AOT_RUNTIME)
123116
}
117+
#else
118+
// The VM service is embedded in the core snapshot.
119+
// 'core' snapshot_kinds do not separate instructions from data, so we don't
120+
// load an instructions file.
121+
const char* snapshot_data_path = "/pkg/data/isolate_core_snapshot_data.bin";
122+
if (!dart_utils::MappedResource::LoadFromNamespace(
123+
nullptr, snapshot_data_path, mapped_isolate_snapshot_data)) {
124+
*error = strdup("Failed to load snapshot for service isolate");
125+
FX_LOG(ERROR, LOG_TAG, *error);
126+
return nullptr;
127+
}
128+
129+
vmservice_data = mapped_isolate_snapshot_data.address();
130+
vmservice_instructions = nullptr;
124131
#endif
125132

126133
bool is_null_safe =

shell/platform/fuchsia/flutter/BUILD.gn

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,21 +346,11 @@ template("jit_runner") {
346346
"$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
347347
dest = "vm_snapshot_data.bin"
348348
},
349-
{
350-
path = rebase_path(
351-
"$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
352-
dest = "vm_snapshot_instructions.bin"
353-
},
354349
{
355350
path = rebase_path(
356351
"$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
357352
dest = "isolate_core_snapshot_data.bin"
358353
},
359-
{
360-
path = rebase_path(
361-
"$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
362-
dest = "isolate_core_snapshot_instructions.bin"
363-
},
364354
]
365355

366356
_vulkan_icds = []

shell/platform/fuchsia/flutter/component_v1.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,13 @@ ComponentV1::ComponentV1(
348348
return MakeFileMapping("/pkg/data/vm_snapshot_data.bin",
349349
false /* executable */);
350350
};
351-
settings_.vm_snapshot_instr = []() {
352-
return MakeFileMapping("/pkg/data/vm_snapshot_instructions.bin",
353-
true /* executable */);
354-
};
355-
356351
settings_.isolate_snapshot_data = []() {
357352
return MakeFileMapping("/pkg/data/isolate_core_snapshot_data.bin",
358353
false /* executable */);
359354
};
360-
settings_.isolate_snapshot_instr = [] {
361-
return MakeFileMapping("/pkg/data/isolate_core_snapshot_instructions.bin",
362-
true /* executable */);
363-
};
355+
356+
// 'core' snapshots do not separate instructions from data, so we
357+
// don't set isolate_snapshot_instr here.
364358
}
365359

366360
#if defined(DART_PRODUCT)

shell/platform/fuchsia/flutter/component_v2.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,13 @@ ComponentV2::ComponentV2(
412412
return MakeFileMapping("/pkg/data/vm_snapshot_data.bin",
413413
false /* executable */);
414414
};
415-
settings_.vm_snapshot_instr = []() {
416-
return MakeFileMapping("/pkg/data/vm_snapshot_instructions.bin",
417-
true /* executable */);
418-
};
419-
420415
settings_.isolate_snapshot_data = []() {
421416
return MakeFileMapping("/pkg/data/isolate_core_snapshot_data.bin",
422417
false /* executable */);
423418
};
424-
settings_.isolate_snapshot_instr = [] {
425-
return MakeFileMapping("/pkg/data/isolate_core_snapshot_instructions.bin",
426-
true /* executable */);
427-
};
419+
420+
// 'core' snapshots do not separate instructions from data, so we
421+
// don't set isolate_snapshot_instr here.
428422
}
429423

430424
#if defined(DART_PRODUCT)

shell/platform/fuchsia/flutter/kernel/BUILD.gn

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,11 @@ template("core_snapshot") {
4444
inputs = [ platform_dill ]
4545

4646
vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot${suffix}.bin"
47-
vm_snapshot_instructions =
48-
"$target_gen_dir/vm_snapshot_instructions${suffix}.bin"
4947
isolate_snapshot_data = "$target_gen_dir/isolate_snapshot${suffix}.bin"
50-
isolate_snapshot_instructions =
51-
"$target_gen_dir/isolate_snapshot_instructions${suffix}.bin"
5248
snapshot_profile = "$target_gen_dir/snapshot_profile${suffix}.json"
5349
outputs = [
5450
vm_snapshot_data,
55-
vm_snapshot_instructions,
5651
isolate_snapshot_data,
57-
isolate_snapshot_instructions,
5852
snapshot_profile,
5953
]
6054

@@ -69,14 +63,10 @@ template("core_snapshot") {
6963
"--lazy_async_stacks",
7064
"--enable_mirrors=false",
7165
"--deterministic",
72-
"--snapshot_kind=core-jit",
66+
"--snapshot_kind=core",
7367
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
74-
"--vm_snapshot_instructions=" +
75-
rebase_path(vm_snapshot_instructions, root_build_dir),
7668
"--isolate_snapshot_data=" +
7769
rebase_path(isolate_snapshot_data, root_build_dir),
78-
"--isolate_snapshot_instructions=" +
79-
rebase_path(isolate_snapshot_instructions, root_build_dir),
8070
"--write_v8_snapshot_profile_to=" +
8171
rebase_path(snapshot_profile, root_build_dir),
8272
]

0 commit comments

Comments
 (0)