mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:42:20 +00:00
7cceaebd49
Refactor `JSStringImpl` to use the js-string-builtins API[1]. When the module `WebAssembly.String` is not available we define a "polyfill" with the previous imports, so this change is backwards compatible. Also updates some of the methods to use avoid multiple `this.length` calls (which do an FFI call), and use unchecked getters when possible. A new library `dart:_error_utils` is introduced for faster range and index checks when the length (or max value) is known to be positive (e.g. when it's the length of a string). For now only `JSStringImpl` and `operator []` and `operator []=` of `JSArrayImpl` are updated to use the new range and index checks. Rest of the libraries will be updated separately. [1]: https://github.com/WebAssembly/js-string-builtins CoreLibraryReviewExempt: dart2wasm specific library change. Change-Id: I9436def0cfe59c631f6f4e15ea06cc18a47a738e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335043 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
42 lines
1.3 KiB
Bash
Executable file
42 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Copyright (c) 2022, 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.
|
|
|
|
# Run the output of dart2wasm on d8.
|
|
|
|
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.
|
|
PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
|
SDK_DIR="$(cd "${PROG_DIR}/../.." ; pwd -P)"
|
|
D8_DIR="$(cd "${PROG_DIR}/../../third_party/d8" ; pwd -P)"
|
|
|
|
# Locate D8 executable. Only macos and linux are supported.
|
|
if [[ `uname` == 'Darwin' ]]; then
|
|
D8_EXEC="$D8_DIR/macos/d8"
|
|
else
|
|
D8_EXEC="$D8_DIR/linux/d8"
|
|
fi
|
|
|
|
# We allow extra d8 options to be passed in through an environment variable.
|
|
if [[ $D8_OPTIONS ]]; then
|
|
read -a OPTIONS <<< "$D8_OPTIONS"
|
|
EXTRA_D8_OPTIONS+=("${OPTIONS[@]}")
|
|
fi
|
|
|
|
# Find the JS runtime based on the input wasm file.
|
|
exec "$D8_EXEC" --turboshaft-wasm --experimental-wasm-imported-strings \
|
|
"${EXTRA_D8_OPTIONS[@]}" \
|
|
"$SDK_DIR/pkg/dart2wasm/bin/run_wasm.js" -- "$(realpath -- "${1%.*}.mjs")" "$@"
|