Files
sdk/pkg/vm/tool/test_bytecode
T
Régis Crelier 41fcbd097c [VM runtime] Initial version of Kernel Bytecode interpreter in VM runtime.
Not fully working yet, only x64, no gc, no frame walking, etc...

Change-Id: I4d8357f6d46371bf21c3d54266cfe26163e3c8dc
Reviewed-on: https://dart-review.googlesource.com/50021
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-05-09 20:29:27 +00:00

67 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2018, 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 bytecode in a kernel file using Dart 2 pipeline and
# interpreting the resulting bytecode.
# Usage
# pkg/vm/tool/test_bytecode ~/foo.dart
set -e
# Pick the architecture and mode to build and test.
BUILD_FLAGS="-m debug -a x64"
BUILD_SUBDIR="DebugX64"
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/../../.."
BUILD_DIR="$SDK_DIR/out/$BUILD_SUBDIR"
# Verify that the VM supports the interpreter, if not, rebuild it.
REBUILD=0
if [ -f $BUILD_DIR/dart ]
then
$BUILD_DIR/dart --trace-interpreter-after=-1 \
$SDK_DIR/runtime/tests/vm/dart/hello_world_test.dart > /dev/null 2>&1 \
|| REBUILD=1
else
REBUILD=1
fi
if [ $REBUILD -ne 0 ]
then
echo "Rebuilding VM to support interpreter"
rm -rf $BUILD_DIR
$SDK_DIR/tools/gn.py $BUILD_FLAGS --gn-args=dart_use_interpreter=true
$SDK_DIR/tools/build.py $BUILD_FLAGS runtime
fi
# Generate dill file containing bytecode for input dart source.
$CUR_DIR/gen_kernel --platform $BUILD_DIR/vm_platform_strong.dill \
--gen-bytecode $@ -o $BUILD_DIR/test_bytecode.dill
# Required flags.
DART_VM_FLAGS="--preview-dart-2 --optimization-counter-threshold=-1 $DART_VM_FLAGS"
# Optional flags.
# DART_VM_FLAGS="--force-log-flush --dump-kernel-bytecode --trace-interpreter-after=0 $DART_VM_FLAGS"
# Execute dill file.
exec $BUILD_DIR/dart $DART_VM_FLAGS $BUILD_DIR/test_bytecode.dill