From 4a5126889031dae8add8974ca478b8cdc2051bb0 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 28 Sep 2018 21:43:04 +0000 Subject: [PATCH] [gen_snapshot] Restore support for --snapshot_kind=vm-aot-assembly; update docs. Disable broken analyzer training runs. Bug: https://github.com/dart-lang/sdk/issues/34616 Change-Id: Ib2bb022f5b095bcd29451741aa4ed557d2f78c17 Reviewed-on: https://dart-review.googlesource.com/77228 Reviewed-by: Zach Anderson Commit-Queue: Ryan Macnak --- runtime/bin/gen_snapshot.cc | 39 +++++++++++++++++----------------- utils/analysis_server/BUILD.gn | 6 ++++-- utils/dartanalyzer/BUILD.gn | 8 ++++--- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc index dcb929b9004..274944f6267 100644 --- a/runtime/bin/gen_snapshot.cc +++ b/runtime/bin/gen_snapshot.cc @@ -114,7 +114,6 @@ static const char* kSnapshotKindNames[] = { V(shared_instructions, shared_instructions_filename) \ V(reused_instructions, reused_instructions_filename) \ V(assembly, assembly_filename) \ - V(script_snapshot, script_snapshot_filename) \ V(dependencies, dependencies_filename) \ V(load_compilation_trace, load_compilation_trace_filename) \ V(package_root, commandline_package_root) \ @@ -159,7 +158,7 @@ static bool IsSnapshottingForPrecompilation() { // clang-format off static void PrintUsage() { Log::PrintErr( -"Usage: gen_snapshot [] [] [] \n" +"Usage: gen_snapshot [] [] \n" " \n" "Common options: \n" "--package_root= \n" @@ -181,21 +180,14 @@ static void PrintUsage() { "--snapshot_kind=core \n" "--vm_snapshot_data= \n" "--isolate_snapshot_data= \n" -"[] \n" +"[] \n" " \n" -"Writes a snapshot of to the specified snapshot files. \n" -"If no is passed, a generic snapshot of all the corelibs \n" +"Writes a snapshot of to the specified snapshot files. \n" +"If no is passed, a generic snapshot of all the corelibs \n" "is created. \n" " \n" -"To create a script snapshot with respect to a given core snapshot: \n" -"--snapshot_kind=script \n" -"--vm_snapshot_data= \n" -"--isolate_snapshot_data= \n" -"--script_snapshot= \n" -" \n" -" \n" -"Writes a snapshot of to the specified snapshot files. \n" -"If no is passed, a generic snapshot of all the corelibs \n" +"Writes a snapshot of to the specified snapshot files. \n" +"If no is passed, a generic snapshot of all the corelibs \n" "is created. \n" " \n" "To create an AOT application snapshot as blobs suitable for loading with \n" @@ -207,7 +199,7 @@ static void PrintUsage() { "--isolate_snapshot_instructions= \n" "[--obfuscate] \n" "[--save-obfuscation-map=] \n" -" \n" +" \n" " \n" "To create an AOT application snapshot as assembly suitable for compilation \n" "as a static or dynamic library: \n" @@ -215,7 +207,7 @@ static void PrintUsage() { "--assembly= \n" "[--obfuscate] \n" "[--save-obfuscation-map=] \n" -" \n" +" \n" " \n" "AOT snapshots can be obfuscated: that is all identifiers will be renamed \n" "during compilation. This mode is enabled with --obfuscate flag. Mapping \n" @@ -332,7 +324,7 @@ static int ParseArguments(int argc, "Building an AOT snapshot as blobs requires specifying output " "files for --vm_snapshot_data, --vm_snapshot_instructions, " "--isolate_snapshot_data and --isolate_snapshot_instructions and a " - "Dart script.\n\n"); + "kernel file.\n\n"); return -1; } break; @@ -341,16 +333,16 @@ static int ParseArguments(int argc, if ((assembly_filename == NULL) || (*script_name == NULL)) { Log::PrintErr( "Building an AOT snapshot as assembly requires specifying " - "an output file for --assembly and a Dart script.\n\n"); + "an output file for --assembly and a kernel file.\n\n"); return -1; } break; } case kVMAOTAssembly: { - if ((assembly_filename == NULL) || (*script_name != NULL)) { + if ((assembly_filename == NULL) || (*script_name == NULL)) { Log::PrintErr( "Building an AOT snapshot as assembly requires specifying " - "an output file for --assembly and a Dart script.\n\n"); + "an output file for --assembly and a kernel file.\n\n"); return -1; } break; @@ -884,6 +876,13 @@ static int GenerateSnapshotFromKernel(const uint8_t* kernel_buffer, LoadCompilationTrace(); CreateAndWriteAppJITSnapshot(); break; + case kVMAOTAssembly: { + File* file = OpenFile(assembly_filename); + RefCntReleaseScope rs(file); + result = Dart_CreateVMAOTSnapshotAsAssembly(StreamingWriteCallback, file); + CHECK_RESULT(result); + break; + } default: UNREACHABLE(); } diff --git a/utils/analysis_server/BUILD.gn b/utils/analysis_server/BUILD.gn index 643c494657b..ed5eb6a34d1 100644 --- a/utils/analysis_server/BUILD.gn +++ b/utils/analysis_server/BUILD.gn @@ -7,7 +7,9 @@ import("../application_snapshot.gni") application_snapshot("analysis_server") { main_dart = "../../pkg/analysis_server/bin/server.dart" training_args = [ - "--sdk=" + rebase_path("../../sdk/"), - "--train-using=" + rebase_path("../../pkg/analyzer_cli") + "--help" + # TODO(34616): This is broken on Fuchsia. + # "--sdk=" + rebase_path("../../sdk/"), + # "--train-using=" + rebase_path("../../pkg/analyzer_cli") ] } diff --git a/utils/dartanalyzer/BUILD.gn b/utils/dartanalyzer/BUILD.gn index 887caf553fd..701a860ebee 100644 --- a/utils/dartanalyzer/BUILD.gn +++ b/utils/dartanalyzer/BUILD.gn @@ -22,9 +22,11 @@ analyzer_files = exec_script("../../tools/list_dart_files.py", application_snapshot("generate_dartanalyzer_snapshot") { main_dart = "../../pkg/analyzer_cli/bin/analyzer.dart" training_args = [ - "--dart-sdk=" + rebase_path("../../sdk/"), - "--train-snapshot", - rebase_path("../../tests/language/first_test.dart") + "--help", + # TODO(34616): This is broken on Fuchsia. + # "--dart-sdk=" + rebase_path("../../sdk/"), + # "--train-snapshot", + # rebase_path("../../tests/language/first_test.dart") ] name = "dartanalyzer" }