Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,10 @@ endif()
enable_testing()

add_test(NAME opt-unit
COMMAND bin/wasm-opt test/unit.wast --flatten --ssa --metrics -O4 -Os --metrics)
COMMAND bin/wasm-opt test/unit.wat --flatten --ssa --metrics -O4 -Os --metrics)
add_test(NAME metrics-emcc
COMMAND bin/wasm-opt test/emcc_hello_world.fromasm --metrics)
add_test(NAME exec-unit
COMMAND bin/wasm-opt test/unit.wast --fuzz-exec)
COMMAND bin/wasm-opt test/unit.wat --fuzz-exec)
add_test(NAME exec-hello
COMMAND bin/wasm-opt test/hello_world.wast --fuzz-exec)
COMMAND bin/wasm-opt test/hello_world.wat --fuzz-exec)
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ passes on it, as well as print it (before and/or after the transformations). For
example, try

````
bin/wasm-opt test/passes/lower-if-else.wast --print
bin/wasm-opt test/passes/lower-if-else.wat --print
````

That will pretty-print out one of the test cases in the test suite. To run a
transformation pass on it, try

````
bin/wasm-opt test/passes/lower-if-else.wast --print --lower-if-else
bin/wasm-opt test/passes/lower-if-else.wat --print --lower-if-else
````

The `lower-if-else` pass lowers if-else into a block and a break. You can see
Expand Down Expand Up @@ -262,7 +262,7 @@ This will print out JavaScript to the console.
For example, try

```
$ bin/wasm2js test/hello_world.wast
$ bin/wasm2js test/hello_world.wat
```

That output contains
Expand All @@ -289,7 +289,7 @@ as a translation of
wasm2js's output is in ES6 module format - basically, it converts a wasm
module into an ES6 module (to run on older browsers and Node.js versions
you can use Babel etc. to convert it to ES5). Let's look at a full example
of calling that hello world wast; first, create the main JS file:
of calling that hello world wat; first, create the main JS file:

```javascript
// main.mjs
Expand All @@ -301,7 +301,7 @@ The run this (note that you need a new enough Node.js with ES6 module
support):

```shell
$ bin/wasm2js test/hello_world.wast -o hello_world.mjs
$ bin/wasm2js test/hello_world.wat -o hello_world.mjs
$ node --experimental-modules main.mjs
the sum of 1 and 2 is: 3
```
Expand Down
2 changes: 1 addition & 1 deletion auto_update_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def update_asm_js_tests():

def update_wasm_opt_tests():
print('\n[ checking wasm-opt -o notation... ]\n')
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wast')
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wat')
cmd = shared.WASM_OPT + [wast, '-o', 'a.wast', '-S']
support.run_command(cmd)
open(wast, 'w').write(open('a.wast').read())
Expand Down
22 changes: 11 additions & 11 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ def run_wasm_opt_tests():
print('\n[ checking wasm-opt -o notation... ]\n')

for extra_args in [[], ['--no-validation']]:
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wast')
shared.delete_from_orbit('a.wast')
out = 'a.wast'
wast = os.path.join(shared.options.binaryen_test, 'hello_world.wat')
shared.delete_from_orbit('a.wat')
out = 'a.wat'
cmd = shared.WASM_OPT + [wast, '-o', out, '-S'] + extra_args
support.run_command(cmd)
shared.fail_if_not_identical_to_file(open(out).read(), wast)

print('\n[ checking wasm-opt binary reading/writing... ]\n')

shutil.copyfile(os.path.join(shared.options.binaryen_test, 'hello_world.wast'), 'a.wast')
shutil.copyfile(os.path.join(shared.options.binaryen_test, 'hello_world.wat'), 'a.wat')
shared.delete_from_orbit('a.wasm')
shared.delete_from_orbit('b.wast')
support.run_command(shared.WASM_OPT + ['a.wast', '-o', 'a.wasm'])
support.run_command(shared.WASM_OPT + ['a.wat', '-o', 'a.wasm'])
assert open('a.wasm', 'rb').read()[0] == 0, 'we emit binary by default'
support.run_command(shared.WASM_OPT + ['a.wasm', '-o', 'b.wast', '-S'])
assert open('b.wast', 'rb').read()[0] != 0, 'we emit text with -S'
Expand Down Expand Up @@ -222,9 +222,9 @@ def run_ctor_eval_tests():
for t in shared.get_tests(shared.get_test_dir('ctor-eval'), ['.wast', '.wasm']):
print('..', os.path.basename(t))
ctors = open(t + '.ctors').read().strip()
cmd = shared.WASM_CTOR_EVAL + [t, '-o', 'a.wast', '-S', '--ctors', ctors]
cmd = shared.WASM_CTOR_EVAL + [t, '-o', 'a.wat', '-S', '--ctors', ctors]
support.run_command(cmd)
actual = open('a.wast').read()
actual = open('a.wat').read()
out = t + '.out'
shared.fail_if_not_identical_to_file(actual, out)

Expand All @@ -235,10 +235,10 @@ def run_wasm_metadce_tests():
for t in shared.get_tests(shared.get_test_dir('metadce'), ['.wast', '.wasm']):
print('..', os.path.basename(t))
graph = t + '.graph.txt'
cmd = shared.WASM_METADCE + [t, '--graph-file=' + graph, '-o', 'a.wast', '-S', '-all']
cmd = shared.WASM_METADCE + [t, '--graph-file=' + graph, '-o', 'a.wat', '-S', '-all']
stdout = support.run_command(cmd)
expected = t + '.dced'
with open('a.wast') as seen:
with open('a.wat') as seen:
shared.fail_if_not_identical_to_file(seen.read(), expected)
shared.fail_if_not_identical_to_file(stdout, expected + '.stdout')

Expand All @@ -257,8 +257,8 @@ def run_wasm_reduce_tests():
support.run_command(shared.WASM_AS + [t, '-o', 'a.wasm'])
support.run_command(shared.WASM_REDUCE + ['a.wasm', '--command=%s b.wasm --fuzz-exec -all' % shared.WASM_OPT[0], '-t', 'b.wasm', '-w', 'c.wasm', '--timeout=4'])
expected = t + '.txt'
support.run_command(shared.WASM_DIS + ['c.wasm', '-o', 'a.wast'])
with open('a.wast') as seen:
support.run_command(shared.WASM_DIS + ['c.wasm', '-o', 'a.wat'])
with open('a.wat') as seen:
shared.fail_if_not_identical_to_file(seen.read(), expected)

# run on a nontrivial fuzz testcase, for general coverage
Expand Down
8 changes: 4 additions & 4 deletions scripts/embedwast.py → scripts/embedwat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
output_file = sys.argv[2]

with open(input_file) as f:
wast = f.read()
wat = f.read()

output = """\
// Automatically generated by embedwast.py
// Automatically generated by embedwat.py

#include "passes/intrinsics-module.h"

static const char theModule[%d] = {
""" % (len(wast) + 1)
""" % (len(wat) + 1)

for c in wast:
for c in wat:
output += str(ord(c)) + ', '

output += '''0
Expand Down
2 changes: 1 addition & 1 deletion scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def get_multiple_opt_choices():
# possible feature options that are sometimes passed to the tools. this
# contains the list of all possible feature flags we can disable (after
# we enable all before that in the constant options)
POSSIBLE_FEATURE_OPTS = run([in_bin('wasm-opt'), '--print-features', '-all', in_binaryen('test', 'hello_world.wast'), '-all']).replace('--enable', '--disable').strip().split('\n')
POSSIBLE_FEATURE_OPTS = run([in_bin('wasm-opt'), '--print-features', '-all', in_binaryen('test', 'hello_world.wat'), '-all']).replace('--enable', '--disable').strip().split('\n')
print('POSSIBLE_FEATURE_OPTS:', POSSIBLE_FEATURE_OPTS)

if __name__ == '__main__':
Expand Down
30 changes: 15 additions & 15 deletions scripts/test/lld.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def args_for_finalize(filename):
def test_wasm_emscripten_finalize():
print('\n[ checking wasm-emscripten-finalize testcases... ]\n')

for wast_path in shared.get_tests(shared.get_test_dir('lld'), ['.wast']):
print('..', wast_path)
is_passive = '.passive.' in wast_path
mem_file = wast_path + '.mem'
for wat_path in shared.get_tests(shared.get_test_dir('lld'), ['.wat']):
print('..', wat_path)
is_passive = '.passive.' in wat_path
mem_file = wat_path + '.mem'
extension_arg_map = {
'.out': [],
}
Expand All @@ -44,13 +44,13 @@ def test_wasm_emscripten_finalize():
'.mem.out': ['--separate-data-segments', mem_file],
})
for ext, ext_args in extension_arg_map.items():
expected_file = wast_path + ext
expected_file = wat_path + ext
if ext != '.out' and not os.path.exists(expected_file):
continue

cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + \
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wat_path, '-S'] + \
ext_args
cmd += args_for_finalize(os.path.basename(wast_path))
cmd += args_for_finalize(os.path.basename(wat_path))
actual = support.run_command(cmd)

if not os.path.exists(expected_file):
Expand All @@ -61,18 +61,18 @@ def test_wasm_emscripten_finalize():
if ext == '.mem.out':
with open(mem_file) as mf:
mem = mf.read()
shared.fail_if_not_identical_to_file(mem, wast_path +
shared.fail_if_not_identical_to_file(mem, wat_path +
'.mem.mem')
os.remove(mem_file)


def update_lld_tests():
print('\n[ updatring wasm-emscripten-finalize testcases... ]\n')

for wast_path in shared.get_tests(shared.get_test_dir('lld'), ['.wast']):
print('..', wast_path)
is_passive = '.passive.' in wast_path
mem_file = wast_path + '.mem'
for wat_path in shared.get_tests(shared.get_test_dir('lld'), ['.wat']):
print('..', wat_path)
is_passive = '.passive.' in wat_path
mem_file = wat_path + '.mem'
extension_arg_map = {
'.out': [],
}
Expand All @@ -81,12 +81,12 @@ def update_lld_tests():
'.mem.out': ['--separate-data-segments', mem_file + '.mem'],
})
for ext, ext_args in extension_arg_map.items():
out_path = wast_path + ext
out_path = wat_path + ext
if ext != '.out' and not os.path.exists(out_path):
continue
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + \
cmd = shared.WASM_EMSCRIPTEN_FINALIZE + [wat_path, '-S'] + \
ext_args
cmd += args_for_finalize(os.path.basename(wast_path))
cmd += args_for_finalize(os.path.basename(wat_path))
actual = support.run_command(cmd)
with open(out_path, 'w') as o:
o.write(actual)
Expand Down
4 changes: 2 additions & 2 deletions src/passes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_custom_command(
OUTPUT WasmIntrinsics.cpp
COMMAND python ${PROJECT_SOURCE_DIR}/scripts/embedwast.py ${PROJECT_SOURCE_DIR}/src/passes/wasm-intrinsics.wast ${CMAKE_CURRENT_BINARY_DIR}/WasmIntrinsics.cpp
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/embedwast.py wasm-intrinsics.wast)
COMMAND python ${PROJECT_SOURCE_DIR}/scripts/embedwat.py ${PROJECT_SOURCE_DIR}/src/passes/wasm-intrinsics.wat ${CMAKE_CURRENT_BINARY_DIR}/WasmIntrinsics.cpp
DEPENDS ${PROJECT_SOURCE_DIR}/scripts/embedwat.py wasm-intrinsics.wat)

set(passes_SOURCES
pass.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

;; This file contains patterns for OptimizeInstructions. Basically, we use a DSL for the patterns,
;; and the DSL is just wasm itself, plus some functions with special meanings
;;
;; This file is converted into OptimizeInstructions.wast.processed by
;; This file is converted into OptimizeInstructions.wat.processed by
;; scripts/process_optimize_instructions.py
;; which makes it importable by C++. Then we just #include it there, avoiding the need to ship
;; a data file on the side.
Expand All @@ -24,4 +23,3 @@
)
)
)

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"\n"
";; This file contains patterns for OptimizeInstructions. Basically, we use a DSL for the patterns,\n"
";; and the DSL is just wasm itself, plus some functions with special meanings\n"
";;\n"
";; This file is converted into OptimizeInstructions.wast.processed by\n"
";; This file is converted into OptimizeInstructions.wat.processed by\n"
";; scripts/process_optimize_instructions.py\n"
";; which makes it importable by C++. Then we just #include it there, avoiding the need to ship\n"
";; a data file on the side.\n"
Expand All @@ -24,4 +23,3 @@
")\n"
")\n"
")\n"
"\n"
2 changes: 1 addition & 1 deletion src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
}
}
}
// try-catch-end is written in the folded wast format as
// try-catch-end is written in the folded wat format as
// (try
// ...
// (catch
Expand Down
4 changes: 2 additions & 2 deletions src/passes/RemoveNonJSOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// intrinsic implementation. Intrinsics don't use themselves to implement
// themselves.
//
// You'll find a large wast blob in `wasm-intrinsics.wast` next to this file
// You'll find a large wat blob in `wasm-intrinsics.wat` next to this file
// which contains all of the injected intrinsics. We manually copy over any
// needed intrinsics from this module into the module that we're optimizing
// after walking the current module.
Expand Down Expand Up @@ -65,7 +65,7 @@ struct RemoveNonJSOpsPass : public WalkerPass<PostWalker<RemoveNonJSOpsPass>> {
return;
}

// Parse the wast blob we have at the end of this file.
// Parse the wat blob we have at the end of this file.
//
// TODO: only do this once per invocation of wasm2asm
Module intrinsicsModule;
Expand Down
2 changes: 1 addition & 1 deletion src/passes/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void PassRunner::addDefaultGlobalOptimizationPostPasses() {
}

static void dumpWast(Name name, Module* wasm) {
// write out the wast
// write out the wat
static int counter = 0;
std::string numstr = std::to_string(counter++);
while (numstr.size() < 3) {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/tools/wasm-as.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, const char* argv[]) {
std::string sourceMapFilename;
std::string sourceMapUrl;
ToolOptions options("wasm-as",
"Assemble a .wast (WebAssembly text format) into a .wasm "
"Assemble a .wat (WebAssembly text format) into a .wasm "
"(WebAssembly binary format)");
options.extra["validate"] = "wasm";
options
Expand Down Expand Up @@ -94,7 +94,7 @@ int main(int argc, const char* argv[]) {
// default output is infile with changed suffix
if (options.extra.find("output") == options.extra.end()) {
options.extra["output"] =
removeSpecificSuffix(options.extra["infile"], ".wast") + ".wasm";
removeSpecificSuffix(options.extra["infile"], ".wat") + ".wasm";
}

auto input(read_file<std::string>(options.extra["infile"], Flags::Text));
Expand Down
2 changes: 1 addition & 1 deletion src/tools/wasm-dis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, const char* argv[]) {
std::string sourceMapFilename;
Options options("wasm-dis",
"Un-assemble a .wasm (WebAssembly binary format) into a "
".wast (WebAssembly text format)");
".wat (WebAssembly text format)");
options
.add("--output",
"-o",
Expand Down
4 changes: 2 additions & 2 deletions src/tools/wasm2js.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ void AssertionEmitter::emit() {
int main(int argc, const char* argv[]) {
Wasm2JSBuilder::Flags flags;
OptimizationOptions options("wasm2js",
"Transform .wasm/.wast files to asm.js");
"Transform .wasm/.wat files to asm.js");
options
.add("--output",
"-o",
Expand Down Expand Up @@ -873,7 +873,7 @@ int main(int argc, const char* argv[]) {

try {
// If the input filename ends in `.wasm`, then parse it in binary form,
// otherwise assume it's a `*.wast` file and go from there.
// otherwise assume it's a `*.wat` file and go from there.
//
// Note that we're not using the built-in `ModuleReader` which will also do
// similar logic here because when testing JS files we use the
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(; Copied from em_asm.wast
(; Copied from em_asm.wat
s/emscripten_asm_const_int/emscripten_asm_const_int_sync_on_main_thread/g
;)
(module
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading