Skip to content

Commit

Permalink
Enable service isolate under precompilation
Browse files Browse the repository at this point in the history
Update dart revision to include changes required to enable profiling
during precompilation
  • Loading branch information
chinmaygarde committed Oct 29, 2015
1 parent c3e03ba commit e63d438
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vars = {

# Note: When updating the Dart revision, ensure that all entries that are
# dependencies of dart are also updated
'dart_revision': '2bf488f9e753ecd5418799c5f0508856670b46aa',
'dart_revision': '37dd876bf1a6e6854abc85ebdd9c513e03743580',
'dart_observatory_packages_revision': '5c199c5954146747f75ed127871207718dc87786',
'dart_root_certificates_revision': 'c3a41df63afacec62fcb8135196177e35fe72f71',

Expand Down
3 changes: 3 additions & 0 deletions sky/engine/bindings/bindings.gni
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ template("dart_precompile") {
rebase_path("//sky/engine/bindings/internals.dart")
dart_ui_path =
rebase_path("$root_build_dir/gen/sky/bindings/dart_ui.dart")
service_path =
rebase_path("//sky/engine/core/script/dart_service_isolate/main.dart")

gen_snapshot_dir =
get_label_info("//dart/runtime/bin:gen_snapshot($dart_host_toolchain)",
Expand All @@ -131,6 +133,7 @@ template("dart_precompile") {
"--url_mapping=dart:mojo.internal,$dart_mojo_internal_path",
"--url_mapping=dart:ui,$dart_ui_path",
"--url_mapping=dart:ui_internals,$dart_ui_internals_path",
"--url_mapping=dart:vmservice_sky,$service_path",
]
}

Expand Down
3 changes: 3 additions & 0 deletions sky/engine/bindings/dart_vm_entry_points.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ dart:ui_internals,::,takeServiceRegistry
dart:ui_internals,::,takeServicesProvidedByEmbedder
dart:ui_internals,::,takeServicesProvidedToEmbedder
dart:ui_internals,::,takeShellProxyHandle
dart:vmservice_sky,::,_addResource
dart:vmservice_sky,::,boot
dart:vmservice_sky,::,main
6 changes: 3 additions & 3 deletions sky/engine/core/script/dart_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,
// Start the handle watcher from the service isolate so it isn't available
// for debugging or general Observatory interaction.
EnsureHandleWatcherStarted();
if (!IsRunningPrecompiledCode() &&
RuntimeEnabledFeatures::observatoryEnabled()) {
if (RuntimeEnabledFeatures::observatoryEnabled()) {
std::string ip = "127.0.0.1";
const intptr_t port = 8181;
const bool service_isolate_booted =
DartServiceIsolate::Startup(ip, port, DartLibraryTagHandler, error);
DartServiceIsolate::Startup(ip, port, DartLibraryTagHandler,
IsRunningPrecompiledCode(), error);
CHECK(service_isolate_booted) << error;
}
}
Expand Down
43 changes: 27 additions & 16 deletions sky/engine/core/script/dart_service_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void DartServiceIsolate::Shutdown(Dart_NativeArguments args) {
bool DartServiceIsolate::Startup(std::string server_ip,
intptr_t server_port,
Dart_LibraryTagHandler embedder_tag_handler,
bool running_precompiled,
char** error) {
Dart_Isolate isolate = Dart_CurrentIsolate();
CHECK(isolate);
Expand All @@ -138,19 +139,29 @@ bool DartServiceIsolate::Startup(std::string server_ip,

Dart_Handle result;

// Use our own library tag handler when loading service isolate sources.
Dart_SetLibraryTagHandler(DartServiceIsolate::LibraryTagHandler);
// Load main script.
Dart_Handle library = LoadScript(kServiceIsolateScript);
DCHECK(library != Dart_Null());
SHUTDOWN_ON_ERROR(library);
// Setup native entry resolution.
result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol);

SHUTDOWN_ON_ERROR(result);
// Finalize loading.
result = Dart_FinalizeLoading(false);
SHUTDOWN_ON_ERROR(result);
if (running_precompiled) {
Dart_Handle uri = Dart_NewStringFromCString("dart:vmservice_sky");
Dart_Handle library = Dart_LookupLibrary(uri);
SHUTDOWN_ON_ERROR(library);
result = Dart_SetRootLibrary(library);
SHUTDOWN_ON_ERROR(result);
result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol);
SHUTDOWN_ON_ERROR(result);
} else {
// Use our own library tag handler when loading service isolate sources.
Dart_SetLibraryTagHandler(DartServiceIsolate::LibraryTagHandler);
// Load main script.
Dart_Handle library = LoadScript(kServiceIsolateScript);
DCHECK(library != Dart_Null());
SHUTDOWN_ON_ERROR(library);
// Setup native entry resolution.
result = Dart_SetNativeResolver(library, GetNativeFunction, GetSymbol);

SHUTDOWN_ON_ERROR(result);
// Finalize loading.
result = Dart_FinalizeLoading(false);
SHUTDOWN_ON_ERROR(result);
}

// Make runnable.
Dart_ExitScope();
Expand All @@ -165,7 +176,7 @@ bool DartServiceIsolate::Startup(std::string server_ip,
Dart_EnterIsolate(isolate);
Dart_EnterScope();

library = Dart_RootLibrary();
Dart_Handle library = Dart_RootLibrary();
SHUTDOWN_ON_ERROR(library);

// Set the HTTP server's ip.
Expand Down Expand Up @@ -266,8 +277,8 @@ Dart_Handle DartServiceIsolate::LoadResources(Dart_Handle library) {
}

Dart_Handle DartServiceIsolate::LibraryTagHandler(Dart_LibraryTag tag,
Dart_Handle library,
Dart_Handle url) {
Dart_Handle library,
Dart_Handle url) {
if (!Dart_IsLibrary(library)) {
return Dart_NewApiError("not a library");
}
Expand Down
1 change: 1 addition & 0 deletions sky/engine/core/script/dart_service_isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class DartServiceIsolate {
static bool Startup(std::string server_ip,
intptr_t server_port,
Dart_LibraryTagHandler embedder_tag_handler,
bool running_precompiled,
char** error);

private:
Expand Down

0 comments on commit e63d438

Please sign in to comment.