Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/tools/tool-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct ToolOptions : public Options {

bool quiet = false;
bool preserveTypeOrder = false;
bool emitModuleNames = false;
IRProfile profile = IRProfile::Normal;

constexpr static const char* ToolOptionsCategory = "Tool options";
Expand Down Expand Up @@ -69,13 +70,19 @@ struct ToolOptions : public Options {
ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { quiet = true; })
.add(
"--experimental-poppy",
"",
"Parse wast files as Poppy IR for testing purposes.",
ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { profile = IRProfile::Poppy; });
.add("--experimental-poppy",
"",
"Parse wast files as Poppy IR for testing purposes.",
ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { profile = IRProfile::Poppy; })
.add("--emit-module-names",
"",
"Emit module names, even if not emitting the rest of the names "
"section.",
ToolOptionsCategory,
Arguments::Zero,
[this](Options*, const std::string&) { emitModuleNames = true; });
(*this)
.addFeature(FeatureSet::SignExt, "sign extension operations")
.addFeature(FeatureSet::Atomics, "atomic operations")
Expand Down
7 changes: 7 additions & 0 deletions src/tools/wasm-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ For more on how to optimize effectively, see
[&outputSourceMapUrl](Options* o, const std::string& argument) {
outputSourceMapUrl = argument;
})

.add_positional("INFILE",
Options::Arguments::One,
[](Options* o, const std::string& argument) {
Expand Down Expand Up @@ -407,6 +408,9 @@ For more on how to optimize effectively, see
ModuleWriter writer(options.passOptions);
writer.setBinary(emitBinary);
writer.setDebugInfo(options.passOptions.debugInfo);
if (options.emitModuleNames) {
writer.setEmitModuleName(true);
}
writer.write(wasm, options.extra["output"]);
firstOutput = runCommand(extraFuzzCommand);
std::cout << "[extra-fuzz-command first output:]\n" << firstOutput << '\n';
Expand Down Expand Up @@ -496,6 +500,9 @@ For more on how to optimize effectively, see
ModuleWriter writer(options.passOptions);
writer.setBinary(emitBinary);
writer.setDebugInfo(options.passOptions.debugInfo);
if (options.emitModuleNames) {
writer.setEmitModuleName(true);
}
if (outputSourceMapFilename.size()) {
writer.setSourceMapFilename(outputSourceMapFilename);
writer.setSourceMapUrl(outputSourceMapUrl);
Expand Down
12 changes: 1 addition & 11 deletions src/tools/wasm-split/split-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,7 @@ WasmSplitOptions::WasmSplitOptions()
[&](Options* o, const std::string& argument) {
secondaryMemoryName = argument;
})
.add(
"--emit-module-names",
"",
"Emit module names, even if not emitting the rest of the names section. "
"Can help differentiate the modules in stack traces. This option will be "
"removed once simpler ways of naming modules are widely available. See "
"https://bugs.chromium.org/p/v8/issues/detail?id=11808.",
WasmSplitOption,
{Mode::Split, Mode::MultiSplit, Mode::Instrument},
Options::Arguments::Zero,
[&](Options* o, const std::string& arguments) { emitModuleNames = true; })

.add("--initial-table",
"",
"A hack to ensure the split and instrumented modules have the same "
Expand Down
3 changes: 0 additions & 3 deletions src/tools/wasm-split/split-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ struct WasmSplitOptions : ToolOptions {
bool placeholderMap = false;
bool stripDebug = false;

// TODO: Remove this. See the comment in wasm-binary.h.
bool emitModuleNames = false;

std::string profileFile;
std::string profileExport = DEFAULT_PROFILE_EXPORT;

Expand Down
15 changes: 15 additions & 0 deletions test/lit/emit-module-names.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
;; Check that --emit-module-names without -g strips function names but generates
;; and keeps the module name.

;; RUN: wasm-opt %s --emit-module-names -o %t.wasm
;; RUN: wasm-dis %t.wasm -o - | filecheck %s

;; CHECK: (module $module-name
;; CHECK: (func $0
;; CHECK-NOT: $foo

(module $module-name
(func $foo
(nop)
)
)
3 changes: 3 additions & 0 deletions test/lit/help/wasm-as.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
3 changes: 3 additions & 0 deletions test/lit/help/wasm-ctor-eval.test
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
3 changes: 3 additions & 0 deletions test/lit/help/wasm-dis.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
3 changes: 3 additions & 0 deletions test/lit/help/wasm-emscripten-finalize.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
3 changes: 3 additions & 0 deletions test/lit/help/wasm-merge.test
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
4 changes: 4 additions & 0 deletions test/lit/help/wasm-metadce.test
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,10 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for
;; CHECK-NEXT: testing purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not
;; CHECK-NEXT: emitting the rest of the names
;; CHECK-NEXT: section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension
Expand Down
4 changes: 4 additions & 0 deletions test/lit/help/wasm-opt.test
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,10 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for
;; CHECK-NEXT: testing purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not
;; CHECK-NEXT: emitting the rest of the names
;; CHECK-NEXT: section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension
Expand Down
3 changes: 3 additions & 0 deletions test/lit/help/wasm-reduce.test
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
12 changes: 3 additions & 9 deletions test/lit/help/wasm-split.test
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,6 @@
;; CHECK-NEXT: memory created to store profile
;; CHECK-NEXT: information.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names [split, multi-split, instrument] Emit
;; CHECK-NEXT: module names, even if not emitting the
;; CHECK-NEXT: rest of the names section. Can help
;; CHECK-NEXT: differentiate the modules in stack
;; CHECK-NEXT: traces. This option will be removed once
;; CHECK-NEXT: simpler ways of naming modules are widely
;; CHECK-NEXT: available. See
;; CHECK-NEXT: https://bugs.chromium.org/p/v8/issues/detail?id=11808.
;; CHECK-NEXT:
;; CHECK-NEXT: --initial-table [split, instrument] A hack to ensure the
;; CHECK-NEXT: split and instrumented modules have the
;; CHECK-NEXT: same table size when using Emscripten's
Expand Down Expand Up @@ -182,6 +173,9 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for testing
;; CHECK-NEXT: purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not emitting
;; CHECK-NEXT: the rest of the names section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension operations
Expand Down
4 changes: 4 additions & 0 deletions test/lit/help/wasm2js.test
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@
;; CHECK-NEXT: --experimental-poppy Parse wast files as Poppy IR for
;; CHECK-NEXT: testing purposes.
;; CHECK-NEXT:
;; CHECK-NEXT: --emit-module-names Emit module names, even if not
;; CHECK-NEXT: emitting the rest of the names
;; CHECK-NEXT: section
;; CHECK-NEXT:
;; CHECK-NEXT: --enable-sign-ext Enable sign extension operations
;; CHECK-NEXT:
;; CHECK-NEXT: --disable-sign-ext Disable sign extension
Expand Down
Loading