Skip to content

Commit

Permalink
Pull in weval branch of SpiderMonkey and add build.
Browse files Browse the repository at this point in the history
This pulls in a new bytecodealliance/gecko-dev commit hash with weval
support, and produces a new separate build of the engine with intrinsics
added so that we can apply the [weval](https://github.com/cfallin/weval)
tool to obtain speedups with AOT compilation/specialization.

This is a re-do of fastly#5, but with fixes from bytecodealliance/gecko-dev#5
applied.
  • Loading branch information
cfallin committed May 26, 2023
1 parent 53b00f7 commit aef99c3
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 51 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@ jobs:
run: |
mkdir dist
sudo apt-get update -y
bash ./build-engine.sh release
tar -a -cf dist/spidermonkey-wasm-static-lib_release.tar.gz release
rm -rf release obj-release
bash ./build-engine.sh debug
tar -a -cf dist/spidermonkey-wasm-static-lib_debug.tar.gz debug
bash ./build-engine.sh release normal
tar -a -cf dist/spidermonkey-wasm-static-lib_release_normal.tar.gz release-normal
rm -rf release-normal obj-release-normal
bash ./build-engine.sh release weval
tar -a -cf dist/spidermonkey-wasm-static-lib_release_weval.tar.gz release-weval
rm -rf release-weval obj-release-weval
bash ./build-engine.sh debug normal
tar -a -cf dist/spidermonkey-wasm-static-lib_debug_normal.tar.gz debug-normal
rm -rf debug-normal obj-debug-normal
bash ./build-engine.sh debug weval
tar -a -cf dist/spidermonkey-wasm-static-lib_debug_weval.tar.gz debug-weval
rm -rf debug-weval obj-debug-weval
- name: Calculate tag name
run: |
Expand Down
49 changes: 30 additions & 19 deletions build-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,44 @@
set -euo pipefail
set -x

if (wasm-opt --version | grep -q "wasm-opt version" ); then
echo "wasm-opt corrupts the SpiderMonkey build; please remove it or alias it to /bin/true!"
exit 1
fi

if [ $# -lt 1 ]; then
echo "Usage: build.sh {release|debug} [{normal|weval}]"
exit 1
fi

if [ $# -eq 1 ]; then
$0 $1 normal
$0 $1 weval
exit 0
fi

working_dir="$(pwd)"
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

mode="${1:-release}"
mozconfig="${working_dir}/mozconfig-${mode}"
objdir="obj-$mode"
outdir="$mode"

cat << EOF > "$mozconfig"
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --target=wasm32-unknown-wasi
ac_add_options --without-system-zlib
ac_add_options --without-intl-api
ac_add_options --disable-jit
ac_add_options --disable-shared-js
ac_add_options --disable-shared-memory
ac_add_options --disable-tests
ac_add_options --disable-clang-plugin
ac_add_options --enable-jitspew
ac_add_options --enable-optimize
ac_add_options --enable-js-streams
# Mode: release or debug
mode=$1
# Variant: normal or weval
variant=$2
mozconfig="${working_dir}/mozconfig-${mode}-${variant}"
objdir="obj-$mode-$variant"
outdir="$mode-$variant"

cat $script_dir/mozconfig.defaults > "$mozconfig"
cat << EOF >> "$mozconfig"
ac_add_options --prefix=${working_dir}/${objdir}/dist
mk_add_options MOZ_OBJDIR=${working_dir}/${objdir}
mk_add_options AUTOCLOBBER=1
EOF

if [ "$variant" == "weval" ]; then
cat $script_dir/mozconfig.weval >> "$mozconfig"
fi

target="$(uname)"
case "$target" in
Linux)
Expand Down
9 changes: 3 additions & 6 deletions download-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# # Get github repository url
gh_url='https://github.'$(cd "$script_dir" && git remote get-url origin | cut -f2 -d. | tr ':' /)

mode="release"
if [[ $1 == "debug" ]]
then
mode="debug"
fi
mode=${1:release}
variant=${2:normal}

git_rev="$(git -C "$script_dir" rev-parse HEAD)"
file="spidermonkey-wasm-static-lib_${mode}.tar.gz"
file="spidermonkey-wasm-static-lib_${mode}_${variant}.tar.gz"
bundle_url="${gh_url}/releases/download/rev_${git_rev}/${file}"

curl --fail -L -O "$bundle_url"
Expand Down
2 changes: 1 addition & 1 deletion gecko-repository
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/bytecodealliance/gecko-dev
https://github.com/bytecodealliance/gecko-dev
2 changes: 1 addition & 1 deletion gecko-revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
69d3daaa3aa4589ac8e60a94c7c7e0592882d272
f0dc4ca253349a4b8bd3bd253fa8421e76888326
13 changes: 13 additions & 0 deletions mozconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --target=wasm32-unknown-wasi
ac_add_options --without-system-zlib
ac_add_options --without-intl-api
ac_add_options --disable-jit
ac_add_options --disable-shared-js
ac_add_options --disable-shared-memory
ac_add_options --disable-tests
ac_add_options --disable-clang-plugin
ac_add_options --enable-jitspew
ac_add_options --enable-optimize
ac_add_options --enable-js-streams
3 changes: 3 additions & 0 deletions mozconfig.weval
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ac_add_options --enable-js-interp-native-callstack
ac_add_options --enable-js-interp-specialization
ac_add_options --enable-js-interp-weval
41 changes: 22 additions & 19 deletions rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,36 @@
set -euo pipefail
set -x

if [ $# -lt 2 ]; then
echo "Usage: rebuild.sh {release|debug} {normal|weval}"
exit 1
fi

if (wasm-opt --version | grep -q "wasm-opt version" ); then
echo "wasm-opt corrupts the SpiderMonkey build; please remove it or alias it to /bin/true!"
exit 1
fi

working_dir="$(pwd)"
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

mode="${1:-release}"
mozconfig="${working_dir}/mozconfig-${mode}"
objdir="obj-$mode"
outdir="$mode"

cat << EOF > "$mozconfig"
ac_add_options --enable-project=js
ac_add_options --enable-application=js
ac_add_options --target=wasm32-unknown-wasi
ac_add_options --without-system-zlib
ac_add_options --without-intl-api
ac_add_options --disable-jit
ac_add_options --disable-shared-js
ac_add_options --disable-shared-memory
ac_add_options --disable-tests
ac_add_options --disable-clang-plugin
ac_add_options --enable-jitspew
ac_add_options --enable-optimize
ac_add_options --enable-js-streams
mode=$1
variant=$2
mozconfig="${working_dir}/mozconfig-${mode}-${variant}"
objdir="obj-$mode-$variant"
outdir="$mode-$variant"

cat $script_dir/mozconfig.defaults > "$mozconfig"
cat << EOF >> "$mozconfig"
ac_add_options --prefix=${working_dir}/${objdir}/dist
mk_add_options MOZ_OBJDIR=${working_dir}/${objdir}
mk_add_options AUTOCLOBBER=1
EOF

if [ "$variant" == "weval" ]; then
cat $script_dir/mozconfig.weval >> "$mozconfig"
fi

target="$(uname)"
case "$target" in
Linux)
Expand Down

0 comments on commit aef99c3

Please sign in to comment.