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
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ to browse the changes between the tags.

See docs/process.md for more on how version tagging works.

3.0.2
3.1.0
-----
- Emscripten in starting to use ES6 features in its core libraries (at last!).
For most users targeting the default set of browsers this is a code size win.
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,7 @@ def modularize():
if shared.target_environment_may_be('node'):
script_url_node = "if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;"
src = '''
var %(EXPORT_NAME)s = (function() {
var %(EXPORT_NAME)s = (() => {
var _scriptDir = %(script_url)s;
%(script_url_node)s
return (%(src)s);
Expand Down
16 changes: 7 additions & 9 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,12 @@ LibraryManager.library = {
var cp = require('child_process');
var ret = cp.spawnSync(cmdstr, [], {shell:true, stdio:'inherit'});

var _W_EXITCODE = function(ret, sig) {
return ((ret) << 8 | (sig));
}
var _W_EXITCODE = (ret, sig) => ((ret) << 8 | (sig));

// this really only can happen if process is killed by signal
if (ret.status === null) {
// sadly node doesn't expose such function
var signalToNumber = function(sig) {
var signalToNumber = (sig) => {
// implement only the most common ones, and fallback to SIGINT
switch (sig) {
case 'SIGHUP': return 1;
Expand Down Expand Up @@ -1177,7 +1175,7 @@ LibraryManager.library = {
var date = initDate();
var value;

var getMatch = function(symbol) {
var getMatch = (symbol) => {
var pos = capture.indexOf(symbol);
// check if symbol appears in regexp
if (pos >= 0) {
Expand Down Expand Up @@ -2530,7 +2528,7 @@ LibraryManager.library = {
emscripten_get_now: ';' +
#if ENVIRONMENT_MAY_BE_NODE
"if (ENVIRONMENT_IS_NODE) {\n" +
" _emscripten_get_now = function() {\n" +
" _emscripten_get_now = () => {\n" +
" var t = process['hrtime']();\n" +
" return t[0] * 1e3 + t[1] / 1e6;\n" +
" };\n" +
Expand All @@ -2539,7 +2537,7 @@ LibraryManager.library = {
#if USE_PTHREADS
// Pthreads need their clocks synchronized to the execution of the main thread, so give them a special form of the function.
"if (ENVIRONMENT_IS_PTHREAD) {\n" +
" _emscripten_get_now = function() { return performance.now() - Module['__performance_now_clock_drift']; };\n" +
" _emscripten_get_now = () => performance.now() - Module['__performance_now_clock_drift'];\n" +
"} else " +
#endif
#if ENVIRONMENT_MAY_BE_SHELL
Expand All @@ -2549,14 +2547,14 @@ LibraryManager.library = {
#endif
#if MIN_IE_VERSION <= 9 || MIN_FIREFOX_VERSION <= 14 || MIN_CHROME_VERSION <= 23 || MIN_SAFARI_VERSION <= 80400 // https://caniuse.com/#feat=high-resolution-time
"if (typeof performance !== 'undefined' && performance.now) {\n" +
" _emscripten_get_now = function() { return performance.now(); }\n" +
" _emscripten_get_now = () => performance.now();\n" +
"} else {\n" +
" _emscripten_get_now = Date.now;\n" +
"}",
#else
// Modern environment where performance.now() is supported:
// N.B. a shorter form "_emscripten_get_now = return performance.now;" is unfortunately not allowed even in current browsers (e.g. FF Nightly 75).
"_emscripten_get_now = function() { return performance.now(); }\n",
"_emscripten_get_now = () => performance.now();\n",
#endif

emscripten_get_now_res: function() { // return resolution of get_now, in nanoseconds
Expand Down
4 changes: 2 additions & 2 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var LibraryBrowser = {
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
#endif
var img = new Image();
img.onload = function img_onload() {
img.onload = () => {
assert(img.complete, 'Image ' + name + ' could not be decoded');
var canvas = document.createElement('canvas');
canvas.width = img.width;
Expand All @@ -161,7 +161,7 @@ var LibraryBrowser = {
Browser.URLObject.revokeObjectURL(url);
if (onload) onload(byteArray);
};
img.onerror = function img_onerror(event) {
img.onerror = (event) => {
out('Image ' + url + ' could not be decoded');
if (onerror) onerror();
};
Expand Down
2 changes: 1 addition & 1 deletion src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ var LibraryGL = {
#endif

#if GL_DISABLE_HALF_FLOAT_EXTENSION_IF_BROKEN
function disableHalfFloatExtensionIfBroken(ctx) {
const disableHalfFloatExtensionIfBroken = (ctx) => {
var t = ctx.createTexture();
ctx.bindTexture(0xDE1/*GL_TEXTURE_2D*/, t);
for (var i = 0; i < 8 && ctx.getError(); ++i) /*no-op*/;
Expand Down
8 changes: 2 additions & 6 deletions src/preamble_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ var tempI64;
#endif

var tempRet0 = 0;
var setTempRet0 = function(value) {
tempRet0 = value;
}
var getTempRet0 = function() {
return tempRet0;
}
var setTempRet0 = (value) => { tempRet0 = value };
var getTempRet0 = () => tempRet0;

function alignUp(x, multiple) {
if (x % multiple > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/proxyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ worker.onmessage = function worker_onmessage(event) {
case 'Image': {
assert(data.method === 'src');
var img = new Image();
img.onload = function() {
img.onload = () => {
assert(img.complete);
var canvas = document.createElement('canvas');
canvas.width = img.width;
Expand All @@ -215,7 +215,7 @@ worker.onmessage = function worker_onmessage(event) {
var imageData = ctx.getImageData(0, 0, img.width, img.height);
worker.postMessage({ target: 'Image', method: 'onload', id: data.id, width: img.width, height: img.height, data: imageData.data, preMain: true });
};
img.onerror = function() {
img.onerror = () => {
worker.postMessage({ target: 'Image', method: 'onerror', id: data.id, preMain: true });
};
img.src = data.src;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// character.
function TextDecoderWrapper(encoding) {
var textDecoder = new TextDecoder(encoding);
this.decode = function(data) {
this.decode = (data) => {
#if ASSERTIONS
assert(data instanceof Uint8Array);
#endif
Expand Down
22 changes: 11 additions & 11 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var moduleOverrides = objAssign({}, Module);

var arguments_ = [];
var thisProgram = './this.program';
var quit_ = function(status, toThrow) {
var quit_ = (status, toThrow) => {
throw toThrow;
};

Expand Down Expand Up @@ -171,7 +171,7 @@ var read_,
// this may no longer be needed under node.
function logExceptionOnExit(e) {
if (e instanceof ExitStatus) return;
var toLog = e;
let toLog = e;
#if ASSERTIONS
if (e && typeof e === 'object' && e.stack) {
toLog = [e, e.stack];
Expand Down Expand Up @@ -232,7 +232,7 @@ if (ENVIRONMENT_IS_NODE) {
process['on']('unhandledRejection', function(reason) { throw reason; });
#endif

quit_ = function(status, toThrow) {
quit_ = (status, toThrow) => {
if (keepRuntimeAlive()) {
process['exitCode'] = status;
throw toThrow;
Expand All @@ -244,7 +244,7 @@ if (ENVIRONMENT_IS_NODE) {
Module['inspect'] = function () { return '[Emscripten Module object]'; };

#if USE_PTHREADS
var nodeWorkerThreads;
let nodeWorkerThreads;
try {
nodeWorkerThreads = require('worker_threads');
} catch (e) {
Expand Down Expand Up @@ -276,7 +276,7 @@ if (ENVIRONMENT_IS_SHELL) {
if (typeof read != 'undefined') {
read_ = function shell_read(f) {
#if SUPPORT_BASE64_EMBEDDING
var data = tryParseAsDataURI(f);
const data = tryParseAsDataURI(f);
if (data) {
return intArrayToString(data);
}
Expand All @@ -286,7 +286,7 @@ if (ENVIRONMENT_IS_SHELL) {
}

readBinary = function readBinary(f) {
var data;
let data;
#if SUPPORT_BASE64_EMBEDDING
data = tryParseAsDataURI(f);
if (data) {
Expand All @@ -302,7 +302,7 @@ if (ENVIRONMENT_IS_SHELL) {
};

readAsync = function readAsync(f, onload, onerror) {
setTimeout(function() { onload(readBinary(f)); }, 0);
setTimeout(() => onload(readBinary(f)), 0);
};

if (typeof scriptArgs != 'undefined') {
Expand All @@ -312,7 +312,7 @@ if (ENVIRONMENT_IS_SHELL) {
}

if (typeof quit === 'function') {
quit_ = function(status, toThrow) {
quit_ = (status, toThrow) => {
logExceptionOnExit(toThrow);
quit(status);
};
Expand Down Expand Up @@ -385,7 +385,7 @@ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {

}

setWindowTitle = function(title) { document.title = title };
setWindowTitle = (title) => document.title = title;
} else
#endif // ENVIRONMENT_MAY_BE_WEB || ENVIRONMENT_MAY_BE_WORKER
{
Expand Down Expand Up @@ -413,8 +413,8 @@ var defaultPrint = console.log.bind(console);
var defaultPrintErr = console.warn.bind(console);
if (ENVIRONMENT_IS_NODE) {
requireNodeFS();
defaultPrint = function(str) { fs.writeSync(1, str + '\n'); };
defaultPrintErr = function(str) { fs.writeSync(2, str + '\n'); };
defaultPrint = (str) => fs.writeSync(1, str + '\n');
defaultPrintErr = (str) => fs.writeSync(2, str + '\n');
}
{{{ makeModuleReceiveWithVar('out', 'print', 'defaultPrint', true) }}}
{{{ makeModuleReceiveWithVar('err', 'printErr', 'defaultPrintErr', true) }}}
Expand Down
2 changes: 1 addition & 1 deletion src/shell_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var Module = {{{ EXPORT_NAME }}};
#if MODULARIZE && EXPORT_READY_PROMISE
// Set up the promise that indicates the Module is initialized
var readyPromiseResolve, readyPromiseReject;
Module['ready'] = new Promise(function(resolve, reject) {
Module['ready'] = new Promise((resolve, reject) => {
readyPromiseResolve = resolve;
readyPromiseReject = reject;
});
Expand Down
8 changes: 4 additions & 4 deletions tests/code_size/hello_webgl2_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 5000,
"a.js.gz": 2422,
"a.js": 4974,
"a.js.gz": 2418,
"a.wasm": 10442,
"a.wasm.gz": 6661,
"total": 16011,
"total_gz": 9462
"total": 15985,
"total_gz": 9458
}
8 changes: 4 additions & 4 deletions tests/code_size/hello_webgl2_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 594,
"a.html.gz": 389,
"a.js": 20040,
"a.js.gz": 8198,
"a.js": 20034,
"a.js.gz": 8200,
"a.mem": 3171,
"a.mem.gz": 2714,
"total": 23805,
"total_gz": 11301
"total": 23799,
"total_gz": 11303
}
8 changes: 4 additions & 4 deletions tests/code_size/hello_webgl_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 569,
"a.html.gz": 379,
"a.js": 4486,
"a.js.gz": 2249,
"a.js": 4480,
"a.js.gz": 2251,
"a.wasm": 10442,
"a.wasm.gz": 6661,
"total": 15497,
"total_gz": 9289
"total": 15491,
"total_gz": 9291
}
8 changes: 4 additions & 4 deletions tests/code_size/hello_webgl_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 594,
"a.html.gz": 389,
"a.js": 19525,
"a.js.gz": 8035,
"a.js": 19519,
"a.js.gz": 8037,
"a.mem": 3171,
"a.mem.gz": 2714,
"total": 23290,
"total_gz": 11138
"total": 23284,
"total_gz": 11140
}
8 changes: 4 additions & 4 deletions tests/code_size/random_printf_wasm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 12988,
"a.html.gz": 6971,
"total": 12988,
"total_gz": 6971
"a.html": 12973,
"a.html.gz": 6974,
"total": 12973,
"total_gz": 6974
}
8 changes: 4 additions & 4 deletions tests/code_size/random_printf_wasm2js.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 17816,
"a.html.gz": 7605,
"total": 17816,
"total_gz": 7605
"a.html": 17801,
"a.html.gz": 7606,
"total": 17801,
"total_gz": 7606
}
2 changes: 0 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,6 @@ def build(self, filename, libraries=[], includes=[], force_c=False, js_outfile=T

self.run_process(cmd, stderr=self.stderr_redirect if not DEBUG else None)
self.assertExists(output)
if js_outfile and not self.uses_es6:
self.verify_es5(output)

if js_outfile and self.uses_memory_init_file():
src = read_file(output)
Expand Down
2 changes: 1 addition & 1 deletion tests/minimal_webgl/library_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mergeInto(LibraryManager.library, {
load_texture_from_url__deps: ['uploadFlipped'],
load_texture_from_url: function(glTexture, url, outW, outH) {
var img = new Image();
img.onload = function() {
img.onload = () => {
HEAPU32[outW>>2] = img.width;
HEAPU32[outH>>2] = img.height;
GLctx.bindTexture(0xDE1/*GLctx.TEXTURE_2D*/, GL.textures[glTexture]);
Expand Down
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_libcxx_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98376
98355
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_libcxx_O2_fexceptions.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
111848
111827
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112835
112814
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127954
127918
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_O1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
58552
58531
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_O2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22140
22119
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15478
15457
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_O3_MAIN_MODULE_2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98468
98447
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_Os.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15275
15254
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12001
11980
2 changes: 1 addition & 1 deletion tests/other/metadce/hello_world_Oz.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15150
15129
2 changes: 1 addition & 1 deletion tests/other/metadce/libcxxabi_message_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13331
13310
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15018
14997
2 changes: 1 addition & 1 deletion tests/other/metadce/mem_O3.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15456
15435
2 changes: 1 addition & 1 deletion tests/other/metadce/mem_O3_ALLOW_MEMORY_GROWTH.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16130
16109
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15913
15892
2 changes: 1 addition & 1 deletion tests/other/metadce/mem_O3_STANDALONE_WASM.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15735
15714
Loading