That means you have to study the old code, which is of course poorly documented and probably buggy; and then try to reproduce it in a sane way.
- https://github.com/ruby/ruby.wasm (compile Ruby to WASM)
- https://mame.github.io/emruby/ (example of Ruby compiled to WASM)
- https://opalrb.com/ (compile a subset of Ruby to JS)
This requires downloading several MB of code (and then caching it in-browser) so would be ideal for internal-only stuff.
(Part of my thinking with this solution is to broadcast "you are asking me to do something that requires a solution this complex to wrangle the problem space effectively" to try to fend off similar inanity in the future, admittedly, perhaps I'm being a bit optimistic/unrealistic heh.)
I guess perhaps you are working with some very obfuscated code, still if you are black box profiling code it might make sense to crack open that box as much as possible. Unless what you are working with is DRM-level "performs like cow dung in a blender" horrifically inefficient, I can't imagine it is obfuscated that badly.
At any rate, hopefully you are paid well for it, reverse engineering is difficult, to say the least.
I decompiled the app, documented the UI and which variable is what. Rewrote the whole app. It was quite painful but good learning experience. I would love to do another one.