Skip to content

Commit 09c1bea

Browse files
mralephcommit-bot@chromium.org
authored andcommitted
[VM] Add VM specific package pkg/vm and use it to host transitionary wrappers.
These wrapper scripts centralize the notion of what Dart 2 means for VM. They enable relevant flags and use relevant intermediate code generation steps where necessary. * pkg/vm/tool/dart2 invokes dart binary with DFE and strong mode. * pkg/vm/tool/precompiler2 uses Fasta and AOT specific Kernel-to-Kernel transformations to generate Kernel binary which then will be compiled with normal Dart VM precompiler. * pkg/vm/tool/dart_precompiled_runtime2 is similar to dart2 wrapper but for running AOT snapshots. Bug: Change-Id: I1f96d545d800f676679fb1058f7905ba0f68df8f Reviewed-on: https://dart-review.googlesource.com/20702 Reviewed-by: Alexander Markov <[email protected]> Reviewed-by: Jonas Termansen <[email protected]> Commit-Queue: Vyacheslav Egorov <[email protected]>
1 parent 0f56888 commit 09c1bea

File tree

4 files changed

+244
-0
lines changed

4 files changed

+244
-0
lines changed

pkg/vm/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This package hosts VM specific Dart code and helper scripts.

pkg/vm/tool/dart2

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
3+
# for details. All rights reserved. Use of this source code is governed by a
4+
# BSD-style license that can be found in the LICENSE file.
5+
6+
# Script for running JIT mode VM with Dart 2 pipeline: using Fasta in DFE
7+
# isolate and strong mode semantics.
8+
9+
function follow_links() {
10+
file="$1"
11+
while [ -h "$file" ]; do
12+
# On Mac OS, readlink -f doesn't work.
13+
file="$(readlink "$file")"
14+
done
15+
echo "$file"
16+
}
17+
18+
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
19+
PROG_NAME="$(follow_links "$BASH_SOURCE")"
20+
21+
# Handle the case where dart-sdk/bin has been symlinked to.
22+
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
23+
24+
if [[ `uname` == 'Darwin' ]];
25+
then
26+
OUT_DIR="$CUR_DIR"/../../../xcodebuild/
27+
else
28+
OUT_DIR="$CUR_DIR"/../../../out/
29+
fi
30+
31+
if [ -z "$DART_CONFIGURATION" ];
32+
then
33+
DIRS=$( ls "$OUT_DIR" )
34+
# list of possible configurations in decreasing desirability
35+
CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32"
36+
"ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE"
37+
"DebugARM" "DebugARM64" "DebugARMV5TE")
38+
DART_CONFIGURATION="None"
39+
for CONFIG in ${CONFIGS[*]}
40+
do
41+
for DIR in $DIRS;
42+
do
43+
if [ "$CONFIG" = "$DIR" ];
44+
then
45+
# choose most desirable configuration that is available and break
46+
DART_CONFIGURATION="$DIR"
47+
break 2
48+
fi
49+
done
50+
done
51+
if [ "$DART_CONFIGURATION" = "None" ]
52+
then
53+
echo "No valid dart configuration found in $OUT_DIR"
54+
exit 1
55+
fi
56+
fi
57+
58+
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
59+
60+
exec "$BIN_DIR"/dart \
61+
--strong \
62+
--reify-generic-functions \
63+
--dfe=${BIN_DIR}/gen/kernel-service.dart.snapshot \
64+
--kernel-binaries=${BIN_DIR} \
65+
"$@"

pkg/vm/tool/dart_precompiled_runtime2

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
3+
# for details. All rights reserved. Use of this source code is governed by a
4+
# BSD-style license that can be found in the LICENSE file.
5+
6+
# Script for running AOT snapshots in Dart 2 mode: with strong mode semantics
7+
# and reified generics enabled.
8+
9+
set -e
10+
11+
function follow_links() {
12+
file="$1"
13+
while [ -h "$file" ]; do
14+
# On Mac OS, readlink -f doesn't work.
15+
file="$(readlink "$file")"
16+
done
17+
echo "$file"
18+
}
19+
20+
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
21+
PROG_NAME="$(follow_links "$BASH_SOURCE")"
22+
23+
# Handle the case where dart-sdk/bin has been symlinked to.
24+
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
25+
26+
if [[ `uname` == 'Darwin' ]];
27+
then
28+
OUT_DIR="$CUR_DIR"/../../../xcodebuild/
29+
else
30+
OUT_DIR="$CUR_DIR"/../../../out/
31+
fi
32+
33+
if [ -z "$DART_CONFIGURATION" ];
34+
then
35+
DIRS=$( ls "$OUT_DIR" )
36+
# list of possible configurations in decreasing desirability
37+
CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32"
38+
"ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE"
39+
"DebugARM" "DebugARM64" "DebugARMV5TE")
40+
DART_CONFIGURATION="None"
41+
for CONFIG in ${CONFIGS[*]}
42+
do
43+
for DIR in $DIRS;
44+
do
45+
if [ "$CONFIG" = "$DIR" ];
46+
then
47+
# choose most desirable configuration that is available and break
48+
DART_CONFIGURATION="$DIR"
49+
break 2
50+
fi
51+
done
52+
done
53+
if [ "$DART_CONFIGURATION" = "None" ]
54+
then
55+
echo "No valid dart configuration found in $OUT_DIR"
56+
exit 1
57+
fi
58+
fi
59+
60+
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
61+
62+
exec "$BIN_DIR"/dart_precompiled_runtime \
63+
--strong \
64+
--reify-generic-functions \
65+
"$@"

pkg/vm/tool/precompiler2

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
3+
# for details. All rights reserved. Use of this source code is governed by a
4+
# BSD-style license that can be found in the LICENSE file.
5+
6+
# Script for generating AOT snapshot using Dart 2 pipeline: Fasta with
7+
# strong mode enabled, AOT specific Kernel-to-Kernel transformations and
8+
# Dart VM precompiler with strong mode semantics and reified generics.
9+
10+
# Parse incomming arguments and extract the value of --packages option if any
11+
# was passed. Split options (--xyz) and non-options into two separate arrays.
12+
# All options will be passed to dart_bootstrap, while --packages will be
13+
# passed to Fasta.
14+
15+
OPTIONS=()
16+
PACKAGES=
17+
18+
ARGV=()
19+
for arg in "$@"; do
20+
case $arg in
21+
--packages=*)
22+
PACKAGES="$arg"
23+
;;
24+
--*)
25+
OPTIONS+=("$arg")
26+
;;
27+
*)
28+
ARGV+=("$arg")
29+
;;
30+
esac
31+
done
32+
33+
if [ "${#ARGV[@]}" -ne 2 ]; then
34+
echo "Usage: $0 [options] <source> <snapshot>"
35+
exit -1
36+
fi
37+
38+
SOURCE_FILE="${ARGV[0]}"
39+
SNAPSHOT_FILE="${ARGV[1]}"
40+
41+
set -e
42+
43+
function follow_links() {
44+
file="$1"
45+
while [ -h "$file" ]; do
46+
# On Mac OS, readlink -f doesn't work.
47+
file="$(readlink "$file")"
48+
done
49+
echo "$file"
50+
}
51+
52+
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
53+
PROG_NAME="$(follow_links "$BASH_SOURCE")"
54+
55+
# Handle the case where dart-sdk/bin has been symlinked to.
56+
CUR_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
57+
58+
if [[ `uname` == 'Darwin' ]];
59+
then
60+
OUT_DIR="$CUR_DIR"/../../../xcodebuild/
61+
else
62+
OUT_DIR="$CUR_DIR"/../../../out/
63+
fi
64+
65+
if [ -z "$DART_CONFIGURATION" ];
66+
then
67+
DIRS=$( ls "$OUT_DIR" )
68+
# list of possible configurations in decreasing desirability
69+
CONFIGS=("ReleaseX64" "ReleaseIA32" "DebugX64" "DebugIA32"
70+
"ReleaseARM" "ReleaseARM64" "ReleaseARMV5TE"
71+
"DebugARM" "DebugARM64" "DebugARMV5TE")
72+
DART_CONFIGURATION="None"
73+
for CONFIG in ${CONFIGS[*]}
74+
do
75+
for DIR in $DIRS;
76+
do
77+
if [ "$CONFIG" = "$DIR" ];
78+
then
79+
# choose most desirable configuration that is available and break
80+
DART_CONFIGURATION="$DIR"
81+
break 2
82+
fi
83+
done
84+
done
85+
if [ "$DART_CONFIGURATION" = "None" ]
86+
then
87+
echo "No valid dart configuration found in $OUT_DIR"
88+
exit 1
89+
fi
90+
fi
91+
92+
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
93+
94+
# Step 1: Generate Kernel binary from the input Dart source.
95+
"$BIN_DIR"/dart pkg/front_end/tool/_fasta/compile.dart \
96+
--strong-mode \
97+
--platform ${BIN_DIR}/vm_platform_strong.dill \
98+
--target vm \
99+
--target-options=strong-aot \
100+
"$PACKAGES" \
101+
-o "$SNAPSHOT_FILE.dill" \
102+
"$SOURCE_FILE"
103+
104+
# Step 2: Generate snapshot from the Kernel binary.
105+
exec "$BIN_DIR"/dart_bootstrap \
106+
--strong \
107+
--reify-generic-functions \
108+
--kernel-binaries=${BIN_DIR} \
109+
--snapshot-kind=app-aot \
110+
--use-blobs \
111+
--snapshot="$SNAPSHOT_FILE" \
112+
"${OPTIONS[@]}" \
113+
"$SNAPSHOT_FILE.dill"

0 commit comments

Comments
 (0)