webassembly / wabt Goto Github PK
View Code? Open in Web Editor NEWThe WebAssembly Binary Toolkit
License: Apache License 2.0
The WebAssembly Binary Toolkit
License: Apache License 2.0
the following
(module (func (loop $a (br $a))) (export "" 0))
(module (func (loop $a $b (br $a))) (export "" 0))
Should generate the same output
However, the first outputs br 0
(infinite loop) and the second outputs br 1
(all is good)
This file crashes the prototype. crash_sexpre_proto.wast.txt
It crashes with
crash_sexpre_proto.wast:3569:37: memory exhausted
(else (if (i32.eq (get_local $jump_dest) (i32.const 16940))
The file is over 50,000 line. I'm generating it with evm2wasm and I added optimization to shink the size. But the source program is huge to start with and I don't think I can make it much smaller on my end.
sexpr-wasm-prototype is a very old name for the project, and doesn't really reflect what it is or does. Any ideas for a better name?
I get
Downloading https://storage.googleapis.com/webassembly/v8-native-prototype/7ee0c81f107ab72d6e46d94e0a1d01be7ae56d34/d8...
curl: (22) The requested URL returned error: 404 Not Found
One thing we've recently been thinking a lot about on Chakra is our testing story for WebAssembly. I think it would be ideal if we could use this as a submodule, and have our testing build wasts using sexpr-wasm on the fly. This would allow us to run WebAssembly tests through our CI without needing to check in a whole bunch of binary files.
However, what makes me hesitant to do this is that V8 is a submodule of sexpr-wasm, and (for obvious reasons) I'd rather not have V8 as a submodule of ChakraCore. So what do you guys think? Feasible to remove that dependency? Also, I'm wondering how V8 handles wasm testing? Presumably you don't have this as a submodule either (that seems like there would be some weird recursion), so do you check in .wasm files, or something else?
Anyone else seeing this error?
make: *** No rule to make target out', needed by
out/wasm.o'. Stop.
Presumably it's due to the trailing slash in the rule "out/:
I've only seen this on a couple systems, and it may be file system dependent as even on those
systems I don't see this if working in a directory on a different mount.
It's easily worked around by pre-creating out, or locally removing the slash after out in the Makefile, so a fix is by no means urgent or even necessary. But I thought I'd file an issue in case anyone can shed some light as to why this might be happening.
Currently if d8 is broken, I just run manually:
out/sexpr-wasm <broken test> -o foo.wasm
gdb --args <d8> test/wasm.js -- foo.wasm
Probably should describe this process in the README. Maybe make it more convenient?
I don't think we currently are?
https://wasm-stat.us/builders/linux/builds/11742/steps/musl/logs/stdio
Reverting #148 locally lets it build again.
The musl.wast looks like
(module
(memory $0 1)
(data ...)
...
(type ...)
...
(import ...)
...
(export ...)
...
(table 19 19 anyfunc)
(elem ...)
(func ...)
...
)
which seems valid?
Similar to run-d8.py
, which uses --d8-executable
for this.
@sbc100 mentioned that we should probably rename the binaries for clarity:
sexpr-wasm -> wast2wasm
wasm-wast -> wasm2wast
That will mean that we can use make install
to do things like install into the waterfall build.
Just noticed this.
Described here, though not in the design repo anywhere.
The spec interpreter reports assertion errors with line numbers from the source. This would be really handy for debugging codegen issues (e.g. in a test suite with hundreds of assertions, which one is failing?). Currently WAOT just tracks and prints the count (i.e. "assertion number X failed") but a line number would be even better. That would have more immediate utility but at some point it might become nice to have line information for expressions too (maybe I want to generate debug info?) That's sort of a speculative use case and may not matter during the time horizon that sexpr-wasm matters, but something that might be nice to have in mind. I'd be happy for asserts for now.
I don't know if it would be better just to hang SourceLocations off of some existing data structure, or pass extra callback args or what, it doesn't matter much to me, I don't think.
Another issue, similar to the br
optional value issues.
(module
(memory 4)
(export "test1" $test1)
(func $test1 (return))
(export "test2" $test2)
(func $test2 (return (nop)))
(export "test3" $test3)
(func $test3 (return (i32.const 1)))
)
0000011: 0000 ; func body size
0000013: 14 ; OPCODE_RETURN
0000011: 0100 ; FIXUP func body size
...
000001b: 0000 ; func body size
000001d: 14 ; OPCODE_RETURN
000001e: 00 ; OPCODE_NOP
000001b: 0200 ; FIXUP func body size
....
0000026: 0000 ; func body size
0000028: 14 ; OPCODE_RETURN
0000029: 09 ; OPCODE_I8_CONST
000002a: 01 ; u8 literal
0000026: 0300 ; FIXUP func body size
Looking at the v8 source code suggests it looks at the number of results types to determine the 'arity' of the return. Both the above functions have the same signature, perhaps the same 'arity' here, yet one excludes a value and the other includes it.
I'd like a solution to take into account the consistency of the type system and multi-value support. I propose that a return
with no expression be equivalent to (return (nop))
.
sexpr-wasm doesn't handle the new select
syntax, which @kripken added to binaryen. This breaks the waterfall.
/cc @dschuff
Specifically:
(block $inner ;; 0
(br $inner)
(br $outer)))))))
->
0000013: 01 ; OPCODE_BLOCK
0000014: 02 ; num expressions
0000015: 06 ; OPCODE_BR
0000016: 00 ; break depth
0000017: 00 ; OPCODE_NOP
0000018: 06 ; OPCODE_BR
0000019: 04 ; break depth
000001a: 00 ; OPCODE_NOP
The block has 2 child expressions but four expressions are emitted. When parsing this produces br 0
followed by nop
and then the function body has a trailing br 4
, nop
which is not only an incorrect decoding but invalid (due to the break depth).
This happens when given any *.wasm file
Starting program: /home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm ../test.wasm
*** Error in `/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm': realloc(): invalid pointer: 0x00007ffff7fc1548 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72055)[0x7ffff7aa9055]
/usr/lib/libc.so.6(+0x779a6)[0x7ffff7aae9a6]
/usr/lib/libc.so.6(realloc+0x1db)[0x7ffff7ab2d0b]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x41ccd5]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x41cd41]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x401990]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x4019ae]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x40c30f]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x40385d]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7ffff7a57610]
/home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm[0x400ff9]
======= Memory map: ========
00400000-00431000 r-xp 00000000 08:03 9838228 /home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm
00631000-00632000 rw-p 00031000 08:03 9838228 /home/null/code/WASM/sexpr-wasm-prototype/out/sexpr-wasm
00632000-00653000 rw-p 00000000 00:00 0 [heap]
7ffff0000000-7ffff0021000 rw-p 00000000 00:00 0
7ffff0021000-7ffff4000000 ---p 00000000 00:00 0
7ffff7821000-7ffff7837000 r-xp 00000000 08:03 19140025 /usr/lib/libgcc_s.so.1
7ffff7837000-7ffff7a36000 ---p 00016000 08:03 19140025 /usr/lib/libgcc_s.so.1
7ffff7a36000-7ffff7a37000 rw-p 00015000 08:03 19140025 /usr/lib/libgcc_s.so.1
7ffff7a37000-7ffff7bd2000 r-xp 00000000 08:03 19139726 /usr/lib/libc-2.22.so
7ffff7bd2000-7ffff7dd1000 ---p 0019b000 08:03 19139726 /usr/lib/libc-2.22.so
7ffff7dd1000-7ffff7dd5000 r--p 0019a000 08:03 19139726 /usr/lib/libc-2.22.so
7ffff7dd5000-7ffff7dd7000 rw-p 0019e000 08:03 19139726 /usr/lib/libc-2.22.so
7ffff7dd7000-7ffff7ddb000 rw-p 00000000 00:00 0
7ffff7ddb000-7ffff7dfd000 r-xp 00000000 08:03 19139725 /usr/lib/ld-2.22.so
7ffff7fbf000-7ffff7fc2000 rw-p 00000000 00:00 0
7ffff7ff6000-7ffff7ff8000 rw-p 00000000 00:00 0
7ffff7ff8000-7ffff7ffa000 r--p 00000000 00:00 0 [vvar]
7ffff7ffa000-7ffff7ffc000 r-xp 00000000 00:00 0 [vdso]
7ffff7ffc000-7ffff7ffd000 r--p 00021000 08:03 19139725 /usr/lib/ld-2.22.so
7ffff7ffd000-7ffff7ffe000 rw-p 00022000 08:03 19139725 /usr/lib/ld-2.22.so
7ffff7ffe000-7ffff7fff000 rw-p 00000000 00:00 0
7ffffffde000-7ffffffff000 rw-p 00000000 00:00 0 [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Program received signal SIGABRT, Aborted.
0x00007ffff7a6a5f8 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff7a6a5f8 in raise () from /usr/lib/libc.so.6
#1 0x00007ffff7a6ba7a in abort () from /usr/lib/libc.so.6
#2 0x00007ffff7aa905a in __libc_message () from /usr/lib/libc.so.6
#3 0x00007ffff7aae9a6 in malloc_printerr () from /usr/lib/libc.so.6
#4 0x00007ffff7ab2d0b in realloc () from /usr/lib/libc.so.6
#5 0x000000000041ccd5 in ensure_capacity (data=0x7ffffffeca98, capacity=0x7ffffffecaa8,
desired_size=2, elt_byte_size=8) at src/wasm-vector.c:16
#6 0x000000000041cd41 in append_element (data=0x7ffffffeca98, size=0x7ffffffecaa0,
capacity=0x7ffffffecaa8, elt_byte_size=8) at src/wasm-vector.c:28
#7 0x0000000000401990 in wasm_append_import_ptr (vec=0x7ffffffeca98) at src/wasm.c:20
#8 0x00000000004019ae in wasm_append_import_ptr_value (vec=0x7ffffffeca98, value=0x7ffffffec058)
at src/wasm.c:20
#9 0x000000000040c30f in wasm_parse (scanner=0x632260, parser=0x7fffffffe380) at src/wasm-parser.y:1275
#10 0x000000000040385d in main (argc=2, argv=0x7fffffffe4b8) at src/sexpr-wasm.c:180
Build on MSVC fails due to missing decl for memcpy. Line 94 at src/wasm-config.h.in,
#elif COMPILER_IS_MSVC
#define WASM_UNUSED
#define WASM_WARN_UNUSED _Check_return_
#define WASM_INLINE __inline
#define WASM_STATIC_ASSERT(x) _STATIC_ASSERT(x)
#define WASM_UNLIKELY(x) (x)
#define WASM_LIKELY(x) (x)
#define WASM_PRINTF_FORMAT(format_arg, first_arg)
__inline unsigned long wasm_clz_u32(unsigned long mask) {
unsigned long index;
_BitScanReverse(&index, mask);
return sizeof(unsigned long) * 8 - (index + 1);
}
__inline unsigned long wasm_clz_u64(unsigned __int64 mask) {
#if _M_X64
unsigned long index;
_BitScanReverse64(&index, mask);
return sizeof(unsigned __int64) * 8 - (index + 1);
#elif _M_IX86
unsigned long index;
unsigned long high_mask;
memcpy(&high_mask, (unsigned char*)&mask + sizeof(unsigned long),
sizeof(unsigned long));
if (_BitScanReverse(&index, high_mask)) {
return sizeof(unsigned long) * 8 - (index + 1);
}
unsigned long low_mask;
memcpy(&low_mask, &mask, sizeof(unsigned long));
_BitScanReverse(&index, low_mask);
return sizeof(unsigned __int64) * 8 - (index + 1);
#else
#error unexpected architecture
#endif
}
Issue is fixed by include <string.h>
I get the following error:
foo.wast:2:11: invalid initial memory size "0\00\"
foo.wast:2:17: invalid max memory size "0\00\00\00"
With this input file, it looks like the last segment makes it sad but I have not clue why. Everything seems properly quoted and escaped. It's happy if I remove all the nulls from the last segment. The quote looks well escaped.
(module
(memory 19448 4294967295
(segment 8 "\10\01\00\00")
(segment 16 "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\03 \02 \02 \02 \02 \02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\02\00\01`\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\08\d8\08\d8\08\d8\08\d8\08\d8\08\d8\08\d8\08\d8\08\d8\08\d8\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\08\d5\08\d5\08\d5\08\d5\08\d5\08\d5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\08\c5\04\c0\04\c0\04\c0\04\c0\04\c0\04\c0\08\d6\08\d6\08\d6\08\d6\08\d6\08\d6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\08\c6\04\c0\04\c0\04\c0\04\c0\02\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
(segment 784 " \05\00\00")
(segment 800 "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\03\00\00\00\04\00\00\00\05\00\00\00\06\00\00\00\07\00\00\00\08\00\00\00\t\00\00\00\n\00\00\00\0b\00\00\00\0c\00\00\00\0d\00\00\00\0e\00\00\00\0f\00\00\00\10\00\00\00\11\00\00\00\12\00\00\00\13\00\00\00\14\00\00\00\15\00\00\00\16\00\00\00\17\00\00\00\18\00\00\00\19\00\00\00\1a\00\00\00\1b\00\00\00\1c\00\00\00\1d\00\00\00\1e\00\00\00\1f\00\00\00 \00\00\00!\00\00\00\"\00\00\00#\00\00\00$\00\00\00%\00\00\00&\00\00\00\'\00\00\00(\00\00\00)\00\00\00*\00\00\00+\00\00\00,\00\00\00-\00\00\00.\00\00\00/\00\00\000\00\00\001\00\00\002\00\00\003\00\00\004\00\00\005\00\00\006\00\00\007\00\00\008\00\00\009\00\00\00:\00\00\00;\00\00\00<\00\00\00=\00\00\00>\00\00\00?\00\00\00@\00\00\00a\00\00\00b\00\00\00c\00\00\00d\00\00\00e\00\00\00f\00\00\00g\00\00\00h\00\00\00i\00\00\00j\00\00\00k\00\00\00l\00\00\00m\00\00\00n\00\00\00o\00\00\00p\00\00\00q\00\00\00r\00\00\00s\00\00\00t\00\00\00u\00\00\00v\00\00\00w\00\00\00x\00\00\00y\00\00\00z\00\00\00[\00\00\00\\\00\00\00]\00\00\00^\00\00\00_\00\00\00`\00\00\00a\00\00\00b\00\00\00c\00\00\00d\00\00\00e\00\00\00f\00\00\00g\00\00\00h\00\00\00i\00\00\00j\00\00\00k\00\00\00l\00\00\00m\00\00\00n\00\00\00o\00\00\00p\00\00\00q\00\00\00r\00\00\00s\00\00\00t\00\00\00u\00\00\00v\00\00\00w\00\00\00x\00\00\00y\00\00\00z\00\00\00{\00\00\00|\00\00\00}\00\00\00~\00\00\00\7f\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
(segment 2336 "0\0b\00\00")
(segment 2352 "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00\03\00\00\00\04\00\00\00\05\00\00\00\06\00\00\00\07\00\00\00\08\00\00\00\t\00\00\00\n\00\00\00\0b\00\00\00\0c\00\00\00\0d\00\00\00\0e\00\00\00\0f\00\00\00\10\00\00\00\11\00\00\00\12\00\00\00\13\00\00\00\14\00\00\00\15\00\00\00\16\00\00\00\17\00\00\00\18\00\00\00\19\00\00\00\1a\00\00\00\1b\00\00\00\1c\00\00\00\1d\00\00\00\1e\00\00\00\1f\00\00\00 \00\00\00!\00\00\00\"\00\00\00#\00\00\00$\00\00\00%\00\00\00&\00\00\00\'\00\00\00(\00\00\00)\00\00\00*\00\00\00+\00\00\00,\00\00\00-\00\00\00.\00\00\00/\00\00\000\00\00\001\00\00\002\00\00\003\00\00\004\00\00\005\00\00\006\00\00\007\00\00\008\00\00\009\00\00\00:\00\00\00;\00\00\00<\00\00\00=\00\00\00>\00\00\00?\00\00\00@\00\00\00A\00\00\00B\00\00\00C\00\00\00D\00\00\00E\00\00\00F\00\00\00G\00\00\00H\00\00\00I\00\00\00J\00\00\00K\00\00\00L\00\00\00M\00\00\00N\00\00\00O\00\00\00P\00\00\00Q\00\00\00R\00\00\00S\00\00\00T\00\00\00U\00\00\00V\00\00\00W\00\00\00X\00\00\00Y\00\00\00Z\00\00\00[\00\00\00\\\00\00\00]\00\00\00^\00\00\00_\00\00\00`\00\00\00A\00\00\00B\00\00\00C\00\00\00D\00\00\00E\00\00\00F\00\00\00G\00\00\00H\00\00\00I\00\00\00J\00\00\00K\00\00\00L\00\00\00M\00\00\00N\00\00\00O\00\00\00P\00\00\00Q\00\00\00R\00\00\00S\00\00\00T\00\00\00U\00\00\00V\00\00\00W\00\00\00X\00\00\00Y\00\00\00Z\00\00\00{\00\00\00|\00\00\00}\00\00\00~\00\00\00\7f\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
)
)
For the following function
(func $return-nop (return (nop)))
(https://github.com/WebAssembly/testsuite/blob/master/functions.wast)
There is a conflict between the function type and return arity.
The type of the function is
; type 0
000000f: 40 ; function form
0000010: 00 ; num params
0000011: 00 ; num results
And the function body is the following
; function body 6
00001a0: 00 ; func body size (guess)
00001a1: 00 ; local decl count
00001a2: 00 ; OPCODE_NOP
00001a3: 09 ; OPCODE_RETURN
00001a4: 01 ; return arity
00001a0: 04 ; FIXUP func body size
Since nop
is: an empty operator that does not yield a value
then the arity of the return statement should be 0 thus having a valid type.
I found this by running the tests, I am surprised this didn't come up in the CI
As in: WebAssembly/design#495
I'm adding support for it in: WebAssembly/binaryen#182
I tried to build emscripten's hello world wast into wasm, but I get errors like
a.out.wast:65:3: global can only be defined in terms of a previously defined global.
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The relevant lines are
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
[..]
(global $STACKTOP (mut i32) (get_global $STACKTOP$asm2wasm$import))
and that error was on the last line there.
I think that wast code should be valid? We import $STACKTOP$asm2wasm$import
, then use it to init a mutable global (asm2wasm needs mutable imports, so first we import, then assign to a mutable since imports can't be mutable).
Are there any plans to introduce support for macros? Something similar to Lisp's defmacro
perhaps, with both the '
and ~
modifiers.
It would make life a bit easier writing wast
. It won't be of course (easily) possible to turn wasm
back to its original form with macros.
The following is valid wast but crashes in wasm-interp.
(module
(func $tst1
(block
(block $l (br $l (i32.const 1)) (nop))
(nop)))
(export "tst" $tst1)
)
The load access byte on the i64.load below is zero, suggesting it is aligned, but would the natural alignment for a 64 bit load be 8 and not 2, so should it be setting the un-aligned bit in the load access byte?
(module (memory 65536 65536)
(func $f1 (result i64)
(i64.load align=2 (i32.const 0))))
; function 0
000000a: 00 ; func flags
000000b: 0000 ; func signature index
000000d: 0000 ; func body size
000000f: 2b ; OPCODE_I64_LOAD_MEM
0000010: 00 ; load access byte <<< should this be 0x80?
0000011: 09 ; OPCODE_I8_CONST
0000012: 00 ; u8 literal
000000d: 0400 ; FIXUP func body size
The following test from the spec seems to conflict with the v8 encoding which can only have one export per function. Should sexp-wasm signal an error on this? Should the spec be changed to make this invalid?
(module (func (i32.const 1)) (export "a" 0) (export "b" 0))
I have a test that generated the following code, and fed it into sexpr-wasm
(module
(func $foomore(call $foo (i32.const 0x0)) )
(func $foo (param i32)(nop))
)
Note the lack of space between $foomore and its opening paren. Sometime between rev 64fb062 and rev 7601228 this stopped being accepted by the parser, which now issues the following confusing error:
:2:23: expected '(', not "$foo"
It looks like the "(call" is getting sucked into the "$foomore" token.
I don't actually know what the rules of s-expressions are in that case; maybe this is the correct behavior?
Seems odd that the v8 encoding requires a nop opcode as fill in br and br_if but sexpr-wasm-prototype will not accept a nop value in the same place?
uncompr.wast:109:11: arity mismatch of br_if value. label expects void, but br value is non-empty
here is my test code
(module
(func (result i32)
(i32.add (i32.const 624485) (i32.const 2))))
LEB of 624485 should be 0xE58E26
But from the prototype if get
; function 0
....
0000014: 0a ; OPCODE_I32_CONST
0000015: 6587 0900 ; u32 literal
....
how is 0x65870900 derived?
The following FP number doesn't parse: 1.e+300
.
Error: unexpected token "1.e+300"
The problem is .e
if I change it to 1.0e+300
it works.
I'm testing a program which encounters the following sexpr-wasm error:
invalid literal "nan:0x7ff8000000000000"
invalid literal "nan:0x7fc00000"
invalid literal "nan:0x7ff8000000000000"
invalid literal "nan:0x7fc00000"
invalid literal "nan:0x7ff8000000000000"
invalid literal "nan:0x7fc00000"
invalid literal "nan:0x7ff8000000000000"
invalid literal "nan:0x7fc00000"
This was generated by binaryen's s2wasm, and seems to be in line with the spec repo. @binji could you confirm?
/cc @kripken @rossberg-chromium
I'm worried I might break it as it stands :)
Also, it should probably be added to the top level Makefile so it ends up on the out
directory?
Updating sexpr-wasm in a pre-built repo causes the following error:
sexpr directory already exists
subprocess.check_call(`git fetch`, cwd=`/b/build/slave/linux/build/src/src/work/sexpr-wasm-prototype`)
subprocess.check_call(`git checkout origin/master`, cwd=`/b/build/slave/linux/build/src/src/work/sexpr-wasm-prototype`)
error: Your local changes to the following files would be overwritten by checkout:
src/wasm-flex-lexer.c
Please, commit your changes or stash them before you can switch branches.
Aborting
Are in-tree builds expected to be clean?
From the example in the Readme
var buffer = readbuffer('test.wasm');
var module = _WASMEXP_.instantiateModule(buffer, {});
module
comes out undefined at the end here. It should export test
Some of the torture tests fail with this because s2wasm emits them in the opposite order as wasmate, e.g.:
(f64.store align=1 offset=8 (i32.const 0) (f64.const 0))
It would be good to also update store-offset.txt adn load-offset.txt, as well as make sure that the spec repo has the same tests.
s2wasm_known_gcc_test_failures.txt has a list of expected failures. I don't run it on the bots yet (will add this afternoon), to repro:
/s/wasm/experimental/buildbot/assemble_files.py --assembler /s/wasm/experimental/buildbot/work/sexpr-wasm-prototype/out/sexpr-wasm --files /s/wasm/experimental/buildbot/work/s2wasm-out/\*.wast --fails /s/wasm/experimental/buildbot/work/sexpr-wasm-prototype/s2wasm_known_gcc_test_failures.txt --out /s/wasm/experimental/buildbot/work/sexpr-wasm-out/
Seems like other folks must have this issue, but a quick search doesn't turn up anything.
test
(module
(import $print_i32 "stdio" "print" (param i32))
(memory 2000000 (segment 8 "0") (segment 16 "world"))
(export "test" 0)
(func (result i32)
(call $print_i32 (i32.const 66))
(i32.add (i32.const 0xFFF6789b) (i32.const 2))))
result
test.wasm:6:11: undefined function variable "$print_i32
The following code fails to encode with sexp-wasm with: t60.wast:7:37: label variable out of range (max 1)
If an explicit label is added to the tableswitch
it succeeds. I've seen other cases where this changes the depths. Does v8 always have an implicit block for a tableswitch
? If so then adding an explicit label should make no difference, and if not then how is the difference encoded?
The v8 encoding seems to accept just one expression per case, so emits a block if there are more than one statement. I assume there is some logic to offset the br
depths and might it only be in this case that the depths would be modified?
(module
(func $f1 (param $i i32) (result i32)
(block $l1
(i32.add (tableswitch (get_local $i)
(table (case $0)) (case $default)
(case $0 (br 0 (i32.const 1)))
(case $default (br 1 (i32.const 2))))
(i32.const 3))))
(export "f1" $f1))
(invoke "f1" (i32.const 0))
(invoke "f1" (i32.const 1))
4 : i32
2 : i32
All of the internal tests are written using the old style, but should be converted to the new style, e.g.:
old style:
(func (result i32)
(local i32)
(block i32
(i32.add (i32.const 1) (get_local 0))))
new style:
(func (result i32)
(local i32)
block i32
i32.const 1
get_local 0
i32.add
end)
Failed to parse this file
./test.wasm:90:19: unexpected token "i32.div"
If I change them all of the i32.div to i32.add it works fine
It looks like this prototype is still using the old if
. For example this
(if
(i32.const 1)
(br 0)
)
gets turned into
(if
(i32.const 1)
(block (br 0))
)
I have a flavor of bison installed, so the new build procedure tries to use it.
Trouble is, it's an older version and cannot consume wasm-bison-parser.y:
sexpr-wasm-prototype/src/wasm-bison-parser.y:101.20-33: error: syntax error, unexpected {...}
make[2]: *** [wasm-bison-parser.c] Error 1
Is there a way to force use of the prebuilt files?
For example, can cmake check the bison version?
The following code emits a single unreachable
operator which does not appear correct. When $i1 is zero this function would return 1.
(module
(func (param $i1 i32) (result i32)
(if_else (get_local $i1)
(block (unreachable))
(i32.const 1))))
0000004: 02 ; WASM_SECTION_FUNCTIONS
0000005: 01 ; num functions
; function 0
0000006: 00 ; func flags
0000007: 0000 ; func signature index
0000009: 0000 ; func body size
000000b: 01 ; OPCODE_BLOCK
000000c: 01 ; num expressions
000000d: 15 ; OPCODE_UNREACHABLE
0000009: 0300 ; FIXUP func body size
000000e: 06 ; WASM_SECTION_END
Some discussion at WebAssembly/design#527
It would be nice if this error message also printed out the import's name:
foo.wast:72385:11: too many parameters to function in call_import. got 4, expected 3
foo.wast:72398:9: too few parameters to function in call_import. got 1, expected 2
Right now I hack around it with grep / cut / xargs / head / tail and it's ugly :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.