Skip to content

Commit

Permalink
Revert "Remove DartSnapshotBuffer and dry up snapshot resolution logi…
Browse files Browse the repository at this point in the history
…c. (flutter#8640)" (flutter#8644)

This reverts commit 905ddb6.
  • Loading branch information
chinmaygarde authored Apr 18, 2019
1 parent 9a53f5f commit 0fcfa0d
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 191 deletions.
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ 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: 0 additions & 41 deletions fml/mapping.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@

#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 @@ -28,8 +22,6 @@ const uint8_t* DataMapping::GetMapping() const {
return data_.data();
}

// NonOwnedMapping

size_t NonOwnedMapping::GetSize() const {
return size_;
}
Expand All @@ -38,37 +30,4 @@ 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: 3 additions & 30 deletions fml/mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#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 @@ -32,7 +31,7 @@ class Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(Mapping);
};

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

~FileMapping() override;

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

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

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

class DataMapping final : public Mapping {
class DataMapping : 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 @@ -84,15 +79,13 @@ class DataMapping final : public Mapping {
FML_DISALLOW_COPY_AND_ASSIGN(DataMapping);
};

class NonOwnedMapping final : public Mapping {
class NonOwnedMapping : 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 @@ -102,26 +95,6 @@ class NonOwnedMapping final : 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: 2 additions & 0 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ 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: 8 additions & 5 deletions runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,14 @@ DartIsolate::CreateDartVMAndEmbedderObjectPair(
Dart_Isolate isolate = Dart_CreateIsolate(
advisory_script_uri, //
advisory_script_entrypoint, //
(*embedder_isolate)->GetIsolateSnapshot()->GetDataMapping(),
(*embedder_isolate)->GetIsolateSnapshot()->GetInstructionsMapping(),
(*embedder_isolate)->GetSharedSnapshot()->GetDataMapping(),
(*embedder_isolate)->GetSharedSnapshot()->GetInstructionsMapping(), flags,
embedder_isolate.get(), error);
(*embedder_isolate)
->GetIsolateSnapshot()
->GetData()
->GetSnapshotPointer(),
(*embedder_isolate)->GetIsolateSnapshot()->GetInstructionsIfPresent(),
(*embedder_isolate)->GetSharedSnapshot()->GetDataIfPresent(),
(*embedder_isolate)->GetSharedSnapshot()->GetInstructionsIfPresent(),
flags, embedder_isolate.get(), error);

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

0 comments on commit 0fcfa0d

Please sign in to comment.