Skip to content

Commit

Permalink
[dart cli] Remove need for dartdev.dill file from sdk
Browse files Browse the repository at this point in the history
The bulid rules generate an appjit snapshot or a kernel file under
dartdev.dart.snapshot depending on whether the target_cpu is the same as
the host_cpu.
Generation of the additional dartdev.dill file is not needed because of
this, the logic to start the dartdev isolate tries to load
dartdev.dart.snapshot as an appjit snapshot first and if that fails it
tries it as a kernel file.

TEST=ci

Change-Id: I1c985bdf543d3eb5e17d968378053cc558fd8a0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306134
Reviewed-by: Ben Konyi <[email protected]>
Commit-Queue: Siva Annamalai <[email protected]>
  • Loading branch information
a-siva authored and Commit Queue committed May 30, 2023
1 parent 4a01368 commit 54dea88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
32 changes: 13 additions & 19 deletions runtime/bin/main_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,21 +586,26 @@ static Dart_Isolate CreateAndSetupDartDevIsolate(const char* script_uri,
int64_t start = Dart_TimelineGetMicros();

auto dartdev_path = DartDevIsolate::TryResolveDartDevSnapshotPath();
if (dartdev_path.get() == nullptr) {
Syslog::PrintErr(
"Failed to start the Dart CLI isolate. Could not resolve DartDev "
"snapshot or kernel.\n");
if (error != nullptr && *error != nullptr) {
free(*error);
*error = nullptr;
}
return nullptr;
}

Dart_Isolate isolate = nullptr;
const uint8_t* isolate_snapshot_data = core_isolate_snapshot_data;
const uint8_t* isolate_snapshot_instructions =
core_isolate_snapshot_instructions;
IsolateGroupData* isolate_group_data = nullptr;
IsolateData* isolate_data = nullptr;

if (error != nullptr) {
*error = nullptr;
}
AppSnapshot* app_snapshot = nullptr;
bool isolate_run_app_snapshot = true;
if (dartdev_path.get() != nullptr &&
(app_snapshot = Snapshot::TryReadAppSnapshot(
if ((app_snapshot = Snapshot::TryReadAppSnapshot(
dartdev_path.get(), /*force_load_elf_from_memory=*/false,
/*decode_uri=*/false)) != nullptr) {
const uint8_t* isolate_snapshot_data = nullptr;
Expand All @@ -621,27 +626,16 @@ static Dart_Isolate CreateAndSetupDartDevIsolate(const char* script_uri,
}

if (isolate == nullptr) {
isolate_run_app_snapshot = false;
dartdev_path = DartDevIsolate::TryResolveDartDevKernelPath();
// dartdev_path was not an application snapshot, try it as a kernel file.
// Clear error from app snapshot and retry from kernel.
if (error != nullptr && *error != nullptr) {
free(*error);
*error = nullptr;
}

isolate_run_app_snapshot = false;
if (app_snapshot != nullptr) {
delete app_snapshot;
}

if (dartdev_path.get() == nullptr) {
Syslog::PrintErr(
"Failed to start the Dart CLI isolate. Could not resolve DartDev "
"snapshot or kernel.\n");
delete isolate_data;
delete isolate_group_data;
return nullptr;
}

isolate_group_data =
new IsolateGroupData(DART_DEV_ISOLATE_NAME, packages_config, nullptr,
isolate_run_app_snapshot);
Expand Down
15 changes: 1 addition & 14 deletions sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ declare_args() {
# ........analysis_server.dart.snapshot
# ........dart2js.dart.snapshot
# ........dart2wasm_product.snapshot (if not on ia32)
# ........dartdev.dart.snapshot
# ........dartdev.dill
# ........dartdev.dart.snapshot (app-jit snapshot or kernel dill file)
# ........dartdevc.dart.snapshot
# ........dds.dart.snapshot
# ........frontend_server.dart.snapshot
Expand Down Expand Up @@ -453,17 +452,6 @@ copy("copy_vm_dill_files") {
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}

copy("copy_dartdev_dill_files") {
visibility = [ ":create_common_sdk" ]
deps = [
":copy_libraries",
"../utils/dartdev:dartdev",
]
sources = [ "$root_out_dir/dartdev.dill" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
}

copy("copy_dart2js_dill_files") {
visibility = [ ":create_full_sdk" ]
deps = [
Expand Down Expand Up @@ -682,7 +670,6 @@ group("create_common_sdk") {
public_deps = [
":copy_api_readme",
":copy_dart",
":copy_dartdev_dill_files",
":copy_dartdoc_files",
":copy_headers",
":copy_libraries_specification",
Expand Down
17 changes: 0 additions & 17 deletions utils/dartdev/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,11 @@ import("../application_snapshot.gni")

group("dartdev") {
public_deps = [
":copy_dartdev_kernel",
":copy_dartdev_snapshot",
":copy_prebuilt_devtools",
]
}

copy("copy_dartdev_kernel") {
visibility = [ ":dartdev" ]
public_deps = [ ":generate_dartdev_kernel" ]
sources = [ "$root_gen_dir/dartdev.dill" ]
outputs = [ "$root_out_dir/dartdev.dill" ]
}

application_snapshot("generate_dartdev_kernel") {
dart_snapshot_kind = "kernel"
main_dart = "../../pkg/dartdev/bin/dartdev.dart"
training_args = []
deps = [ "../dds:dds" ]
vm_args = [ "--sound-null-safety" ]
output = "$root_gen_dir/dartdev.dill"
}

copy("copy_dartdev_snapshot") {
visibility = [ ":dartdev" ]
public_deps = [ ":generate_dartdev_snapshot" ]
Expand Down

0 comments on commit 54dea88

Please sign in to comment.