diff options
| author | Nick Fitzgerald <fitzgen@gmail.com> | 2019-02-07 17:05:23 +0100 |
|---|---|---|
| committer | Nick Fitzgerald <fitzgen@gmail.com> | 2019-02-08 10:07:08 +0100 |
| commit | 05df9ff41537bab6586eea7ad9272eeb611e09e1 (patch) | |
| tree | c4336d115557ab7cbc3490eb3f569d92a7b0d631 /src/test/run-make/wasm-stringify-ints-small | |
| parent | c104b5c89767101a40ef173eb84d3aa1122e5e9a (diff) | |
Add a wasm code size test for stringifying numbers
Diffstat (limited to 'src/test/run-make/wasm-stringify-ints-small')
| -rw-r--r-- | src/test/run-make/wasm-stringify-ints-small/Makefile | 10 | ||||
| -rwxr-xr-x | src/test/run-make/wasm-stringify-ints-small/foo.rs | 39 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/test/run-make/wasm-stringify-ints-small/Makefile b/src/test/run-make/wasm-stringify-ints-small/Makefile new file mode 100644 index 00000000000..18e47242f80 --- /dev/null +++ b/src/test/run-make/wasm-stringify-ints-small/Makefile @@ -0,0 +1,10 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown + wc -c < $(TMPDIR)/foo.wasm + [ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "21000" ] +else +all: +endif diff --git a/src/test/run-make/wasm-stringify-ints-small/foo.rs b/src/test/run-make/wasm-stringify-ints-small/foo.rs new file mode 100755 index 00000000000..6aa249aabeb --- /dev/null +++ b/src/test/run-make/wasm-stringify-ints-small/foo.rs @@ -0,0 +1,39 @@ +#![crate_type = "cdylib"] + +extern "C" { + fn observe(ptr: *const u8, len: usize); + + fn get_u8() -> u8; + fn get_i8() -> i8; + fn get_u16() -> u16; + fn get_i16() -> i16; + fn get_u32() -> u32; + fn get_i32() -> i32; + fn get_u64() -> u64; + fn get_i64() -> i64; + fn get_usize() -> usize; + fn get_isize() -> isize; +} + +macro_rules! stringify { + ( $($f:ident)* ) => { + $( + let s = $f().to_string(); + observe(s.as_ptr(), s.len()); + )* + }; +} + +#[no_mangle] +pub unsafe extern "C" fn foo() { + stringify!(get_u8); + stringify!(get_i8); + stringify!(get_u16); + stringify!(get_i16); + stringify!(get_u32); + stringify!(get_i32); + stringify!(get_u64); + stringify!(get_i64); + stringify!(get_usize); + stringify!(get_isize); +} |
