New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS version #65
Comments
That would be super cool! I have not tried compiling to asm.js or wasm. Perhaps you can give it a go and report back? |
I'll give it a try. |
It works! It's about twice as large as the other one (516 KB vs 277 KB), and it fails a few tests from https://github.com/kripken/cxx_demangle/blob/master/test/test.js :
The timings in that test also report a slight regression (~250ms instead of ~230ms for 1000 invocations), but there was a lot of variance, and part of the regression might be caused by the extra string copy that my extern C wrapper function does in order to get a null-terminated C string. I'm going to clean up my experiment and push it to github. |
Is there anything I can add to the Travis CI builds to make sure that asm.js/wasm compilation doesn't accidentally break in the future?
I'll look into these once I get all the libiberty tests passing (which I suspect might fix these failures as well).
FWIW, I haven't looked at performance at all yet.
FWIW, For the owned and borowed versions, it doesn't need a null terminator. |
I wonder what the code size profiling tools are like for asm.js/wasm (let alone Rust integration) ... Any idea? |
Not sure about CI. Installing the emscripten SDK every time the test runs might be a bit much, I think it even compiled parts of llvm for me... If you want to test the JS compiled result, you'll also need to run all the stuff from the cxx_demangle repo and its tests. Passing the string to cpp_demangle doesn't copy, I think; it's when I return the result that I need to do the copy. I call I don't know anything about emscripten code size profiling tools. |
The extra copy is definitely avoidable. We don't have to return a const char* there, we could also just fill a user-provided buffer and return a length. That would probably be better. It would also make the job easier for the emscripten-supplied function that converts a C string into a JS string. That goes through UTF8ArrayToString which searches for the null byte again in order to know the length of the string, and then (for strings longer than 25 bytes) calls u8Array.subarray which also makes a copy. |
That was wrong; u8Array.subarray doesn't make a copy. (But it allocates a JS object, i.e. garbage, which UTF8ArrayToString wants to avoid.) |
I got it down to 455 KB by following the instructions at https://kripken.github.io/emscripten-site/docs/optimizing/Optimizing-Code.html#code-size and I also eliminated the copy. |
Nice! Did that improve performance? |
Not noticeably so. I haven't run the perf tests for a high enough number of iterations to have enough certainty. |
Closing - this doesn't seem to be necessary. wasm-pack and wasm_bindgen make it easy enough for anybody to write their own wasm / JS wrapper. |
Have you tried compiling this to asm.js / wasm?
I wonder if the result would be smaller than http://searchfox.org/mozilla-central/source/devtools/client/shared/demangle.js which is 277 KB. If so, I'd like to use it for firefox-devtools/profiler#167.
The text was updated successfully, but these errors were encountered: