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
22 changes: 13 additions & 9 deletions src/jsifier.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,21 @@ ${argConversions}

// apply LIBRARY_DEBUG if relevant
if (LIBRARY_DEBUG && !isJsOnlySymbol(symbol)) {
snippet = modifyJSFunction(
snippet,
(args, body, async) => `\
snippet = modifyJSFunction(snippet, (args, body, async, oneliner) => {
var run_func;
if (oneliner) {
run_func = `var ret = ${body}`;
} else {
run_func = `var ret = (() => { ${body} })();`;
}
return `\
function(${args}) {
var ret = (() => { if (runtimeDebug) err("[library call:${mangled}: " + Array.prototype.slice.call(arguments).map(prettyPrint) + "]");
${body}
})();
if (runtimeDebug && typeof ret != "undefined") err(" [ return:" + prettyPrint(ret));
if (runtimeDebug) err("[library call:${mangled}: " + Array.prototype.slice.call(arguments).map(prettyPrint) + "]");
${run_func}
if (runtimeDebug) err(" [ return:" + prettyPrint(ret));
return ret;
}`,
);
}`;
});
}

const sig = LibraryManager.library[symbol + '__sig'];
Expand Down
7 changes: 5 additions & 2 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,16 @@ var LibraryPThread = {
__pthread_create_js__noleakcheck: true,
#endif
__pthread_create_js__deps: ['$spawnThread', 'pthread_self', '$pthreadCreateProxied',
'emscripten_has_threading_support',
#if OFFSCREENCANVAS_SUPPORT
'malloc',
#endif
],
__pthread_create_js: (pthread_ptr, attr, startRoutine, arg) => {
if (typeof SharedArrayBuffer == 'undefined') {
err('Current environment does not support SharedArrayBuffer, pthreads are not available!');
if (!_emscripten_has_threading_support()) {
#if ASSERTIONS
dbg('pthread_create: environment does not support SharedArrayBuffer, pthreads are not available');
#endif
return {{{ cDefs.EAGAIN }}};
}
#if PTHREADS_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ var runtimeDebug = true; // Switch to false at runtime to disable logging at the
var printObjectList = [];

function prettyPrint(arg) {
if (typeof arg == 'undefined') return '!UNDEFINED!';
if (typeof arg == 'undefined') return 'undefined';
if (typeof arg == 'boolean') arg = arg + 0;
if (!arg) return arg;
var index = printObjectList.indexOf(arg);
Expand Down
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 @@
4951
4911
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 @@
10465
10376
9 changes: 5 additions & 4 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3847,11 +3847,12 @@ def test_pthread_condition_variable(self):

# Test that pthreads are able to do printf.
@parameterized({
'': (False,),
'debug': (True,),
'': ([],),
'O3': (['-O3'],),
'debug': (['-sLIBRARY_DEBUG'],),
})
def test_pthread_printf(self, debug):
self.btest_exit('pthread/test_pthread_printf.c', args=['-O3', '-pthread', '-sPTHREAD_POOL_SIZE', '-sLIBRARY_DEBUG=%d' % debug])
def test_pthread_printf(self, args):
self.btest_exit('pthread/test_pthread_printf.c', args=['-pthread', '-sPTHREAD_POOL_SIZE'] + args)

# Test that pthreads are able to do cout. Failed due to https://bugzilla.mozilla.org/show_bug.cgi?id=1154858.
def test_pthread_iostream(self):
Expand Down
Loading