This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Symbol changes #1, LLVM
ClosedPublic

Authored by ncw on Jan 15 2018, 8:50 AM.

Details

Summary

First chunk split out of D41954.

Must be committed simultaneously with LLD change, D42076.

Changes:

  • Get rid of DEBUG_FUNCTION_NAME symbols. When we actually debug data, maybe we'll want somewhere to put it... but having a symbol that just stores the name of another symbol seems odd. It means you have multiple Symbols with the same name, one containing the actual function and another containing the name!
  • Store the names in a vector on the WasmObjectFile when reading them in. Also stash them on the WasmFunctions themselves. The names are not "symbol names" or aliases or anything, they're just the name that a debugger should show against the function body itself. NB. The WasmObjectFile stores them so that they can be exported in the YAML losslessly, and hence the tests can be precise.
  • Enforce that the CODE section has been read in before reading the "names" section. Requires minor adjustment to some tests.

Diff Detail

Repository
rL LLVM

Event Timeline

ncw created this revision.Jan 15 2018, 8:50 AM
ncw edited the summary of this revision. (Show Details)

I think dropping the debug names from the symbol table seems like a good idea.
I'm not so sure about dropping the the imports from the name section. It seems at least like a separate change.
I like added requirement on the section ordering, although I'd prefer a more explicit way to check for it.

What do you think about dropping the name section completely from the compiler output? If the compiler output is meant mainly as a linker input perhaps we don't need a names section at all (since its arguably redundant in the face of the symbol table stuff).

lib/Object/WasmObjectFile.cpp
273 ↗(On Diff #129866)

Seems like an odd way to verify this, but I can't think of a better one of the top of my head.

My proposal to drop the writing of the name section completely: https://github.com/WebAssembly/tool-conventions/issues/37. We should probably wait for @sunfish from implementing it.

ncw added a comment.Jan 17 2018, 4:29 AM

I think dropping the debug names from the symbol table seems like a good idea.
I'm not so sure about dropping the the imports from the name section. It seems at least like a separate change.
I like added requirement on the section ordering, although I'd prefer a more explicit way to check for it.

What do you think about dropping the name section completely from the compiler output? If the compiler output is meant mainly as a linker input perhaps we don't need a names section at all (since its arguably redundant in the face of the symbol table stuff).

I agree with dropping the names section completely in WasmObjectWriter. That seems to me like a separate change - could I do that as another patch, after this?

You're right I shouldn't have sneaked in the change to drop names for imports. It's there from a previous version to the patch, but actually now imports could stay. In favour of dropping their names: a) it's useless file bloat; b) neither the Chrome devtools disassembler nor binaryen/wasm-dis make use of the names for imports, although I suppose they could in future. For the time being though I've reverted it.

ncw updated this revision to Diff 130126.Jan 17 2018, 4:31 AM
ncw edited the summary of this revision. (Show Details)

Updated:

  • Reverted change to remove imports from NAME section. They are now written out as before.
sbc100 accepted this revision.Jan 17 2018, 9:59 AM

LGTM, I'll try to land this one now.

This revision is now accepted and ready to land.Jan 17 2018, 9:59 AM
ncw added a comment.Jan 17 2018, 10:08 AM

Thanks for the reviews! I created a fair amount of work for you with these.

(It's dinner-time now, but I'll try and check my work emails later tonight in case there's anything I can help with, to save a 24hr turnaround.)

This revision was automatically updated to reflect the committed changes.
This comment was removed by sbc100.