Skip to content
Merged
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
24 changes: 12 additions & 12 deletions test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ var MEMFS = {
mount(mount) {
return MEMFS.createNode(null, "/", 16895, 0);
},
createNode(parent, name, mode, dev) {
Comment thread
sbc100 marked this conversation as resolved.
Resolved
createNode(parent, name, mode, dev = undefined) {
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
// not supported
throw new FS.ErrnoError(63);
Expand Down Expand Up @@ -1112,7 +1112,7 @@ var MEMFS = {
}
throw MEMFS.doesNotExistError;
},
mknod(parent, name, mode, dev) {
mknod(parent, name, mode, dev = undefined) {
return MEMFS.createNode(parent, name, mode, dev);
},
rename(old_node, new_dir, new_name) {
Expand Down Expand Up @@ -1618,7 +1618,7 @@ var FS = {
// if we failed to find it in the cache, call into the VFS
return FS.lookup(parent, name);
},
createNode(parent, name, mode, rdev) {
createNode(parent, name, mode, rdev = undefined) {
var node = new FS.FSNode(parent, name, mode, rdev);
FS.hashAddNode(node);
return node;
Expand Down Expand Up @@ -2003,7 +2003,7 @@ var FS = {
}
}
},
mkdev(path, mode, dev) {
mkdev(path, mode, dev = undefined) {
if (typeof dev === "undefined") {
dev = mode;
mode = 438;
Expand Down Expand Up @@ -2457,7 +2457,7 @@ var FS = {
stream.ungotten = [];
return stream.position;
},
read(stream, buffer, offset, length, position) {
read(stream, buffer, offset, length, position = undefined) {
if (length < 0 || position < 0) {
throw new FS.ErrnoError(28);
}
Expand All @@ -2483,7 +2483,7 @@ var FS = {
if (!seeking) stream.position += bytesRead;
return bytesRead;
},
write(stream, buffer, offset, length, position, canOwn) {
write(stream, buffer, offset, length, position = undefined, canOwn = undefined) {
if (length < 0 || position < 0) {
throw new FS.ErrnoError(28);
}
Expand Down Expand Up @@ -2702,7 +2702,7 @@ var FS = {
"MEMFS": MEMFS
};
},
init(input, output, error) {
init(input = undefined, output = undefined, error = undefined) {
FS.initialized = true;
// Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here
FS.createStandardStreams(input, output, error);
Expand All @@ -2717,7 +2717,7 @@ var FS = {
}
}
},
createPath(parent, path, canRead, canWrite) {
createPath(parent, path, canRead = undefined, canWrite = undefined) {
parent = typeof parent === "string" ? parent : FS.getPath(parent);
var parts = path.split("/").reverse();
while (parts.length) {
Expand All @@ -2733,12 +2733,12 @@ var FS = {
}
return current;
},
createFile(parent, name, properties, canRead, canWrite) {
createFile(parent, name, properties, canRead = undefined, canWrite = undefined) {
var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
var mode = FS_getMode(canRead, canWrite);
return FS.create(path, mode);
},
createDataFile(parent, name, data, canRead, canWrite, canOwn) {
createDataFile(parent, name, data = undefined, canRead = undefined, canWrite = undefined, canOwn = undefined) {
var path = name;
if (parent) {
parent = typeof parent === "string" ? parent : FS.getPath(parent);
Expand All @@ -2756,7 +2756,7 @@ var FS = {
FS.chmod(node, mode);
}
},
createDevice(parent, name, input, output) {
createDevice(parent, name, input = undefined, output = undefined) {
var path = PATH.join2(typeof parent === "string" ? parent : FS.getPath(parent), name);
var mode = FS_getMode(!!input, !!output);
FS.createDevice.major ??= 64;
Expand Down Expand Up @@ -2823,7 +2823,7 @@ var FS = {
}
}
},
createLazyFile(parent, name, url, canRead, canWrite) {
createLazyFile(parent, name, url, canRead = undefined, canWrite = undefined) {
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
// Actual getting is abstracted away for eventual reuse.
class LazyUint8Array {
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_esm_integration.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"a.out.mjs": 671,
"a.out.mjs.gz": 401,
"a.out.support.mjs": 6094,
"a.out.support.mjs.gz": 2390,
"a.out.support.mjs": 6068,
"a.out.support.mjs.gz": 2379,
"a.out.nodebug.wasm": 1220,
"a.out.nodebug.wasm.gz": 757,
"total": 7985,
"total_gz": 3548,
"total": 7959,
"total_gz": 3537,
"sent": [
"a (fd_write)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_minimal_esm_integration.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"a.out.mjs": 683,
"a.out.mjs.gz": 410,
"a.out.support.mjs": 2965,
"a.out.support.mjs.gz": 1234,
"a.out.support.mjs": 2949,
"a.out.support.mjs.gz": 1227,
"a.out.nodebug.wasm": 75,
"a.out.nodebug.wasm.gz": 87,
"total": 3723,
"total_gz": 1731,
"total": 3707,
"total_gz": 1724,
"sent": [],
"imports": [],
"exports": [
Expand Down
20 changes: 10 additions & 10 deletions test/codesize/test_no_closure_code_size.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"hello_world.js": 8058,
"hello_world.js.gz": 2932,
"hello_world.js": 8021,
"hello_world.js.gz": 2926,
"hello_world.wasm": 1188,
"hello_world.wasm.gz": 733,
"web.js": 6153,
"web.js.gz": 2277,
"web.js": 6128,
"web.js.gz": 2269,
"web.wasm": 1188,
"web.wasm.gz": 733,
"strict.js": 6181,
"strict.js.gz": 2341,
"strict.js": 6152,
"strict.js.gz": 2335,
"strict.wasm": 1188,
"strict.wasm.gz": 733,
"files.js": 54672,
"files.js.gz": 15388,
"files.js": 54296,
"files.js.gz": 15296,
"files.wasm": 371,
"files.wasm.gz": 264,
"total": 78999,
"total_gz": 25401
"total": 78532,
"total_gz": 25289
}
21 changes: 0 additions & 21 deletions test/js_optimizer/stripDefaultUndefined-output.js

This file was deleted.

20 changes: 0 additions & 20 deletions test/js_optimizer/stripDefaultUndefined.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_codesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def run_codesize_test(self, filename, cflags, check_funcs=True, check_full_js=Fa
outfile = 'a.out.mjs' if esm else 'a.out.js'
js_file = 'a.out.support.mjs' if esm else outfile

# Run once without closure and parse output to find the JS->wasm imports.
# Run once without closure or terser minification and parse output to find the JS->wasm imports.
build_cmd = [compiler_for(filename), filename, '-o', outfile, '--output-eol=linux', '--emit-minification-map=minify.map'] + cflags + self.get_cflags()
self.run_process(build_cmd + ['-g2'])
# find the imports we send from JS
Expand Down
1 change: 0 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,6 @@ def test_extern_prepost(self):
'JSDCE-fors': (['JSDCE'],),
'JSDCE-objectPattern': (['JSDCE'],),
'AJSDCE': (['AJSDCE'],),
'stripDefaultUndefined': (['stripDefaultUndefined'],),
Comment thread
sbc100 marked this conversation as resolved.
Resolved
'emitDCEGraph': (['emitDCEGraph', '--no-print'],),
'emitDCEGraph-closure': (['emitDCEGraph', '--no-print', '--closure-friendly'], 'emitDCEGraph.js'),
'emitDCEGraph-dynCall': (['emitDCEGraph', '--no-print'],),
Expand Down
30 changes: 9 additions & 21 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -410,25 +410,6 @@ function AJSDCE(ast) {
JSDCE(ast, /* aggressive= */ true);
}

// Strip `= undefined` default values from function parameters and destructuring
// patterns. These default values have no runtime semantic effect (since
// `undefined` is already the default), and are only needed by Closure Compiler
// for arity/type checking.
function stripDefaultUndefined(ast) {
fullWalk(ast, (node) => {
if (
node.type === 'AssignmentPattern' &&
node.right.type === 'Identifier' &&
node.right.name === 'undefined'
) {
const left = node.left;
delete node.left;
delete node.right;
Object.assign(node, left);
}
});
}

function isWasmImportsAssign(node) {
// var wasmImports = ..
// or
Expand Down Expand Up @@ -1822,6 +1803,7 @@ const {
verbose,
'no-print': noPrint,
'minify-whitespace': minifyWhitespace,
compress,
outfile,
},
positionals: [infile, ...passes],
Expand All @@ -1832,6 +1814,7 @@ const {
verbose: {type: 'boolean'},
'no-print': {type: 'boolean'},
'minify-whitespace': {type: 'boolean'},
compress: {type: 'boolean'},
outfile: {type: 'string', short: 'o'},
},
allowPositionals: true,
Expand Down Expand Up @@ -1877,7 +1860,6 @@ if (closureFriendly) {
const registry = {
JSDCE,
AJSDCE,
stripDefaultUndefined,
applyImportAndExportNameChanges,
emitDCEGraph,
applyDCEGraphRemovals,
Expand Down Expand Up @@ -1951,7 +1933,13 @@ if (!noPrint) {
} else {
output = minify_sync(ast, {
parse: {spidermonkey: true},
compress: false,
compress: compress
? {
defaults: false,
evaluate: true,
keep_fargs: false,
}
: false,
mangle: false,
format,
}).code;
Expand Down
4 changes: 1 addition & 3 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,12 +818,10 @@ def minify_wasm_js(js_file, wasm_file, expensive_optimizations, debug_info):
else:
passes.append('JSDCE')

if not settings.USE_CLOSURE_COMPILER:
passes.append('stripDefaultUndefined')

# Don't minify if we are going to run closure compiler afterwards
if settings.MINIFY_WHITESPACE and not settings.MAYBE_CLOSURE_COMPILER:
passes.append('--minify-whitespace')
passes.append('--compress')

if passes:
logger.debug('running cleanup on shell code: ' + ' '.join(passes))
Expand Down
Loading