Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -986,8 +986,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/integration/meta/dart_
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/kernel/libraries.json
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/logging.h
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/main.cc
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/mapped_resource.cc
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/mapped_resource.h
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/aot_product_runtime
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/aot_runtime
FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/meta/dart_aot_product_runner.cmx
Expand Down Expand Up @@ -1070,6 +1068,8 @@ FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/handle_exceptio
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/handle_exception.h
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/inlines.h
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/logging.h
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/mapped_resource.cc
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/mapped_resource.h
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/tempfs.cc
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/tempfs.h
FILE: ../../../flutter/shell/platform/fuchsia/runtime/dart/utils/vmo.cc
Expand Down
31 changes: 13 additions & 18 deletions shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ template("runner") {
"dart_runner.h",
"logging.h",
"main.cc",
"mapped_resource.cc",
"mapped_resource.h",
"service_isolate.cc",
"service_isolate.h",
]
Expand All @@ -41,17 +39,22 @@ template("runner") {

dart_deps = []
if (!invoker.product) {
dart_deps += [ "//third_party/dart/runtime/bin:dart_io_api" ]
dart_deps += [
"//third_party/dart/runtime/bin:dart_io_api",
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils:utils",
]
} else {
dart_deps += [ "//third_party/dart/runtime/bin:dart_io_api_product" ]
dart_deps += [
"//third_party/dart/runtime/bin:dart_io_api_product",
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils:utils_product",
]
}

deps = [
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/shell/platform/fuchsia/dart-pkg/fuchsia",
"$flutter_root/shell/platform/fuchsia/dart-pkg/zircon",
"$flutter_root/shell/platform/fuchsia/runtime/dart/utils",
"$fuchsia_sdk_root/pkg:async",
"$fuchsia_sdk_root/pkg:async-cpp",
"$fuchsia_sdk_root/pkg:async-default",
Expand Down Expand Up @@ -156,32 +159,24 @@ template("aot_runner_package") {

resources = []
if (!invoker.product) {
vmservice_data = rebase_path(
get_label_info("vmservice:vmservice_snapshot", "target_gen_dir") +
"/vmservice_data.aotsnapshot")
vmservice_instr = rebase_path(
vmservice_snapshot = rebase_path(
get_label_info("vmservice:vmservice_snapshot", "target_gen_dir") +
"/vmservice_instructions.aotsnapshot")
"/vmservice_snapshot.so")
dart_profiler_symbols = rebase_path(
get_label_info(
"$flutter_root/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_aot_runner",
"target_gen_dir") + "/dart_aot_runner.dartprofilersymbols")

inputs = [
vmservice_data,
vmservice_instr,
vmservice_snapshot,
observatory_archive_file,
dart_profiler_symbols,
]

resources += [
{
path = vmservice_data
dest = "vmservice_isolate_snapshot_data.bin"
},
{
path = vmservice_instr
dest = "vmservice_isolate_snapshot_instructions.bin"
path = vmservice_snapshot
dest = "vmservice_snapshot.so"
},
{
path = rebase_path(observatory_archive_file)
Expand Down
51 changes: 29 additions & 22 deletions shell/platform/fuchsia/dart_runner/dart_component_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <regex>
#include <utility>

#include "runtime/dart/utils/files.h"
#include "runtime/dart/utils/handle_exception.h"
#include "runtime/dart/utils/inlines.h"
#include "runtime/dart/utils/tempfs.h"
Expand Down Expand Up @@ -193,18 +194,18 @@ bool DartComponentController::SetupNamespace() {
}

bool DartComponentController::SetupFromKernel() {
MappedResource manifest;
if (!MappedResource::LoadFromNamespace(
dart_utils::MappedResource manifest;
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/app.dilplist", manifest)) {
return false;
}

if (!MappedResource::LoadFromNamespace(
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "pkg/data/isolate_core_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
if (!MappedResource::LoadFromNamespace(
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "pkg/data/isolate_core_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
Expand All @@ -231,8 +232,9 @@ bool DartComponentController::SetupFromKernel() {
std::string path = data_path_ + "/" + str.substr(start, end - start);
start = end + 1;

MappedResource kernel;
if (!MappedResource::LoadFromNamespace(namespace_, path, kernel)) {
dart_utils::MappedResource kernel;
if (!dart_utils::MappedResource::LoadFromNamespace(namespace_, path,
kernel)) {
FX_LOGF(ERROR, LOG_TAG, "Failed to find kernel: %s", path.c_str());
Dart_ExitScope();
return false;
Expand Down Expand Up @@ -262,25 +264,30 @@ bool DartComponentController::SetupFromKernel() {

bool DartComponentController::SetupFromAppSnapshot() {
#if !defined(AOT_RUNTIME)
// If we start generating app-jit snapshots, the code below should be able
// handle that case without modification.
return false;
#else

if (!MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}

if (!MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
// Load the ELF snapshot as available, and fall back to a blobs snapshot
// otherwise.
const uint8_t *isolate_data, *isolate_instructions;
if (elf_snapshot_.Load(namespace_, data_path_ + "/app_aot_snapshot.so")) {
isolate_data = elf_snapshot_.IsolateData();
isolate_instructions = elf_snapshot_.IsolateInstrs();
if (isolate_data == nullptr || isolate_instructions == nullptr) {
return false;
}
} else {
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_data.bin",
isolate_snapshot_data_)) {
return false;
}
if (!dart_utils::MappedResource::LoadFromNamespace(
namespace_, data_path_ + "/isolate_snapshot_instructions.bin",
isolate_snapshot_instructions_, true /* executable */)) {
return false;
}
}

return CreateIsolate(isolate_snapshot_data_.address(),
isolate_snapshot_instructions_.address());
return CreateIsolate(isolate_data, isolate_instructions);
#endif // defined(AOT_RUNTIME)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <lib/zx/timer.h>

#include "lib/fidl/cpp/binding.h"
#include "mapped_resource.h"
#include "runtime/dart/utils/mapped_resource.h"
#include "third_party/dart/runtime/include/dart_api.h"

namespace dart_runner {
Expand Down Expand Up @@ -72,9 +72,10 @@ class DartComponentController : public fuchsia::sys::ComponentController {
fdio_ns_t* namespace_ = nullptr;
int stdoutfd_ = -1;
int stderrfd_ = -1;
MappedResource isolate_snapshot_data_;
MappedResource isolate_snapshot_instructions_;
std::vector<MappedResource> kernel_peices_;
dart_utils::ElfSnapshot elf_snapshot_; // AOT snapshot
dart_utils::MappedResource isolate_snapshot_data_; // JIT snapshot
dart_utils::MappedResource isolate_snapshot_instructions_; // JIT snapshot
std::vector<dart_utils::MappedResource> kernel_peices_;

Dart_Isolate isolate_;
int32_t return_code_ = 0;
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/fuchsia/dart_runner/dart_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ DartRunner::DartRunner() : context_(sys::ComponentContext::Create()) {
params.vm_snapshot_data = ::_kDartVmSnapshotData;
params.vm_snapshot_instructions = ::_kDartVmSnapshotInstructions;
#else
if (!MappedResource::LoadFromNamespace(
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "pkg/data/vm_snapshot_data.bin", vm_snapshot_data_)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot data");
}
if (!MappedResource::LoadFromNamespace(
if (!dart_utils::MappedResource::LoadFromNamespace(
nullptr, "pkg/data/vm_snapshot_instructions.bin",
vm_snapshot_instructions_, true /* executable */)) {
FX_LOG(FATAL, LOG_TAG, "Failed to load vm snapshot instructions");
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/fuchsia/dart_runner/dart_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <lib/fidl/cpp/binding_set.h>
#include <lib/sys/cpp/component_context.h>

#include "mapped_resource.h"
#include "runtime/dart/utils/mapped_resource.h"

namespace dart_runner {

Expand All @@ -30,8 +30,8 @@ class DartRunner : public fuchsia::sys::Runner {
fidl::BindingSet<fuchsia::sys::Runner> bindings_;

#if !defined(AOT_RUNTIME)
MappedResource vm_snapshot_data_;
MappedResource vm_snapshot_instructions_;
dart_utils::MappedResource vm_snapshot_data_;
dart_utils::MappedResource vm_snapshot_instructions_;
#endif

// Disallow copy and assignment.
Expand Down
100 changes: 0 additions & 100 deletions shell/platform/fuchsia/dart_runner/mapped_resource.cc

This file was deleted.

Loading