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
1 change: 0 additions & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ def is_supported_link_flag(f):
'getMemory',
'addRunDependency',
'removeRunDependency',
'calledRun',
]

if shared.Settings.USE_PTHREADS:
Expand Down
6 changes: 4 additions & 2 deletions src/base64Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Decodes a base64 string.
* @param {String} input The string to decode.
* @param {string} input The string to decode.
*/
var decodeBase64 = typeof atob === 'function' ? atob : function (input) {
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
Expand Down Expand Up @@ -46,11 +46,13 @@ function intArrayFromBase64(s) {
if (typeof ENVIRONMENT_IS_NODE === 'boolean' && ENVIRONMENT_IS_NODE) {
var buf;
try {
// TODO: Update Node.js externs, Closure does not recognize the following Buffer.from()
/**@suppress{checkTypes}*/
buf = Buffer.from(s, 'base64');
} catch (_) {
buf = new Buffer(s, 'base64');
}
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
return new Uint8Array(buf['buffer'], buf['byteOffset'], buf['byteLength']);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/closure-externs/node-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var Buffer = function(var_args) {};
* @param {ArrayBuffer|SharedArrayBuffer} arrayBuffer
* @param {number=} byteOffset
* @param {number=} length
* @return {buffer.Buffer}
* @return {nodeBuffer.Buffer}
* @nosideeffects
*/
Buffer.from = function(arrayBuffer, byteOffset, length) {};
14 changes: 13 additions & 1 deletion src/embind/embind.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var LibraryEmbind = {
the appropriate overload to call from an function overload table. This selector function is only used if multiple overloads are
actually registered, since it carries a slight performance penalty. */
$exposePublicSymbol__deps: ['$ensureOverloadTable', '$throwBindingError'],
$exposePublicSymbol__docs: '/** @param {number=} numArguments */',
$exposePublicSymbol: function(name, value, numArguments) {
if (Module.hasOwnProperty(name)) {
if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
Expand All @@ -150,6 +151,7 @@ var LibraryEmbind = {
},

$replacePublicSymbol__deps: ['$throwInternalError'],
$replacePublicSymbol__docs: '/** @param {number=} numArguments */',
$replacePublicSymbol: function(name, value, numArguments) {
if (!Module.hasOwnProperty(name)) {
throwInternalError('Replacing nonexistant public symbol');
Expand Down Expand Up @@ -298,6 +300,7 @@ var LibraryEmbind = {
'$awaitingDependencies', '$registeredTypes',
'$typeDependencies', '$throwBindingError',
'$whenDependentTypesAreResolved'],
$registerType__docs: '/** @param {Object=} options */',
$registerType: function(rawType, registeredInstance, options) {
options = options || {};

Expand Down Expand Up @@ -852,7 +855,7 @@ var LibraryEmbind = {
var heap = HEAPU32;
var size = heap[handle]; // in elements
var data = heap[handle + 1]; // byte offset into emscripten heap
return new TA(heap['buffer'], data, size);
return new TA(buffer, data, size);
}

name = readLatin1String(name);
Expand Down Expand Up @@ -1498,6 +1501,14 @@ var LibraryEmbind = {
RegisteredPointer.prototype['fromWireType'] = RegisteredPointer_fromWireType;
},

$RegisteredPointer__docs: `/** @constructor
@param {*=} pointeeType,
@param {*=} sharingPolicy,
@param {*=} rawGetPointee,
@param {*=} rawConstructor,
@param {*=} rawShare,
@param {*=} rawDestructor,
*/`,
$RegisteredPointer__deps: [
'$constNoSmartPtrRawPointerToWireType', '$genericPointerToWireType',
'$nonConstNoSmartPtrRawPointerToWireType', '$init_RegisteredPointer'],
Expand Down Expand Up @@ -1852,6 +1863,7 @@ var LibraryEmbind = {
}
},

$RegisteredClass__docs: '/** @constructor */',
$RegisteredClass: function(
name,
constructor,
Expand Down
2 changes: 1 addition & 1 deletion src/embind/emval.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ var LibraryEmVal = {
},

_emval_lookupTypes__deps: ['$requireRegisteredType'],
_emval_lookupTypes: function(argCount, argTypes, argWireTypes) {
_emval_lookupTypes: function(argCount, argTypes) {
var a = new Array(argCount);
for (var i = 0; i < argCount; ++i) {
a[i] = requireRegisteredType(
Expand Down
2 changes: 1 addition & 1 deletion src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ LibraryManager.library = {
#else // asm.js:
var newBuffer = new ArrayBuffer(size);
if (newBuffer.byteLength != size) return /*undefined, allocation did not succeed*/;
new Int8Array(newBuffer).set(HEAP8);
new Int8Array(newBuffer).set(/**@type{!Int8Array}*/(HEAP8));
_emscripten_replace_memory(newBuffer);
updateGlobalBufferAndViews(newBuffer);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ var LibraryJSEvents = {
emscripten_set_orientationchange_callback_on_thread__sig: 'iiiii',
emscripten_set_orientationchange_callback_on_thread__deps: ['_registerOrientationChangeEventCallback'],
emscripten_set_orientationchange_callback_on_thread: function(userData, useCapture, callbackfunc, targetThread) {
if (!screen || !screen.addEventListener) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
if (!screen || !screen['addEventListener']) return {{{ cDefine('EMSCRIPTEN_RESULT_NOT_SUPPORTED') }}};
__registerOrientationChangeEventCallback(screen, userData, useCapture, callbackfunc, {{{ cDefine('EMSCRIPTEN_EVENT_ORIENTATIONCHANGE') }}}, "orientationchange", targetThread);
return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
},
Expand Down
27 changes: 19 additions & 8 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,17 +892,24 @@ var SyscallsLibrary = {
__syscall150__nothrow: true,
__syscall150__proxy: false,
__syscall150__sig: 'iii',
__syscall150: '__syscall153', // mlock
__syscall150: function(addr, len) { // mlock
return 0;
},
__syscall151__nothrow: true,
__syscall151__proxy: false,
__syscall151__sig: 'iii',
__syscall151: '__syscall153', // munlock
__syscall151: function(addr, len) { // munlock
return 0;
},
__syscall152__nothrow: true,
__syscall152__proxy: false,
__syscall152__sig: 'iii',
__syscall152: '__syscall153', // mlockall
__syscall152__sig: 'ii',
__syscall152: function(flags) { // mlockall
return 0;
},
__syscall153__nothrow: true,
__syscall153__proxy: false,
__syscall153__sig: 'i',
__syscall153: function() { // munlockall
return 0;
},
Expand Down Expand Up @@ -983,11 +990,11 @@ var SyscallsLibrary = {
return 0;
},
__syscall195: function(path, buf) { // SYS_stat64
var path = SYSCALLS.getStr(path);
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.stat, path, buf);
},
__syscall196: function(path, buf) { // SYS_lstat64
var path = SYSCALLS.getStr(path);
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.lstat, path, buf);
},
__syscall197: function(fd, buf) { // SYS_fstat64
Expand Down Expand Up @@ -1194,7 +1201,7 @@ var SyscallsLibrary = {
return 0;
},
__syscall268: function(path, size, buf) { // statfs64
var path = SYSCALLS.getStr(path);
path = SYSCALLS.getStr(path);
#if ASSERTIONS
assert(size === {{{ C_STRUCTS.statfs.__size__ }}});
#endif
Expand Down Expand Up @@ -1735,7 +1742,11 @@ for (var x in SyscallsLibrary) {
}
#if SYSCALL_DEBUG
if (which && t.indexOf(', varargs') != -1) {
post += 'SYSCALLS.varargs = undefined;\n';
if (canThrow) {
post += 'finally { SYSCALLS.varargs = undefined; }\n';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we always emit a try if SYSCALL_DEBUG? (even if it's nothrow etc.?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, only if canThrow is enabled.

} else {
post += 'SYSCALLS.varargs = undefined;\n';
}
}
if (which) {
pre += "err('syscall! ' + [" + which + ", '" + SYSCALL_CODE_TO_NAME[which] + "']);\n";
Expand Down
4 changes: 1 addition & 3 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,7 @@ function isExportedByForceFilesystem(name) {
name === 'FS_unlink' ||
name === 'getMemory' ||
name === 'addRunDependency' ||
name === 'removeRunDependency' ||
name === 'calledRun';
name === 'removeRunDependency';
}

// export parts of the JS runtime that the user asked for
Expand Down Expand Up @@ -508,7 +507,6 @@ function exportRuntime() {
'ALLOC_STACK',
'ALLOC_DYNAMIC',
'ALLOC_NONE',
'calledRun',
];
if (ASSERTIONS) {
// check all exported things exist, warn about typos
Expand Down
5 changes: 2 additions & 3 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ function run(args) {
// or while the async setStatus time below was happening
if (calledRun) return;
calledRun = true;
#if 'calledRun' in EXPORTED_RUNTIME_METHODS_SET
Module['calledRun'] = true;
#endif

if (ABORT) return;

Expand Down Expand Up @@ -374,10 +372,11 @@ function checkUnflushedContent() {
try { // it doesn't matter if it fails
#if SYSCALLS_REQUIRE_FILESYSTEM == 0
var flush = {{{ '$flush_NO_FILESYSTEM' in addedLibraryItems ? 'flush_NO_FILESYSTEM' : 'null' }}};
if (flush) flush();
#else
var flush = Module['_fflush'];
#endif
if (flush) flush(0);
#endif
#if '$FS' in addedLibraryItems && '$TTY' in addedLibraryItems
// also flush in the JS FS layer
['stdout', 'stderr'].forEach(function(name) {
Expand Down
5 changes: 5 additions & 0 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ function getCFunc(ident) {
}

// C calling interface.
/** @param {Array=} argTypes
@param {Arguments|Array=} args
@param {Object=} opts */
function ccall(ident, returnType, argTypes, args, opts) {
// For fast lookup of conversion functions
var toC = {
Expand Down Expand Up @@ -189,6 +192,8 @@ function ccall(ident, returnType, argTypes, args, opts) {
return ret;
}

/** @param {Array=} argTypes
@param {Object=} opts */
function cwrap(ident, returnType, argTypes, opts) {
#if !ASSERTIONS
argTypes = argTypes || [];
Expand Down
14 changes: 11 additions & 3 deletions src/runtime_safe_heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// In MINIMAL_RUNTIME, setValue() and getValue() are only available when building with safe heap enabled, for heap safety checking.
// In traditional runtime, setValue() and getValue() are always available (although their use is highly discouraged due to perf penalties)

/** @type {function(number, number, string, boolean=)} */
/** @param {number} ptr
@param {number} value
@param {string} type
@param {number|boolean=} noSafe */
function setValue(ptr, value, type, noSafe) {
type = type || 'i8';
if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
Expand Down Expand Up @@ -35,7 +38,9 @@ function setValue(ptr, value, type, noSafe) {
#endif
}

/** @type {function(number, string, boolean=)} */
/** @param {number} ptr
@param {string} type
@param {number|boolean=} noSafe */
function getValue(ptr, type, noSafe) {
type = type || 'i8';
if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit
Expand Down Expand Up @@ -72,6 +77,7 @@ function getValue(ptr, type, noSafe) {


#if SAFE_HEAP
/** @param {number|boolean=} isFloat */
function getSafeHeapType(bytes, isFloat) {
switch (bytes) {
case 1: return 'i8';
Expand All @@ -86,6 +92,7 @@ function getSafeHeapType(bytes, isFloat) {
var SAFE_HEAP_COUNTER = 0;
#endif

/** @param {number|boolean=} isFloat */
function SAFE_HEAP_STORE(dest, value, bytes, isFloat) {
#if SAFE_HEAP_LOG
out('SAFE_HEAP store: ' + [dest, value, bytes, isFloat, SAFE_HEAP_COUNTER++]);
Expand All @@ -101,6 +108,7 @@ function SAFE_HEAP_STORE_D(dest, value, bytes) {
SAFE_HEAP_STORE(dest, value, bytes, true);
}

/** @param {number|boolean=} isFloat */
function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) {
if (dest <= 0) abort('segmentation fault loading ' + bytes + ' bytes from address ' + dest);
if (dest % bytes !== 0) abort('alignment error loading from address ' + dest + ', which was expected to be aligned to a multiple of ' + bytes);
Expand All @@ -109,7 +117,7 @@ function SAFE_HEAP_LOAD(dest, bytes, unsigned, isFloat) {
assert(HEAP32[DYNAMICTOP_PTR>>2] <= HEAP8.length);
var type = getSafeHeapType(bytes, isFloat);
var ret = getValue(dest, type, 1);
if (unsigned) ret = unSign(ret, parseInt(type.substr(1)), 1);
if (unsigned) ret = unSign(ret, parseInt(type.substr(1), 10), 1);
#if SAFE_HEAP_LOG
out('SAFE_HEAP load: ' + [dest, ret, bytes, isFloat, unsigned, SAFE_HEAP_COUNTER++]);
#endif
Expand Down
1 change: 1 addition & 0 deletions tests/Module-exports/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* prevents the runtime exiting. This is necessary as otherwise things like
* printf don't seem to work from methods called by JavaScript.
*/
/** @suppress{checkTypes} */
Module = {
'noExitRuntime' : true
};
1 change: 1 addition & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,7 @@ def test_files(self):
print('base', self.emcc_args)

create_test_file('pre.js', '''
/** @suppress{checkTypes}*/
Module = {
'noFSInit': true,
'preRun': function() {
Expand Down
Loading