diff --git a/src/library_fs.js b/src/library_fs.js index cca4d14a84550..71566c744dfd7 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -115,6 +115,36 @@ FS.staticInit();` + filesystems: null, syncFSRequests: 0, // we warn if there are multiple in flight at once +#if ASSERTIONS + ErrnoError: class extends Error { +#else + ErrnoError: class { +#endif + // 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 + // as different FS objects have their own FS.ErrnoError each, + // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs. + // we'll use the reliable test `err.name == "ErrnoError"` instead + constructor(errno) { +#if ASSERTIONS + super(ERRNO_MESSAGES[errno]); +#endif + // TODO(sbc): Use the inline member delclaration syntax once we + // support it in acorn and closure. + this.name = 'ErrnoError'; + this.errno = errno; +#if ASSERTIONS + for (var key in ERRNO_CODES) { + if (ERRNO_CODES[key] === errno) { + this.code = key; + break; + } + } +#endif + } + }, + // // paths // @@ -1404,53 +1434,12 @@ FS.staticInit();` + assert(stderr.fd === 2, `invalid handle for stderr (${stderr.fd})`); #endif }, - ensureErrnoError() { - if (FS.ErrnoError) return; - FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno) { - // 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 - // as different FS objects have their own FS.ErrnoError each, - // the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs. - // we'll use the reliable test `err.name == "ErrnoError"` instead - this.name = 'ErrnoError'; - this.setErrno = /** @this{Object} */ function(errno) { - this.errno = errno; -#if ASSERTIONS - for (var key in ERRNO_CODES) { - if (ERRNO_CODES[key] === errno) { - this.code = key; - break; - } - } -#endif - }; - this.setErrno(errno); -#if ASSERTIONS - this.message = ERRNO_MESSAGES[errno]; -#else - this.message = 'FS error'; -#endif - -#if ASSERTIONS && !MINIMAL_RUNTIME - // Try to get a maximally helpful stack trace. On Node.js, getting Error.stack - // now ensures it shows what we want. - if (this.stack) { - // Define the stack property for Node.js 4, which otherwise errors on the next line. - Object.defineProperty(this, "stack", { value: (new Error).stack, writable: true }); - } -#endif // ASSERTIONS - }; - FS.ErrnoError.prototype = new Error(); - FS.ErrnoError.prototype.constructor = FS.ErrnoError; + staticInit() { // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info) [{{{ cDefs.ENOENT }}}].forEach((code) => { FS.genericErrors[code] = new FS.ErrnoError(code); FS.genericErrors[code].stack = ''; }); - }, - staticInit() { - FS.ensureErrnoError(); FS.nameTable = new Array(4096); @@ -1482,8 +1471,6 @@ FS.staticInit();` + #endif FS.init.initialized = true; - FS.ensureErrnoError(); - // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here Module['stdin'] = input || Module['stdin']; Module['stdout'] = output || Module['stdout']; diff --git a/src/library_noderawfs.js b/src/library_noderawfs.js index 699ed8bdf78ad..15758d0e4d752 100644 --- a/src/library_noderawfs.js +++ b/src/library_noderawfs.js @@ -20,6 +20,7 @@ addToLibrary({ } } }; + /** @suppress {partialAlias} */ var VFS = Object.assign({}, FS); for (var _key in NODERAWFS) { FS[_key] = _wrapNodeError(NODERAWFS[_key]); diff --git a/test/other/metadce/test_metadce_cxx_ctors1.gzsize b/test/other/metadce/test_metadce_cxx_ctors1.gzsize index 87e1a92de80b2..15f1e2d52af10 100644 --- a/test/other/metadce/test_metadce_cxx_ctors1.gzsize +++ b/test/other/metadce/test_metadce_cxx_ctors1.gzsize @@ -1 +1 @@ -9932 +9950 diff --git a/test/other/metadce/test_metadce_cxx_ctors1.jssize b/test/other/metadce/test_metadce_cxx_ctors1.jssize index ef8d02c7b4c52..9f92ad5a75e08 100644 --- a/test/other/metadce/test_metadce_cxx_ctors1.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors1.jssize @@ -1 +1 @@ -24693 +24550 diff --git a/test/other/metadce/test_metadce_cxx_ctors2.gzsize b/test/other/metadce/test_metadce_cxx_ctors2.gzsize index e075aaa54a983..86f16586ec479 100644 --- a/test/other/metadce/test_metadce_cxx_ctors2.gzsize +++ b/test/other/metadce/test_metadce_cxx_ctors2.gzsize @@ -1 +1 @@ -9915 +9933 diff --git a/test/other/metadce/test_metadce_cxx_ctors2.jssize b/test/other/metadce/test_metadce_cxx_ctors2.jssize index b32c1ee20e951..9a0a588d1fcb0 100644 --- a/test/other/metadce/test_metadce_cxx_ctors2.jssize +++ b/test/other/metadce/test_metadce_cxx_ctors2.jssize @@ -1 +1 @@ -24661 +24518 diff --git a/test/other/metadce/test_metadce_cxx_except.gzsize b/test/other/metadce/test_metadce_cxx_except.gzsize index deca973733bad..4e2a4b06f87ef 100644 --- a/test/other/metadce/test_metadce_cxx_except.gzsize +++ b/test/other/metadce/test_metadce_cxx_except.gzsize @@ -1 +1 @@ -11010 +11019 diff --git a/test/other/metadce/test_metadce_cxx_except.jssize b/test/other/metadce/test_metadce_cxx_except.jssize index d7bf552030bbc..995555ed8a7c4 100644 --- a/test/other/metadce/test_metadce_cxx_except.jssize +++ b/test/other/metadce/test_metadce_cxx_except.jssize @@ -1 +1 @@ -28583 +28439 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm.gzsize b/test/other/metadce/test_metadce_cxx_except_wasm.gzsize index 55223f1554dc1..a121be018ad9a 100644 --- a/test/other/metadce/test_metadce_cxx_except_wasm.gzsize +++ b/test/other/metadce/test_metadce_cxx_except_wasm.gzsize @@ -1 +1 @@ -9899 +9913 diff --git a/test/other/metadce/test_metadce_cxx_except_wasm.jssize b/test/other/metadce/test_metadce_cxx_except_wasm.jssize index b85dcbb09ed54..522789f776377 100644 --- a/test/other/metadce/test_metadce_cxx_except_wasm.jssize +++ b/test/other/metadce/test_metadce_cxx_except_wasm.jssize @@ -1 +1 @@ -24586 +24442 diff --git a/test/other/metadce/test_metadce_cxx_mangle.gzsize b/test/other/metadce/test_metadce_cxx_mangle.gzsize index d817e31f8830c..41b390d6d2f9c 100644 --- a/test/other/metadce/test_metadce_cxx_mangle.gzsize +++ b/test/other/metadce/test_metadce_cxx_mangle.gzsize @@ -1 +1 @@ -11016 +11029 diff --git a/test/other/metadce/test_metadce_cxx_mangle.jssize b/test/other/metadce/test_metadce_cxx_mangle.jssize index d7bf552030bbc..995555ed8a7c4 100644 --- a/test/other/metadce/test_metadce_cxx_mangle.jssize +++ b/test/other/metadce/test_metadce_cxx_mangle.jssize @@ -1 +1 @@ -28583 +28439 diff --git a/test/other/metadce/test_metadce_cxx_noexcept.gzsize b/test/other/metadce/test_metadce_cxx_noexcept.gzsize index 87e1a92de80b2..15f1e2d52af10 100644 --- a/test/other/metadce/test_metadce_cxx_noexcept.gzsize +++ b/test/other/metadce/test_metadce_cxx_noexcept.gzsize @@ -1 +1 @@ -9932 +9950 diff --git a/test/other/metadce/test_metadce_cxx_noexcept.jssize b/test/other/metadce/test_metadce_cxx_noexcept.jssize index ef8d02c7b4c52..9f92ad5a75e08 100644 --- a/test/other/metadce/test_metadce_cxx_noexcept.jssize +++ b/test/other/metadce/test_metadce_cxx_noexcept.jssize @@ -1 +1 @@ -24693 +24550 diff --git a/test/other/metadce/test_metadce_files_js_fs.gzsize b/test/other/metadce/test_metadce_files_js_fs.gzsize index fc1347e76e0df..ffd7b3d6e32c8 100644 --- a/test/other/metadce/test_metadce_files_js_fs.gzsize +++ b/test/other/metadce/test_metadce_files_js_fs.gzsize @@ -1 +1 @@ -7871 +7883 diff --git a/test/other/metadce/test_metadce_files_js_fs.jssize b/test/other/metadce/test_metadce_files_js_fs.jssize index b3945f1ded561..dda2834b85a76 100644 --- a/test/other/metadce/test_metadce_files_js_fs.jssize +++ b/test/other/metadce/test_metadce_files_js_fs.jssize @@ -1 +1 @@ -19715 +19571