Skip to content

Commit

Permalink
Revert "Some cleanups enabled by removing support for Dart. (flutter#…
Browse files Browse the repository at this point in the history
…5621)" (flutter#6205)

This reverts commit 4c2448d.
  • Loading branch information
rmacnak-google authored Sep 8, 2018
1 parent 3358115 commit bf96dbe
Show file tree
Hide file tree
Showing 24 changed files with 731 additions and 195 deletions.
1 change: 1 addition & 0 deletions common/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace blink {
std::string Settings::ToString() const {
std::stringstream stream;
stream << "Settings: " << std::endl;
stream << "script_snapshot_path: " << script_snapshot_path << std::endl;
stream << "vm_snapshot_data_path: " << vm_snapshot_data_path << std::endl;
stream << "vm_snapshot_instr_path: " << vm_snapshot_instr_path << std::endl;
stream << "isolate_snapshot_data_path: " << isolate_snapshot_data_path
Expand Down
3 changes: 3 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ using TaskObserverRemove = std::function<void(intptr_t /* key */)>;

struct Settings {
// VM settings
std::string script_snapshot_path;
std::string platform_kernel_path;

std::string vm_snapshot_data_path;
std::string vm_snapshot_instr_path;
std::string isolate_snapshot_data_path;
Expand Down
326 changes: 187 additions & 139 deletions lib/snapshot/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,145 +25,199 @@ copy("generate_dart_ui") {
]
}

# Fuchsia's snapshot requires a different platform with extra dart: libraries.
if (!is_fuchsia) {
compiled_action("generate_snapshot_bin") {
tool = "//third_party/dart/runtime/bin:gen_snapshot"

platform_kernel = "$root_out_dir/flutter_patched_sdk/platform_strong.dill"
inputs = [
platform_kernel,
]
deps = [
":kernel_platform_files",
]

vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin"
vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin"
isolate_snapshot_data = "$target_gen_dir/isolate_snapshot.bin"
isolate_snapshot_instructions =
"$target_gen_dir/isolate_snapshot_instructions.bin"
outputs = [
vm_snapshot_data,
vm_snapshot_instructions,
isolate_snapshot_data,
isolate_snapshot_instructions,
]

args = [
"--snapshot_kind=core",
"--await_is_keyword",
"--enable_mirrors=false",
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data),
"--vm_snapshot_instructions=" + rebase_path(vm_snapshot_instructions),
"--isolate_snapshot_data=" + rebase_path(isolate_snapshot_data),
"--isolate_snapshot_instructions=" +
rebase_path(isolate_snapshot_instructions),
rebase_path(platform_kernel),
]

if (is_debug) {
args += [
"--enable_asserts",
"--enable_type_checks",
"--error_on_bad_type",
"--error_on_bad_override",
]
action("generate_snapshot_bin") {
if (is_fuchsia) {
snapshot_dart = "snapshot_fuchsia.dart"

# TODO(rmacnak): Fuchsia cross builds use the wrong Dart target
# architecture, and have added steps that depend on this error for
# reasonable build times (e.g., invoking the analyzer).
if (target_cpu == host_cpu) {
snapshot_kind = "core-jit"
} else {
snapshot_kind = "core"
}
} else {
snapshot_dart = "snapshot.dart"
snapshot_kind = "core"
}

# Generates an assembly file defining a given symbol with the bytes from a
# binary file. Places the symbol in a text section if 'executable' is true,
# otherwise places the symbol in a read-only data section.
template("bin_to_assembly") {
assert(defined(invoker.deps), "Must define deps")
assert(defined(invoker.input), "Must define input binary file")
assert(defined(invoker.output), "Must define output assembly file")
assert(defined(invoker.symbol), "Must define symbol name")
assert(defined(invoker.executable), "Must define boolean executable")

action(target_name) {
deps = invoker.deps
script = "//third_party/dart/runtime/tools/bin_to_assembly.py"
args = [
"--input",
rebase_path(invoker.input),
"--output",
rebase_path(invoker.output),
"--symbol_name",
invoker.symbol,
"--target_os",
current_os,
]
if (invoker.executable) {
args += [ "--executable" ]
}
inputs = [
script,
invoker.input,
]
outputs = [
invoker.output,
]
}
deps = [
":generate_dart_ui",
"//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)",
]
depfile = "$target_gen_dir/core_snapshot.d"

inputs = [
"//third_party/dart/runtime/tools/create_snapshot_bin.py",
snapshot_dart,
] + dart_ui_files
if (is_fuchsia) {
inputs += [ "fuchsia_compilation_trace.txt" ]
}

bin_to_assembly("vm_snapshot_data_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/vm_isolate_snapshot.bin"
output = "$target_gen_dir/vm_snapshot_data.S"
symbol = "kDartVmSnapshotData"
executable = false
}
vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin"
vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin"
isolate_snapshot_data = "$target_gen_dir/isolate_snapshot.bin"
isolate_snapshot_instructions =
"$target_gen_dir/isolate_snapshot_instructions.bin"
outputs = [
vm_snapshot_data,
vm_snapshot_instructions,
isolate_snapshot_data,
isolate_snapshot_instructions,
]

bin_to_assembly("vm_snapshot_instructions_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/vm_snapshot_instructions.bin"
output = "$target_gen_dir/vm_snapshot_instructions.S"
symbol = "kDartVmSnapshotInstructions"
executable = true
}
rebased_dart_ui_path = rebase_path(dart_ui_path)

gen_snapshot_dir = get_label_info(
"//third_party/dart/runtime/bin:gen_snapshot($host_toolchain)",
"root_out_dir")
script = "//third_party/dart/runtime/tools/create_snapshot_bin.py"

args = [
"--executable",
rebase_path("$gen_snapshot_dir/gen_snapshot"),
"--script",
rebase_path(snapshot_dart),
"--snapshot_kind",
snapshot_kind,
"--vm_flag",
"--await_is_keyword",
"--vm_flag",
"--enable_mirrors=false",
"--vm_output_bin",
rebase_path(vm_snapshot_data, root_build_dir),
"--vm_instructions_output_bin",
rebase_path(vm_snapshot_instructions, root_build_dir),
"--isolate_output_bin",
rebase_path(isolate_snapshot_data, root_build_dir),
"--isolate_instructions_output_bin",
rebase_path(isolate_snapshot_instructions, root_build_dir),
"--url_mapping=dart:ui,$rebased_dart_ui_path",
"--vm_flag",
"--dependencies=" + rebase_path(depfile),
]

bin_to_assembly("isolate_snapshot_data_assembly") {
deps = [
":generate_snapshot_bin",
if (is_debug) {
args += [
"--vm_flag",
"--enable_asserts",
"--vm_flag",
"--enable_type_checks",
"--vm_flag",
"--error_on_bad_type",
"--vm_flag",
"--error_on_bad_override",
]
input = "$target_gen_dir/isolate_snapshot.bin"
output = "$target_gen_dir/isolate_snapshot_data.S"
symbol = "kDartIsolateSnapshotData"
executable = false
}

bin_to_assembly("isolate_snapshot_instructions_assembly") {
deps = [
":generate_snapshot_bin",
if (is_fuchsia) {
inputs += zircon_sdk_ext_files + mozart_dart_sdk_ext_files
zircon_path = rebase_path(zircon_sdk_ext_lib)
fuchsia_path = rebase_path(fuchsia_sdk_ext_lib)
mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib)
args += [
"--url_mapping=dart:zircon,$zircon_path",
"--url_mapping=dart:fuchsia,$fuchsia_path",
"--url_mapping=dart:mozart.internal,$mozart_internal_path",
"--load_compilation_trace",
rebase_path("fuchsia_compilation_trace.txt"),
]
input = "$target_gen_dir/isolate_snapshot_instructions.bin"
output = "$target_gen_dir/isolate_snapshot_instructions.S"
symbol = "kDartIsolateSnapshotInstructions"
executable = true
}
}

source_set("snapshot") {
deps = [
":isolate_snapshot_data_assembly",
":isolate_snapshot_instructions_assembly",
":vm_snapshot_data_assembly",
":vm_snapshot_instructions_assembly",
# Generates an assembly file defining a given symbol with the bytes from a
# binary file. Places the symbol in a text section if 'executable' is true,
# otherwise places the symbol in a read-only data section.
template("bin_to_assembly") {
assert(defined(invoker.deps), "Must define deps")
assert(defined(invoker.input), "Must define input binary file")
assert(defined(invoker.output), "Must define output assembly file")
assert(defined(invoker.symbol), "Must define symbol name")
assert(defined(invoker.executable), "Must define boolean executable")

action(target_name) {
deps = invoker.deps
script = "//third_party/dart/runtime/tools/bin_to_assembly.py"
args = [
"--input",
rebase_path(invoker.input),
"--output",
rebase_path(invoker.output),
"--symbol_name",
invoker.symbol,
"--target_os",
current_os,
]
sources = [
"$target_gen_dir/isolate_snapshot_data.S",
"$target_gen_dir/isolate_snapshot_instructions.S",
"$target_gen_dir/vm_snapshot_data.S",
"$target_gen_dir/vm_snapshot_instructions.S",
if (invoker.executable) {
args += [ "--executable" ]
}
inputs = [
script,
invoker.input,
]
outputs = [
invoker.output,
]
}
}

bin_to_assembly("vm_snapshot_data_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/vm_isolate_snapshot.bin"
output = "$target_gen_dir/vm_snapshot_data.S"
symbol = "kDartVmSnapshotData"
executable = false
}

bin_to_assembly("vm_snapshot_instructions_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/vm_snapshot_instructions.bin"
output = "$target_gen_dir/vm_snapshot_instructions.S"
symbol = "kDartVmSnapshotInstructions"
executable = true
}

bin_to_assembly("isolate_snapshot_data_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/isolate_snapshot.bin"
output = "$target_gen_dir/isolate_snapshot_data.S"
symbol = "kDartIsolateSnapshotData"
executable = false
}

bin_to_assembly("isolate_snapshot_instructions_assembly") {
deps = [
":generate_snapshot_bin",
]
input = "$target_gen_dir/isolate_snapshot_instructions.bin"
output = "$target_gen_dir/isolate_snapshot_instructions.S"
symbol = "kDartIsolateSnapshotInstructions"
executable = true
}

source_set("snapshot") {
deps = [
":isolate_snapshot_data_assembly",
":isolate_snapshot_instructions_assembly",
":vm_snapshot_data_assembly",
":vm_snapshot_instructions_assembly",
]
sources = [
"$target_gen_dir/isolate_snapshot_data.S",
"$target_gen_dir/isolate_snapshot_instructions.S",
"$target_gen_dir/vm_snapshot_data.S",
"$target_gen_dir/vm_snapshot_instructions.S",
]
}

compile_platform("non_strong_platform") {
libraries_specification_uri = "libraries.json"

Expand Down Expand Up @@ -228,28 +282,22 @@ template("generate_entry_points_json_with_gen_snapshot") {
output = invoker.output

tool = "//third_party/dart/runtime/bin:gen_snapshot"
inputs = [ input ] + extra_inputs
inputs = [
input,
] + extra_inputs
outputs = [
output,

# Though they are not consumed, GN needs to know to create the output directory.
"$target_gen_dir/dummy.vm_data.snapshot",
"$target_gen_dir/dummy.vm_instr.snapshot",
"$target_gen_dir/dummy.isolate_data.snapshot",
"$target_gen_dir/dummy.isolate_instr.snapshot",
]
args = [
"--print-precompiler-entry-points=" + rebase_path(output),
"--snapshot-kind=app-aot-blobs",
"--vm_snapshot_data=" +
rebase_path("$target_gen_dir/dummy.vm_data.snapshot"),
"--vm_snapshot_instructions=" +
rebase_path("$target_gen_dir/dummy.vm_instr.snapshot"),
"--isolate_snapshot_data=" +
rebase_path("$target_gen_dir/dummy.isolate_data.snapshot"),
"--isolate_snapshot_instructions=" +
rebase_path("$target_gen_dir/dummy.isolate_instr.snapshot"),
] + extra_args + [ rebase_path(input) ]
"--print-precompiler-entry-points=" + rebase_path(output),
"--snapshot-kind=app-aot-blobs",
"--vm_snapshot_data=" + rebase_path("$target_gen_dir/dummy.vm_data.snapshot"),
"--vm_snapshot_instructions=" + rebase_path("$target_gen_dir/dummy.vm_instr.snapshot"),
"--isolate_snapshot_data=" + rebase_path("$target_gen_dir/dummy.isolate_data.snapshot"),
"--isolate_snapshot_instructions=" + rebase_path("$target_gen_dir/dummy.isolate_instr.snapshot"),
] + extra_args + [
rebase_path(input),
]
}
}

Expand Down
Loading

0 comments on commit bf96dbe

Please sign in to comment.