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
8 changes: 2 additions & 6 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2362,12 +2362,8 @@ addToLibrary({
},

$HandleAllocator: class {
constructor() {
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
// Use inline field declarations.
this.allocated = [undefined];
this.freelist = [];
}
allocated = [undefined];
freelist = [];
get(id) {
#if ASSERTIONS
assert(this.allocated[id] !== undefined, `invalid handle: ${id}`);
Expand Down
40 changes: 15 additions & 25 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ FS.staticInit();
#else
ErrnoError: class {
#endif
name = 'ErrnoError';
// We set the `name` property to be able to identify `FS.ErrnoError`
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
// - when using PROXYFS, an error can come from an underlying FS
Expand All @@ -84,9 +85,6 @@ FS.staticInit();
#if ASSERTIONS
super(runtimeInitialized ? strError(errno) : '');
#endif
// TODO(sbc): Use the inline member declaration syntax once we
// support it in acorn and closure.
this.name = 'ErrnoError';
this.errno = errno;
#if ASSERTIONS
for (var key in ERRNO_CODES) {
Expand All @@ -100,16 +98,11 @@ FS.staticInit();
},

FSStream: class {
constructor() {
// TODO(https://github.com/emscripten-core/emscripten/issues/21414):
// Use inline field declarations.
this.shared = {};
shared = {};
#if USE_CLOSURE_COMPILER
// Closure compiler requires us to declare all properties in the
// constructor.
this.node = null;
// Closure compiler requires us to declare all properties ahead of time
node = null;
#endif
}
get object() {
return this.node;
}
Expand Down Expand Up @@ -139,21 +132,21 @@ FS.staticInit();
}
},
FSNode: class {
node_ops = {};
stream_ops = {};
readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
writeMode = {{{ cDefs.S_IWUGO }}};
mounted = null;
constructor(parent, name, mode, rdev) {
if (!parent) {
parent = this; // root node sets parent to itself
}
this.parent = parent;
this.mount = parent.mount;
this.mounted = null;
this.id = FS.nextInode++;
this.name = name;
this.mode = mode;
this.node_ops = {};
this.stream_ops = {};
this.rdev = rdev;
this.readMode = {{{ cDefs.S_IRUGO }}} | {{{ cDefs.S_IXUGO }}};
this.writeMode = {{{ cDefs.S_IWUGO }}};
}
get read() {
return (this.mode & this.readMode) === this.readMode;
Expand Down Expand Up @@ -1667,17 +1660,14 @@ FS.staticInit();
// Lazy chunked Uint8Array (implements get and length from Uint8Array).
// Actual getting is abstracted away for eventual reuse.
class LazyUint8Array {
constructor() {
this.lengthKnown = false;
this.chunks = []; // Loaded chunks. Index is the chunk number
lengthKnown = false;
chunks = []; // Loaded chunks. Index is the chunk number
#if USE_CLOSURE_COMPILER
// Closure compiler requires us to declare all properties in the
// constructor.
this.getter = undefined;
this._length = 0;
this._chunkSize = 0;
// Closure compiler requires us to declare all properties ahead of time.
getter = undefined;
_length = 0;
_chunkSize = 0;
#endif
}
get(idx) {
if (idx > this.length-1 || idx < 0) {
return undefined;
Expand Down
11 changes: 6 additions & 5 deletions src/library_wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

var WasiLibrary = {
#if !MINIMAL_RUNTIME
$ExitStatus__docs: '/** @constructor */',
$ExitStatus: function(status) {
this.name = 'ExitStatus';
this.message = `Program terminated with exit(${status})`;
this.status = status;
$ExitStatus: class {
name = 'ExitStatus';
constructor(status) {
this.message = `Program terminated with exit(${status})`;
this.status = status;
}
},
proc_exit__deps: ['$ExitStatus', '$keepRuntimeAlive'],
#endif
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8475
8472
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20806
20767
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8456
8453
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20774
20735
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9500
9499
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24650
24611
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8436
8431
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20699
20660
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8436
8431
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20699
20660
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8364
8365
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20385
20346
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9505
9502
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24651
24612
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8475
8472
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20806
20767
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3900
3903
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8633
8638
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7600
7601
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18701
18662
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2981
2993
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6270
6275
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8016
8032
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O0.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21307
21321
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2803
2816
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6918
6932
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2490
2503
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4977
4982
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2408
2419
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4823
4828
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Os.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2408
2419
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4823
4828
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Oz.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2387
2400
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4789
4794
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6328
6340
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_dylink.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13877
13882
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2408
2419
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_hello_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4823
4828
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1961
1974
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4044
4049
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1998
2010
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4093
4098
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2421
2431
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4966
4971
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2566
2577
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_grow.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5248
5253
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2263
2274
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4654
4659
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_standalone.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2222
2233
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_mem_O3_standalone.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4584
4589
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1984
1996
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4095
4100
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1998
2010
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4093
4098
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1998
2010
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4093
4098
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4722
4735
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_minimal_pthreads.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9949
9954
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
54871
54876
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_no_asserts.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
30527
30529
2 changes: 1 addition & 1 deletion test/other/test_unoptimized_code_size_strict.js.size
Original file line number Diff line number Diff line change
@@ -1 +1 @@
53745
53785
3 changes: 1 addition & 2 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2037,8 +2037,7 @@ if (extraInfoStart > 0) {
// outputted code if --closureFriendly was requested.
const sourceComments = {};
const params = {
// Keep in sync with --language_in that we pass to closure in building.py
ecmaVersion: 2021,
ecmaVersion: 'latest',
sourceType: exportES6 ? 'module' : 'script',
allowAwaitOutsideFunction: true,
};
Expand Down
3 changes: 1 addition & 2 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ def closure_compiler(filename, advanced=True, extra_closure_args=None):
CLOSURE_EXTERNS += [path_from_root('src/closure-externs/dyncall-externs.js')]

args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS']
# Keep in sync with ecmaVersion in tools/acorn-optimizer.mjs
args += ['--language_in', 'ECMASCRIPT_2021']
args += ['--language_in', 'UNSTABLE']
# We do transpilation using babel
args += ['--language_out', 'NO_TRANSPILE']
# Tell closure never to inject the 'use strict' directive.
Expand Down
Loading