提交 64ac5e8e 编写于 作者: A Alexander Aprelev 提交者: GitHub

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

This is follow-up to https://github.com/dart-lang/sdk/commit/c7faf2dc6b64b65e04d677fa3ad68c1e90e19bff, which made Dart_LoadKernel responsible for the bytes.
上级 be87a63f
......@@ -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(
......
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册