Skip to content
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

Add webassembly language #6429

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

afonso360
Copy link

👋 Hey,

This PR adds support for the Webassembly Text Language (#1871). Currently it only supports the wasmtime compiler, but it should be possible to add others (i.e. v8 / wasmer / etc...).

It looks like the monaco does not support the WAT language, so I've added a simple mode for it, that is mostly copied from the clojure mode with some changes. From what I've tested it seems to work reasonably well.

image

lib/languages.ts Show resolved Hide resolved
Comment on lines +2 to +3
objdumper=llvm-objdump
objdumperType=llvm
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used llvm-objdump here because wasmtime supports a --target=<triple> parameter that cross-compiles WASM modules for other architectures. The problem is that when using objdump it then can't disassemble the resulting file. I'm not sure if there is a better solution to handle these cases

Copy link
Member

@RubenRBS RubenRBS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks a lot for taking the time to add support for this, we really appreciate it :)

I have a few minor comments on the config files, but other than that, this looks great!

etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
etc/config/wasm.defaults.properties Outdated Show resolved Hide resolved
lib/languages.ts Show resolved Hide resolved
static/modes/wat-mode.ts Fixed Show resolved Hide resolved
static/modes/wat-mode.ts Fixed Show resolved Hide resolved
The previous regex had a exponential backtracking issue under some inputs.
@syrusakbary
Copy link

I'd love to have Wasmer supported as well! Let me know if we can help with that :)

@afonso360
Copy link
Author

afonso360 commented May 14, 2024

Awesome! I already have a WIP patch locally adding wasmer! I was waiting to get this merged in before proposing that.


escapes: /^\\(?:["'\\bfnrt]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,

qualifiedSymbols: /^(?:[^\\/[\]\d\s"#'(),;@^`{}~][^\\[\]\s"(),;@^`{}~]*)*(?=[\\[\]\s"(),;@^`{}~]|$)/,

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with '!' and containing many repetitions of '!'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants