Files
sdk/runtime/bin/isolate_data.h
T
Siva Annamalai 1e5eab3a14 - reorganize DartUtils::PrepareForScriptLoading so that it does not have the wait for service load port code in it. This is needed so that it is possible to not wait for the service load port when running with a full application snapshot that requires no loading.
- cache builtin_lib in IsolateData so that the cached value can be used withouit having to call Builtin::LoadAndCheckLibrary which creates new string objects everytime it is called.

Review URL: https://codereview.chromium.org/1663963002 .
2016-02-04 09:18:31 -08:00

83 lines
2.0 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef BIN_ISOLATE_DATA_H_
#define BIN_ISOLATE_DATA_H_
#include "include/dart_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
namespace dart {
namespace bin {
// Forward declaration.
class EventHandler;
// Data associated with every isolate in the standalone VM
// embedding. This is used to free external resources for each isolate
// when the isolate shuts down.
class IsolateData {
public:
IsolateData(const char* url,
const char* package_root,
const char* packages_file)
: script_url((url != NULL) ? strdup(url) : NULL),
package_root(NULL),
packages_file(NULL),
udp_receive_buffer(NULL),
load_async_id(-1),
builtin_lib_(NULL) {
if (package_root != NULL) {
ASSERT(packages_file == NULL);
this->package_root = strdup(package_root);
} else if (packages_file != NULL) {
this->packages_file = strdup(packages_file);
}
}
~IsolateData() {
free(script_url);
script_url = NULL;
free(package_root);
package_root = NULL;
free(packages_file);
packages_file = NULL;
free(udp_receive_buffer);
udp_receive_buffer = NULL;
if (builtin_lib_ != NULL) {
Dart_DeletePersistentHandle(builtin_lib_);
}
}
Dart_Handle builtin_lib() const {
ASSERT(builtin_lib_ != NULL);
ASSERT(!Dart_IsError(builtin_lib_));
return builtin_lib_;
}
void set_builtin_lib(Dart_Handle lib) {
ASSERT(builtin_lib_ == NULL);
ASSERT(lib != NULL);
ASSERT(!Dart_IsError(lib));
builtin_lib_ = Dart_NewPersistentHandle(lib);
}
char* script_url;
char* package_root;
char* packages_file;
uint8_t* udp_receive_buffer;
int64_t load_async_id;
private:
Dart_Handle builtin_lib_;
DISALLOW_COPY_AND_ASSIGN(IsolateData);
};
} // namespace bin
} // namespace dart
#endif // BIN_ISOLATE_DATA_H_