Pass ownership of the kernel bytes to the Dart_LoadKernel. (flutter/engine#4078)

This is follow-up to c7faf2dc6b, which made Dart_LoadKernel responsible for the bytes.
This commit is contained in:
Alexander Aprelev
2017-09-08 14:33:50 -07:00
committed by GitHub
parent 93c9eb30ef
commit 70c9742292
2 changed files with 4 additions and 11 deletions

View File

@@ -45,7 +45,7 @@ std::string ResolvePath(std::string path) {
} // namespace
DartController::DartController() : ui_dart_state_(nullptr),
kernel_bytes(nullptr), platform_kernel_bytes(nullptr) {}
platform_kernel_bytes(nullptr) {}
DartController::~DartController() {
if (ui_dart_state_) {
@@ -56,9 +56,6 @@ DartController::~DartController() {
Dart_ShutdownIsolate(); // deletes ui_dart_state_
ui_dart_state_ = nullptr;
}
if (kernel_bytes) {
free(kernel_bytes);
}
if (platform_kernel_bytes) {
free(platform_kernel_bytes);
}
@@ -113,9 +110,9 @@ static void CopyVectorBytes(const std::vector<uint8_t>& vector,
tonic::DartErrorHandleType DartController::RunFromKernel(
const std::vector<uint8_t>& kernel) {
tonic::DartState::Scope scope(dart_state());
// Copy kernel bytes so they won't go away after we exit this method.
// This is needed because original kernel data has to be available
// during code execution.
// Copy kernel bytes and pass ownership of the copy to the Dart_LoadKernel,
// which is expected to release them.
uint8_t* kernel_bytes = nullptr;
CopyVectorBytes(kernel, kernel_bytes);
Dart_Handle result = Dart_LoadKernel(

View File

@@ -42,10 +42,6 @@ class DartController {
// during isolate shutdown.
UIDartState* ui_dart_state_;
// Kernel binary image of dart script. This is copied and maintained
// for dart script lifespan, so that kernel loading mechanism can
// incrementally build the dart objects from it.
uint8_t* kernel_bytes;
// Kernel binary image of platform core libraries. This is copied and
// maintained for dart script lifespan, so that kernel loading mechanism can
// incrementally build the dart objects from it.