Skip to content

Commit 6b6c0ec

Browse files
committed
Access dynCall_*() functions directly so that references to them can be minified by Closure, instead of routing via Module['dyncall_*'] which is an unminifiable access.
1 parent f426829 commit 6b6c0ec

14 files changed

+121
-112
lines changed

src/Fetch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ function emscripten_start_fetch(fetch, successcb, errorcb, progresscb) {
487487
#if FETCH_DEBUG
488488
console.log('fetch: operation success. e: ' + e);
489489
#endif
490-
if (onsuccess && typeof dynCall === 'function') Module['dynCall_vi'](onsuccess, fetch);
490+
if (onsuccess) Module['dynCall_vi'](onsuccess, fetch);
491491
else if (successcb) successcb(fetch);
492492
};
493493

@@ -499,29 +499,29 @@ function emscripten_start_fetch(fetch, successcb, errorcb, progresscb) {
499499
#if FETCH_DEBUG
500500
console.log('fetch: IndexedDB store succeeded.');
501501
#endif
502-
if (onsuccess && typeof dynCall === 'function') Module['dynCall_vi'](onsuccess, fetch);
502+
if (onsuccess) Module['dynCall_vi'](onsuccess, fetch);
503503
else if (successcb) successcb(fetch);
504504
};
505505
var storeError = function(fetch, xhr, e) {
506506
#if FETCH_DEBUG
507507
console.error('fetch: IndexedDB store failed.');
508508
#endif
509-
if (onsuccess && typeof dynCall === 'function') Module['dynCall_vi'](onsuccess, fetch);
509+
if (onsuccess) Module['dynCall_vi'](onsuccess, fetch);
510510
else if (successcb) successcb(fetch);
511511
};
512512
__emscripten_fetch_cache_data(Fetch.dbInstance, fetch, xhr.response, storeSuccess, storeError);
513513
};
514514

515515
var reportProgress = function(fetch, xhr, e) {
516-
if (onprogress && typeof dynCall === 'function') Module['dynCall_vi'](onprogress, fetch);
516+
if (onprogress) Module['dynCall_vi'](onprogress, fetch);
517517
else if (progresscb) progresscb(fetch);
518518
};
519519

520520
var reportError = function(fetch, xhr, e) {
521521
#if FETCH_DEBUG
522522
console.error('fetch: operation failed: ' + e);
523523
#endif
524-
if (onerror && typeof dynCall === 'function') Module['dynCall_vi'](onerror, fetch);
524+
if (onerror) Module['dynCall_vi'](onerror, fetch);
525525
else if (errorcb) errorcb(fetch);
526526
};
527527

src/library.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4587,7 +4587,7 @@ LibraryManager.library = {
45874587
var trace = _emscripten_get_callstack_js();
45884588
var parts = trace.split('\n');
45894589
for (var i = 0; i < parts.length; i++) {
4590-
var ret = Module['dynCall_iii'](func, 0, arg);
4590+
var ret = {{{ makeDynCall('iii') }}}(func, 0, arg);
45914591
if (ret !== 0) return;
45924592
}
45934593
},

src/library_browser.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ var LibraryBrowser = {
791791
function doCallback(callback) {
792792
if (callback) {
793793
var stack = stackSave();
794-
Module['dynCall_vi'](callback, allocate(intArrayFromString(_file), 'i8', ALLOC_STACK));
794+
{{{ makeDynCall('vi') }}}(callback, allocate(intArrayFromString(_file), 'i8', ALLOC_STACK));
795795
stackRestore(stack);
796796
}
797797
}
@@ -825,10 +825,10 @@ var LibraryBrowser = {
825825
Browser.asyncLoad(UTF8ToString(url), function(byteArray) {
826826
var buffer = _malloc(byteArray.length);
827827
HEAPU8.set(byteArray, buffer);
828-
Module['dynCall_viii'](onload, arg, buffer, byteArray.length);
828+
{{{ makeDynCall('viii') }}}(onload, arg, buffer, byteArray.length);
829829
_free(buffer);
830830
}, function() {
831-
if (onerror) Module['dynCall_vi'](onerror, arg);
831+
if (onerror) {{{ makeDynCall('vi') }}}(onerror, arg);
832832
}, true /* no need for run dependency, this is async but will not do any prepare etc. step */ );
833833
},
834834

@@ -865,27 +865,27 @@ var LibraryBrowser = {
865865
FS.createDataFile( _file.substr(0, index), _file.substr(index + 1), new Uint8Array(http.response), true, true, false);
866866
if (onload) {
867867
var stack = stackSave();
868-
Module['dynCall_viii'](onload, handle, arg, allocate(intArrayFromString(_file), 'i8', ALLOC_STACK));
868+
{{{ makeDynCall('viii') }}}(onload, handle, arg, allocate(intArrayFromString(_file), 'i8', ALLOC_STACK));
869869
stackRestore(stack);
870870
}
871871
} else {
872-
if (onerror) Module['dynCall_viii'](onerror, handle, arg, http.status);
872+
if (onerror) {{{ makeDynCall('viii') }}}(onerror, handle, arg, http.status);
873873
}
874874

875875
delete Browser.wgetRequests[handle];
876876
};
877877

878878
// ERROR
879879
http.onerror = function http_onerror(e) {
880-
if (onerror) Module['dynCall_viii'](onerror, handle, arg, http.status);
880+
if (onerror) {{{ makeDynCall('viii') }}}(onerror, handle, arg, http.status);
881881
delete Browser.wgetRequests[handle];
882882
};
883883

884884
// PROGRESS
885885
http.onprogress = function http_onprogress(e) {
886886
if (e.lengthComputable || (e.lengthComputable === undefined && e.total != 0)) {
887887
var percentComplete = (e.loaded / e.total)*100;
888-
if (onprogress) Module['dynCall_viii'](onprogress, handle, arg, percentComplete);
888+
if (onprogress) {{{ makeDynCall('viii') }}}(onprogress, handle, arg, percentComplete);
889889
}
890890
};
891891

@@ -926,25 +926,25 @@ var LibraryBrowser = {
926926
var byteArray = new Uint8Array(http.response);
927927
var buffer = _malloc(byteArray.length);
928928
HEAPU8.set(byteArray, buffer);
929-
if (onload) Module['dynCall_viiii'](onload, handle, arg, buffer, byteArray.length);
929+
if (onload) {{{ makeDynCall('viiii') }}}(onload, handle, arg, buffer, byteArray.length);
930930
if (free) _free(buffer);
931931
} else {
932-
if (onerror) Module['dynCall_viiii'](onerror, handle, arg, http.status, http.statusText);
932+
if (onerror) {{{ makeDynCall('viiii') }}}(onerror, handle, arg, http.status, http.statusText);
933933
}
934934
delete Browser.wgetRequests[handle];
935935
};
936936

937937
// ERROR
938938
http.onerror = function http_onerror(e) {
939939
if (onerror) {
940-
Module['dynCall_viiii'](onerror, handle, arg, http.status, http.statusText);
940+
{{{ makeDynCall('viiii') }}}(onerror, handle, arg, http.status, http.statusText);
941941
}
942942
delete Browser.wgetRequests[handle];
943943
};
944944

945945
// PROGRESS
946946
http.onprogress = function http_onprogress(e) {
947-
if (onprogress) Module['dynCall_viiii'](onprogress, handle, arg, e.loaded, e.lengthComputable || e.lengthComputable === undefined ? e.total : 0);
947+
if (onprogress) {{{ makeDynCall('viiii') }}}(onprogress, handle, arg, e.loaded, e.lengthComputable || e.lengthComputable === undefined ? e.total : 0);
948948
};
949949

950950
// ABORT
@@ -988,10 +988,10 @@ var LibraryBrowser = {
988988
PATH.basename(_file),
989989
new Uint8Array(data.object.contents), true, true,
990990
function() {
991-
if (onload) Module['dynCall_vi'](onload, file);
991+
if (onload) {{{ makeDynCall('vi') }}}(onload, file);
992992
},
993993
function() {
994-
if (onerror) Module['dynCall_vi'](onerror, file);
994+
if (onerror) {{{ makeDynCall('vi') }}}(onerror, file);
995995
},
996996
true // don'tCreateFile - it's already there
997997
);
@@ -1015,10 +1015,10 @@ var LibraryBrowser = {
10151015
{{{ makeHEAPView('U8', 'data', 'data + size') }}},
10161016
true, true,
10171017
function() {
1018-
if (onload) Module['dynCall_vii'](onload, arg, cname);
1018+
if (onload) {{{ makeDynCall('vii') }}}(onload, arg, cname);
10191019
},
10201020
function() {
1021-
if (onerror) Module['dynCall_vi'](onerror, arg);
1021+
if (onerror) {{{ makeDynCall('vi') }}}(onerror, arg);
10221022
},
10231023
true // don'tCreateFile - it's already there
10241024
);
@@ -1273,15 +1273,15 @@ var LibraryBrowser = {
12731273
// Runs natively in pthread, no __proxy needed.
12741274
_emscripten_push_main_loop_blocker: function(func, arg, name) {
12751275
Browser.mainLoop.queue.push({ func: function() {
1276-
Module['dynCall_vi'](func, arg);
1276+
{{{ makeDynCall('vi') }}}(func, arg);
12771277
}, name: UTF8ToString(name), counted: true });
12781278
Browser.mainLoop.updateStatus();
12791279
},
12801280

12811281
// Runs natively in pthread, no __proxy needed.
12821282
_emscripten_push_uncounted_main_loop_blocker: function(func, arg, name) {
12831283
Browser.mainLoop.queue.push({ func: function() {
1284-
Module['dynCall_vi'](func, arg);
1284+
{{{ makeDynCall('vi') }}}(func, arg);
12851285
}, name: UTF8ToString(name), counted: false });
12861286
Browser.mainLoop.updateStatus();
12871287
},

src/library_glfw.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ var LibraryGLFW = {
356356
if (charCode == 0 || (charCode >= 0x00 && charCode <= 0x1F)) return;
357357

358358
#if USE_GLFW == 2
359-
Module['dynCall_vii'](GLFW.active.charFunc, charCode, 1);
359+
{{{ makeDynCall('vii') }}}(GLFW.active.charFunc, charCode, 1);
360360
#endif
361361

362362
#if USE_GLFW == 3
363-
Module['dynCall_vii'](GLFW.active.charFunc, GLFW.active.id, charCode);
363+
{{{ makeDynCall('vii') }}}(GLFW.active.charFunc, GLFW.active.id, charCode);
364364
#endif
365365
},
366366

@@ -378,12 +378,12 @@ var LibraryGLFW = {
378378
if (!GLFW.active.keyFunc) return;
379379

380380
#if USE_GLFW == 2
381-
Module['dynCall_vii'](GLFW.active.keyFunc, key, status);
381+
{{{ makeDynCall('vii') }}}(GLFW.active.keyFunc, key, status);
382382
#endif
383383

384384
#if USE_GLFW == 3
385385
if (repeat) status = 2; // GLFW_REPEAT
386-
Module['dynCall_viiiii'](GLFW.active.keyFunc, GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
386+
{{{ makeDynCall('viiiii') }}}(GLFW.active.keyFunc, GLFW.active.id, key, keyCode, status, GLFW.getModBits(GLFW.active));
387387
#endif
388388
},
389389

@@ -428,11 +428,11 @@ var LibraryGLFW = {
428428
if (event.target != Module["canvas"] || !GLFW.active.cursorPosFunc) return;
429429

430430
#if USE_GLFW == 2
431-
Module['dynCall_vii'](GLFW.active.cursorPosFunc, Browser.mouseX, Browser.mouseY);
431+
{{{ makeDynCall('vii') }}}(GLFW.active.cursorPosFunc, Browser.mouseX, Browser.mouseY);
432432
#endif
433433

434434
#if USE_GLFW == 3
435-
Module['dynCall_vidd'](GLFW.active.cursorPosFunc, GLFW.active.id, Browser.mouseX, Browser.mouseY);
435+
{{{ makeDynCall('vidd') }}}(GLFW.active.cursorPosFunc, GLFW.active.id, Browser.mouseX, Browser.mouseY);
436436
#endif
437437
},
438438

@@ -456,7 +456,7 @@ var LibraryGLFW = {
456456
if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
457457

458458
#if USE_GLFW == 3
459-
Module['dynCall_vii'](GLFW.active.cursorEnterFunc, GLFW.active.id, 1);
459+
{{{ makeDynCall('vii') }}}(GLFW.active.cursorEnterFunc, GLFW.active.id, 1);
460460
#endif
461461
},
462462

@@ -466,7 +466,7 @@ var LibraryGLFW = {
466466
if (event.target != Module["canvas"] || !GLFW.active.cursorEnterFunc) return;
467467

468468
#if USE_GLFW == 3
469-
Module['dynCall_vii'](GLFW.active.cursorEnterFunc, GLFW.active.id, 0);
469+
{{{ makeDynCall('vii') }}}(GLFW.active.cursorEnterFunc, GLFW.active.id, 0);
470470
#endif
471471
},
472472

@@ -491,11 +491,11 @@ var LibraryGLFW = {
491491
if (!GLFW.active.mouseButtonFunc) return;
492492

493493
#if USE_GLFW == 2
494-
Module['dynCall_vii'](GLFW.active.mouseButtonFunc, eventButton, status);
494+
{{{ makeDynCall('vii') }}}(GLFW.active.mouseButtonFunc, eventButton, status);
495495
#endif
496496

497497
#if USE_GLFW == 3
498-
Module['dynCall_viiii'](GLFW.active.mouseButtonFunc, GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
498+
{{{ makeDynCall('viiii') }}}(GLFW.active.mouseButtonFunc, GLFW.active.id, eventButton, status, GLFW.getModBits(GLFW.active));
499499
#endif
500500
},
501501

@@ -518,7 +518,7 @@ var LibraryGLFW = {
518518
if (!GLFW.active || !GLFW.active.scrollFunc || event.target != Module['canvas']) return;
519519

520520
#if USE_GLFW == 2
521-
Module['dynCall_vi'](GLFW.active.scrollFunc, GLFW.wheelPos);
521+
{{{ makeDynCall('vi') }}}(GLFW.active.scrollFunc, GLFW.wheelPos);
522522
#endif
523523

524524
#if USE_GLFW == 3
@@ -532,7 +532,7 @@ var LibraryGLFW = {
532532
sy = event.deltaY;
533533
}
534534

535-
Module['dynCall_vidd'](GLFW.active.scrollFunc, GLFW.active.id, sx, sy);
535+
{{{ makeDynCall('vidd') }}}(GLFW.active.scrollFunc, GLFW.active.id, sx, sy);
536536
#endif
537537

538538
event.preventDefault();
@@ -587,11 +587,11 @@ var LibraryGLFW = {
587587
if (!GLFW.active.windowSizeFunc) return;
588588

589589
#if USE_GLFW == 2
590-
Module['dynCall_vii'](GLFW.active.windowSizeFunc, GLFW.active.width, GLFW.active.height);
590+
{{{ makeDynCall('vii') }}}(GLFW.active.windowSizeFunc, GLFW.active.width, GLFW.active.height);
591591
#endif
592592

593593
#if USE_GLFW == 3
594-
Module['dynCall_viii'](GLFW.active.windowSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
594+
{{{ makeDynCall('viii') }}}(GLFW.active.windowSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
595595
#endif
596596
},
597597

@@ -601,7 +601,7 @@ var LibraryGLFW = {
601601
if (!GLFW.active.framebufferSizeFunc) return;
602602

603603
#if USE_GLFW == 3
604-
Module['dynCall_viii'](GLFW.active.framebufferSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
604+
{{{ makeDynCall('viii') }}}(GLFW.active.framebufferSizeFunc, GLFW.active.id, GLFW.active.width, GLFW.active.height);
605605
#endif
606606
},
607607

@@ -684,7 +684,7 @@ var LibraryGLFW = {
684684
};
685685

686686
if (GLFW.joystickFunc) {
687-
Module['dynCall_vii'](GLFW.joystickFunc, joy, 0x00040001); // GLFW_CONNECTED
687+
{{{ makeDynCall('vii') }}}(GLFW.joystickFunc, joy, 0x00040001); // GLFW_CONNECTED
688688
}
689689
}
690690

@@ -702,7 +702,7 @@ var LibraryGLFW = {
702702
console.log('glfw joystick disconnected',joy);
703703

704704
if (GLFW.joystickFunc) {
705-
Module['dynCall_vii'](GLFW.joystickFunc, joy, 0x00040002); // GLFW_DISCONNECTED
705+
{{{ makeDynCall('vii') }}}(GLFW.joystickFunc, joy, 0x00040002); // GLFW_DISCONNECTED
706706
}
707707

708708
_free(GLFW.joys[joy].id);
@@ -780,7 +780,7 @@ var LibraryGLFW = {
780780
var data = e.target.result;
781781
FS.writeFile(path, new Uint8Array(data));
782782
if (++written === count) {
783-
Module['dynCall_viii'](GLFW.active.dropFunc, GLFW.active.id, count, filenames);
783+
{{{ makeDynCall('viii') }}}(GLFW.active.dropFunc, GLFW.active.id, count, filenames);
784784

785785
for (var i = 0; i < filenamesArray.length; ++i) {
786786
_free(filenamesArray[i]);
@@ -820,7 +820,7 @@ var LibraryGLFW = {
820820
// function returns.
821821
// GLFW3 on the over hand doesn't have this behavior (https://github.com/glfw/glfw/issues/62).
822822
if (!win.windowSizeFunc) return;
823-
Module['dynCall_vii'](win.windowSizeFunc, win.width, win.height);
823+
{{{ makeDynCall('vii') }}}(win.windowSizeFunc, win.width, win.height);
824824
#endif
825825
},
826826

@@ -966,11 +966,11 @@ var LibraryGLFW = {
966966
if (!win.windowSizeFunc) return;
967967

968968
#if USE_GLFW == 2
969-
Module['dynCall_vii'](win.windowSizeFunc, width, height);
969+
{{{ makeDynCall('vii') }}}(win.windowSizeFunc, width, height);
970970
#endif
971971

972972
#if USE_GLFW == 3
973-
Module['dynCall_viii'](win.windowSizeFunc, win.id, width, height);
973+
{{{ makeDynCall('viii') }}}(win.windowSizeFunc, win.id, width, height);
974974
#endif
975975
},
976976

@@ -1030,7 +1030,7 @@ var LibraryGLFW = {
10301030

10311031
#if USE_GLFW == 3
10321032
if (win.windowCloseFunc)
1033-
Module['dynCall_vi'](win.windowCloseFunc, win.id);
1033+
{{{ makeDynCall('vi') }}}(win.windowCloseFunc, win.id);
10341034
#endif
10351035

10361036
GLFW.windows[win.id - 1] = null;

0 commit comments

Comments
 (0)