No-copy kernel loading. (flutter/engine#5580)

Required by https://dart-review.googlesource.com/c/sdk/+/60202
This commit is contained in:
Ryan Macnak
2018-06-21 15:44:04 -07:00
committed by GitHub
parent bfc31675be
commit 0474c47fec
2 changed files with 19 additions and 6 deletions

View File

@@ -278,8 +278,9 @@ bool DartIsolate::PrepareForRunningFromPrecompiledCode() {
return true;
}
static bool LoadScriptSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
bool DartIsolate::LoadScriptSnapshot(
std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
FXL_CHECK(last_piece) << "Script snapshots cannot be divided";
if (tonic::LogIfError(Dart_LoadScriptFromSnapshot(mapping->GetMapping(),
mapping->GetSize()))) {
@@ -288,8 +289,12 @@ static bool LoadScriptSnapshot(std::shared_ptr<const fml::Mapping> mapping,
return true;
}
static bool LoadKernelSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
bool DartIsolate::LoadKernelSnapshot(
std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
// Mapping must be retained until isolate shutdown.
kernel_buffers_.push_back(mapping);
Dart_Handle library =
Dart_LoadLibraryFromKernel(mapping->GetMapping(), mapping->GetSize());
if (tonic::LogIfError(library)) {
@@ -308,8 +313,8 @@ static bool LoadKernelSnapshot(std::shared_ptr<const fml::Mapping> mapping,
return true;
}
static bool LoadSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
bool DartIsolate::LoadSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece) {
if (Dart_IsKernel(mapping->GetMapping(), mapping->GetSize())) {
return LoadKernelSnapshot(std::move(mapping), last_piece);
} else {

View File

@@ -92,6 +92,13 @@ class DartIsolate : public UIDartState {
fml::WeakPtr<DartIsolate> GetWeakIsolatePtr() const;
private:
bool LoadScriptSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece);
bool LoadKernelSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece);
bool LoadSnapshot(std::shared_ptr<const fml::Mapping> mapping,
bool last_piece);
class AutoFireClosure {
public:
AutoFireClosure(fxl::Closure closure) : closure_(std::move(closure)) {}
@@ -111,6 +118,7 @@ class DartIsolate : public UIDartState {
Phase phase_ = Phase::Unknown;
const fxl::RefPtr<DartSnapshot> isolate_snapshot_;
const fxl::RefPtr<DartSnapshot> shared_snapshot_;
std::vector<std::shared_ptr<const fml::Mapping>> kernel_buffers_;
std::vector<std::unique_ptr<AutoFireClosure>> shutdown_callbacks_;
ChildIsolatePreparer child_isolate_preparer_;
std::unique_ptr<fml::WeakPtrFactory<DartIsolate>> weak_factory_;