Emscripten generates code that allows the caller to provide the Wasm module (thorugh Module.instantiateWasm), with a fallback in case .instantiateWasm is not provided. We always define instantiateWasm, so we can hard-code the check and let our dead code elimination logic remove the unused fallback. This commit also improved the dead code elimination logic so that if a function declaration becomes unused as a result of removing dead code, the function itself is removed.
42 lines
486 B
JavaScript
42 lines
486 B
JavaScript
function f1() {
|
|
return;
|
|
var i = 0;
|
|
}
|
|
f1();
|
|
|
|
function f2() {
|
|
return 1;
|
|
var i = 0;
|
|
}
|
|
f2();
|
|
|
|
function f3() {
|
|
var i = 0;
|
|
throw "test";
|
|
var j = 0;
|
|
}
|
|
f3();
|
|
|
|
function f4() {
|
|
var i = 0;
|
|
if (true) {
|
|
return;
|
|
}
|
|
throw "test";
|
|
var j = 0;
|
|
}
|
|
f4();
|
|
|
|
var obj = {
|
|
method1() { return; var i = 0; },
|
|
method2() { return; },
|
|
};
|
|
|
|
class C {
|
|
method1() { return; var i = 0; }
|
|
method2() { return; }
|
|
}
|
|
|
|
var arrow1 = () => { return; var i = 0; };
|
|
var arrow2 = () => { return; };
|