Files
sdk/pkg/vm/tool/precompiler2
T
Alexander Markov a681867054 [vm/kernel/aot] Prepare to enable type flow analysis in Flutter
* Introduce --tfa option in gen_kernel and 'useGlobalTypeFlowAnalysis'
  parameter in compileToKernel(), which is used in Flutter's frontend
  server.

* Split entry_points_extra.json into 2 parts: common to all embedders
  and specific to a standalone VM (entry_points_extra_standalone.json).

* Extract generation of entry points JSON files into a separate .gni
  file, introduce action to generate entry points JSON using
  gen_snapshot instead of dart_bootstrap (required for Flutter), and
  action to copy checked-in extra entry points file.

Issue: https://github.com/dart-lang/sdk/issues/30480
Change-Id: Ie0af9d7128d7fc0e3a9d623fd3c1589e87c83f5c
Reviewed-on: https://dart-review.googlesource.com/43884
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2018-02-27 19:59:19 +00:00

102 lines
3.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2017, 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.
# Script for generating AOT snapshot using Dart 2 pipeline: Fasta with
# strong mode enabled, AOT specific Kernel-to-Kernel transformations and
# Dart VM precompiler with strong mode semantics and reified generics.
# Parse incoming arguments and extract the value of --packages option if any
# was passed. Split options (--xyz) and non-options into two separate arrays.
# All options will be passed to dart_bootstrap, while --packages will be
# passed to Fasta.
set -e
OPTIONS=()
GEN_KERNEL_OPTIONS=()
PACKAGES=
ARGV=()
for arg in "$@"; do
case $arg in
--packages=*)
PACKAGES="$arg"
;;
--sync-async | \
--no-sync-async | \
--tfa | \
--no-tfa )
GEN_KERNEL_OPTIONS+=("$arg")
;;
--*)
OPTIONS+=("$arg")
;;
*)
ARGV+=("$arg")
;;
esac
done
if [ "${#ARGV[@]}" -ne 2 ]; then
echo "Usage: $0 [options] <source> <snapshot>"
exit 1
fi
SOURCE_FILE="${ARGV[0]}"
SNAPSHOT_FILE="${ARGV[1]}"
function follow_links() {
file="$1"
while [ -h "$file" ]; do
# On Mac OS, readlink -f doesn't work.
file="$(readlink "$file")"
done
echo "$file"
}
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
PROG_NAME="$(follow_links "$BASH_SOURCE")"
# Handle the case where dart-sdk/bin has been symlinked to.
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
SDK_DIR="$CUR_DIR/../../.."
if [[ `uname` == 'Darwin' ]]; then
OUT_DIR="$SDK_DIR/xcodebuild"
else
OUT_DIR="$SDK_DIR/out"
fi
export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
BIN_DIR="$OUT_DIR/$DART_CONFIGURATION"
ENTRY_POINTS="--entry-points ${BIN_DIR}/gen/runtime/bin/precompiler_entry_points.json \
--entry-points ${SDK_DIR}/pkg/vm/lib/transformations/type_flow/entry_points_extra.json \
--entry-points ${SDK_DIR}/pkg/vm/lib/transformations/type_flow/entry_points_extra_standalone.json"
# Step 1: Generate Kernel binary from the input Dart source.
"$BIN_DIR"/dart \
--limit-ints-to-64-bits \
"${SDK_DIR}/pkg/vm/bin/gen_kernel.dart" \
--platform "${BIN_DIR}/vm_platform_strong.dill" \
--aot \
"${GEN_KERNEL_OPTIONS[@]}" \
$PACKAGES \
$ENTRY_POINTS \
-o "$SNAPSHOT_FILE.dill" \
"$SOURCE_FILE"
# Step 2: Generate snapshot from the Kernel binary.
exec "$BIN_DIR"/dart_bootstrap \
--strong \
--reify-generic-functions \
--limit-ints-to-64-bits \
--snapshot-kind=app-aot \
--use-blobs \
--snapshot="$SNAPSHOT_FILE" \
"${OPTIONS[@]}" \
"$SNAPSHOT_FILE.dill"