forked from mit-plv/fiat-crypto
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy WASM integration to https://mit-plv.github.io/fiat-crypto (mit…
…-plv#1749) Work around asnyc wasm code cf ocaml-wasm/wasm_of_ocaml#11
- Loading branch information
1 parent
d0e5b2f
commit ca174d7
Showing
4 changed files
with
127 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
document.addEventListener('DOMContentLoaded', async function() { | ||
const wasmCheckbox = document.getElementById('wasm'); | ||
const extraWasmLabel = document.getElementById('extraWasmLabel'); | ||
wasmCheckbox.disabled = true; // Initially disable the checkbox | ||
|
||
try { | ||
const features = { | ||
tailCall: await wasmFeatureDetect.tailCall(), | ||
gc: await wasmFeatureDetect.gc(), | ||
exceptions: await wasmFeatureDetect.exceptions() | ||
}; | ||
|
||
const unsupportedFeatures = Object.entries(features) | ||
.filter(([feature, supported]) => !supported) | ||
.map(([feature]) => feature); | ||
|
||
if (unsupportedFeatures.length === 0) { | ||
wasmCheckbox.disabled = false; // Re-enable the checkbox if all features are supported | ||
} else { | ||
wasmCheckbox.checked = false; | ||
|
||
let featureText = unsupportedFeatures.join(', '); | ||
let firefoxText = unsupportedFeatures.map(feature => { | ||
if (feature === 'tailCall') return 'javascript.options.wasm_tail_calls'; | ||
if (feature === 'gc') return 'javascript.options.wasm_gc'; | ||
if (feature === 'exceptions') return 'javascript.options.wasm_exceptions'; | ||
return feature; | ||
}).join(', '); | ||
|
||
if (navigator.userAgent.includes('Firefox')) { | ||
extraWasmLabel.innerHTML = `(enable <code>${firefoxText}</code> in <code>about:config</code>)`; | ||
} else { | ||
extraWasmLabel.innerHTML = `(missing wasm support for: ${featureText})`; | ||
} | ||
} | ||
} catch (error) { | ||
console.error('Error checking wasm feature support:', error); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
self.importScripts("wasm_fiat_crypto.js"); | ||
self.onmessage = function(e) { | ||
try { | ||
const result = synthesize(e.data); | ||
postMessage({result: result}); | ||
} catch (err) { | ||
postMessage({error: err}); | ||
} | ||
}; | ||
let pending = []; | ||
self.onmessage = function (e) { pending.push(e); }; | ||
setTimeout(function () { | ||
self.onmessage = function(e) { | ||
try { | ||
const result = synthesize(e.data); | ||
postMessage({result: result}); | ||
} catch (err) { | ||
postMessage({error: err}); | ||
} | ||
}; | ||
pending.forEach(e => { self.onmessage(e); }); | ||
pending = []; | ||
}, 1000); |