This commit is contained in:
Alon Zakai 2015-07-30 17:12:57 -07:00
Родитель 03ebf6fc59
Коммит 50f7b19f20
2 изменённых файлов: 6 добавлений и 2 удалений

2
emcc
Просмотреть файл

@ -1820,7 +1820,7 @@ try {
if shared.Settings.WASM:
logging.debug('converting to WebAssembly')
wasm_target = unsuffixed(js_target) + '.wasm'
subprocess.check_call([shared.PYTHON, shared.path_from_root('third_party', 'wasm-polyfill', 'wasmator.py'), js_target, wasm_target])
subprocess.check_call([shared.PYTHON, shared.path_from_root('third_party', 'wasm-polyfill', 'wasmator.py'), js_target, wasm_target, shared.Settings.EXPORT_NAME])
log_time('final emitting')

6
third_party/wasm-polyfill/wasmator.py поставляемый
Просмотреть файл

@ -30,6 +30,7 @@ import shared as emscripten
jsfile = sys.argv[1]
wasmfile = sys.argv[2]
export_name = sys.argv[3]
tempfile = jsfile + '.temp.js'
tempfile2 = jsfile + '.temp2.js'
@ -86,17 +87,20 @@ function runEmscriptenModule(Module, unwasmed_) {
''' + patched + '''
return Module;
}
''' + open(path_in_polyfill('jslib', 'load-wasm.js')).read() + '''
// note: web worker messages must be queued, as we delay the scripts chance to listen to them
var ''' + export_name + ''';
loadWebAssembly("''' + wasmfile + '''", 'load-wasm-worker.js').then(function(unwasmed) {
if (typeof importScripts === 'function') {
onmessage = null;
}
runEmscriptenModule(typeof Module !== 'undefined' ? Module : {}, unwasmed);
''' + export_name + ''' = runEmscriptenModule(typeof Module !== 'undefined' ? Module : {}, unwasmed);
if (typeof importScripts === 'function' && onmessage) {
queuedMessages.forEach(function(e) {
onmessage(e);