Commit 141a4ebc authored by Jacob Durrant's avatar Jacob Durrant
Browse files

Mock vina params now mostly alphabetized.

parent e1a006ca
/**
* Webina Copyright 2019 Jacob Durrant
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file is part of Webina, released under the Apache 2.0 License. See
// LICENSE.md or go to https://opensource.org/licenses/Apache-2.0 for full
// details. Copyright 2019 Jacob D. Durrant.
// There are a few variables and functions from vina.js that I want to easily
// access from here.
var VERSION = "1.0.0"; // Replaced by compile script.
console.log("Webina JavaScript Library " + VERSION);
var WEBINA_Module;
// A shiv for decodeBase64.
var decodeBase64 = "function" == typeof atob ? atob : function (r) {
var e, t, a, i, n, o, f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", m = "", s = 0;
for (r = r.replace(/[^A-Za-z0-9\+\/\=]/g, ""); e = f.indexOf(r.charAt(s++)) << 2 | (i = f.indexOf(r.charAt(s++))) >> 4, t = (15 & i) << 4 | (n = f.indexOf(r.charAt(s++))) >> 2, a = (3 & n) << 6 | (o = f.indexOf(r.charAt(s++))), m += String.fromCharCode(e), 64 !== n && (m += String.fromCharCode(t)), 64 !== o && (m += String.fromCharCode(a)), s < r.length;)
return m;
};
// Make Webina global namespace.
var Webina = (function () {
return {
WEBINA_ENVIRONMENT_IS_NODE: window["WEBINA_ENVIRONMENT_IS_NODE"],
WEBINA_lengthBytesUTF8: window["WEBINA_lengthBytesUTF8"],
WEBINA_stringToUTF8Array: window["WEBINA_stringToUTF8Array"],
WEBINA_assert: window["WEBINA_assert"],
WEBINA_ASSERTIONS: 1,
WEBINA_DATA_URI_PREFIX: "data:application/octet-stream;base64,",
WEBINA_BASE_URL: "./",
FS: window["FS"],
start: function start(vinaParams, receptorPDBQTTxt, ligandPDBQTTxt, onDone, onError, baseUrl) {
var _this = this;
// baseUrl = undefined; // For debugging.
var baseUrlMsg = "\nWEBINA\n======\n\n";
if (baseUrl !== undefined) {
if (baseUrl.slice(baseUrl.length - 1) !== "/") {
baseUrl += "/";
}
this.WEBINA_BASE_URL = baseUrl;
baseUrlMsg += "User specified baseUrl: " + baseUrl + "\n";
}
else {
baseUrlMsg += "No baseUrl specified, so using ./\n\n";
baseUrlMsg += "Use Webina.start() to specify the baseUrl:\n";
baseUrlMsg += " function start(vinaParams, receptorPDBQTTxt, \n";
baseUrlMsg += " ligandPDBQTTxt, onDone, \n";
baseUrlMsg += " onError, baseUrl)\n";
}
baseUrlMsg += "\nExpecting files at the following locations:\n";
for (var i = 0; i < 5; i++) {
var fileName = ["Webina.min.js", "vina.html.mem",
"vina.min.js", "vina.worker.min.js",
"vina.wasm"][i];
baseUrlMsg += " " + (baseUrl === undefined ? "./" : baseUrl) + fileName + "\n";
}
baseUrlMsg += "\n";
if (baseUrl !== undefined) {
console.log(baseUrlMsg);
}
else {
console.warn(baseUrlMsg);
}
if (onError === undefined) {
onError = function () {
console.log("Webina encountered an error! Does your browser support WebAssembly?");
};
}
// Create a module object for WASM.
WEBINA_Module = {
"preRun": [],
"postRun": [],
"stdOut": "",
"stdErr": "",
"print": function () {
return function (e) {
1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")),
window["WEBINA_Module"]["stdOut"] += e + "\n";
};
}(),
"printErr": function (e) {
// 1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")), console.error(e)
1 < arguments.length && (e = Array.prototype.slice.call(arguments).join(" ")),
window["WEBINA_Module"]["stdErr"] += e + "\n";
},
"setStatus": function (e) {
if (e === "") {
// This happens when it is done running.
if (onDone !== undefined) {
var outTxt = new TextDecoder("utf-8").decode(window["FS"]["readFile"]('ligand_out.pdbqt'));
var stdOut = window["WEBINA_Module"]["stdOut"];
var stdErr = window["WEBINA_Module"]["stdErr"];
onDone(outTxt, stdOut, stdErr);
}
}
},
"onError": onError,
"catchError": function (n) {
onError(n);
// throw n; // Don't throw the errr. You're catching it now.
},
"receptorPDBQTTxt": receptorPDBQTTxt,
"ligandPDBQTTxt": ligandPDBQTTxt
};
if (vinaParams["receptor"] !== undefined) {
console.warn("Webina does not support Vina's --receptor parameter. Instead, pass the content of the receptor file as a string to the webina.start() function.");
}
if (vinaParams["receptor"] !== undefined) {
console.warn("Webina does not support Vina's --ligand parameter. Instead, pass the content of the ligand file as a string to the webina.start() function.");
}
// Receptor and ligand files are always the same.
WEBINA_Module['arguments'] = [
'--receptor', '/receptor.pdbqt',
'--ligand', '/ligand.pdbqt',
];
// For some reason, WebAssembly always uses one more processor
// than specified. Compensate for that here. But sometimes it
// doesn't, so commenting out... Confusing.
// if ((vinaParams["cpu"] !== undefined) && (vinaParams["cpu"] > 1)) {
// vinaParams["cpu"] = vinaParams["cpu"] - 1;
// }
// Add in the remaining values. Note that there is no validation here.
var paramNames = Object.keys(vinaParams);
var paramNamesLen = paramNames.length;
for (var i = 0; i < paramNamesLen; i++) {
var key = paramNames[i];
var val = vinaParams[key];
WEBINA_Module['arguments'].push('--' + key);
if (typeof (val) !== "boolean") {
WEBINA_Module['arguments'].push(String(val));
}
}
window["WEBINA_Module"] = WEBINA_Module;
// Initialize the memory
var memoryInitializer = this.WEBINA_BASE_URL + "vina.html.mem";
memoryInitializer = WEBINA_Module["locateFile"] ? WEBINA_Module["locateFile"](memoryInitializer, "") : memoryInitializer, WEBINA_Module["memoryInitializerRequestURL"] = memoryInitializer;
var meminitXHR = WEBINA_Module["memoryInitializerRequest"] = new XMLHttpRequest;
meminitXHR.onloadend = function () {
if (meminitXHR.status === 404) {
var msg = "Unable to access " + memoryInitializer + ". See JavaScript console for warnings. The \"baseUrl\" variable passed to Webina is likely incorrect.";
WEBINA_Module["catchError"]({ "message": msg });
console.warn(msg);
}
else {
var script = document.createElement("script");
script.src = _this.WEBINA_BASE_URL + "vina.js";
document.body.appendChild(script);
}
};
meminitXHR.open("GET", memoryInitializer, !0);
meminitXHR.responseType = "arraybuffer";
meminitXHR.send(null);
},
isDataURI: function (r) {
return String.prototype.startsWith ? r.startsWith(this.WEBINA_DATA_URI_PREFIX) : 0 === r.indexOf(this.WEBINA_DATA_URI_PREFIX);
},
intArrayFromBase64: function (e) {
if ("boolean" == typeof this.WEBINA_ENVIRONMENT_IS_NODE && this.WEBINA_ENVIRONMENT_IS_NODE) {
var t;
try {
t = Buffer.from(e, "base64");
}
catch (r) {
t = new Buffer(e, "base64");
}
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
}
try {
for (var r = decodeBase64(e), a = new Uint8Array(r.length), i = 0; i < r.length; ++i)
a[i] = r.charCodeAt(i);
return a;
}
catch (r) {
throw new Error("Converting base64 string to bytes failed.");
}
},
// Not used?
tryParseAsDataURI: function (r) {
if (this.isDataURI(r))
return this.intArrayFromBase64(r.slice(this.WEBINA_DATA_URI_PREFIX.length));
},
// Not used?
intArrayFromString: function (r, e, t) {
var a = 0 < t ? t : this.WEBINA_lengthBytesUTF8(r) + 1, i = new Array(a), n = this.WEBINA_stringToUTF8Array(r, i, 0, i.length);
return e && (i.length = n), i;
},
// Not used?
intArrayToString: function (r) {
for (var e = [], t = 0; t < r.length; t++) {
var a = r[t];
255 < a && (this.WEBINA_ASSERTIONS && this.WEBINA_assert(!1, "Character code " + a + " (" + String.fromCharCode(a) + ") at offset " + t + " not in 0x00-0xFF."), a &= 255), e.push(String.fromCharCode(a));
}
return e.join("");
}
};
})();
/**
* Webina Copyright 2019 Jacob Durrant
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var c=0;return function(){return c<a.length?{done:!1,value:a[c++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};
$jscomp.SymbolClass=function(a,c){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:c})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};$jscomp.Symbol=function(){function a(b){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(b||"")+"_"+c++,b)}var c=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};
$jscomp.iteratorFromArray=function(a,c){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var b=0,d={next:function(){if(b<a.length){var e=b++;return{value:c(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};
$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in b||(b[e]={});b=b[e]}a=a[a.length-1];d=b[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:c})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6","es3");var VERSION="1.0.0";console.log("Webina JavaScript Library "+VERSION);
var WEBINA_Module,decodeBase64="function"==typeof atob?atob:function(a){var c,b,d,e,f,m,g="",h=0;for(a=a.replace(/[^A-Za-z0-9\+\/=]/g,"");c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++))<<2|(e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)))>>4,b=(15&e)<<4|(f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)))>>2,d=(3&f)<<6|(m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++))),
g+=String.fromCharCode(c),64!==f&&(g+=String.fromCharCode(b)),64!==m&&(g+=String.fromCharCode(d)),h<a.length;)return g},Webina=function(){return{WEBINA_ENVIRONMENT_IS_NODE:window.WEBINA_ENVIRONMENT_IS_NODE,WEBINA_lengthBytesUTF8:window.WEBINA_lengthBytesUTF8,WEBINA_stringToUTF8Array:window.WEBINA_stringToUTF8Array,WEBINA_assert:window.WEBINA_assert,WEBINA_ASSERTIONS:1,WEBINA_DATA_URI_PREFIX:"data:application/octet-stream;base64,",WEBINA_BASE_URL:"./",FS:window.FS,start:function(a,c,b,d,e,f){var m=
this,g="\nWEBINA\n======\n\n";void 0!==f?("/"!==f.slice(f.length-1)&&(f+="/"),this.WEBINA_BASE_URL=f,g+="User specified baseUrl: "+f+"\n"):g+="No baseUrl specified, so using ./\n\nUse Webina.start() to specify the baseUrl:\n function start(vinaParams, receptorPDBQTTxt, \n ligandPDBQTTxt, onDone, \n onError, baseUrl)\n";g+="\nExpecting files at the following locations:\n";for(var h=0;5>h;h++)g+=" "+(void 0===f?"./":f)+["Webina.min.min.js","vina.html.mem","vina.min.min.js",
"vina.worker.min.min.js","vina.wasm"][h]+"\n";g+="\n";void 0!==f?console.log(g):console.warn(g);void 0===e&&(e=function(){console.log("Webina encountered an error! Does your browser support WebAssembly?")});WEBINA_Module={preRun:[],postRun:[],stdOut:"",stdErr:"",print:function(){return function(a){1<arguments.length&&(a=Array.prototype.slice.call(arguments).join(" "));window.WEBINA_Module.stdOut+=a+"\n"}}(),printErr:function(a){1<arguments.length&&(a=Array.prototype.slice.call(arguments).join(" "));window.WEBINA_Module.stdErr+=
a+"\n"},setStatus:function(a){""===a&&void 0!==d&&(a=(new TextDecoder("utf-8")).decode(window.FS.readFile("ligand_out.pdbqt")),d(a,window.WEBINA_Module.stdOut,window.WEBINA_Module.stdErr))},onError:e,catchError:function(a){e(a)},receptorPDBQTTxt:c,ligandPDBQTTxt:b};void 0!==a.receptor&&console.warn("Webina does not support Vina's --receptor parameter. Instead, pass the content of the receptor file as a string to the webina.start() function.");void 0!==a.receptor&&console.warn("Webina does not support Vina's --ligand parameter. Instead, pass the content of the ligand file as a string to the webina.start() function.");
WEBINA_Module.arguments=["--receptor","/receptor.pdbqt","--ligand","/ligand.pdbqt"];c=Object.keys(a);b=c.length;for(h=0;h<b;h++)f=c[h],g=a[f],WEBINA_Module.arguments.push("--"+f),"boolean"!==typeof g&&WEBINA_Module.arguments.push(String(g));window.WEBINA_Module=WEBINA_Module;var k=this.WEBINA_BASE_URL+"vina.html.mem";k=WEBINA_Module.locateFile?WEBINA_Module.locateFile(k,""):k;WEBINA_Module.memoryInitializerRequestURL=k;var l=WEBINA_Module.memoryInitializerRequest=new XMLHttpRequest;l.onloadend=function(){if(404===
l.status){var a="Unable to access "+k+'. See JavaScript console for warnings. The "baseUrl" variable passed to Webina is likely incorrect.';WEBINA_Module.catchError({message:a});console.warn(a)}else a=document.createElement("script"),a.src=m.WEBINA_BASE_URL+"vina.min.js",document.body.appendChild(a)};l.open("GET",k,!0);l.responseType="arraybuffer";l.send(null)},isDataURI:function(a){return String.prototype.startsWith?a.startsWith(this.WEBINA_DATA_URI_PREFIX):0===a.indexOf(this.WEBINA_DATA_URI_PREFIX)},
intArrayFromBase64:function(a){if("boolean"==typeof this.WEBINA_ENVIRONMENT_IS_NODE&&this.WEBINA_ENVIRONMENT_IS_NODE){try{var c=Buffer.from(a,"base64")}catch(e){c=new Buffer(a,"base64")}return new Uint8Array(c.buffer,c.byteOffset,c.byteLength)}try{var b=decodeBase64(a),d=new Uint8Array(b.length);for(a=0;a<b.length;++a)d[a]=b.charCodeAt(a);return d}catch(e){throw Error("Converting base64 string to bytes failed.");}},tryParseAsDataURI:function(a){if(this.isDataURI(a))return this.intArrayFromBase64(a.slice(this.WEBINA_DATA_URI_PREFIX.length))},
intArrayFromString:function(a,c,b){b=0<b?b:this.WEBINA_lengthBytesUTF8(a)+1;b=Array(b);a=this.WEBINA_stringToUTF8Array(a,b,0,b.length);return c&&(b.length=a),b},intArrayToString:function(a){for(var c=[],b=0;b<a.length;b++){var d=a[b];255<d&&(this.WEBINA_ASSERTIONS&&this.WEBINA_assert(!1,"Character code "+d+" ("+String.fromCharCode(d)+") at offset "+b+" not in 0x00-0xFF."),d&=255);c.push(String.fromCharCode(d))}return c.join("")}}}();
This diff is collapsed.
This diff is collapsed.
// Copyright 2015 The Emscripten Authors. All rights reserved.
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.
// Pthread Web Worker startup routine:
// This is the entry point file that is loaded first by each Web Worker
// that executes pthreads on the Emscripten application.
// Thread-local:
var threadInfoStruct = 0; // Info area for this thread in Emscripten HEAP (shared). If zero, this worker is not currently hosting an executing pthread.
var selfThreadId = 0; // The ID of this thread. 0 if not hosting a pthread.
var parentThreadId = 0; // The ID of the parent pthread that launched this thread.
var tempDoublePtr = 0; // A temporary memory area for global float and double marshalling operations.
// Thread-local: Each thread has its own allocated stack space.
var STACK_BASE = 0;
var STACKTOP = 0;
var STACK_MAX = 0;
// These are system-wide memory area parameters that are set at main runtime startup in main thread, and stay constant throughout the application.
var buffer; // All pthreads share the same Emscripten HEAP as SharedArrayBuffer with the main execution thread.
var DYNAMICTOP_PTR = 0;
var DYNAMIC_BASE = 0;
var noExitRuntime;
var PthreadWorkerInit = {};
// performance.now() is specced to return a wallclock time in msecs since that Web Worker/main thread launched. However for pthreads this can cause
// subtle problems in emscripten_get_now() as this essentially would measure time from pthread_create(), meaning that the clocks between each threads
// would be wildly out of sync. Therefore sync all pthreads to the clock on the main browser thread, so that different threads see a somewhat
// coherent clock across each of them (+/- 0.1msecs in testing)
var __performance_now_clock_drift = 0;
// Cannot use console.log or console.error in a web worker, since that would risk a browser deadlock! https://bugzilla.mozilla.org/show_bug.cgi?id=1049091
// Therefore implement custom logging facility for threads running in a worker, which queue the messages to main thread to print.
var WEBINA_Module = {};
// These modes need to assign to these variables because of how scoping works in them.
function WEBINA_assert(condition, text) {
if (!condition) abort('Assertion failed: ' + text);
}
// When error objects propagate from Web Worker to main thread, they lose helpful call stack and thread ID information, so print out errors early here,
// before that happens.
this.addEventListener('error', function(e) {
if (e.message.indexOf('SimulateInfiniteLoop') != -1) return e.preventDefault();
var errorSource = ' in ' + e.filename + ':' + e.lineno + ':' + e.colno;
console.error('Pthread ' + selfThreadId + ' uncaught exception' + (e.filename || e.lineno || e.colno ? errorSource : "") + ': ' + e.message + '. Error object:');
console.error(e.error);
});
function threadPrintErr() {
var text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
console.error(new Error().stack);
}
function threadAlert() {
var text = Array.prototype.slice.call(arguments).join(' ');
postMessage({cmd: 'alert', text: text, threadId: selfThreadId});
}
var err = threadPrintErr;
this.alert = threadAlert;
// When using postMessage to send an object, it is processed by the structured clone algorithm.
// The prototype, and hence methods, on that object is then lost. This function adds back the lost prototype.
// This does not work with nested objects that has prototypes, but it suffices for WasmSourceMap and WasmOffsetConverter.
function resetPrototype(constructor, attrs) {
var object = Object.create(constructor.prototype);
for (var key in attrs) {
if (attrs.hasOwnProperty(key)) {
object[key] = attrs[key];
}
}
return object;
}
WEBINA_Module['instantiateWasm'] = function(info, receiveInstance) {
// Instantiate from the module posted from the main thread.
// We can just use sync instantiation in the worker.
var instance = new WebAssembly.Instance(wasmModule, info);
// We don't need the module anymore; new threads will be spawned from the main thread.
wasmModule = null;
receiveInstance(instance); // The second 'module' parameter is intentionally null here, we don't need to keep a ref to the WEBINA_Module object from here.
return instance.exports;
};
var wasmModule;
var wasmMemory;
this.onmessage = function(e) {
try {
if (e.data.cmd === 'load') { // Preload command that is called once per worker to parse and load the Emscripten code.
// Initialize the thread-local field(s):
tempDoublePtr = e.data.tempDoublePtr;
// Initialize the global "process"-wide fields:
DYNAMIC_BASE = e.data.DYNAMIC_BASE;
DYNAMICTOP_PTR = e.data.DYNAMICTOP_PTR;
// The Wasm module will have import fields for STACKTOP and STACK_MAX. At 'load' stage of Worker startup, we are just
// spawning this Web Worker to act as a host for future created pthreads, i.e. we do not have a pthread to start up here yet.
// (A single Worker can also host multiple pthreads throughout its lifetime, shutting down a pthread will not shut down its hosting Worker,
// but the Worker is reused for later spawned pthreads). The 'run' stage below will actually start running a pthread.
// The stack space for a pthread is allocated and deallocated when a pthread is actually run, not yet at Worker 'load' stage.
// However, the WebAssembly module we are loading up here has import fields for STACKTOP and STACK_MAX, which it needs to get filled in
// immediately at Wasm WEBINA_Module instantiation time. The values of these will not get used until pthread is actually running some code, so
// we'll proceed to set up temporary invalid values for these fields for import purposes. Then whenever a pthread is launched at 'run' stage
// below, these values are rewritten to establish proper stack area for the particular pthread.
WEBINA_Module['STACK_MAX'] = WEBINA_Module['STACKTOP'] = 0x7FFFFFFF;
// WEBINA_Module and memory were sent from main thread
wasmModule = e.data.wasmModule;
wasmMemory = e.data.wasmMemory;
buffer = wasmMemory.buffer;
PthreadWorkerInit = e.data.PthreadWorkerInit;
WEBINA_Module['ENVIRONMENT_IS_PTHREAD'] = true;
if (typeof e.data.urlOrBlob === 'string') {
importScripts(e.data.urlOrBlob);
} else {
var objectUrl = URL.createObjectURL(e.data.urlOrBlob);
importScripts(objectUrl);
URL.revokeObjectURL(objectUrl);
}
if (typeof FS !== 'undefined' && typeof FS.createStandardStreams === 'function') FS.createStandardStreams();
postMessage({ cmd: 'loaded' });
} else if (e.data.cmd === 'objectTransfer') {
PThread.receiveObjectTransfer(e.data);
} else if (e.data.cmd === 'run') { // This worker was idle, and now should start executing its pthread entry point.
__performance_now_clock_drift = performance.now() - e.data.time; // Sync up to the clock of the main thread.
threadInfoStruct = e.data.threadInfoStruct;
__register_pthread_ptr(threadInfoStruct, /*isMainBrowserThread=*/0, /*isMainRuntimeThread=*/0); // Pass the thread address inside the asm.js scope to store it for fast access that avoids the need for a FFI out.
selfThreadId = e.data.selfThreadId;
parentThreadId = e.data.parentThreadId;
// Establish the stack frame for this thread in global scope
var max = e.data.stackBase + e.data.stackSize;
var top = e.data.stackBase;
STACK_BASE = top;
STACKTOP = top;
STACK_MAX = max;
WEBINA_assert(threadInfoStruct);
WEBINA_assert(selfThreadId);
WEBINA_assert(parentThreadId);
WEBINA_assert(STACK_BASE != 0);
WEBINA_assert(max > e.data.stackBase);
WEBINA_assert(max > top);
WEBINA_assert(e.data.stackBase === top);
// Call inside asm.js/wasm module to set up the stack frame for this pthread in asm.js/wasm module scope
WEBINA_Module['establishStackSpace'](e.data.stackBase, e.data.stackBase + e.data.stackSize);
writeStackCookie();
PThread.receiveObjectTransfer(e.data);
PThread.setThreadStatus(_pthread_self(), 1/*EM_THREAD_STATUS_RUNNING*/);
try {
// pthread entry points are always of signature 'void *ThreadMain(void *arg)'
// Native codebases sometimes spawn threads with other thread entry point signatures,
// such as void ThreadMain(void *arg), void *ThreadMain(), or void ThreadMain().
// That is not acceptable per C/C++ specification, but x86 compiler ABI extensions
// enable that to work. If you find the following line to crash, either change the signature
// to "proper" void *ThreadMain(void *arg) form, or try linking with the Emscripten linker
// flag -s EMULATE_FUNCTION_POINTER_CASTS=1 to add in emulation for this x86 ABI extension.
var result = WEBINA_Module['dynCall_ii'](e.data.start_routine, e.data.arg);
checkStackCookie();
} catch(e) {
if (e === 'Canceled!') {
PThread.threadCancel();
return;
} else if (e === 'SimulateInfiniteLoop' || e === 'pthread_exit') {
return;
} else {
Atomics.store(HEAPU32, (threadInfoStruct + 4 /*C_STRUCTS.pthread.threadExitCode*/ ) >> 2, (e instanceof ExitStatus) ? e.status : -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/);
Atomics.store(HEAPU32, (threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/ ) >> 2, 1); // Mark the thread as no longer running.
if (typeof(_emscripten_futex_wake) !== "function") {
err("Thread Initialisation failed.");
throw e;
}
_emscripten_futex_wake(threadInfoStruct + 0 /*C_STRUCTS.pthread.threadStatus*/, 0x7FFFFFFF/*INT_MAX*/); // Wake all threads waiting on this thread to finish.
if (!(e instanceof ExitStatus)) throw e;
}
}
// The thread might have finished without calling pthread_exit(). If so, then perform the exit operation ourselves.
// (This is a no-op if explicit pthread_exit() had been called prior.)
if (!noExitRuntime) PThread.threadExit(result);
} else if (e.data.cmd === 'cancel') { // Main thread is asking for a pthread_cancel() on this thread.
if (threadInfoStruct && PThread.thisThreadCancelState == 0/*PTHREAD_CANCEL_ENABLE*/) {
PThread.threadCancel();
}
} else if (e.data.target === 'setimmediate') {
// no-op
} else if (e.data.cmd === 'processThreadQueue') {
if (threadInfoStruct) { // If this thread is actually running?
_emscripten_current_thread_process_queued_calls();
}
} else {
err('worker.js received unknown command ' + e.data.cmd);
console.error(e.data);
}
} catch(e) {
console.error('worker.js onmessage() captured an uncaught exception: ' + e);
console.error(e.stack);
throw e;
}
};
var threadInfoStruct=0,selfThreadId=0,parentThreadId=0,tempDoublePtr=0,STACK_BASE=0,STACKTOP=0,STACK_MAX=0,buffer,DYNAMICTOP_PTR=0,DYNAMIC_BASE=0,noExitRuntime,PthreadWorkerInit={},__performance_now_clock_drift=0,WEBINA_Module={};function WEBINA_assert(a,b){a||abort("Assertion failed: "+b)}
this.addEventListener("error",function(a){if(-1!=a.message.indexOf("SimulateInfiniteLoop"))return a.preventDefault();var b=" in "+a.filename+":"+a.lineno+":"+a.colno;console.error("Pthread "+selfThreadId+" uncaught exception"+(a.filename||a.lineno||a.colno?b:"")+": "+a.message+". Error object:");console.error(a.error)});function threadPrintErr(){var a=Array.prototype.slice.call(arguments).join(" ");console.error(a);console.error(Error().stack)}
function threadAlert(){var a=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:a,threadId:selfThreadId})}var err=threadPrintErr;this.alert=threadAlert;function resetPrototype(a,b){a=Object.create(a.prototype);for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return a}WEBINA_Module.instantiateWasm=function(a,b){a=new WebAssembly.Instance(wasmModule,a);wasmModule=null;b(a);return a.exports};var wasmModule,wasmMemory;
this.onmessage=function(a){try{if("load"===a.data.cmd){tempDoublePtr=a.data.tempDoublePtr;DYNAMIC_BASE=a.data.DYNAMIC_BASE;DYNAMICTOP_PTR=a.data.DYNAMICTOP_PTR;WEBINA_Module.STACK_MAX=WEBINA_Module.STACKTOP=2147483647;wasmModule=a.data.wasmModule;wasmMemory=a.data.wasmMemory;buffer=wasmMemory.buffer;PthreadWorkerInit=a.data.PthreadWorkerInit;WEBINA_Module.ENVIRONMENT_IS_PTHREAD=!0;if("string"===typeof a.data.urlOrBlob)importScripts(a.data.urlOrBlob);else{var b=URL.createObjectURL(a.data.urlOrBlob);
importScripts(b);URL.revokeObjectURL(b)}"undefined"!==typeof FS&&"function"===typeof FS.createStandardStreams&&FS.createStandardStreams();postMessage({cmd:"loaded"})}else if("objectTransfer"===a.data.cmd)PThread.receiveObjectTransfer(a.data);else if("run"===a.data.cmd){__performance_now_clock_drift=performance.now()-a.data.time;threadInfoStruct=a.data.threadInfoStruct;__register_pthread_ptr(threadInfoStruct,0,0);selfThreadId=a.data.selfThreadId;parentThreadId=a.data.parentThreadId;var d=a.data.stackBase+
a.data.stackSize,e=a.data.stackBase;STACKTOP=STACK_BASE=e;STACK_MAX=d;WEBINA_assert(threadInfoStruct);WEBINA_assert(selfThreadId);WEBINA_assert(parentThreadId);WEBINA_assert(0!=STACK_BASE);WEBINA_assert(d>a.data.stackBase);WEBINA_assert(d>e);WEBINA_assert(a.data.stackBase===e);WEBINA_Module.establishStackSpace(a.data.stackBase,a.data.stackBase+a.data.stackSize);writeStackCookie();PThread.receiveObjectTransfer(a.data);PThread.setThreadStatus(_pthread_self(),1);try{var f=WEBINA_Module.dynCall_ii(a.data.start_routine,
a.data.arg);checkStackCookie()}catch(c){if("Canceled!"===c){PThread.threadCancel();return}if("SimulateInfiniteLoop"===c||"pthread_exit"===c)return;Atomics.store(HEAPU32,threadInfoStruct+4>>2,c instanceof ExitStatus?c.status:-2);Atomics.store(HEAPU32,threadInfoStruct+0>>2,1);if("function"!==typeof _emscripten_futex_wake)throw err("Thread Initialisation failed."),c;_emscripten_futex_wake(threadInfoStruct+0,2147483647);if(!(c instanceof ExitStatus))throw c;}noExitRuntime||PThread.threadExit(f)}else"cancel"===
a.data.cmd?threadInfoStruct&&0==PThread.thisThreadCancelState&&PThread.threadCancel():"setimmediate"!==a.data.target&&("processThreadQueue"===a.data.cmd?threadInfoStruct&&_emscripten_current_thread_process_queued_calls():(err("worker.min.js received unknown command "+a.data.cmd),console.error(a.data)))}catch(c){throw console.error("worker.min.js onmessage() captured an uncaught exception: "+c),console.error(c.stack),c;}};
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Webina</title>
<link rel="shortcut icon" href="favicon.ico"><link href="vendors.a60461f7d6b6cc0ca2d6.1.css" rel="stylesheet"><link href="styles.a60461f7d6b6cc0ca2d6.3.css" rel="stylesheet"></head>
<link rel="shortcut icon" href="favicon.ico"><link href="vendors.fcf47e43952982c9dca9.vendors.css" rel="stylesheet"><link href="styles.css.fcf47e43952982c9dca9.styles.css.css" rel="stylesheet"></head>
<body>
<div id="app"></div>
......@@ -19,6 +19,6 @@
<script src="vue.min.js"></script>
<script src="vuex.min.js"></script>
<script src="bootstrap-vue.min.js"></script>
<script type="text/javascript" src="runtime.a60461f7d6b6cc0ca2d6.js"></script><script type="text/javascript" src="vendors.a60461f7d6b6cc0ca2d6.js"></script><script type="text/javascript" src="app.a60461f7d6b6cc0ca2d6.js"></script><script type="text/javascript" src="styles.a60461f7d6b6cc0ca2d6.js"></script><script type="text/javascript" src="styles.css.a60461f7d6b6cc0ca2d6.js"></script></body>
<script type="text/javascript" src="runtime.fcf47e43952982c9dca9.js"></script><script type="text/javascript" src="vendors.fcf47e43952982c9dca9.js"></script><script type="text/javascript" src="app.fcf47e43952982c9dca9.js"></script><script type="text/javascript" src="styles.css.fcf47e43952982c9dca9.js"></script></body>
</html>
This diff is collapsed.
(function(m){function p(a){for(var b=a[0],c=a[1],d=a[2],f,h,e=0,g=[];e<b.length;e++)h=b[e],Object.prototype.hasOwnProperty.call(k,h)&&k[h]&&g.push(k[h][0]),k[h]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(m[f]=c[f]);for(q&&q(a);g.length;)g.shift()();l.push.apply(l,d||[]);return r()}function r(){for(var a,b=0;b<l.length;b++){for(var n=l[b],d=!0,f=1;f<n.length;f++)0!==k[n[f]]&&(d=!1);d&&(l.splice(b--,1),a=c(c.s=n[0]))}return a}function c(a){if(e[a])return e[a].exports;var b=e[a]={i:a,l:!1,
exports:{}};m[a].call(b.exports,b,b.exports,c);b.l=!0;return b.exports}var e={},k={0:0},l=[];c.m=m;c.c=e;c.d=function(a,b,d){c.o(a,b)||Object.defineProperty(a,b,{enumerable:!0,get:d})};c.r=function(a){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"});Object.defineProperty(a,"__esModule",{value:!0})};c.t=function(a,b){b&1&&(a=c(a));if(b&8||b&4&&"object"===typeof a&&a&&a.__esModule)return a;var d=Object.create(null);c.r(d);Object.defineProperty(d,
"default",{enumerable:!0,value:a});if(b&2&&"string"!=typeof a)for(var e in a)c.d(d,e,function(b){return a[b]}.bind(null,e));return d};c.n=function(a){var b=a&&a.__esModule?function(){return a["default"]}:function(){return a};c.d(b,"a",b);return b};c.o=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};c.p="";var d=window.webpackJsonp=window.webpackJsonp||[],t=d.push.bind(d);d.push=p;d=d.slice();for(var g=0;g<d.length;g++)p(d[g]);var q=t;r()})([]);
This diff is collapsed.
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{1:function(b,c,a){a("+eM2");a("LdiE");a("GwUf");b.exports=a("8Lv4")},"8Lv4":function(b,c,a){},GwUf:function(b,c,a){}}]);
(function(){(window.webpackJsonp=window.webpackJsonp||[]).push([[4],[],[[1,0,1,3]]])}).call(this||window);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment