This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Rename function types to signatures
AbandonedPublic

Authored by aheejin on Nov 19 2018, 12:51 AM.

Details

Reviewers
dschuff
sbc100
Summary

Currently both of function signatures (WasmSignature objects) and
signature indices (unsigned ints) are often represented with variable
'FunctionTypes', which is confusing. I renamed some of them in D54096,
and this continues to rename other uses to signatures and signature
indices.

Should land with D54690.

Diff Detail

Event Timeline

aheejin created this revision.Nov 19 2018, 12:51 AM
aheejin retitled this revision from [WebAssembly] Rename function types to signatures (NFC) to [WebAssembly] Rename function types to signatures.Nov 19 2018, 12:53 AM
aheejin edited the summary of this revision. (Show Details)
sbc100 accepted this revision.Nov 19 2018, 12:38 PM

lgtm %nits

include/llvm/Object/Wasm.h
133–134

Its a little tricky because these corresponds exactly to the wasm "Types" section, which is how this terminology crept in. I suppose its ok for llvm to deviate from the wasm spec here.

134

Maybe just functionSignatures?

lib/MC/WasmObjectWriter.cpp
328

Looks like the return of these two is never uses, perhaps they should just return void.. not part of this CL though.

test/ObjectYAML/wasm/event_section.yaml
18

I think I prefer just "Signatures" or "FunctionSignatures"

tools/obj2yaml/wasm2yaml.cpp
165

Just "Signature" here since this could be an exception sig now right?

tools/yaml2obj/yaml2wasm.cpp
277

Hmm.. another place where diverging from the spec makes this is little less readable I think.

This revision is now accepted and ready to land.Nov 19 2018, 12:38 PM
dschuff added inline comments.Nov 19 2018, 4:25 PM
lib/MC/WasmObjectWriter.cpp
234–235

One thing I started trying to do was remove WasmObjectWriter's version of WasmSignature (it now has a name that reflects what it is, which is good; but it's basically a duplicate of the one in BinaryFormat, which is bad). It's kind of annoying to find a good place to put it though, which is why I didn't finish.

aheejin updated this revision to Diff 174708.Nov 19 2018, 4:37 PM
aheejin marked 2 inline comments as done.
  • Address comments

So the main reason I started this is, we have signatures (WasmSignature objects), signature indices (uint32_t), and other custom types for other sections (GlobalType and EventType). And all these three are represented by variable names like 'Types' / '***Types`, and I wanted to use different variable and functions names for each of these to be more readable. But as you said, it's subtle because we can't change the name of 'Type Section', so ¯\_(ツ)_/¯

include/llvm/Object/Wasm.h
133–134

We also renamed it as Signatures here, which motivated me to rename these for the sake of consistency. We can change both (and possibly other places) back to types though.

134

Then we end up calling both WasmSignature objects and indices (uint32_t) as 'Signatures'. One of the main purpose of this patch is to distinguish them. If you think that makes things more confusing, I think I can drop this patch.

lib/MC/WasmObjectWriter.cpp
328

Done in D54734.

dschuff added inline comments.Nov 19 2018, 5:23 PM
include/llvm/Object/Wasm.h
134

In most parts of the compiler I think we want to be quite explicit about what kind of kind of type we are talking about because there are so many (e.g. MVT, wasm::ValueType, WasmSignature etc). Keeping those straight globally might be worth more than lining up exactly with the spec in the object file format. OTOH if this code is pretty well separated from e.g. MI (yes), and MC (maybe?) and every construct in here unambiguously lines up with something from the wasm object file format and not one of those other sets of abstractions, then we don't have to worry as much about that.

aheejin added inline comments.Nov 20 2018, 5:23 PM
include/llvm/Object/Wasm.h
134

I wanted to use the same terms with at least with MC, because they are the reader and writer for the same object file format. But anyway, if this direction does not look better, I can change the MC part to match this part to use 'type's.

I general I think this is good change. I think there will always be point in the abstraction where we start prefering "spec" terms over "llvm" terms.

I certainly prefer the latest version WRT to the yaml output.

I'm ok with this change if @dschuff is

aheejin updated this revision to Diff 174859.Nov 20 2018, 6:13 PM
  • R_WEBASSEMBLY_TYPE_INDEX_LEB -> R_WEBASSEMBLY_SIGNATURE_INDEX_LEB
aheejin abandoned this revision.Nov 25 2018, 12:35 AM

In this comment, Rossberg said

Drive-by comment: the Wasm spec intentionally calls this type index, not signature index. The reason being that we expect additional forms of type definitions to appear in the type section in the future, see e.g. the GC proposal.

So I guess for the moment it's better to drop this CL to be cautious.