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
2 changes: 0 additions & 2 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ FILE: ../../../flutter/runtime/dart_service_isolate.h
FILE: ../../../flutter/runtime/dart_service_isolate_unittests.cc
FILE: ../../../flutter/runtime/dart_snapshot.cc
FILE: ../../../flutter/runtime/dart_snapshot.h
FILE: ../../../flutter/runtime/dart_snapshot_buffer.cc
FILE: ../../../flutter/runtime/dart_snapshot_buffer.h
FILE: ../../../flutter/runtime/dart_vm.cc
FILE: ../../../flutter/runtime/dart_vm.h
FILE: ../../../flutter/runtime/dart_vm_data.cc
Expand Down
41 changes: 41 additions & 0 deletions fml/mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

#include "flutter/fml/mapping.h"

#include <sstream>

namespace fml {

// FileMapping

uint8_t* FileMapping::GetMutableMapping() {
return mutable_mapping_;
}

// Data Mapping

DataMapping::DataMapping(std::vector<uint8_t> data) : data_(std::move(data)) {}

DataMapping::~DataMapping() = default;
Expand All @@ -22,6 +28,8 @@ const uint8_t* DataMapping::GetMapping() const {
return data_.data();
}

// NonOwnedMapping

size_t NonOwnedMapping::GetSize() const {
return size_;
}
Expand All @@ -30,4 +38,37 @@ const uint8_t* NonOwnedMapping::GetMapping() const {
return data_;
}

// Symbol Mapping

SymbolMapping::SymbolMapping(fml::RefPtr<fml::NativeLibrary> native_library,
const char* symbol_name)
: native_library_(std::move(native_library)) {
if (native_library_ && symbol_name != nullptr) {
mapping_ = native_library_->ResolveSymbol(symbol_name);

if (mapping_ == nullptr) {
// Apparently, dart_bootstrap seems to account for the Mac behavior of
// requiring the underscore prefixed symbol name on non-Mac platforms as
// well. As a fallback, check the underscore prefixed variant of the
// symbol name and allow callers to not have handle this on a per platform
// toolchain quirk basis.

std::stringstream underscore_symbol_name;
underscore_symbol_name << "_" << symbol_name;
mapping_ =
native_library_->ResolveSymbol(underscore_symbol_name.str().c_str());
}
}
}

SymbolMapping::~SymbolMapping() = default;

size_t SymbolMapping::GetSize() const {
return 0;
}

const uint8_t* SymbolMapping::GetMapping() const {
return mapping_;
}

} // namespace fml
33 changes: 30 additions & 3 deletions fml/mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "flutter/fml/build_config.h"
#include "flutter/fml/file.h"
#include "flutter/fml/macros.h"
#include "flutter/fml/native_library.h"
#include "flutter/fml/unique_fd.h"

namespace fml {
Expand All @@ -31,7 +32,7 @@ class Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(Mapping);
};

class FileMapping : public Mapping {
class FileMapping final : public Mapping {
public:
enum class Protection {
kRead,
Expand All @@ -45,8 +46,10 @@ class FileMapping : public Mapping {

~FileMapping() override;

// |Mapping|
size_t GetSize() const override;

// |Mapping|
const uint8_t* GetMapping() const override;

uint8_t* GetMutableMapping();
Expand All @@ -63,14 +66,16 @@ class FileMapping : public Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(FileMapping);
};

class DataMapping : public Mapping {
class DataMapping final : public Mapping {
public:
DataMapping(std::vector<uint8_t> data);

~DataMapping() override;

// |Mapping|
size_t GetSize() const override;

// |Mapping|
const uint8_t* GetMapping() const override;

private:
Expand All @@ -79,13 +84,15 @@ class DataMapping : public Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(DataMapping);
};

class NonOwnedMapping : public Mapping {
class NonOwnedMapping final : public Mapping {
public:
NonOwnedMapping(const uint8_t* data, size_t size)
: data_(data), size_(size) {}

// |Mapping|
size_t GetSize() const override;

// |Mapping|
const uint8_t* GetMapping() const override;

private:
Expand All @@ -95,6 +102,26 @@ class NonOwnedMapping : public Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(NonOwnedMapping);
};

class SymbolMapping final : public Mapping {
public:
SymbolMapping(fml::RefPtr<fml::NativeLibrary> native_library,
const char* symbol_name);

~SymbolMapping() override;

// |Mapping|
size_t GetSize() const override;

// |Mapping|
const uint8_t* GetMapping() const override;

private:
fml::RefPtr<fml::NativeLibrary> native_library_;
const uint8_t* mapping_ = nullptr;

FML_DISALLOW_COPY_AND_ASSIGN(SymbolMapping);
};

} // namespace fml

#endif // FLUTTER_FML_MAPPING_H_
2 changes: 0 additions & 2 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ source_set("runtime") {
"dart_service_isolate.h",
"dart_snapshot.cc",
"dart_snapshot.h",
"dart_snapshot_buffer.cc",
"dart_snapshot_buffer.h",
"dart_vm.cc",
"dart_vm.h",
"dart_vm_data.cc",
Expand Down
13 changes: 5 additions & 8 deletions runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,11 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair(
Dart_Isolate isolate = Dart_CreateIsolate(
advisory_script_uri, //
advisory_script_entrypoint, //
(*embedder_isolate)
->GetIsolateSnapshot()
->GetData()
->GetSnapshotPointer(),
(*embedder_isolate)->GetIsolateSnapshot()->GetInstructionsIfPresent(),
(*embedder_isolate)->GetSharedSnapshot()->GetDataIfPresent(),
(*embedder_isolate)->GetSharedSnapshot()->GetInstructionsIfPresent(),
flags, embedder_isolate.get(), error);
(*embedder_isolate)->GetIsolateSnapshot()->GetDataMapping(),
(*embedder_isolate)->GetIsolateSnapshot()->GetInstructionsMapping(),
(*embedder_isolate)->GetSharedSnapshot()->GetDataMapping(),
(*embedder_isolate)->GetSharedSnapshot()->GetInstructionsMapping(), flags,
embedder_isolate.get(), error);

if (isolate == nullptr) {
FML_DLOG(ERROR) << *error;
Expand Down
Loading