Skip to content

Commit

Permalink
Use standard/new proxying for syscalls (#7920)
Browse files Browse the repository at this point in the history
Just marks them as sync proxying, like the JS library stuff, erasing the custom proxying from before.

I think this doesn't give any benefit aside from simplifying the code.
  • Loading branch information
kripken authored Jan 31, 2019
1 parent c91d44b commit 68d9981
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ function JSify(data, functionsOnly) {
}
}

var snippet = LibraryManager.library[ident];
var original = LibraryManager.library[ident];
var snippet = original;
var redirectedIdent = null;
var deps = LibraryManager.library[ident + '__deps'] || [];
deps.forEach(function(dep) {
Expand Down Expand Up @@ -266,14 +267,13 @@ function JSify(data, functionsOnly) {
// Emit the body of a JS library function.
var proxyingMode = LibraryManager.library[ident + '__proxy'];
if (USE_PTHREADS && proxyingMode) {
var sig = LibraryManager.library[ident + '__sig'];
if (!sig) throw 'Missing function signature field "' + ident + '__sig"! (Using proxying mode requires specifying the signature of the function)';
sig = sig.replace(/f/g, 'i'); // TODO: Implement float signatures.
if (proxyingMode !== 'sync' && proxyingMode !== 'async') {
throw 'Invalid proxyingMode ' + ident + '__proxy: \'' + proxyingMode + '\' specified!';
}
var sync = proxyingMode === 'sync';
if (sig.length > 1) {
assert(typeof original === 'function');
var hasArgs = original.length > 0;
if (hasArgs) {
// If the function takes parameters, forward those to the proxied function call
var processedSnippet = snippet.replace(/function\s+(.*)?\s*\((.*?)\)\s*{/, 'function $1($2) {\nif (ENVIRONMENT_IS_PTHREAD) return _emscripten_proxy_to_main_thread_js(' + proxiedFunctionTable.length + ', ' + (+sync) + ', $2);');
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,9 +1686,6 @@ for (var x in SyscallsLibrary) {
if (typeof t === 'string') continue;
t = t.toString();
var pre = '', post = '';
#if USE_PTHREADS
pre += 'if (ENVIRONMENT_IS_PTHREAD) { return _emscripten_sync_run_in_main_thread_2({{{ cDefine("EM_PROXIED_SYSCALL") }}}, ' + which + ', varargs) }\n';
#endif
pre += 'SYSCALLS.varargs = varargs;\n';
#if SYSCALL_DEBUG
pre += "err('syscall! ' + [" + which + ", '" + SYSCALL_CODE_TO_NAME[which] + "']);\n";
Expand Down Expand Up @@ -1726,6 +1723,10 @@ for (var x in SyscallsLibrary) {
SyscallsLibrary[x] = eval('(' + t + ')');
if (!SyscallsLibrary[x + '__deps']) SyscallsLibrary[x + '__deps'] = [];
SyscallsLibrary[x + '__deps'].push('$SYSCALLS');
#if USE_PTHREADS
// proxy all syscalls synchronously, for their return values
SyscallsLibrary[x + '__proxy'] = 'sync';
#endif
}

#if USE_PTHREADS
Expand Down

0 comments on commit 68d9981

Please sign in to comment.