-
Notifications
You must be signed in to change notification settings - Fork 479
Description
Most of the languages have some way of expressing code metadata on the source level. It's probably not an issue for binary format since it's easy to add unknown sections [1] that will refer encoded op-codes/data by offsets in the e.g. function sections. However the wast/s-expression is missing this capability, and currently this format is heavily used for prototyping. While it's possible to provide this information as comment e.g. with '!' added (;!DILocation (line 2) (column 9) (scope (!4)));)
, it will be nice to define it as a syntax and probably skip/ignore that for MVP (as we do it for the comments). What we are trying to reach here is some verifiable structure for the nested metadata tags.
The main use case is to include source-level debug information into intermediate WebAssembly language. At the end we would like to see something like LLVM has (see [2] and [3]). Perhaps something like:
...
(!dgb $1)
(func (!dbg $2) (param i64) (result i64)
(!dbg $3) (if_else (i64.eq (get_local 0) (i64.const 0))
(!dbg $4) (i64.const 1)
(!dbg $5) (i64.mul (get_local 0) (call 0 (i64.sub (get_local 0) (i64.const 1))))
)
)
(!set $0 (!DIFile (filename "src/factorial.cpp")))
(!set $1 (!DISubprogram (name "fac_rec") (file $0)))
(!set $2 (!DILocalVariable (name "n") (scope $1)))
(!set $3 (!DILocation (line 2) (column 9) (scope $1)))
...
The main idea will be to associate some metadata with s-expression list nodes, but still be something we can validate and serialize to/deserialize from binary format.
(Related issues found [4])
[1] https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#unknown-sections
[2] http://llvm.org/docs/LangRef.html#metadata
[3] http://llvm.org/docs/SourceLevelDebugging.html#object-lifetimes-and-scoping
[4] WebAssembly/design#208