diff --git a/CMakeLists.txt b/CMakeLists.txt index 18f50bc9b..a3c110e93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -557,10 +557,10 @@ if (BUILD_TOOLS) INSTALL ) - # wasm-opcodecnt + # wasm-stats wabt_executable( - NAME wasm-opcodecnt - SOURCES src/tools/wasm-opcodecnt.cc src/binary-reader-opcnt.cc + NAME wasm-stats + SOURCES src/tools/wasm-stats.cc src/binary-reader-stats.cc INSTALL ) diff --git a/README.md b/README.md index 882a1180c..99634b8d8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ WABT (we pronounce it "wabbit") is a suite of tools for WebAssembly, including: - [**wasm-strip**](https://webassembly.github.io/wabt/doc/wasm-strip.1.html): remove sections of a WebAssembly binary file - [**wasm-validate**](https://webassembly.github.io/wabt/doc/wasm-validate.1.html): validate a file in the WebAssembly binary format - [**wast2json**](https://webassembly.github.io/wabt/doc/wast2json.1.html): convert a file in the wasm spec test format to a JSON file and associated wasm binary files - - [**wasm-opcodecnt**](https://webassembly.github.io/wabt/doc/wasm-opcodecnt.1.html): count opcode usage for instructions + - [**wasm-stats**](https://webassembly.github.io/wabt/doc/wasm-stats.1.html): output stats for a module - [**spectest-interp**](https://webassembly.github.io/wabt/doc/spectest-interp.1.html): read a Spectest JSON file, and run its tests in the interpreter These tools are intended for use in (or for development of) toolchains or other diff --git a/docs/doc/spectest-interp.1.html b/docs/doc/spectest-interp.1.html index b02f9e10f..2c0a26542 100644 --- a/docs/doc/spectest-interp.1.html +++ b/docs/doc/spectest-interp.1.html @@ -90,7 +90,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wasm-decompile.1.html b/docs/doc/wasm-decompile.1.html index 5a8b326bf..20a899d37 100644 --- a/docs/doc/wasm-decompile.1.html +++ b/docs/doc/wasm-decompile.1.html @@ -80,7 +80,7 @@

wasm2wat(1), wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wasm-interp.1.html b/docs/doc/wasm-interp.1.html index 347b5910c..f596557c3 100644 --- a/docs/doc/wasm-interp.1.html +++ b/docs/doc/wasm-interp.1.html @@ -102,7 +102,7 @@

<

wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wasm-objdump.1.html b/docs/doc/wasm-objdump.1.html index 2037974e9..24c50cce7 100644 --- a/docs/doc/wasm-objdump.1.html +++ b/docs/doc/wasm-objdump.1.html @@ -77,7 +77,7 @@

<

wasm-interp(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wasm-opcodecnt.1.html b/docs/doc/wasm-stats.1.html similarity index 89% rename from docs/doc/wasm-opcodecnt.1.html rename to docs/doc/wasm-stats.1.html index c561e08fb..2923b3b60 100644 --- a/docs/doc/wasm-opcodecnt.1.html +++ b/docs/doc/wasm-stats.1.html @@ -27,22 +27,22 @@

-wasm-opcodecnt — -
count opcode usage for instructions
+wasm-stats — +
show stats for a module

- +
wasm-opcodecntwasm-stats [options] file ...

-wasm-opcodecnt reads a file in the wasm binary format, - and counts opcode usage for instructions. +wasm-stats reads a file in the wasm binary format, + and shows stats.

The options are as follows:

, @@ -64,9 +64,9 @@

-Parse binary file test.wasm and write pcode dist file test.dist +Parse binary file test.wasm and write opcode dist file test.dist

-
$ wasm-opcodecnt test.wasm -o +
$ wasm-stats test.wasm -o test.dist
diff --git a/docs/doc/wasm-strip.1.html b/docs/doc/wasm-strip.1.html index 036e54d24..6ca008501 100644 --- a/docs/doc/wasm-strip.1.html +++ b/docs/doc/wasm-strip.1.html @@ -60,7 +60,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-validate(1), wasm2c(1), wasm2wat(1), diff --git a/docs/doc/wasm-validate.1.html b/docs/doc/wasm-validate.1.html index 909c731a3..ea2081e99 100644 --- a/docs/doc/wasm-validate.1.html +++ b/docs/doc/wasm-validate.1.html @@ -84,7 +84,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm2c(1), wasm2wat(1), diff --git a/docs/doc/wasm2c.1.html b/docs/doc/wasm2c.1.html index 172f7be43..854f21528 100644 --- a/docs/doc/wasm2c.1.html +++ b/docs/doc/wasm2c.1.html @@ -86,7 +86,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2wat(1), diff --git a/docs/doc/wasm2wat.1.html b/docs/doc/wasm2wat.1.html index 728f2e505..43dc6aca0 100644 --- a/docs/doc/wasm2wat.1.html +++ b/docs/doc/wasm2wat.1.html @@ -97,7 +97,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wast2json.1.html b/docs/doc/wast2json.1.html index fe550fce3..07ddeb752 100644 --- a/docs/doc/wast2json.1.html +++ b/docs/doc/wast2json.1.html @@ -97,7 +97,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wat-desugar.1.html b/docs/doc/wat-desugar.1.html index 9a57fc4ca..e4bb892af 100644 --- a/docs/doc/wat-desugar.1.html +++ b/docs/doc/wat-desugar.1.html @@ -95,7 +95,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/docs/doc/wat2wasm.1.html b/docs/doc/wat2wasm.1.html index 425ba3e14..638934ce1 100644 --- a/docs/doc/wat2wasm.1.html +++ b/docs/doc/wat2wasm.1.html @@ -102,7 +102,7 @@

wasm-interp(1), wasm-objdump(1), - wasm-opcodecnt(1), + wasm-stats(1), wasm-strip(1), wasm-validate(1), wasm2c(1), diff --git a/include/wabt/binary-reader-opcnt.h b/include/wabt/binary-reader-stats.h similarity index 100% rename from include/wabt/binary-reader-opcnt.h rename to include/wabt/binary-reader-stats.h diff --git a/man/spectest-interp.1 b/man/spectest-interp.1 index 2322435e9..791fdb3ec 100644 --- a/man/spectest-interp.1 +++ b/man/spectest-interp.1 @@ -72,7 +72,7 @@ Parse test.json and run the spec tests .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wasm-decompile.1 b/man/wasm-decompile.1 index 5ddeb6f51..1f65ca9cc 100644 --- a/man/wasm-decompile.1 +++ b/man/wasm-decompile.1 @@ -66,7 +66,7 @@ Parse binary file test.wasm and write text file test.dcmp .Sh SEE ALSO .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wasm-interp.1 b/man/wasm-interp.1 index e4de437ff..7055a2df8 100644 --- a/man/wasm-interp.1 +++ b/man/wasm-interp.1 @@ -95,7 +95,7 @@ Parse test.wasm and run all its exported functions, setting the value stack size .Sh SEE ALSO .Xr wasm-decompile 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , @@ -107,4 +107,4 @@ Parse test.wasm and run all its exported functions, setting the value stack size .Sh BUGS If you find a bug, please report it at .br -.Lk https://github.com/WebAssembly/wabt/issues . \ No newline at end of file +.Lk https://github.com/WebAssembly/wabt/issues . diff --git a/man/wasm-objdump.1 b/man/wasm-objdump.1 index 448a9a4d9..5994c79ad 100644 --- a/man/wasm-objdump.1 +++ b/man/wasm-objdump.1 @@ -40,7 +40,7 @@ Print section offsets instead of file offsets in code disassembly .Sh SEE ALSO .Xr wasm-decompile 1 , .Xr wasm-interp 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wasm-opcodecnt.1 b/man/wasm-stats.1 similarity index 87% rename from man/wasm-opcodecnt.1 rename to man/wasm-stats.1 index 5fcc30126..1c4b80119 100644 --- a/man/wasm-opcodecnt.1 +++ b/man/wasm-stats.1 @@ -2,15 +2,15 @@ .Dt WABT 1 .Os .Sh NAME -.Nm wasm-opcodecnt -.Nd count opcode usage for instructions +.Nm wasm-stats +.Nd show stats for a module .Sh SYNOPSIS -.Nm wasm-opcodecnt +.Nm wasm-stats .Op options .Ar .Sh DESCRIPTION .Nm -Read a file in the wasm binary format, and count opcode usage for instructions. +Read a file in the wasm binary format, and show stats. .Pp The options are as follows: .Bl -tag -width Ds @@ -64,9 +64,9 @@ Cutoff for reporting counts less than N Separator text between element and count when reporting counts .El .Sh EXAMPLES -Parse binary file test.wasm and write pcode dist file test.dist +Parse binary file test.wasm and write opcode dist file test.dist .Pp -.Dl $ wasm-opcodecnt test.wasm -o test.dist +.Dl $ wasm-stats test.wasm -o test.dist .Sh SEE ALSO .Xr wasm-decompile 1 , .Xr wasm-interp 1 , diff --git a/man/wasm-strip.1 b/man/wasm-strip.1 index 943bd3f90..fe51b6b57 100644 --- a/man/wasm-strip.1 +++ b/man/wasm-strip.1 @@ -29,7 +29,7 @@ Remove all custom sections from test.wasm .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wasm-validate.1 b/man/wasm-validate.1 index 6bfacf5f4..489801413 100644 --- a/man/wasm-validate.1 +++ b/man/wasm-validate.1 @@ -69,7 +69,7 @@ Validate binary file test.wasm .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm2c 1 , .Xr wasm2wat 1 , diff --git a/man/wasm2c.1 b/man/wasm2c.1 index 40d38eef2..0b8900c2a 100644 --- a/man/wasm2c.1 +++ b/man/wasm2c.1 @@ -75,7 +75,7 @@ Parse test.wasm, write test.c and test.h, but ignore the debug names, if any .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2wat 1 , diff --git a/man/wasm2wat.1 b/man/wasm2wat.1 index 6a0006684..7840f21a6 100644 --- a/man/wasm2wat.1 +++ b/man/wasm2wat.1 @@ -85,7 +85,7 @@ Parse test.wasm, write test.wat, but ignore the debug names, if any .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wast2json.1 b/man/wast2json.1 index 77f37a5d8..88a1d80a8 100644 --- a/man/wast2json.1 +++ b/man/wast2json.1 @@ -78,7 +78,7 @@ Modules are written to spec-test.0.wasm, spec-test.1.wasm, etc. .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wat-desugar.1 b/man/wat-desugar.1 index 56537e0c5..07e693be4 100644 --- a/man/wat-desugar.1 +++ b/man/wat-desugar.1 @@ -83,7 +83,7 @@ Generate names for indexed variables .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/man/wat2wasm.1 b/man/wat2wasm.1 index f13966530..b9cba0ac7 100644 --- a/man/wat2wasm.1 +++ b/man/wat2wasm.1 @@ -87,7 +87,7 @@ Parse spec-test.wast, and write verbose output to stdout (including the meaning .Xr wasm-decompile 1 , .Xr wasm-interp 1 , .Xr wasm-objdump 1 , -.Xr wasm-opcodecnt 1 , +.Xr wasm-stats 1 , .Xr wasm-strip 1 , .Xr wasm-validate 1 , .Xr wasm2c 1 , diff --git a/scripts/help2man.lua b/scripts/help2man.lua index ed128b0c7..ab23733e7 100644 --- a/scripts/help2man.lua +++ b/scripts/help2man.lua @@ -2,7 +2,7 @@ local format_br = '\n.br\n' local tools = { - "wasm-decompile", "wasm-interp", "wasm-objdump", "wasm-opcodecnt", + "wasm-decompile", "wasm-interp", "wasm-objdump", "wasm-stats", "wasm-strip", "wasm-validate", "wasm2c", "wasm2wat", "wast2json", "wat-desugar", "wat2wasm", "spectest-interp" } diff --git a/src/binary-reader-opcnt.cc b/src/binary-reader-stats.cc similarity index 99% rename from src/binary-reader-opcnt.cc rename to src/binary-reader-stats.cc index 3177dbb7e..df0c438fd 100644 --- a/src/binary-reader-opcnt.cc +++ b/src/binary-reader-stats.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "wabt/binary-reader-opcnt.h" +#include "wabt/binary-reader-stats.h" #include #include diff --git a/src/tools/wasm-opcodecnt.cc b/src/tools/wasm-stats.cc similarity index 93% rename from src/tools/wasm-opcodecnt.cc rename to src/tools/wasm-stats.cc index 058d807fd..d8fb1fb43 100644 --- a/src/tools/wasm-opcodecnt.cc +++ b/src/tools/wasm-stats.cc @@ -24,7 +24,7 @@ #include #include -#include "wabt/binary-reader-opcnt.h" +#include "wabt/binary-reader-stats.h" #include "wabt/binary-reader.h" #include "wabt/option-parser.h" #include "wabt/stream.h" @@ -45,16 +45,15 @@ static std::unique_ptr s_log_stream; static Features s_features; static const char s_description[] = - R"( Read a file in the wasm binary format, and count opcode usage for - instructions. + R"( Read a file in the wasm binary format, and output stats. examples: - # parse binary file test.wasm and write pcode dist file test.dist - $ wasm-opcodecnt test.wasm -o test.dist + # parse binary file test.wasm and write opcode dist file test.dist + $ wasm-stats test.wasm -o test.dist )"; static void ParseOptions(int argc, char** argv) { - OptionParser parser("wasm-opcodecnt", s_description); + OptionParser parser("wasm-stats", s_description); parser.AddOption('v', "verbose", "Use multiple times for more info", []() { s_verbose++; @@ -63,7 +62,7 @@ static void ParseOptions(int argc, char** argv) { }); s_features.AddOptions(&parser); parser.AddOption('o', "output", "FILENAME", - "Output file for the opcode counts, by default use stdout", + "Output file for the stats, by default use stdout", [](const char* argument) { s_outfile = argument; }); parser.AddOption( 'c', "cutoff", "N", "Cutoff for reporting counts less than N", diff --git a/test/README.md b/test/README.md index 4a6c59e6b..84a841140 100644 --- a/test/README.md +++ b/test/README.md @@ -145,8 +145,8 @@ The currently supported list of tools (see interpreter. - `run-gen-wasm-decompile`: parse a "gen-wasm" text file (which can describe invalid binary files), then parse via `wasm-decompile` and display the result. -- `run-opcodecnt`: parse a wasm text file, convert it to binary, then display - opcode usage counts. +- `run-stats`: parse a wasm text file, convert it to binary, then display + stats. - `run-gen-spec-js`: parse wasm spec test text file, convert it to a JSON file and a collection of `.wasm` and `.wast` files, then take all of these files and generate a JavaScript file that will execute the same tests. @@ -177,7 +177,7 @@ subdirectory: JavaScript file. - `help`: Tests the output of running with the `--help` flag on each tool. - `interp`: Tests the `wasm-interp` tool. -- `opcodecnt`: Tests the `wasm-opcodecnt` tool. +- `stats`: Tests the `wasm-stats` tool. - `parse`: Tests parsing via the `wat2wasm` tool. - `regress`: Various regression tests that are irregular and don't fit naturally in the other directories. diff --git a/test/find_exe.py b/test/find_exe.py index 040c1ee6b..5fa1bf9a1 100644 --- a/test/find_exe.py +++ b/test/find_exe.py @@ -25,7 +25,7 @@ REPO_ROOT_DIR = os.path.dirname(SCRIPT_DIR) EXECUTABLES = [ 'wat2wasm', 'wast2json', 'wasm2wat', 'wasm-objdump', 'wasm-interp', - 'wasm-opcodecnt', 'wat-desugar', 'spectest-interp', 'wasm-validate', + 'wasm-stats', 'wat-desugar', 'spectest-interp', 'wasm-validate', 'wasm2c', 'wasm-strip', 'wasm-decompile' ] @@ -89,8 +89,8 @@ def GetSpectestInterpExecutable(override=None): return FindExecutable('spectest-interp', override) -def GetWasmOpcodeCntExecutable(override=None): - return FindExecutable('wasm-opcodecnt', override) +def GetWasmStatsExecutable(override=None): + return FindExecutable('wasm-stats', override) def GetWatDesugarExecutable(override=None): diff --git a/test/help/wasm-opcodecnt.txt b/test/help/wasm-stats.txt similarity index 86% rename from test/help/wasm-opcodecnt.txt rename to test/help/wasm-stats.txt index d6899d61f..fb3b75834 100644 --- a/test/help/wasm-opcodecnt.txt +++ b/test/help/wasm-stats.txt @@ -1,14 +1,13 @@ -;;; RUN: %(wasm-opcodecnt)s +;;; RUN: %(wasm-stats)s ;;; ARGS: --help (;; STDOUT ;;; -usage: wasm-opcodecnt [options] filename+ +usage: wasm-stats [options] filename+ - Read a file in the wasm binary format, and count opcode usage for - instructions. + Read a file in the wasm binary format, and output stats. examples: - # parse binary file test.wasm and write pcode dist file test.dist - $ wasm-opcodecnt test.wasm -o test.dist + # parse binary file test.wasm and write opcode dist file test.dist + $ wasm-stats test.wasm -o test.dist options: --help Print this help message @@ -33,7 +32,7 @@ options: --enable-extended-const Enable Extended constant expressions --enable-relaxed-simd Enable Relaxed SIMD --enable-all Enable all features - -o, --output=FILENAME Output file for the opcode counts, by default use stdout + -o, --output=FILENAME Output file for the stats, by default use stdout -c, --cutoff=N Cutoff for reporting counts less than N -s, --separator=SEPARATOR Separator text between element and count when reporting counts ;;; STDOUT ;;) diff --git a/test/run-tests.py b/test/run-tests.py index 5c5202d15..0bd241ea3 100755 --- a/test/run-tests.py +++ b/test/run-tests.py @@ -133,9 +133,9 @@ ('RUN', '%(wasm-decompile)s %(temp_file)s.wasm'), ('VERBOSE-ARGS', ['--print-cmd', '-v']), ], - 'run-opcodecnt': [ + 'run-stats': [ ('RUN', '%(wat2wasm)s %(in_file)s -o %(temp_file)s.wasm'), - ('RUN', '%(wasm-opcodecnt)s %(temp_file)s.wasm'), + ('RUN', '%(wasm-stats)s %(temp_file)s.wasm'), ('VERBOSE-ARGS', ['--print-cmd', '-v']), ], 'run-gen-spec-js': [ diff --git a/test/opcodecnt/basic.txt b/test/stats/basic.txt similarity index 96% rename from test/opcodecnt/basic.txt rename to test/stats/basic.txt index 33cf7e2f9..7dc0203a4 100644 --- a/test/opcodecnt/basic.txt +++ b/test/stats/basic.txt @@ -1,4 +1,4 @@ -;;; TOOL: run-opcodecnt +;;; TOOL: run-stats (module (memory (data "hello, world")) (func diff --git a/test/opcodecnt/cutoff.txt b/test/stats/cutoff.txt similarity index 92% rename from test/opcodecnt/cutoff.txt rename to test/stats/cutoff.txt index ca85ad1f7..4f5bf5c46 100644 --- a/test/opcodecnt/cutoff.txt +++ b/test/stats/cutoff.txt @@ -1,4 +1,4 @@ -;;; TOOL: run-opcodecnt +;;; TOOL: run-stats ;;; ARGS: --cutoff 3 (module (func diff --git a/test/opcodecnt/immediates.txt b/test/stats/immediates.txt similarity index 98% rename from test/opcodecnt/immediates.txt rename to test/stats/immediates.txt index e7568145c..4ea0f5c07 100644 --- a/test/opcodecnt/immediates.txt +++ b/test/stats/immediates.txt @@ -1,4 +1,4 @@ -;;; TOOL: run-opcodecnt +;;; TOOL: run-stats (module (memory 1) (func