Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/lib/libbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ var LibraryBrowser = {
},

// TODO: currently not callable from a pthread, but immediately calls onerror() if not on main thread.
emscripten_async_load_script__deps: ['$UTF8ToString', '$runDependencies', '$dependenciesFulfilled'],
emscripten_async_load_script__deps: ['$UTF8ToString', '$runDependencies', '$resolveRunDeps'],
emscripten_async_load_script: async (url, onload, onerror) => {
url = UTF8ToString(url);
#if PTHREADS
Expand All @@ -634,7 +634,7 @@ var LibraryBrowser = {
if (onload) {
var onloadCallback = () => callUserCallback({{{ makeDynCall('v', 'onload') }}});
if (runDependencies > 0) {
dependenciesFulfilled = onloadCallback;
resolveRunDeps().then(onloadCallback);
} else {
onloadCallback();
}
Expand Down
3 changes: 3 additions & 0 deletions src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2266,11 +2266,14 @@ addToLibrary({
// Note that you can add dependencies in preRun, even though
// it happens right before run - run will be postponed until
// the dependencies are met.
$runDependencies__deps: ['$resolveRunDeps'],
$runDependencies__internal: true,
$runDependencies: 0,
// overridden to take different actions when all run dependencies are fulfilled
$dependenciesFulfilled__internal: true,
$dependenciesFulfilled: null,
$resolveRunDeps__internal: true,
$resolveRunDeps: () => new Promise((resolve) => dependenciesFulfilled = resolve),
#if ASSERTIONS
$runDependencyTracking__internal: true,
$runDependencyTracking: {},
Expand Down
16 changes: 3 additions & 13 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,14 @@ function stackCheckInit() {
}
#endif

{{{ asyncIf(MODULARIZE) }}}function run({{{ MAIN_READS_PARAMS ? 'args = programArgs' : '' }}}) {
{{{ asyncIf(MODULARIZE || '$runDependencies' in addedLibraryItems) }}}function run({{{ MAIN_READS_PARAMS ? 'args = programArgs' : '' }}}) {

#if '$runDependencies' in addedLibraryItems
if (runDependencies > 0) {
#if RUNTIME_DEBUG
dbg('run() called, but dependencies remain, so not running');
#endif
#if MODULARIZE
await new Promise((resolve) => dependenciesFulfilled = resolve);
#else
dependenciesFulfilled = run;
return;
#endif
await resolveRunDeps();
}
#endif

Expand All @@ -149,12 +144,7 @@ function stackCheckInit() {
#if RUNTIME_DEBUG
dbg('run() called, but dependencies remain, so not running');
#endif
#if MODULARIZE
await new Promise((resolve) => dependenciesFulfilled = resolve);
#else
dependenciesFulfilled = run;
return;
#endif
await resolveRunDeps();
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_cxx_ctors1.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"a.out.js": 19192,
"a.out.js": 19198,
"a.out.js.gz": 7944,
"a.out.nodebug.wasm": 132666,
"a.out.nodebug.wasm.gz": 49962,
"total": 151858,
"total": 151864,
"total_gz": 57906,
"sent": [
"__cxa_throw",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_ctors2.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 19169,
"a.out.js.gz": 7931,
"a.out.js": 19175,
"a.out.js.gz": 7932,
"a.out.nodebug.wasm": 132092,
"a.out.nodebug.wasm.gz": 49625,
"total": 151261,
"total_gz": 57556,
"total": 151267,
"total_gz": 57557,
"sent": [
"__cxa_throw",
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23166,
"a.out.js.gz": 8928,
"a.out.js": 23172,
"a.out.js.gz": 8931,
"a.out.nodebug.wasm": 172586,
"a.out.nodebug.wasm.gz": 57501,
"total": 195752,
"total_gz": 66429,
"total": 195758,
"total_gz": 66432,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_except_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 18995,
"a.out.js.gz": 7862,
"a.out.js": 19000,
"a.out.js.gz": 7863,
"a.out.nodebug.wasm": 147991,
"a.out.nodebug.wasm.gz": 55370,
"total": 166986,
"total_gz": 63232,
"total": 166991,
"total_gz": 63233,
"sent": [
"_abort_js",
"_tzset_js",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_cxx_except_wasm_legacy.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"a.out.js": 19069,
"a.out.js": 19074,
"a.out.js.gz": 7884,
"a.out.nodebug.wasm": 145797,
"a.out.nodebug.wasm.gz": 54992,
"total": 164866,
"total": 164871,
"total_gz": 62876,
"sent": [
"_abort_js",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_lto.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 18532,
"a.out.js.gz": 7634,
"a.out.js": 18538,
"a.out.js.gz": 7635,
"a.out.nodebug.wasm": 102168,
"a.out.nodebug.wasm.gz": 39572,
"total": 120700,
"total_gz": 47206,
"total": 120706,
"total_gz": 47207,
"sent": [
"a (emscripten_resize_heap)",
"b (_setitimer_js)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_cxx_mangle.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 23216,
"a.out.js.gz": 8947,
"a.out.js": 23222,
"a.out.js.gz": 8951,
"a.out.nodebug.wasm": 239015,
"a.out.nodebug.wasm.gz": 79854,
"total": 262231,
"total_gz": 88801,
"total": 262237,
"total_gz": 88805,
"sent": [
"__cxa_begin_catch",
"__cxa_end_catch",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_cxx_noexcept.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"a.out.js": 19192,
"a.out.js": 19198,
"a.out.js.gz": 7944,
"a.out.nodebug.wasm": 134666,
"a.out.nodebug.wasm.gz": 50806,
"total": 153858,
"total": 153864,
"total_gz": 58750,
"sent": [
"__cxa_throw",
Expand Down
10 changes: 5 additions & 5 deletions test/codesize/test_codesize_file_preload.expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,8 @@ var FS_createDataFile = (...args) => FS.createDataFile(...args);

var getUniqueRunDependency = id => id;

var resolveRunDeps = () => new Promise(resolve => dependenciesFulfilled = resolve);

var runDependencies = 0;

var dependenciesFulfilled = null;
Expand Down Expand Up @@ -3177,16 +3179,14 @@ function callMain() {
}
}

function run() {
async function run() {
if (runDependencies > 0) {
dependenciesFulfilled = run;
return;
await resolveRunDeps();
}
preRun();
// a preRun added a dependency, run will be called later
if (runDependencies > 0) {
dependenciesFulfilled = run;
return;
await resolveRunDeps();
}
function doRun() {
// run may have just been called through dependencies being fulfilled just in this very frame,
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_file_preload.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 22108,
"a.out.js.gz": 9183,
"a.out.js": 22138,
"a.out.js.gz": 9194,
"a.out.nodebug.wasm": 1666,
"a.out.nodebug.wasm.gz": 945,
"total": 23774,
"total_gz": 10128,
"total": 23804,
"total_gz": 10139,
"sent": [
"a (fd_write)"
],
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_files_js_fs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 17840,
"a.out.js.gz": 7285,
"a.out.js": 17846,
"a.out.js.gz": 7286,
"a.out.nodebug.wasm": 381,
"a.out.nodebug.wasm.gz": 260,
"total": 18221,
"total_gz": 7545,
"total": 18227,
"total_gz": 7546,
"sent": [
"a (fd_write)",
"b (fd_read)",
Expand Down
8 changes: 4 additions & 4 deletions test/codesize/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26265,
"a.out.js.gz": 11182,
"a.out.js": 26271,
"a.out.js.gz": 11181,
"a.out.nodebug.wasm": 17861,
"a.out.nodebug.wasm.gz": 9019,
"total": 44126,
"total_gz": 20201,
"total": 44132,
"total_gz": 20200,
"sent": [
"__syscall_stat64",
"emscripten_resize_heap",
Expand Down
4 changes: 2 additions & 2 deletions test/codesize/test_codesize_hello_dylink_all.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"a.out.js": 268274,
"a.out.js": 268334,
"a.out.nodebug.wasm": 587640,
"total": 855914,
"total": 855974,
"sent": [
"IMG_Init",
"IMG_Load",
Expand Down
Loading