mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-16 16:20:49 +00:00
Merge branch 'master' into feature/compile-and-run-nginx-wasm
# Conflicts: # src/bin/wasmer.rs # src/recovery.rs
This commit is contained in:
commit
1f49f0358f
125
install.sh
125
install.sh
@ -127,9 +127,13 @@ wasmer_detect_profile() {
|
||||
}
|
||||
|
||||
wasmer_link() {
|
||||
printf "$cyan> Adding to \$PATH...$reset\n"
|
||||
printf "$cyan> Adding to bash profile...$reset\n"
|
||||
WASMER_PROFILE="$(wasmer_detect_profile)"
|
||||
SOURCE_STR="\nexport PATH=\"\$HOME/.wasmer/bin:\$PATH\"\n"
|
||||
LOAD_STR="\n# Wasmer\nexport WASMER_DIR=\"\$HOME/.wasmer\"\n[ -s \"\$WASMER_DIR/wasmer.sh\" ] && source \"\$WASMER_DIR/wasmer.sh\" # This loads wasmer\n"
|
||||
SOURCE_STR="# Wasmer config\nexport WASMER_DIR=\"\$HOME/.wasmer\"\nexport PATH=\"\$HOME/.wasmer/bin:\$PATH\"\n"
|
||||
|
||||
# We create the wasmer.sh file
|
||||
echo "$SOURCE_STR" > "$HOME/.wasmer/wasmer.sh"
|
||||
|
||||
if [ -z "${WASMER_PROFILE-}" ] ; then
|
||||
printf "${red}Profile not found. Tried:\n* ${WASMER_PROFILE} (as defined in \$PROFILE)\n* ~/.bashrc\n* ~/.bash_profile\n* ~/.zshrc\n* ~/.profile.\n"
|
||||
@ -139,24 +143,25 @@ wasmer_link() {
|
||||
printf "* Append the following lines to the correct file yourself:$reset\n"
|
||||
command printf "${SOURCE_STR}"
|
||||
else
|
||||
if ! grep -q 'wasmer' "$WASMER_PROFILE"; then
|
||||
if [[ $WASMER_PROFILE == *"fish"* ]]; then
|
||||
command fish -c 'set -U fish_user_paths $fish_user_paths ~/.wasmer/bin'
|
||||
else
|
||||
command printf "$SOURCE_STR" >> "$WASMER_PROFILE"
|
||||
fi
|
||||
if ! grep -q 'wasmer.sh' "$WASMER_PROFILE"; then
|
||||
# if [[ $WASMER_PROFILE == *"fish"* ]]; then
|
||||
# command fish -c 'set -U fish_user_paths $fish_user_paths ~/.wasmer/bin'
|
||||
# else
|
||||
command printf "$LOAD_STR" >> "$WASMER_PROFILE"
|
||||
# fi
|
||||
fi
|
||||
printf "\033[1A$cyan> Adding to \$PATH... ✓$reset\n"
|
||||
printf "\033[1A$cyan> Adding to bash profile... ✓$reset\n"
|
||||
printf "${dim}Note: We've added the following to your $WASMER_PROFILE\n"
|
||||
echo "If this isn't the profile of your current shell then please add the following to your correct profile:"
|
||||
printf "$SOURCE_STR$reset\n"
|
||||
printf "$LOAD_STR$reset\n"
|
||||
|
||||
version=`$HOME/.wasmer/bin/wasmer --version` || (
|
||||
printf "$red> wasmer was installed, but doesn't seem to be working :($reset\n"
|
||||
exit 1;
|
||||
)
|
||||
|
||||
printf "$green> Successfully installed $version!\n${reset}Please open another terminal where the \`${bold}wasmer$reset\` command will now be available.$reset\n"
|
||||
printf "$green> Successfully installed $version!\n\n${reset}If you want to have the command available now please execute:\nsource $HOME/.wasmer/wasmer.sh$reset\n"
|
||||
printf "\nOtherwise, wasmer will be available the next time you open the terminal.\n"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -225,26 +230,30 @@ wasmer_install() {
|
||||
magenta2="${reset}\033[34m"
|
||||
magenta3="${reset}\033[34;2m"
|
||||
|
||||
printf "${reset}Installing Wasmer!$reset\n"
|
||||
printf "
|
||||
${magenta1} ${magenta2} ${magenta3}###${reset}
|
||||
${magenta1} ${magenta2} ${magenta3}#####${reset}
|
||||
${magenta1} ${magenta2}### ${magenta3}######${reset}
|
||||
${magenta1} ${magenta2}###### ${magenta3}#############${reset}
|
||||
${magenta1}# ${magenta2}####### ${magenta3}##############${reset}
|
||||
${magenta1}##### ${magenta2}#############${magenta3}#########${reset}
|
||||
${magenta1}######${magenta2}###############${magenta3}#######${reset}
|
||||
${magenta1}############${magenta2}#########${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3} ###${reset}
|
||||
${magenta1}##############${magenta2}#######
|
||||
${magenta1}###########${magenta2} ###
|
||||
${magenta1}########${magenta2}
|
||||
${magenta1}####${reset}
|
||||
if which wasmer >/dev/null; then
|
||||
printf "${reset}Updating wasmer$reset\n"
|
||||
else
|
||||
printf "${reset}Installing Wasmer!$reset\n"
|
||||
printf "
|
||||
${magenta1} ${magenta2} ${magenta3}###${reset}
|
||||
${magenta1} ${magenta2} ${magenta3}#####${reset}
|
||||
${magenta1} ${magenta2}### ${magenta3}######${reset}
|
||||
${magenta1} ${magenta2}###### ${magenta3}#############${reset}
|
||||
${magenta1}# ${magenta2}####### ${magenta3}##############${reset}
|
||||
${magenta1}##### ${magenta2}#############${magenta3}#########${reset}
|
||||
${magenta1}######${magenta2}###############${magenta3}#######${reset}
|
||||
${magenta1}############${magenta2}#########${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3}#######${reset}
|
||||
${magenta1}##############${magenta2}#######${magenta3} ###${reset}
|
||||
${magenta1}##############${magenta2}#######
|
||||
${magenta1}###########${magenta2} ###
|
||||
${magenta1}########${magenta2}
|
||||
${magenta1}####${reset}
|
||||
|
||||
"
|
||||
fi
|
||||
# if [ -d "$HOME/.wasmer" ]; then
|
||||
# if which wasmer; then
|
||||
# local latest_url
|
||||
@ -290,9 +299,45 @@ wasmer_install() {
|
||||
|
||||
|
||||
wasmer_reset() {
|
||||
unset -f wasmer_install wasmer_reset wasmer_download_json wasmer_link wasmer_detect_profile wasmer_download_file wasmer_download wasmer_verify_or_quit
|
||||
unset -f wasmer_install wasmer_compareversions wasmer_reset wasmer_download_json wasmer_link wasmer_detect_profile wasmer_download_file wasmer_download wasmer_verify_or_quit
|
||||
}
|
||||
|
||||
# Example taken from
|
||||
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
|
||||
wasmer_compareversions () {
|
||||
if [[ $1 == $2 ]]
|
||||
then
|
||||
echo "="
|
||||
return 0
|
||||
fi
|
||||
local IFS=.
|
||||
local i ver1=($1) ver2=($2)
|
||||
# fill empty fields in ver1 with zeros
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
|
||||
do
|
||||
ver1[i]=0
|
||||
done
|
||||
for ((i=0; i<${#ver1[@]}; i++))
|
||||
do
|
||||
if [[ -z ${ver2[i]} ]]
|
||||
then
|
||||
# fill empty fields in ver2 with zeros
|
||||
ver2[i]=0
|
||||
fi
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]}))
|
||||
then
|
||||
echo ">"
|
||||
return 0
|
||||
fi
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]}))
|
||||
then
|
||||
echo "<"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "="
|
||||
return 0
|
||||
}
|
||||
|
||||
wasmer_download() {
|
||||
# identify platform based on uname output
|
||||
@ -322,6 +367,26 @@ wasmer_download() {
|
||||
printf "\033[1A$cyan> Getting wasmer releases... ✓$reset\n"
|
||||
fi
|
||||
|
||||
if which wasmer >/dev/null; then
|
||||
WASMER_VERSION=$(wasmer --version | sed 's/[a-z[:blank:]]//g')
|
||||
WASMER_COMPARE=$(wasmer_compareversions $WASMER_VERSION $WASMER_RELEASE_TAG)
|
||||
# printf "version: $WASMER_COMPARE\n"
|
||||
case $WASMER_COMPARE in
|
||||
# WASMER_VERSION = WASMER_RELEASE_TAG
|
||||
"=")
|
||||
printf "You are already on the latest release of wasmer: ${WASMER_RELEASE_TAG}\n";
|
||||
exit 0
|
||||
;;
|
||||
# WASMER_VERSION > WASMER_RELEASE_TAG
|
||||
">")
|
||||
printf "You are on a more recent version ($WASMER_VERSION) than the published one (${WASMER_RELEASE_TAG})\n";
|
||||
exit 0
|
||||
;;
|
||||
# WASMER_VERSION < WASMER_RELEASE_TAG (we continue)
|
||||
"<")
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# fetch the real release data to make sure it exists before we attempt a download
|
||||
wasmer_download_json RELEASE_DATA "$RELEASES_URL/tag/$WASMER_RELEASE_TAG"
|
||||
|
||||
|
@ -81,7 +81,7 @@ This spectests are currently covered:
|
||||
- memory.wast ✅
|
||||
- memory_grow.wast ✅
|
||||
- memory_redundancy.wast ✅
|
||||
- memory_trap.wast
|
||||
- memory_trap.wast ✅
|
||||
- names.wast ✅
|
||||
- nop.wast ✅
|
||||
- return.wast ✅
|
||||
@ -99,7 +99,7 @@ This spectests are currently covered:
|
||||
- typecheck.wast ✅
|
||||
- unreachable.wast
|
||||
- unreached-invalid.wast
|
||||
- unwind.wast
|
||||
- unwind.wast ✅
|
||||
- utf8-custom-section-id.wast
|
||||
- utf8-import-field.wast
|
||||
- utf8-import-module.wast
|
||||
|
270
spectests/memory_trap.wast
Normal file
270
spectests/memory_trap.wast
Normal file
@ -0,0 +1,270 @@
|
||||
(module
|
||||
(memory 1)
|
||||
|
||||
(func $addr_limit (result i32)
|
||||
(i32.mul (memory.size) (i32.const 0x10000))
|
||||
)
|
||||
|
||||
(func (export "store") (param $i i32) (param $v i32)
|
||||
(i32.store (i32.add (call $addr_limit) (get_local $i)) (get_local $v))
|
||||
)
|
||||
|
||||
(func (export "load") (param $i i32) (result i32)
|
||||
(i32.load (i32.add (call $addr_limit) (get_local $i)))
|
||||
)
|
||||
|
||||
(func (export "memory.grow") (param i32) (result i32)
|
||||
(memory.grow (get_local 0))
|
||||
)
|
||||
)
|
||||
|
||||
(assert_return (invoke "store" (i32.const -4) (i32.const 42)))
|
||||
(assert_return (invoke "load" (i32.const -4)) (i32.const 42))
|
||||
(assert_trap (invoke "store" (i32.const -3) (i32.const 13)) "out of bounds memory access")
|
||||
(assert_trap (invoke "load" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "store" (i32.const -2) (i32.const 13)) "out of bounds memory access")
|
||||
(assert_trap (invoke "load" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "store" (i32.const -1) (i32.const 13)) "out of bounds memory access")
|
||||
(assert_trap (invoke "load" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "store" (i32.const 0) (i32.const 13)) "out of bounds memory access")
|
||||
(assert_trap (invoke "load" (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "store" (i32.const 0x80000000) (i32.const 13)) "out of bounds memory access")
|
||||
(assert_trap (invoke "load" (i32.const 0x80000000)) "out of bounds memory access")
|
||||
(assert_return (invoke "memory.grow" (i32.const 0x10001)) (i32.const -1))
|
||||
|
||||
(module
|
||||
(memory 1)
|
||||
(data (i32.const 0) "abcdefgh")
|
||||
(data (i32.const 0xfff8) "abcdefgh")
|
||||
|
||||
(func (export "i32.load") (param $a i32) (result i32)
|
||||
(i32.load (get_local $a))
|
||||
)
|
||||
(func (export "i64.load") (param $a i32) (result i64)
|
||||
(i64.load (get_local $a))
|
||||
)
|
||||
(func (export "f32.load") (param $a i32) (result f32)
|
||||
(f32.load (get_local $a))
|
||||
)
|
||||
(func (export "f64.load") (param $a i32) (result f64)
|
||||
(f64.load (get_local $a))
|
||||
)
|
||||
(func (export "i32.load8_s") (param $a i32) (result i32)
|
||||
(i32.load8_s (get_local $a))
|
||||
)
|
||||
(func (export "i32.load8_u") (param $a i32) (result i32)
|
||||
(i32.load8_u (get_local $a))
|
||||
)
|
||||
(func (export "i32.load16_s") (param $a i32) (result i32)
|
||||
(i32.load16_s (get_local $a))
|
||||
)
|
||||
(func (export "i32.load16_u") (param $a i32) (result i32)
|
||||
(i32.load16_u (get_local $a))
|
||||
)
|
||||
(func (export "i64.load8_s") (param $a i32) (result i64)
|
||||
(i64.load8_s (get_local $a))
|
||||
)
|
||||
(func (export "i64.load8_u") (param $a i32) (result i64)
|
||||
(i64.load8_u (get_local $a))
|
||||
)
|
||||
(func (export "i64.load16_s") (param $a i32) (result i64)
|
||||
(i64.load16_s (get_local $a))
|
||||
)
|
||||
(func (export "i64.load16_u") (param $a i32) (result i64)
|
||||
(i64.load16_u (get_local $a))
|
||||
)
|
||||
(func (export "i64.load32_s") (param $a i32) (result i64)
|
||||
(i64.load32_s (get_local $a))
|
||||
)
|
||||
(func (export "i64.load32_u") (param $a i32) (result i64)
|
||||
(i64.load32_u (get_local $a))
|
||||
)
|
||||
(func (export "i32.store") (param $a i32) (param $v i32)
|
||||
(i32.store (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i64.store") (param $a i32) (param $v i64)
|
||||
(i64.store (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "f32.store") (param $a i32) (param $v f32)
|
||||
(f32.store (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "f64.store") (param $a i32) (param $v f64)
|
||||
(f64.store (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i32.store8") (param $a i32) (param $v i32)
|
||||
(i32.store8 (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i32.store16") (param $a i32) (param $v i32)
|
||||
(i32.store16 (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i64.store8") (param $a i32) (param $v i64)
|
||||
(i64.store8 (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i64.store16") (param $a i32) (param $v i64)
|
||||
(i64.store16 (get_local $a) (get_local $v))
|
||||
)
|
||||
(func (export "i64.store32") (param $a i32) (param $v i64)
|
||||
(i64.store32 (get_local $a) (get_local $v))
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "i32.store" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const 0xffff) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const 0xfffe) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const 0xfffd) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const -2) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const -3) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store" (i32.const -4) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfffe) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfffd) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfffc) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfffb) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfffa) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const 0xfff9) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -3) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -4) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -5) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -6) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -7) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store" (i32.const -8) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const 0x10000) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const 0xffff) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const 0xfffe) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const 0xfffd) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const -1) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const -2) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const -3) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.store" (i32.const -4) (f32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0x10000) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xffff) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfffe) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfffd) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfffc) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfffb) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfffa) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const 0xfff9) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -1) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -2) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -3) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -4) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -5) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -6) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -7) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.store" (i32.const -8) (f64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store8" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store8" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store16" (i32.const 0x10000) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store16" (i32.const 0xffff) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store16" (i32.const -1) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.store16" (i32.const -2) (i32.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store8" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store8" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store16" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store16" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store16" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store16" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const 0x10000) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const 0xffff) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const 0xfffe) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const 0xfffd) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const -1) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const -2) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const -3) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.store32" (i32.const -4) (i64.const 0)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load" (i32.const -4)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfffc)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfffb)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfffa)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const 0xfff9)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -4)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -5)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -6)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -7)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load" (i32.const -8)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f32.load" (i32.const -4)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfffc)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfffb)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfffa)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const 0xfff9)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -4)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -5)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -6)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -7)) "out of bounds memory access")
|
||||
(assert_trap (invoke "f64.load" (i32.const -8)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load8_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load8_s" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load8_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load8_u" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_s" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_s" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_u" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i32.load16_u" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load8_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load8_s" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load8_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load8_u" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_s" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_s" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_u" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load16_u" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_s" (i32.const -4)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const 0x10000)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const 0xffff)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const 0xfffe)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const 0xfffd)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const -1)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const -2)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const -3)) "out of bounds memory access")
|
||||
(assert_trap (invoke "i64.load32_u" (i32.const -4)) "out of bounds memory access")
|
||||
|
||||
;; No memory was changed
|
||||
(assert_return (invoke "i64.load" (i32.const 0xfff8)) (i64.const 0x6867666564636261))
|
||||
(assert_return (invoke "i64.load" (i32.const 0)) (i64.const 0x6867666564636261))
|
267
spectests/unwind.wast
Normal file
267
spectests/unwind.wast
Normal file
@ -0,0 +1,267 @@
|
||||
;; Test that control-flow transfer unwinds stack and it can be anything after.
|
||||
|
||||
(module
|
||||
(func (export "func-unwind-by-unreachable")
|
||||
(i32.const 3) (i64.const 1) (unreachable)
|
||||
)
|
||||
(func (export "func-unwind-by-br")
|
||||
(i32.const 3) (i64.const 1) (br 0)
|
||||
)
|
||||
(func (export "func-unwind-by-br-value") (result i32)
|
||||
(i32.const 3) (i64.const 1) (br 0 (i32.const 9))
|
||||
)
|
||||
(func (export "func-unwind-by-br_if")
|
||||
(i32.const 3) (i64.const 1) (drop (drop (br_if 0 (i32.const 1))))
|
||||
)
|
||||
(func (export "func-unwind-by-br_if-value") (result i32)
|
||||
(i32.const 3) (i64.const 1) (drop (drop (br_if 0 (i32.const 9) (i32.const 1))))
|
||||
)
|
||||
(func (export "func-unwind-by-br_table")
|
||||
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 0))
|
||||
)
|
||||
(func (export "func-unwind-by-br_table-value") (result i32)
|
||||
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||
)
|
||||
(func (export "func-unwind-by-return") (result i32)
|
||||
(i32.const 3) (i64.const 1) (return (i32.const 9))
|
||||
)
|
||||
|
||||
(func (export "block-unwind-by-unreachable")
|
||||
(block (i32.const 3) (i64.const 1) (unreachable))
|
||||
)
|
||||
(func (export "block-unwind-by-br") (result i32)
|
||||
(block (i32.const 3) (i64.const 1) (br 0)) (i32.const 9)
|
||||
)
|
||||
(func (export "block-unwind-by-br-value") (result i32)
|
||||
(block (result i32) (i32.const 3) (i64.const 1) (br 0 (i32.const 9)))
|
||||
)
|
||||
(func (export "block-unwind-by-br_if") (result i32)
|
||||
(block (i32.const 3) (i64.const 1) (drop (drop (br_if 0 (i32.const 1))))) (i32.const 9)
|
||||
)
|
||||
(func (export "block-unwind-by-br_if-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3) (i64.const 1) (drop (drop (br_if 0 (i32.const 9) (i32.const 1))))
|
||||
)
|
||||
)
|
||||
(func (export "block-unwind-by-br_table") (result i32)
|
||||
(block (i32.const 3) (i64.const 1) (br_table 0 (i32.const 0))) (i32.const 9)
|
||||
)
|
||||
(func (export "block-unwind-by-br_table-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3) (i64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||
)
|
||||
)
|
||||
(func (export "block-unwind-by-return") (result i32)
|
||||
(block (result i32) (i32.const 3) (i64.const 1) (return (i32.const 9)))
|
||||
)
|
||||
|
||||
(func (export "block-nested-unwind-by-unreachable") (result i32)
|
||||
(block (result i32) (i32.const 3) (block (i64.const 1) (unreachable)))
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br") (result i32)
|
||||
(block (i32.const 3) (block (i64.const 1) (br 1)) (drop)) (i32.const 9)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3) (block (i64.const 1) (br 1 (i32.const 9)))
|
||||
)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br_if") (result i32)
|
||||
(block (i32.const 3) (block (i64.const 1) (drop (br_if 1 (i32.const 1)))) (drop)) (i32.const 9)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br_if-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3) (block (i64.const 1) (drop (drop (br_if 1 (i32.const 9) (i32.const 1)))))
|
||||
)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br_table") (result i32)
|
||||
(block
|
||||
(i32.const 3) (block (i64.const 1) (br_table 1 (i32.const 1)))
|
||||
(drop)
|
||||
)
|
||||
(i32.const 9)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-br_table-value") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3)
|
||||
(block (i64.const 1) (br_table 1 (i32.const 9) (i32.const 1)))
|
||||
)
|
||||
)
|
||||
(func (export "block-nested-unwind-by-return") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 3) (block (i64.const 1) (return (i32.const 9)))
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "unary-after-unreachable") (result i32)
|
||||
(f32.const 0) (unreachable) (i64.eqz)
|
||||
)
|
||||
(func (export "unary-after-br") (result i32)
|
||||
(block (result i32) (f32.const 0) (br 0 (i32.const 9)) (i64.eqz))
|
||||
)
|
||||
(func (export "unary-after-br_if") (result i32)
|
||||
(block (result i32)
|
||||
(i64.const 0) (drop (br_if 0 (i32.const 9) (i32.const 1))) (i64.eqz)
|
||||
)
|
||||
)
|
||||
(func (export "unary-after-br_table") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (br_table 0 0 (i32.const 9) (i32.const 0)) (i64.eqz)
|
||||
)
|
||||
)
|
||||
(func (export "unary-after-return") (result i32)
|
||||
(f32.const 0) (return (i32.const 9)) (i64.eqz)
|
||||
)
|
||||
|
||||
(func (export "binary-after-unreachable") (result i32)
|
||||
(f32.const 0) (f64.const 1) (unreachable) (i64.eq)
|
||||
)
|
||||
(func (export "binary-after-br") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (f64.const 1) (br 0 (i32.const 9)) (i64.eq)
|
||||
)
|
||||
)
|
||||
(func (export "binary-after-br_if") (result i32)
|
||||
(block (result i32)
|
||||
(i64.const 0) (i64.const 1) (drop (br_if 0 (i32.const 9) (i32.const 1)))
|
||||
(i64.eq)
|
||||
)
|
||||
)
|
||||
(func (export "binary-after-br_table") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (f64.const 1) (br_table 0 (i32.const 9) (i32.const 0))
|
||||
(i64.eq)
|
||||
)
|
||||
)
|
||||
(func (export "binary-after-return") (result i32)
|
||||
(f32.const 0) (f64.const 1) (return (i32.const 9)) (i64.eq)
|
||||
)
|
||||
|
||||
(func (export "select-after-unreachable") (result i32)
|
||||
(f32.const 0) (f64.const 1) (i64.const 0) (unreachable) (select)
|
||||
)
|
||||
(func (export "select-after-br") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (f64.const 1) (i64.const 0) (br 0 (i32.const 9)) (select)
|
||||
)
|
||||
)
|
||||
(func (export "select-after-br_if") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 0) (i32.const 1) (i32.const 0)
|
||||
(drop (br_if 0 (i32.const 9) (i32.const 1)))
|
||||
(select)
|
||||
)
|
||||
)
|
||||
(func (export "select-after-br_table") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (f64.const 1) (i64.const 0)
|
||||
(br_table 0 (i32.const 9) (i32.const 0))
|
||||
(select)
|
||||
)
|
||||
)
|
||||
(func (export "select-after-return") (result i32)
|
||||
(f32.const 0) (f64.const 1) (i64.const 1) (return (i32.const 9)) (select)
|
||||
)
|
||||
|
||||
(func (export "block-value-after-unreachable") (result i32)
|
||||
(block (result i32) (f32.const 0) (unreachable))
|
||||
)
|
||||
(func (export "block-value-after-br") (result i32)
|
||||
(block (result i32) (f32.const 0) (br 0 (i32.const 9)))
|
||||
)
|
||||
(func (export "block-value-after-br_if") (result i32)
|
||||
(block (result i32)
|
||||
(i32.const 0) (drop (br_if 0 (i32.const 9) (i32.const 1)))
|
||||
)
|
||||
)
|
||||
(func (export "block-value-after-br_table") (result i32)
|
||||
(block (result i32)
|
||||
(f32.const 0) (br_table 0 0 (i32.const 9) (i32.const 0))
|
||||
)
|
||||
)
|
||||
(func (export "block-value-after-return") (result i32)
|
||||
(block (result i32) (f32.const 0) (return (i32.const 9)))
|
||||
)
|
||||
|
||||
(func (export "loop-value-after-unreachable") (result i32)
|
||||
(loop (result i32) (f32.const 0) (unreachable))
|
||||
)
|
||||
(func (export "loop-value-after-br") (result i32)
|
||||
(block (result i32) (loop (result i32) (f32.const 0) (br 1 (i32.const 9))))
|
||||
)
|
||||
(func (export "loop-value-after-br_if") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32)
|
||||
(i32.const 0) (drop (br_if 1 (i32.const 9) (i32.const 1)))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(func (export "loop-value-after-br_table") (result i32)
|
||||
(block (result i32)
|
||||
(loop (result i32)
|
||||
(f32.const 0) (br_table 1 1 (i32.const 9) (i32.const 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
(func (export "loop-value-after-return") (result i32)
|
||||
(loop (result i32) (f32.const 0) (return (i32.const 9)))
|
||||
)
|
||||
)
|
||||
|
||||
(assert_trap (invoke "func-unwind-by-unreachable") "unreachable")
|
||||
(assert_return (invoke "func-unwind-by-br"))
|
||||
(assert_return (invoke "func-unwind-by-br-value") (i32.const 9))
|
||||
(assert_return (invoke "func-unwind-by-br_if"))
|
||||
(assert_return (invoke "func-unwind-by-br_if-value") (i32.const 9))
|
||||
(assert_return (invoke "func-unwind-by-br_table"))
|
||||
(assert_return (invoke "func-unwind-by-br_table-value") (i32.const 9))
|
||||
(assert_return (invoke "func-unwind-by-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "block-unwind-by-unreachable") "unreachable")
|
||||
(assert_return (invoke "block-unwind-by-br") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-br-value") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-br_if") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-br_if-value") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-br_table") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-br_table-value") (i32.const 9))
|
||||
(assert_return (invoke "block-unwind-by-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "block-nested-unwind-by-unreachable") "unreachable")
|
||||
(assert_return (invoke "block-nested-unwind-by-br") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-br-value") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-br_if") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-br_if-value") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-br_table") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-br_table-value") (i32.const 9))
|
||||
(assert_return (invoke "block-nested-unwind-by-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "unary-after-unreachable") "unreachable")
|
||||
(assert_return (invoke "unary-after-br") (i32.const 9))
|
||||
(assert_return (invoke "unary-after-br_if") (i32.const 9))
|
||||
(assert_return (invoke "unary-after-br_table") (i32.const 9))
|
||||
(assert_return (invoke "unary-after-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "binary-after-unreachable") "unreachable")
|
||||
(assert_return (invoke "binary-after-br") (i32.const 9))
|
||||
(assert_return (invoke "binary-after-br_if") (i32.const 9))
|
||||
(assert_return (invoke "binary-after-br_table") (i32.const 9))
|
||||
(assert_return (invoke "binary-after-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "select-after-unreachable") "unreachable")
|
||||
(assert_return (invoke "select-after-br") (i32.const 9))
|
||||
(assert_return (invoke "select-after-br_if") (i32.const 9))
|
||||
(assert_return (invoke "select-after-br_table") (i32.const 9))
|
||||
(assert_return (invoke "select-after-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "block-value-after-unreachable") "unreachable")
|
||||
(assert_return (invoke "block-value-after-br") (i32.const 9))
|
||||
(assert_return (invoke "block-value-after-br_if") (i32.const 9))
|
||||
(assert_return (invoke "block-value-after-br_table") (i32.const 9))
|
||||
(assert_return (invoke "block-value-after-return") (i32.const 9))
|
||||
|
||||
(assert_trap (invoke "loop-value-after-unreachable") "unreachable")
|
||||
(assert_return (invoke "loop-value-after-br") (i32.const 9))
|
||||
(assert_return (invoke "loop-value-after-br_if") (i32.const 9))
|
||||
(assert_return (invoke "loop-value-after-br_table") (i32.const 9))
|
||||
(assert_return (invoke "loop-value-after-return") (i32.const 9))
|
@ -1,20 +1,5 @@
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate libc;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
extern crate byteorder;
|
||||
extern crate nix;
|
||||
extern crate rayon;
|
||||
extern crate wasmer;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
@ -24,16 +9,7 @@ use std::process::exit;
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
#[macro_use]
|
||||
mod recovery;
|
||||
pub mod apis;
|
||||
pub mod common;
|
||||
pub mod sighandler;
|
||||
#[cfg(test)]
|
||||
mod spectests;
|
||||
pub mod webassembly;
|
||||
use wasmer::*;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "wasmer", about = "WASM execution runtime.")]
|
||||
@ -42,6 +18,10 @@ enum CLIOptions {
|
||||
/// Run a WebAssembly file. Formats accepted: wasm, wast
|
||||
#[structopt(name = "run")]
|
||||
Run(Run),
|
||||
|
||||
/// Update wasmer to the latest version
|
||||
#[structopt(name = "self-update")]
|
||||
SelfUpdate,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
@ -118,5 +98,6 @@ fn main() {
|
||||
let options = CLIOptions::from_args();
|
||||
match options {
|
||||
CLIOptions::Run(options) => run(options),
|
||||
CLIOptions::SelfUpdate => update::self_update(),
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ static ENV_VAR: &str = "WASM_GENERATE_SPECTESTS";
|
||||
static BANNER: &str = "// Rust test file autogenerated with cargo build (src/build_spectests.rs).
|
||||
// Please do NOT modify it by hand, as it will be reseted on next build.\n";
|
||||
|
||||
const TESTS: [&str; 58] = [
|
||||
const TESTS: [&str; 60] = [
|
||||
"spectests/address.wast",
|
||||
"spectests/align.wast",
|
||||
"spectests/binary.wast",
|
||||
@ -61,6 +61,7 @@ const TESTS: [&str; 58] = [
|
||||
"spectests/memory.wast",
|
||||
"spectests/memory_grow.wast",
|
||||
"spectests/memory_redundancy.wast",
|
||||
"spectests/memory_trap.wast",
|
||||
"spectests/nop.wast",
|
||||
"spectests/return_.wast",
|
||||
"spectests/select.wast",
|
||||
@ -74,6 +75,7 @@ const TESTS: [&str; 58] = [
|
||||
"spectests/traps.wast",
|
||||
"spectests/typecheck.wast",
|
||||
"spectests/types.wast",
|
||||
"spectests/unwind.wast",
|
||||
];
|
||||
|
||||
fn wabt2rust_type(v: &Value) -> String {
|
||||
|
29
src/lib.rs
Normal file
29
src/lib.rs
Normal file
@ -0,0 +1,29 @@
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate libc;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
extern crate byteorder;
|
||||
pub extern crate nix; // re-exported for usage in macros
|
||||
extern crate rayon;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
#[macro_use]
|
||||
pub mod recovery;
|
||||
pub mod apis;
|
||||
pub mod common;
|
||||
pub mod sighandler;
|
||||
#[cfg(test)]
|
||||
mod spectests;
|
||||
pub mod webassembly;
|
||||
pub mod update;
|
@ -5,6 +5,7 @@
|
||||
//! unless you have memory unsafety elsewhere in your code.
|
||||
|
||||
use std::cell::{Cell, UnsafeCell};
|
||||
use std::sync::Once;
|
||||
use nix::libc::siginfo_t;
|
||||
|
||||
extern "C" {
|
||||
@ -13,6 +14,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
const SETJMP_BUFFER_LEN: usize = 27;
|
||||
pub static SIGHANDLER_INIT: Once = Once::new();
|
||||
|
||||
thread_local! {
|
||||
pub static SETJMP_BUFFER: UnsafeCell<[::nix::libc::c_int; SETJMP_BUFFER_LEN]> = UnsafeCell::new([0; SETJMP_BUFFER_LEN]);
|
||||
@ -30,16 +32,18 @@ thread_local! {
|
||||
macro_rules! call_protected {
|
||||
($x:expr) => {
|
||||
unsafe {
|
||||
use crate::recovery::{setjmp, SETJMP_BUFFER, CAUGHT_ADDRESS};
|
||||
use crate::recovery::{setjmp, CAUGHT_ADDRESS, SETJMP_BUFFER, SIGHANDLER_INIT};
|
||||
use crate::sighandler::install_sighandler;
|
||||
use crate::webassembly::ErrorKind;
|
||||
|
||||
use nix::sys::signal::{Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV};
|
||||
use crate::nix::sys::signal::{Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV};
|
||||
|
||||
let jmp_buf = SETJMP_BUFFER.with(|buf| buf.get());
|
||||
let prev_jmp_buf = *jmp_buf;
|
||||
|
||||
install_sighandler();
|
||||
SIGHANDLER_INIT.call_once(|| {
|
||||
install_sighandler();
|
||||
});
|
||||
|
||||
let signum = setjmp(jmp_buf as *mut ::nix::libc::c_void);
|
||||
if signum != 0 {
|
||||
|
3409
src/spectests/memory_trap.rs
Normal file
3409
src/spectests/memory_trap.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -60,6 +60,7 @@ mod loop_;
|
||||
mod memory;
|
||||
mod memory_grow;
|
||||
mod memory_redundancy;
|
||||
mod memory_trap;
|
||||
mod nop;
|
||||
mod return_;
|
||||
mod select;
|
||||
@ -73,3 +74,4 @@ mod token;
|
||||
mod traps;
|
||||
mod typecheck;
|
||||
mod types;
|
||||
mod unwind;
|
||||
|
1142
src/spectests/unwind.rs
Normal file
1142
src/spectests/unwind.rs
Normal file
File diff suppressed because it is too large
Load Diff
17
src/update.rs
Normal file
17
src/update.rs
Normal file
@ -0,0 +1,17 @@
|
||||
//! When wasmer self-update is executed, this is what gets executed
|
||||
use std::process::{Command, Stdio};
|
||||
use std::io;
|
||||
|
||||
pub fn self_update() {
|
||||
println!("Fetching latest installer");
|
||||
let cmd = Command::new("curl").arg("https://get.wasmer.io").arg("-sSfL")
|
||||
.stdout(Stdio::piped()).spawn().unwrap();
|
||||
|
||||
let mut the_process = Command::new("sh")
|
||||
.stdin(cmd.stdout.unwrap())
|
||||
.stdout(Stdio::inherit())
|
||||
.spawn()
|
||||
.ok().expect("Failed to execute.");
|
||||
|
||||
the_process.wait();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user