[wasm][bcl] Use zlib for DeflateStream on WASM profile (#14308)
commit0562fde077f11bfd81ae0c2ce5c467ae2928c259
authorKenneth Pouncey <kjpou@pt.lu>
Thu, 6 Jun 2019 03:07:56 +0000 (6 05:07 +0200)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2019 03:07:56 +0000 (6 05:07 +0200)
tree2eed0db04329db0b56d4963287c83437019a4da1
parent2b3a23c511657e7f764571caf6804c33e01b5a19
[wasm][bcl] Use zlib for DeflateStream on WASM profile (#14308)

* [wasm][bcl] Use zlib for DeflateStream on WASM profile

- Add `-s USE-ZLIB=1` flag for the emscripten build of `mono.js`
- Add new `zlib-helper` module build that is included in the `mono` wasm build.
- This adds roughly 300 kb to the size.

* Add zlib calls to `icall` for `WASM` profile

* Address comments use `TARGET_WASM` instead of `HOST_WASM`

* Hack around JS exception: RuntimeError: indirect call signature mismatch

- Instead of using the function pointer from DeflateStream (Marshal.GetFunctionPointerForDelegate) obtain the callback functions from the object itself.

* Update error messages and add exception parameter to `mono_runtime_invoke`.

* Add `mono/support` zlib include sources files to make `package` target.

* Add `zlib-helper` build to packager.

- Note: Right now only supports zlib build from mono tree build.
- Add `zlibtest.cs` scenario to compress and uncompress using DeflateStream and GZip.
- Add test to make file to build and run aot version of ziplibtest.

* Add copy of zlib header support files to `package-wasm-runtime`

- The support library is not built for wasm but the zlib include files are needed to build support during wasm build.
- See mono.js build and the use of the `-s USE_ZLIB=1` flag.
- The include files will be used in packager.exe to build zlib support for wasm.

* Use the zlib includes from support to build the zlib support.

* Setup base tests for testing System.IO.Compression integration

* Formatting

* Add more ziparchive tests

* Formatting and indentation

* Add more Zip tests

* Add more tests.

- Add more tests for ZipArchive.
- Add tests for Deflate - small, large and very large strings.
- Add tests for GZipStream - small, large and very large strings.

* Fix merge of EMCC_FLAGS

* Add new option to packager to enable the use of zlib

-   --enable-zlib (enable the use of zlib for System.IO.Compression support)
        type: bool  default: false

- update packager doc

* Address review comments

- Change `enable-zlib` to `zlib`
17 files changed:
mcs/class/System/System.IO.Compression/DeflateStream.cs
mono/metadata/icall-decl.h
mono/metadata/icall-def.h
mono/metadata/icall.c
sdks/builds/wasm.mk
sdks/wasm/Makefile
sdks/wasm/docs/packager.md
sdks/wasm/packager.cs
sdks/wasm/tests/browser/HttpTestSuite.cs
sdks/wasm/tests/browser/ZipTestSuite.cs [new file with mode: 0644]
sdks/wasm/tests/browser/karma.conf.js
sdks/wasm/tests/browser/resources/archive.zip [new file with mode: 0644]
sdks/wasm/tests/browser/resources/test.nupkg [new file with mode: 0644]
sdks/wasm/tests/browser/zip-spec.html [new file with mode: 0644]
sdks/wasm/tests/browser/zip-spec.js [new file with mode: 0644]
sdks/wasm/zlib-helper.c [new file with mode: 0644]
sdks/wasm/zlibtest.cs [new file with mode: 0644]